排行榜

This commit is contained in:
xiabin 2025-01-18 17:56:36 +08:00
parent f5e81e9c94
commit 30e266eebc
38 changed files with 2845 additions and 673 deletions

View File

@ -22,5 +22,7 @@ go install github.com/google/wire/cmd/wire@latest
#### 通过gentool生成,model和query目录下的文件
```shell
go install gorm.io/gen/tools/gentool@latest
gentool -dsn "root:youtu!0113@tcp(localhost:3306)/ecpm?charset=utf8&parseTime=True&loc=Local" -fieldNullable -fieldWithIndexTag -fieldWithTypeTag -withUnitTest -fieldSignable
```

View File

@ -1,7 +0,0 @@
package ecpm_httpserver
import "github.com/gin-gonic/gin"
type Controller interface {
InitRoutes(r *gin.Engine)
}

View File

@ -0,0 +1,43 @@
package controller
import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"youtu_ecpm/api/gin/service"
"youtu_ecpm/dao/query"
)
type AppUserInfo struct {
*Controller
logger *zap.Logger
appUser *service.AppUserInfo
}
func NewAppUserInfoController(logger *zap.Logger, q *query.Query) *AppUserInfo {
return &AppUserInfo{
logger: logger,
appUser: service.NewAppUserInfo(q),
}
}
func (ctl *AppUserInfo) SetAppAccount(c *gin.Context) {
var req struct {
ID uint64 `gorm:"column:id;type:bigint unsigned;primaryKey;autoIncrement:true" json:"id" binding:"required"`
Nickname string `gorm:"column:nickname;type:varchar(255);not null;comment:昵称" json:"nickname" binding:"required"` // 昵称
ImageURL string `gorm:"column:image_url;type:varchar(255);not null;comment:头像" json:"image_url" binding:"required"` // 头像
}
if err := c.ShouldBind(&req); err != nil {
ctl.logger.Sugar().Error(err)
ctl.ResponseErr(c, err)
return
}
if err := ctl.appUser.UpdateUserNickNameAndImageUrl(c, req.ID, req.Nickname, req.ImageURL); err != nil {
ctl.logger.Sugar().Error(err)
ctl.ResponseErr(c, err)
return
}
c.JSON(200, "ok")
}

View File

@ -0,0 +1,30 @@
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Controller struct {
}
func (c *Controller) ResponseErr(ctx *gin.Context, err error) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusInternalServerError,
"msg": err.Error(),
})
}
func (c *Controller) ResponseErrParam(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusBadRequest,
"msg": "请求参数错误",
})
}
func (c *Controller) ResponseOk(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"msg": "ok",
})
}

View File

@ -2,19 +2,24 @@ package controller
import (
"context"
"errors"
"gitea.youtukeji.com.cn/xiabin/douyin-openapi/cache"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"net/http"
"time"
"youtu_ecpm/api/gin/service"
"youtu_ecpm/dao/model"
"youtu_ecpm/dao/query"
"youtu_ecpm/pkg/douyinapi"
)
type DouyinOpenApiController struct {
logger *zap.Logger
douyinCli *douyinapi.DouYinOpenApiClient
q *query.Query
*Controller
logger *zap.Logger
douyinCli *douyinapi.DouYinOpenApiClient
appUser *service.AppUserInfo
appAccount *service.AppAccount
}
// NewDouyinOpenApiController 实例化控制器
@ -25,17 +30,41 @@ func NewDouyinOpenApiController(logger *zap.Logger, q *query.Query) *DouyinOpenA
// 创建抖音客户端
douyinCli := douyinapi.NewDouYinOpenApiClient()
// 获取数据库中的数据
list, err := q.Douyin.WithContext(context.Background()).Find()
ctx := context.Background()
var result []struct {
AppID string `gorm:"column:app_id;type:char(20);not null;index:app_id,priority:1" json:"app_id"`
Secret string `gorm:"column:secret;type:char(40);not null" json:"secret"`
EcpmValue uint32 `gorm:"column:ecpm_value;type:int unsigned;not null;comment:值" json:"ecpm_value"` // 值
EcpmView uint32 `gorm:"column:ecpm_view;type:int unsigned;not null;comment:浏览次数" json:"ecpm_view"` // 浏览次数
}
account := q.AppAccount
cfg := q.DouyinEcpmConfig
//获取抖音配置
err := account.WithContext(ctx).
Select(
account.AppID,
account.Secret,
cfg.EcpmValue,
cfg.EcpmView,
).Where(account.Type.Eq(0)).
LeftJoin(cfg, cfg.AppAccountID.EqCol(account.ID)).
Scan(&result)
if err != nil {
logger.Sugar().Error("获取数据失败", err)
}
// 将数据库中的数据存储到内存中
for _, v := range list {
for _, v := range result {
douyinCli.NewAndStoreDouYinOpenApi(v.AppID, v.Secret, v.EcpmValue, v.EcpmView, cache.NewMemory())
}
return &DouyinOpenApiController{
logger: logger,
douyinCli: douyinCli,
logger: logger,
douyinCli: douyinCli,
appUser: service.NewAppUserInfo(q),
appAccount: service.NewAppAccount(q),
}
}
@ -87,30 +116,40 @@ func (ctl *DouyinOpenApiController) Code2OpenId(c *gin.Context) {
douyinCli, err := ctl.douyinCli.GetDouYinOpenApi(appId)
if err != nil {
ctl.logger.Sugar().Error("获取小程序登录地址失败", err)
c.JSON(200, gin.H{
"code": 500,
"msg": err.Error(),
})
ctl.ResponseErr(c, err)
return
}
res, err := douyinCli.Api.Code2Session(code, anonymousOpenid)
if err != nil {
ctl.logger.Sugar().Error("获取小程序登录地址失败", err)
c.JSON(200, gin.H{
"code": 500,
"msg": http.StatusOK,
})
ctl.ResponseErr(c, err)
return
}
if res.Errcode != 0 {
ctl.logger.Sugar().Errorf("Code2Session 错误,res : %+v", res)
c.JSON(200, gin.H{
"code": 500,
"msg": http.StatusOK,
})
ctl.ResponseErr(c, errors.New(res.Errmsg))
return
}
accountId, err := ctl.appAccount.GetAppAccountIdByAppId(c, appId)
if err != nil {
ctl.ResponseErr(c, err)
return
}
err = ctl.appUser.SaveUserInfoByRes(c, &model.AppUserInfo{
AppAccountID: accountId,
Openid: res.Openid,
Unionid: res.Unionid,
AnonymousOpenid: res.AnonymousOpenid,
})
if err != nil {
ctl.ResponseErr(c, err)
return
}
c.String(http.StatusOK, res.Openid)
}

View File

@ -0,0 +1,59 @@
package controller
import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"net/http"
"youtu_ecpm/api/gin/service"
"youtu_ecpm/dao/query"
)
type RankingList struct {
Controller
appUser *service.AppUserInfo
ranking *service.RankingList
logger *zap.Logger
}
func NewRankingList(logger *zap.Logger, q *query.Query) *RankingList {
return &RankingList{appUser: service.NewAppUserInfo(q), logger: logger}
}
func (ctl *RankingList) GetRankingList(c *gin.Context) {
var req struct {
AppId uint32 `json:"app_id" binding:"required"`
}
if err := c.ShouldBind(&req); err != nil {
ctl.ResponseErr(c, err)
return
}
res, err := ctl.ranking.GetRankingList(c, req.AppId)
if err != nil {
ctl.logger.Sugar().Error("获取", zap.Error(err))
ctl.ResponseErr(c, err)
return
}
c.JSON(http.StatusOK, res)
}
func (ctl *RankingList) SetScore(c *gin.Context) {
var req struct {
AppId uint32 `json:"app_id" binding:"required"`
Score uint32 `json:"score" binding:"required"`
UserId uint64 `json:"user_id" binding:"required"`
}
if err := c.ShouldBind(&req); err != nil {
ctl.ResponseErrParam(c)
return
}
err := ctl.ranking.SetScore(c, req.AppId, req.UserId, req.Score)
if err != nil {
ctl.logger.Sugar().Error("设置分数失败", zap.Error(err))
ctl.ResponseErr(c, err)
return
}
ctl.ResponseOk(c)
return
}

View File

@ -0,0 +1,104 @@
package controller
import (
"context"
"errors"
"gitea.youtukeji.com.cn/xiabin/douyin-openapi/cache"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"net/http"
"youtu_ecpm/api/gin/service"
"youtu_ecpm/dao/model"
"youtu_ecpm/dao/query"
"youtu_ecpm/pkg/wechat_api"
)
type WechatOpenApiController struct {
*Controller
logger *zap.Logger
wechatCli *wechat_api.WechatApi
appUser *service.AppUserInfo
appAccount *service.AppAccount
}
// NewWechatOpenApiController 实例化控制器
// logger: 日志
// q: 数据库
// 将数据库中的数据存储到内存中
func NewWechatOpenApiController(logger *zap.Logger, q *query.Query) *WechatOpenApiController {
// 创建抖音客户端
weChatApiCli := wechat_api.NewWechatOpenApiClient()
// 获取数据库中的数据
ctx := context.Background()
account := q.AppAccount
cfg := q.DouyinEcpmConfig
//获取抖音配置
result, err := account.WithContext(ctx).
Select(
account.AppID,
account.Secret,
).Where(account.Type.Eq(1)).
LeftJoin(cfg, cfg.AppAccountID.EqCol(account.ID)).
Find()
if err != nil {
logger.Sugar().Error("获取数据失败", err)
}
// 将数据库中的数据存储到内存中
for _, v := range result {
weChatApiCli.NewAndStoreWechatOpenApi(v.AppID, v.Secret, cache.NewMemory())
}
return &WechatOpenApiController{
logger: logger,
wechatCli: weChatApiCli,
appUser: service.NewAppUserInfo(q),
appAccount: service.NewAppAccount(q),
}
}
// Code2OpenId 获取openId
func (ctl *WechatOpenApiController) Code2OpenId(c *gin.Context) {
code := c.Query("code")
appId := c.Query("app_id")
wechatCli, err := ctl.wechatCli.GetWechatOpenApi(appId)
if err != nil {
ctl.logger.Sugar().Error("获取小程序登录地址失败", err)
ctl.ResponseErr(c, err)
return
}
res, err := wechatCli.GetAuth().Code2Session(code)
if err != nil {
ctl.logger.Sugar().Error("获取小程序登录地址失败", err)
ctl.ResponseErr(c, err)
return
}
if res.ErrCode != 0 {
ctl.logger.Sugar().Errorf("Code2Session 错误,res : %+v", res)
ctl.ResponseErr(c, errors.New(res.ErrMsg))
return
}
accountId, err := ctl.appAccount.GetAppAccountIdByAppId(c, appId)
if err != nil {
ctl.ResponseErr(c, err)
return
}
err = ctl.appUser.SaveUserInfoByRes(c, &model.AppUserInfo{
AppAccountID: accountId,
Openid: res.OpenID,
Unionid: res.UnionID,
})
if err != nil {
ctl.ResponseErr(c, err)
return
}
c.String(http.StatusOK, res.OpenID)
}

View File

@ -61,4 +61,21 @@ func InitRouter(r *gin.Engine, logger *zap.Logger, q *query.Query) {
douyinCtl := controller.NewDouyinOpenApiController(logger, q)
r.GET("/get-ecpm", douyinCtl.GetEcpm)
r.GET("/code2openId", douyinCtl.Code2OpenId)
appUserCtl := controller.NewAppUserInfoController(logger, q)
r.POST("/app_user_info/SetAppAccount", appUserCtl.SetAppAccount)
{
rankingCtl := controller.NewRankingList(logger, q)
g := r.Group("/ranking")
g.GET("/list", rankingCtl.GetRankingList)
g.POST("/set_score", rankingCtl.SetScore)
}
{
wechatCtl := controller.NewWechatOpenApiController(logger, q)
g := r.Group("/wechat")
g.GET("/code2openId", wechatCtl.Code2OpenId)
}
}

View File

@ -0,0 +1,22 @@
package service
import (
"context"
"youtu_ecpm/dao/query"
)
type AppAccount struct {
q *query.Query
}
func NewAppAccount(q *query.Query) *AppAccount {
return &AppAccount{q: q}
}
func (a *AppAccount) GetAppAccountIdByAppId(ctx context.Context, appId string) (id uint32, err error) {
m, err := a.q.AppAccount.WithContext(ctx).Where(a.q.AppAccount.AppID.Eq(appId)).Select(a.q.AppAccount.ID).Limit(1).First()
if err != nil {
return 0, err
}
return m.ID, nil
}

View File

@ -0,0 +1,36 @@
package service
import (
"context"
"errors"
"gorm.io/gorm"
"youtu_ecpm/dao/model"
"youtu_ecpm/dao/query"
)
type AppUserInfo struct {
q *query.Query
}
func NewAppUserInfo(q *query.Query) *AppUserInfo {
return &AppUserInfo{q: q}
}
func (a *AppUserInfo) SaveUserInfoByRes(c context.Context, res *model.AppUserInfo) (err error) {
m, err := a.q.AppUserInfo.WithContext(c).Where(a.q.AppUserInfo.Openid.Eq(res.Openid), a.q.AppAccount.AppID.Eq(res.Openid)).Join(a.q.AppAccount, a.q.AppAccount.ID.EqCol(a.q.AppUserInfo.AppAccountID)).Take()
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return
}
if m == nil || m.ID == 0 {
err = a.q.AppUserInfo.WithContext(c).Create(res)
}
return
}
func (a *AppUserInfo) UpdateUserNickNameAndImageUrl(ctx context.Context, id uint64, nickname string, url string) (err error) {
_, err = a.q.AppUserInfo.WithContext(ctx).Where(a.q.AppUserInfo.ID.Eq(id)).Updates(&model.AppUserInfo{ID: id, Nickname: nickname, Avatar: url})
return
}

View File

@ -0,0 +1,102 @@
package service
import (
"context"
"gitea.youtukeji.com.cn/xiabin/douyin-openapi/cache"
"strconv"
"sync"
"youtu_ecpm/dao/model"
"youtu_ecpm/dao/query"
)
type RankingList struct {
q *query.Query
cache cache.Cache
lock sync.Mutex
}
func NewRankingList(q *query.Query, c cache.Cache) *RankingList {
return &RankingList{q, c, sync.Mutex{}}
}
type RankingListData struct {
Nickname string `gorm:"column:nickname;type:varchar(255);not null;comment:昵称" json:"nickname"` // 昵称
Avatar string `gorm:"column:avatar;type:varchar(255);not null;comment:头像" json:"avatar"` // 头像
Score uint32 `gorm:"column:score;type:int unsigned;not null" json:"score"`
}
func (s *RankingList) GetRankingList(ctx context.Context, appId uint32) (res []RankingListData, err error) {
if val := s.cache.Get(strconv.Itoa(int(appId))); val != nil {
res = val.([]RankingListData)
return
}
s.lock.Lock()
defer s.lock.Unlock()
if val := s.cache.Get(strconv.Itoa(int(appId))); val != nil {
res = val.([]RankingListData)
return
}
//get data
aui := s.q.AppUserInfo
gameScore := s.q.GameScore
err = gameScore.WithContext(ctx).
Join(aui, gameScore.AppUserID.EqCol(aui.ID)).
Select(gameScore.Score, aui.Nickname, aui.Avatar).
Where(gameScore.AppAccount.Eq(appId)).
Order(gameScore.Score.Desc()).
Limit(20).Scan(&res)
if err != nil {
return
}
//Cache
err = s.cache.Set(strconv.Itoa(int(appId)), res, 60)
if err != nil {
return
}
return
}
func (s *RankingList) SetScore(ctx context.Context, appId uint32, userId uint64, score uint32) (err error) {
err = s.q.GameScore.WithContext(ctx).Save(&model.GameScore{
AppAccount: appId,
AppUserID: userId,
Score: score,
})
if err != nil {
return
}
//Cache
if val := s.cache.Get(strconv.Itoa(int(appId))); val != nil {
list := val.([]RankingListData)
lastScore := list[len(list)-1].Score
if score > lastScore {
s.lock.Lock()
defer s.lock.Unlock()
aui := s.q.AppUserInfo
user, err := aui.WithContext(ctx).Where(aui.ID.Eq(userId)).Select(aui.Nickname, aui.Avatar).Take()
if err != nil {
return err
}
rank := RankingListData{user.Nickname, user.Avatar, score}
if len(list) < 20 {
list = append(list, rank)
} else {
list[len(list)-1] = rank
}
err = s.cache.Set(strconv.Itoa(int(appId)), list, 60)
if err != nil {
return err
}
}
}
return
}

View File

@ -0,0 +1,26 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameAppAccount = "app_account"
// AppAccount mapped from table <app_account>
type AppAccount struct {
ID uint32 `gorm:"column:id;type:int unsigned;primaryKey;autoIncrement:true" json:"id"`
Type uint32 `gorm:"column:type;type:tinyint unsigned;not null;comment:类型(0:抖音,1:微信)" json:"type"` // 类型(0:抖音,1:微信)
AppID string `gorm:"column:app_id;type:char(20);not null;index:app_id,priority:1" json:"app_id"`
Secret string `gorm:"column:secret;type:char(40);not null" json:"secret"`
Remark *string `gorm:"column:remark;type:varchar(255);comment:备注" json:"remark"` // 备注
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:time" json:"deleted_at"`
}
// TableName AppAccount's table name
func (*AppAccount) TableName() string {
return TableNameAppAccount
}

View File

@ -0,0 +1,23 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameAppUserInfo = "app_user_info"
// AppUserInfo mapped from table <app_user_info>
type AppUserInfo struct {
ID uint64 `gorm:"column:id;type:bigint unsigned;primaryKey;autoIncrement:true" json:"id"`
AppAccountID uint32 `gorm:"column:app_account_id;type:int unsigned;not null;comment:app_account表外键" json:"app_account_id"` // app_account表外键
Openid string `gorm:"column:openid;type:varchar(255);not null" json:"openid"`
Unionid string `gorm:"column:unionid;type:varchar(255);not null" json:"unionid"`
Nickname string `gorm:"column:nickname;type:varchar(255);not null;comment:昵称" json:"nickname"` // 昵称
Avatar string `gorm:"column:avatar;type:varchar(255);not null;comment:头像" json:"avatar"` // 头像
AnonymousOpenid string `gorm:"column:anonymous_openid;type:varchar(255);not null;comment:匿名openid" json:"anonymous_openid"` // 匿名openid
}
// TableName AppUserInfo's table name
func (*AppUserInfo) TableName() string {
return TableNameAppUserInfo
}

View File

@ -1,21 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameDouyin = "douyin"
// Douyin mapped from table <douyin>
type Douyin struct {
ID uint32 `gorm:"column:id;type:int unsigned;primaryKey;autoIncrement:true" json:"id"`
AppID string `gorm:"column:app_id;type:varchar(20);not null" json:"app_id"`
Secret string `gorm:"column:secret;type:varchar(40);not null" json:"secret"`
EcpmValue uint32 `gorm:"column:ecpm_value;type:int unsigned;not null" json:"ecpm_value"`
EcpmView uint32 `gorm:"column:ecpm_view;type:int unsigned;not null" json:"ecpm_view"`
}
// TableName Douyin's table name
func (*Douyin) TableName() string {
return TableNameDouyin
}

View File

@ -0,0 +1,20 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameDouyinEcpmConfig = "douyin_ecpm_config"
// DouyinEcpmConfig mapped from table <douyin_ecpm_config>
type DouyinEcpmConfig struct {
ID uint32 `gorm:"column:id;type:int unsigned;primaryKey;autoIncrement:true" json:"id"`
AppAccountID uint32 `gorm:"column:app_account_id;type:int unsigned;not null;index:app_account_id,priority:1" json:"app_account_id"`
EcpmValue uint32 `gorm:"column:ecpm_value;type:int unsigned;not null;comment:值" json:"ecpm_value"` // 值
EcpmView uint32 `gorm:"column:ecpm_view;type:int unsigned;not null;comment:浏览次数" json:"ecpm_view"` // 浏览次数
}
// TableName DouyinEcpmConfig's table name
func (*DouyinEcpmConfig) TableName() string {
return TableNameDouyinEcpmConfig
}

View File

@ -0,0 +1,19 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameGameScore = "game_score"
// GameScore mapped from table <game_score>
type GameScore struct {
AppUserID uint64 `gorm:"column:app_user_id;type:bigint unsigned;primaryKey" json:"app_user_id"`
AppAccount uint32 `gorm:"column:app_account;type:int unsigned;primaryKey" json:"app_account"`
Score uint32 `gorm:"column:score;type:int unsigned;not null" json:"score"`
}
// TableName GameScore's table name
func (*GameScore) TableName() string {
return TableNameGameScore
}

View File

@ -0,0 +1,349 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"youtu_ecpm/dao/model"
)
func newAppAccount(db *gorm.DB, opts ...gen.DOOption) appAccount {
_appAccount := appAccount{}
_appAccount.appAccountDo.UseDB(db, opts...)
_appAccount.appAccountDo.UseModel(&model.AppAccount{})
tableName := _appAccount.appAccountDo.TableName()
_appAccount.ALL = field.NewAsterisk(tableName)
_appAccount.ID = field.NewUint32(tableName, "id")
_appAccount.Type = field.NewUint32(tableName, "type")
_appAccount.AppID = field.NewString(tableName, "app_id")
_appAccount.Secret = field.NewString(tableName, "secret")
_appAccount.Remark = field.NewString(tableName, "remark")
_appAccount.DeletedAt = field.NewField(tableName, "deleted_at")
_appAccount.fillFieldMap()
return _appAccount
}
type appAccount struct {
appAccountDo appAccountDo
ALL field.Asterisk
ID field.Uint32
Type field.Uint32 // 类型(0:抖音,1:微信)
AppID field.String
Secret field.String
Remark field.String // 备注
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (a appAccount) Table(newTableName string) *appAccount {
a.appAccountDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appAccount) As(alias string) *appAccount {
a.appAccountDo.DO = *(a.appAccountDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appAccount) updateTableName(table string) *appAccount {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewUint32(table, "id")
a.Type = field.NewUint32(table, "type")
a.AppID = field.NewString(table, "app_id")
a.Secret = field.NewString(table, "secret")
a.Remark = field.NewString(table, "remark")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appAccount) WithContext(ctx context.Context) *appAccountDo {
return a.appAccountDo.WithContext(ctx)
}
func (a appAccount) TableName() string { return a.appAccountDo.TableName() }
func (a appAccount) Alias() string { return a.appAccountDo.Alias() }
func (a appAccount) Columns(cols ...field.Expr) gen.Columns { return a.appAccountDo.Columns(cols...) }
func (a *appAccount) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appAccount) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 6)
a.fieldMap["id"] = a.ID
a.fieldMap["type"] = a.Type
a.fieldMap["app_id"] = a.AppID
a.fieldMap["secret"] = a.Secret
a.fieldMap["remark"] = a.Remark
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appAccount) clone(db *gorm.DB) appAccount {
a.appAccountDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appAccount) replaceDB(db *gorm.DB) appAccount {
a.appAccountDo.ReplaceDB(db)
return a
}
type appAccountDo struct{ gen.DO }
func (a appAccountDo) Debug() *appAccountDo {
return a.withDO(a.DO.Debug())
}
func (a appAccountDo) WithContext(ctx context.Context) *appAccountDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appAccountDo) ReadDB() *appAccountDo {
return a.Clauses(dbresolver.Read)
}
func (a appAccountDo) WriteDB() *appAccountDo {
return a.Clauses(dbresolver.Write)
}
func (a appAccountDo) Session(config *gorm.Session) *appAccountDo {
return a.withDO(a.DO.Session(config))
}
func (a appAccountDo) Clauses(conds ...clause.Expression) *appAccountDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appAccountDo) Returning(value interface{}, columns ...string) *appAccountDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appAccountDo) Not(conds ...gen.Condition) *appAccountDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appAccountDo) Or(conds ...gen.Condition) *appAccountDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appAccountDo) Select(conds ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appAccountDo) Where(conds ...gen.Condition) *appAccountDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appAccountDo) Order(conds ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appAccountDo) Distinct(cols ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appAccountDo) Omit(cols ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appAccountDo) Join(table schema.Tabler, on ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appAccountDo) LeftJoin(table schema.Tabler, on ...field.Expr) *appAccountDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appAccountDo) RightJoin(table schema.Tabler, on ...field.Expr) *appAccountDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appAccountDo) Group(cols ...field.Expr) *appAccountDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appAccountDo) Having(conds ...gen.Condition) *appAccountDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appAccountDo) Limit(limit int) *appAccountDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appAccountDo) Offset(offset int) *appAccountDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appAccountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *appAccountDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appAccountDo) Unscoped() *appAccountDo {
return a.withDO(a.DO.Unscoped())
}
func (a appAccountDo) Create(values ...*model.AppAccount) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appAccountDo) CreateInBatches(values []*model.AppAccount, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appAccountDo) Save(values ...*model.AppAccount) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appAccountDo) First() (*model.AppAccount, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Take() (*model.AppAccount, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Last() (*model.AppAccount, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Find() ([]*model.AppAccount, error) {
result, err := a.DO.Find()
return result.([]*model.AppAccount), err
}
func (a appAccountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppAccount, err error) {
buf := make([]*model.AppAccount, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appAccountDo) FindInBatches(result *[]*model.AppAccount, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appAccountDo) Attrs(attrs ...field.AssignExpr) *appAccountDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appAccountDo) Assign(attrs ...field.AssignExpr) *appAccountDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appAccountDo) Joins(fields ...field.RelationField) *appAccountDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appAccountDo) Preload(fields ...field.RelationField) *appAccountDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appAccountDo) FirstOrInit() (*model.AppAccount, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) FirstOrCreate() (*model.AppAccount, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) FindByPage(offset int, limit int) (result []*model.AppAccount, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appAccountDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appAccountDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appAccountDo) Delete(models ...*model.AppAccount) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appAccountDo) withDO(do gen.Dao) *appAccountDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,146 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"fmt"
"testing"
"youtu_ecpm/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
func init() {
InitializeDB()
err := _gen_test_db.AutoMigrate(&model.AppAccount{})
if err != nil {
fmt.Printf("Error: AutoMigrate(&model.AppAccount{}) fail: %s", err)
}
}
func Test_appAccountQuery(t *testing.T) {
appAccount := newAppAccount(_gen_test_db)
appAccount = *appAccount.As(appAccount.TableName())
_do := appAccount.WithContext(context.Background()).Debug()
primaryKey := field.NewString(appAccount.TableName(), clause.PrimaryKey)
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
if err != nil {
t.Error("clean table <app_account> fail:", err)
return
}
_, ok := appAccount.GetFieldByName("")
if ok {
t.Error("GetFieldByName(\"\") from appAccount success")
}
err = _do.Create(&model.AppAccount{})
if err != nil {
t.Error("create item in table <app_account> fail:", err)
}
err = _do.Save(&model.AppAccount{})
if err != nil {
t.Error("create item in table <app_account> fail:", err)
}
err = _do.CreateInBatches([]*model.AppAccount{{}, {}}, 10)
if err != nil {
t.Error("create item in table <app_account> fail:", err)
}
_, err = _do.Select(appAccount.ALL).Take()
if err != nil {
t.Error("Take() on table <app_account> fail:", err)
}
_, err = _do.First()
if err != nil {
t.Error("First() on table <app_account> fail:", err)
}
_, err = _do.Last()
if err != nil {
t.Error("First() on table <app_account> fail:", err)
}
_, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatch() on table <app_account> fail:", err)
}
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*model.AppAccount{}, 10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatches() on table <app_account> fail:", err)
}
_, err = _do.Select(appAccount.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
if err != nil {
t.Error("Find() on table <app_account> fail:", err)
}
_, err = _do.Distinct(primaryKey).Take()
if err != nil {
t.Error("select Distinct() on table <app_account> fail:", err)
}
_, err = _do.Select(appAccount.ALL).Omit(primaryKey).Take()
if err != nil {
t.Error("Omit() on table <app_account> fail:", err)
}
_, err = _do.Group(primaryKey).Find()
if err != nil {
t.Error("Group() on table <app_account> fail:", err)
}
_, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
if err != nil {
t.Error("Scopes() on table <app_account> fail:", err)
}
_, _, err = _do.FindByPage(0, 1)
if err != nil {
t.Error("FindByPage() on table <app_account> fail:", err)
}
_, err = _do.ScanByPage(&model.AppAccount{}, 0, 1)
if err != nil {
t.Error("ScanByPage() on table <app_account> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
if err != nil {
t.Error("FirstOrInit() on table <app_account> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
if err != nil {
t.Error("FirstOrCreate() on table <app_account> fail:", err)
}
var _a _another
var _aPK = field.NewString(_a.TableName(), "id")
err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("Join() on table <app_account> fail:", err)
}
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("LeftJoin() on table <app_account> fail:", err)
}
_, err = _do.Not().Or().Clauses().Take()
if err != nil {
t.Error("Not/Or/Clauses on table <app_account> fail:", err)
}
}

View File

@ -0,0 +1,353 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"youtu_ecpm/dao/model"
)
func newAppUserInfo(db *gorm.DB, opts ...gen.DOOption) appUserInfo {
_appUserInfo := appUserInfo{}
_appUserInfo.appUserInfoDo.UseDB(db, opts...)
_appUserInfo.appUserInfoDo.UseModel(&model.AppUserInfo{})
tableName := _appUserInfo.appUserInfoDo.TableName()
_appUserInfo.ALL = field.NewAsterisk(tableName)
_appUserInfo.ID = field.NewUint64(tableName, "id")
_appUserInfo.AppAccountID = field.NewUint32(tableName, "app_account_id")
_appUserInfo.Openid = field.NewString(tableName, "openid")
_appUserInfo.Unionid = field.NewString(tableName, "unionid")
_appUserInfo.Nickname = field.NewString(tableName, "nickname")
_appUserInfo.Avatar = field.NewString(tableName, "avatar")
_appUserInfo.AnonymousOpenid = field.NewString(tableName, "anonymous_openid")
_appUserInfo.fillFieldMap()
return _appUserInfo
}
type appUserInfo struct {
appUserInfoDo appUserInfoDo
ALL field.Asterisk
ID field.Uint64
AppAccountID field.Uint32 // app_account表外键
Openid field.String
Unionid field.String
Nickname field.String // 昵称
Avatar field.String // 头像
AnonymousOpenid field.String // 匿名openid
fieldMap map[string]field.Expr
}
func (a appUserInfo) Table(newTableName string) *appUserInfo {
a.appUserInfoDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appUserInfo) As(alias string) *appUserInfo {
a.appUserInfoDo.DO = *(a.appUserInfoDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appUserInfo) updateTableName(table string) *appUserInfo {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewUint64(table, "id")
a.AppAccountID = field.NewUint32(table, "app_account_id")
a.Openid = field.NewString(table, "openid")
a.Unionid = field.NewString(table, "unionid")
a.Nickname = field.NewString(table, "nickname")
a.Avatar = field.NewString(table, "avatar")
a.AnonymousOpenid = field.NewString(table, "anonymous_openid")
a.fillFieldMap()
return a
}
func (a *appUserInfo) WithContext(ctx context.Context) *appUserInfoDo {
return a.appUserInfoDo.WithContext(ctx)
}
func (a appUserInfo) TableName() string { return a.appUserInfoDo.TableName() }
func (a appUserInfo) Alias() string { return a.appUserInfoDo.Alias() }
func (a appUserInfo) Columns(cols ...field.Expr) gen.Columns { return a.appUserInfoDo.Columns(cols...) }
func (a *appUserInfo) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appUserInfo) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 7)
a.fieldMap["id"] = a.ID
a.fieldMap["app_account_id"] = a.AppAccountID
a.fieldMap["openid"] = a.Openid
a.fieldMap["unionid"] = a.Unionid
a.fieldMap["nickname"] = a.Nickname
a.fieldMap["avatar"] = a.Avatar
a.fieldMap["anonymous_openid"] = a.AnonymousOpenid
}
func (a appUserInfo) clone(db *gorm.DB) appUserInfo {
a.appUserInfoDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appUserInfo) replaceDB(db *gorm.DB) appUserInfo {
a.appUserInfoDo.ReplaceDB(db)
return a
}
type appUserInfoDo struct{ gen.DO }
func (a appUserInfoDo) Debug() *appUserInfoDo {
return a.withDO(a.DO.Debug())
}
func (a appUserInfoDo) WithContext(ctx context.Context) *appUserInfoDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appUserInfoDo) ReadDB() *appUserInfoDo {
return a.Clauses(dbresolver.Read)
}
func (a appUserInfoDo) WriteDB() *appUserInfoDo {
return a.Clauses(dbresolver.Write)
}
func (a appUserInfoDo) Session(config *gorm.Session) *appUserInfoDo {
return a.withDO(a.DO.Session(config))
}
func (a appUserInfoDo) Clauses(conds ...clause.Expression) *appUserInfoDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appUserInfoDo) Returning(value interface{}, columns ...string) *appUserInfoDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appUserInfoDo) Not(conds ...gen.Condition) *appUserInfoDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appUserInfoDo) Or(conds ...gen.Condition) *appUserInfoDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appUserInfoDo) Select(conds ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appUserInfoDo) Where(conds ...gen.Condition) *appUserInfoDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appUserInfoDo) Order(conds ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appUserInfoDo) Distinct(cols ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appUserInfoDo) Omit(cols ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appUserInfoDo) Join(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appUserInfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appUserInfoDo) RightJoin(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appUserInfoDo) Group(cols ...field.Expr) *appUserInfoDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appUserInfoDo) Having(conds ...gen.Condition) *appUserInfoDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appUserInfoDo) Limit(limit int) *appUserInfoDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appUserInfoDo) Offset(offset int) *appUserInfoDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appUserInfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *appUserInfoDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appUserInfoDo) Unscoped() *appUserInfoDo {
return a.withDO(a.DO.Unscoped())
}
func (a appUserInfoDo) Create(values ...*model.AppUserInfo) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appUserInfoDo) CreateInBatches(values []*model.AppUserInfo, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appUserInfoDo) Save(values ...*model.AppUserInfo) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appUserInfoDo) First() (*model.AppUserInfo, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppUserInfo), nil
}
}
func (a appUserInfoDo) Take() (*model.AppUserInfo, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppUserInfo), nil
}
}
func (a appUserInfoDo) Last() (*model.AppUserInfo, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppUserInfo), nil
}
}
func (a appUserInfoDo) Find() ([]*model.AppUserInfo, error) {
result, err := a.DO.Find()
return result.([]*model.AppUserInfo), err
}
func (a appUserInfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppUserInfo, err error) {
buf := make([]*model.AppUserInfo, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appUserInfoDo) FindInBatches(result *[]*model.AppUserInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appUserInfoDo) Attrs(attrs ...field.AssignExpr) *appUserInfoDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appUserInfoDo) Assign(attrs ...field.AssignExpr) *appUserInfoDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appUserInfoDo) Joins(fields ...field.RelationField) *appUserInfoDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appUserInfoDo) Preload(fields ...field.RelationField) *appUserInfoDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appUserInfoDo) FirstOrInit() (*model.AppUserInfo, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppUserInfo), nil
}
}
func (a appUserInfoDo) FirstOrCreate() (*model.AppUserInfo, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppUserInfo), nil
}
}
func (a appUserInfoDo) FindByPage(offset int, limit int) (result []*model.AppUserInfo, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appUserInfoDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appUserInfoDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appUserInfoDo) Delete(models ...*model.AppUserInfo) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appUserInfoDo) withDO(do gen.Dao) *appUserInfoDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,146 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"fmt"
"testing"
"youtu_ecpm/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
func init() {
InitializeDB()
err := _gen_test_db.AutoMigrate(&model.AppUserInfo{})
if err != nil {
fmt.Printf("Error: AutoMigrate(&model.AppUserInfo{}) fail: %s", err)
}
}
func Test_appUserInfoQuery(t *testing.T) {
appUserInfo := newAppUserInfo(_gen_test_db)
appUserInfo = *appUserInfo.As(appUserInfo.TableName())
_do := appUserInfo.WithContext(context.Background()).Debug()
primaryKey := field.NewString(appUserInfo.TableName(), clause.PrimaryKey)
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
if err != nil {
t.Error("clean table <app_user_info> fail:", err)
return
}
_, ok := appUserInfo.GetFieldByName("")
if ok {
t.Error("GetFieldByName(\"\") from appUserInfo success")
}
err = _do.Create(&model.AppUserInfo{})
if err != nil {
t.Error("create item in table <app_user_info> fail:", err)
}
err = _do.Save(&model.AppUserInfo{})
if err != nil {
t.Error("create item in table <app_user_info> fail:", err)
}
err = _do.CreateInBatches([]*model.AppUserInfo{{}, {}}, 10)
if err != nil {
t.Error("create item in table <app_user_info> fail:", err)
}
_, err = _do.Select(appUserInfo.ALL).Take()
if err != nil {
t.Error("Take() on table <app_user_info> fail:", err)
}
_, err = _do.First()
if err != nil {
t.Error("First() on table <app_user_info> fail:", err)
}
_, err = _do.Last()
if err != nil {
t.Error("First() on table <app_user_info> fail:", err)
}
_, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatch() on table <app_user_info> fail:", err)
}
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*model.AppUserInfo{}, 10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatches() on table <app_user_info> fail:", err)
}
_, err = _do.Select(appUserInfo.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
if err != nil {
t.Error("Find() on table <app_user_info> fail:", err)
}
_, err = _do.Distinct(primaryKey).Take()
if err != nil {
t.Error("select Distinct() on table <app_user_info> fail:", err)
}
_, err = _do.Select(appUserInfo.ALL).Omit(primaryKey).Take()
if err != nil {
t.Error("Omit() on table <app_user_info> fail:", err)
}
_, err = _do.Group(primaryKey).Find()
if err != nil {
t.Error("Group() on table <app_user_info> fail:", err)
}
_, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
if err != nil {
t.Error("Scopes() on table <app_user_info> fail:", err)
}
_, _, err = _do.FindByPage(0, 1)
if err != nil {
t.Error("FindByPage() on table <app_user_info> fail:", err)
}
_, err = _do.ScanByPage(&model.AppUserInfo{}, 0, 1)
if err != nil {
t.Error("ScanByPage() on table <app_user_info> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
if err != nil {
t.Error("FirstOrInit() on table <app_user_info> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
if err != nil {
t.Error("FirstOrCreate() on table <app_user_info> fail:", err)
}
var _a _another
var _aPK = field.NewString(_a.TableName(), "id")
err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("Join() on table <app_user_info> fail:", err)
}
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("LeftJoin() on table <app_user_info> fail:", err)
}
_, err = _do.Not().Or().Clauses().Take()
if err != nil {
t.Error("Not/Or/Clauses on table <app_user_info> fail:", err)
}
}

View File

@ -1,343 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"youtu_ecpm/dao/model"
)
func newDouyin(db *gorm.DB, opts ...gen.DOOption) douyin {
_douyin := douyin{}
_douyin.douyinDo.UseDB(db, opts...)
_douyin.douyinDo.UseModel(&model.Douyin{})
tableName := _douyin.douyinDo.TableName()
_douyin.ALL = field.NewAsterisk(tableName)
_douyin.ID = field.NewUint32(tableName, "id")
_douyin.AppID = field.NewString(tableName, "app_id")
_douyin.Secret = field.NewString(tableName, "secret")
_douyin.EcpmValue = field.NewUint32(tableName, "ecpm_value")
_douyin.EcpmView = field.NewUint32(tableName, "ecpm_view")
_douyin.fillFieldMap()
return _douyin
}
type douyin struct {
douyinDo douyinDo
ALL field.Asterisk
ID field.Uint32
AppID field.String
Secret field.String
EcpmValue field.Uint32
EcpmView field.Uint32
fieldMap map[string]field.Expr
}
func (d douyin) Table(newTableName string) *douyin {
d.douyinDo.UseTable(newTableName)
return d.updateTableName(newTableName)
}
func (d douyin) As(alias string) *douyin {
d.douyinDo.DO = *(d.douyinDo.As(alias).(*gen.DO))
return d.updateTableName(alias)
}
func (d *douyin) updateTableName(table string) *douyin {
d.ALL = field.NewAsterisk(table)
d.ID = field.NewUint32(table, "id")
d.AppID = field.NewString(table, "app_id")
d.Secret = field.NewString(table, "secret")
d.EcpmValue = field.NewUint32(table, "ecpm_value")
d.EcpmView = field.NewUint32(table, "ecpm_view")
d.fillFieldMap()
return d
}
func (d *douyin) WithContext(ctx context.Context) *douyinDo { return d.douyinDo.WithContext(ctx) }
func (d douyin) TableName() string { return d.douyinDo.TableName() }
func (d douyin) Alias() string { return d.douyinDo.Alias() }
func (d douyin) Columns(cols ...field.Expr) gen.Columns { return d.douyinDo.Columns(cols...) }
func (d *douyin) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := d.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (d *douyin) fillFieldMap() {
d.fieldMap = make(map[string]field.Expr, 5)
d.fieldMap["id"] = d.ID
d.fieldMap["app_id"] = d.AppID
d.fieldMap["secret"] = d.Secret
d.fieldMap["ecpm_value"] = d.EcpmValue
d.fieldMap["ecpm_view"] = d.EcpmView
}
func (d douyin) clone(db *gorm.DB) douyin {
d.douyinDo.ReplaceConnPool(db.Statement.ConnPool)
return d
}
func (d douyin) replaceDB(db *gorm.DB) douyin {
d.douyinDo.ReplaceDB(db)
return d
}
type douyinDo struct{ gen.DO }
func (d douyinDo) Debug() *douyinDo {
return d.withDO(d.DO.Debug())
}
func (d douyinDo) WithContext(ctx context.Context) *douyinDo {
return d.withDO(d.DO.WithContext(ctx))
}
func (d douyinDo) ReadDB() *douyinDo {
return d.Clauses(dbresolver.Read)
}
func (d douyinDo) WriteDB() *douyinDo {
return d.Clauses(dbresolver.Write)
}
func (d douyinDo) Session(config *gorm.Session) *douyinDo {
return d.withDO(d.DO.Session(config))
}
func (d douyinDo) Clauses(conds ...clause.Expression) *douyinDo {
return d.withDO(d.DO.Clauses(conds...))
}
func (d douyinDo) Returning(value interface{}, columns ...string) *douyinDo {
return d.withDO(d.DO.Returning(value, columns...))
}
func (d douyinDo) Not(conds ...gen.Condition) *douyinDo {
return d.withDO(d.DO.Not(conds...))
}
func (d douyinDo) Or(conds ...gen.Condition) *douyinDo {
return d.withDO(d.DO.Or(conds...))
}
func (d douyinDo) Select(conds ...field.Expr) *douyinDo {
return d.withDO(d.DO.Select(conds...))
}
func (d douyinDo) Where(conds ...gen.Condition) *douyinDo {
return d.withDO(d.DO.Where(conds...))
}
func (d douyinDo) Order(conds ...field.Expr) *douyinDo {
return d.withDO(d.DO.Order(conds...))
}
func (d douyinDo) Distinct(cols ...field.Expr) *douyinDo {
return d.withDO(d.DO.Distinct(cols...))
}
func (d douyinDo) Omit(cols ...field.Expr) *douyinDo {
return d.withDO(d.DO.Omit(cols...))
}
func (d douyinDo) Join(table schema.Tabler, on ...field.Expr) *douyinDo {
return d.withDO(d.DO.Join(table, on...))
}
func (d douyinDo) LeftJoin(table schema.Tabler, on ...field.Expr) *douyinDo {
return d.withDO(d.DO.LeftJoin(table, on...))
}
func (d douyinDo) RightJoin(table schema.Tabler, on ...field.Expr) *douyinDo {
return d.withDO(d.DO.RightJoin(table, on...))
}
func (d douyinDo) Group(cols ...field.Expr) *douyinDo {
return d.withDO(d.DO.Group(cols...))
}
func (d douyinDo) Having(conds ...gen.Condition) *douyinDo {
return d.withDO(d.DO.Having(conds...))
}
func (d douyinDo) Limit(limit int) *douyinDo {
return d.withDO(d.DO.Limit(limit))
}
func (d douyinDo) Offset(offset int) *douyinDo {
return d.withDO(d.DO.Offset(offset))
}
func (d douyinDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *douyinDo {
return d.withDO(d.DO.Scopes(funcs...))
}
func (d douyinDo) Unscoped() *douyinDo {
return d.withDO(d.DO.Unscoped())
}
func (d douyinDo) Create(values ...*model.Douyin) error {
if len(values) == 0 {
return nil
}
return d.DO.Create(values)
}
func (d douyinDo) CreateInBatches(values []*model.Douyin, batchSize int) error {
return d.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (d douyinDo) Save(values ...*model.Douyin) error {
if len(values) == 0 {
return nil
}
return d.DO.Save(values)
}
func (d douyinDo) First() (*model.Douyin, error) {
if result, err := d.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Douyin), nil
}
}
func (d douyinDo) Take() (*model.Douyin, error) {
if result, err := d.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Douyin), nil
}
}
func (d douyinDo) Last() (*model.Douyin, error) {
if result, err := d.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Douyin), nil
}
}
func (d douyinDo) Find() ([]*model.Douyin, error) {
result, err := d.DO.Find()
return result.([]*model.Douyin), err
}
func (d douyinDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Douyin, err error) {
buf := make([]*model.Douyin, 0, batchSize)
err = d.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (d douyinDo) FindInBatches(result *[]*model.Douyin, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return d.DO.FindInBatches(result, batchSize, fc)
}
func (d douyinDo) Attrs(attrs ...field.AssignExpr) *douyinDo {
return d.withDO(d.DO.Attrs(attrs...))
}
func (d douyinDo) Assign(attrs ...field.AssignExpr) *douyinDo {
return d.withDO(d.DO.Assign(attrs...))
}
func (d douyinDo) Joins(fields ...field.RelationField) *douyinDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Joins(_f))
}
return &d
}
func (d douyinDo) Preload(fields ...field.RelationField) *douyinDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Preload(_f))
}
return &d
}
func (d douyinDo) FirstOrInit() (*model.Douyin, error) {
if result, err := d.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Douyin), nil
}
}
func (d douyinDo) FirstOrCreate() (*model.Douyin, error) {
if result, err := d.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Douyin), nil
}
}
func (d douyinDo) FindByPage(offset int, limit int) (result []*model.Douyin, count int64, err error) {
result, err = d.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = d.Offset(-1).Limit(-1).Count()
return
}
func (d douyinDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = d.Count()
if err != nil {
return
}
err = d.Offset(offset).Limit(limit).Scan(result)
return
}
func (d douyinDo) Scan(result interface{}) (err error) {
return d.DO.Scan(result)
}
func (d douyinDo) Delete(models ...*model.Douyin) (result gen.ResultInfo, err error) {
return d.DO.Delete(models)
}
func (d *douyinDo) withDO(do gen.Dao) *douyinDo {
d.DO = *do.(*gen.DO)
return d
}

View File

@ -1,146 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"fmt"
"testing"
"youtu_ecpm/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
func init() {
InitializeDB()
err := _gen_test_db.AutoMigrate(&model.Douyin{})
if err != nil {
fmt.Printf("Error: AutoMigrate(&model.Douyin{}) fail: %s", err)
}
}
func Test_douyinQuery(t *testing.T) {
douyin := newDouyin(_gen_test_db)
douyin = *douyin.As(douyin.TableName())
_do := douyin.WithContext(context.Background()).Debug()
primaryKey := field.NewString(douyin.TableName(), clause.PrimaryKey)
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
if err != nil {
t.Error("clean table <douyin> fail:", err)
return
}
_, ok := douyin.GetFieldByName("")
if ok {
t.Error("GetFieldByName(\"\") from douyin success")
}
err = _do.Create(&model.Douyin{})
if err != nil {
t.Error("create item in table <douyin> fail:", err)
}
err = _do.Save(&model.Douyin{})
if err != nil {
t.Error("create item in table <douyin> fail:", err)
}
err = _do.CreateInBatches([]*model.Douyin{{}, {}}, 10)
if err != nil {
t.Error("create item in table <douyin> fail:", err)
}
_, err = _do.Select(douyin.ALL).Take()
if err != nil {
t.Error("Take() on table <douyin> fail:", err)
}
_, err = _do.First()
if err != nil {
t.Error("First() on table <douyin> fail:", err)
}
_, err = _do.Last()
if err != nil {
t.Error("First() on table <douyin> fail:", err)
}
_, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatch() on table <douyin> fail:", err)
}
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*model.Douyin{}, 10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatches() on table <douyin> fail:", err)
}
_, err = _do.Select(douyin.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
if err != nil {
t.Error("Find() on table <douyin> fail:", err)
}
_, err = _do.Distinct(primaryKey).Take()
if err != nil {
t.Error("select Distinct() on table <douyin> fail:", err)
}
_, err = _do.Select(douyin.ALL).Omit(primaryKey).Take()
if err != nil {
t.Error("Omit() on table <douyin> fail:", err)
}
_, err = _do.Group(primaryKey).Find()
if err != nil {
t.Error("Group() on table <douyin> fail:", err)
}
_, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
if err != nil {
t.Error("Scopes() on table <douyin> fail:", err)
}
_, _, err = _do.FindByPage(0, 1)
if err != nil {
t.Error("FindByPage() on table <douyin> fail:", err)
}
_, err = _do.ScanByPage(&model.Douyin{}, 0, 1)
if err != nil {
t.Error("ScanByPage() on table <douyin> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
if err != nil {
t.Error("FirstOrInit() on table <douyin> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
if err != nil {
t.Error("FirstOrCreate() on table <douyin> fail:", err)
}
var _a _another
var _aPK = field.NewString(_a.TableName(), "id")
err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("Join() on table <douyin> fail:", err)
}
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("LeftJoin() on table <douyin> fail:", err)
}
_, err = _do.Not().Or().Clauses().Take()
if err != nil {
t.Error("Not/Or/Clauses on table <douyin> fail:", err)
}
}

View File

@ -0,0 +1,343 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"youtu_ecpm/dao/model"
)
func newDouyinEcpmConfig(db *gorm.DB, opts ...gen.DOOption) douyinEcpmConfig {
_douyinEcpmConfig := douyinEcpmConfig{}
_douyinEcpmConfig.douyinEcpmConfigDo.UseDB(db, opts...)
_douyinEcpmConfig.douyinEcpmConfigDo.UseModel(&model.DouyinEcpmConfig{})
tableName := _douyinEcpmConfig.douyinEcpmConfigDo.TableName()
_douyinEcpmConfig.ALL = field.NewAsterisk(tableName)
_douyinEcpmConfig.ID = field.NewUint32(tableName, "id")
_douyinEcpmConfig.AppAccountID = field.NewUint32(tableName, "app_account_id")
_douyinEcpmConfig.EcpmValue = field.NewUint32(tableName, "ecpm_value")
_douyinEcpmConfig.EcpmView = field.NewUint32(tableName, "ecpm_view")
_douyinEcpmConfig.fillFieldMap()
return _douyinEcpmConfig
}
type douyinEcpmConfig struct {
douyinEcpmConfigDo douyinEcpmConfigDo
ALL field.Asterisk
ID field.Uint32
AppAccountID field.Uint32
EcpmValue field.Uint32 // 值
EcpmView field.Uint32 // 浏览次数
fieldMap map[string]field.Expr
}
func (d douyinEcpmConfig) Table(newTableName string) *douyinEcpmConfig {
d.douyinEcpmConfigDo.UseTable(newTableName)
return d.updateTableName(newTableName)
}
func (d douyinEcpmConfig) As(alias string) *douyinEcpmConfig {
d.douyinEcpmConfigDo.DO = *(d.douyinEcpmConfigDo.As(alias).(*gen.DO))
return d.updateTableName(alias)
}
func (d *douyinEcpmConfig) updateTableName(table string) *douyinEcpmConfig {
d.ALL = field.NewAsterisk(table)
d.ID = field.NewUint32(table, "id")
d.AppAccountID = field.NewUint32(table, "app_account_id")
d.EcpmValue = field.NewUint32(table, "ecpm_value")
d.EcpmView = field.NewUint32(table, "ecpm_view")
d.fillFieldMap()
return d
}
func (d *douyinEcpmConfig) WithContext(ctx context.Context) *douyinEcpmConfigDo {
return d.douyinEcpmConfigDo.WithContext(ctx)
}
func (d douyinEcpmConfig) TableName() string { return d.douyinEcpmConfigDo.TableName() }
func (d douyinEcpmConfig) Alias() string { return d.douyinEcpmConfigDo.Alias() }
func (d douyinEcpmConfig) Columns(cols ...field.Expr) gen.Columns {
return d.douyinEcpmConfigDo.Columns(cols...)
}
func (d *douyinEcpmConfig) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := d.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (d *douyinEcpmConfig) fillFieldMap() {
d.fieldMap = make(map[string]field.Expr, 4)
d.fieldMap["id"] = d.ID
d.fieldMap["app_account_id"] = d.AppAccountID
d.fieldMap["ecpm_value"] = d.EcpmValue
d.fieldMap["ecpm_view"] = d.EcpmView
}
func (d douyinEcpmConfig) clone(db *gorm.DB) douyinEcpmConfig {
d.douyinEcpmConfigDo.ReplaceConnPool(db.Statement.ConnPool)
return d
}
func (d douyinEcpmConfig) replaceDB(db *gorm.DB) douyinEcpmConfig {
d.douyinEcpmConfigDo.ReplaceDB(db)
return d
}
type douyinEcpmConfigDo struct{ gen.DO }
func (d douyinEcpmConfigDo) Debug() *douyinEcpmConfigDo {
return d.withDO(d.DO.Debug())
}
func (d douyinEcpmConfigDo) WithContext(ctx context.Context) *douyinEcpmConfigDo {
return d.withDO(d.DO.WithContext(ctx))
}
func (d douyinEcpmConfigDo) ReadDB() *douyinEcpmConfigDo {
return d.Clauses(dbresolver.Read)
}
func (d douyinEcpmConfigDo) WriteDB() *douyinEcpmConfigDo {
return d.Clauses(dbresolver.Write)
}
func (d douyinEcpmConfigDo) Session(config *gorm.Session) *douyinEcpmConfigDo {
return d.withDO(d.DO.Session(config))
}
func (d douyinEcpmConfigDo) Clauses(conds ...clause.Expression) *douyinEcpmConfigDo {
return d.withDO(d.DO.Clauses(conds...))
}
func (d douyinEcpmConfigDo) Returning(value interface{}, columns ...string) *douyinEcpmConfigDo {
return d.withDO(d.DO.Returning(value, columns...))
}
func (d douyinEcpmConfigDo) Not(conds ...gen.Condition) *douyinEcpmConfigDo {
return d.withDO(d.DO.Not(conds...))
}
func (d douyinEcpmConfigDo) Or(conds ...gen.Condition) *douyinEcpmConfigDo {
return d.withDO(d.DO.Or(conds...))
}
func (d douyinEcpmConfigDo) Select(conds ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Select(conds...))
}
func (d douyinEcpmConfigDo) Where(conds ...gen.Condition) *douyinEcpmConfigDo {
return d.withDO(d.DO.Where(conds...))
}
func (d douyinEcpmConfigDo) Order(conds ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Order(conds...))
}
func (d douyinEcpmConfigDo) Distinct(cols ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Distinct(cols...))
}
func (d douyinEcpmConfigDo) Omit(cols ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Omit(cols...))
}
func (d douyinEcpmConfigDo) Join(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Join(table, on...))
}
func (d douyinEcpmConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.LeftJoin(table, on...))
}
func (d douyinEcpmConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.RightJoin(table, on...))
}
func (d douyinEcpmConfigDo) Group(cols ...field.Expr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Group(cols...))
}
func (d douyinEcpmConfigDo) Having(conds ...gen.Condition) *douyinEcpmConfigDo {
return d.withDO(d.DO.Having(conds...))
}
func (d douyinEcpmConfigDo) Limit(limit int) *douyinEcpmConfigDo {
return d.withDO(d.DO.Limit(limit))
}
func (d douyinEcpmConfigDo) Offset(offset int) *douyinEcpmConfigDo {
return d.withDO(d.DO.Offset(offset))
}
func (d douyinEcpmConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *douyinEcpmConfigDo {
return d.withDO(d.DO.Scopes(funcs...))
}
func (d douyinEcpmConfigDo) Unscoped() *douyinEcpmConfigDo {
return d.withDO(d.DO.Unscoped())
}
func (d douyinEcpmConfigDo) Create(values ...*model.DouyinEcpmConfig) error {
if len(values) == 0 {
return nil
}
return d.DO.Create(values)
}
func (d douyinEcpmConfigDo) CreateInBatches(values []*model.DouyinEcpmConfig, batchSize int) error {
return d.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (d douyinEcpmConfigDo) Save(values ...*model.DouyinEcpmConfig) error {
if len(values) == 0 {
return nil
}
return d.DO.Save(values)
}
func (d douyinEcpmConfigDo) First() (*model.DouyinEcpmConfig, error) {
if result, err := d.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.DouyinEcpmConfig), nil
}
}
func (d douyinEcpmConfigDo) Take() (*model.DouyinEcpmConfig, error) {
if result, err := d.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.DouyinEcpmConfig), nil
}
}
func (d douyinEcpmConfigDo) Last() (*model.DouyinEcpmConfig, error) {
if result, err := d.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.DouyinEcpmConfig), nil
}
}
func (d douyinEcpmConfigDo) Find() ([]*model.DouyinEcpmConfig, error) {
result, err := d.DO.Find()
return result.([]*model.DouyinEcpmConfig), err
}
func (d douyinEcpmConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DouyinEcpmConfig, err error) {
buf := make([]*model.DouyinEcpmConfig, 0, batchSize)
err = d.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (d douyinEcpmConfigDo) FindInBatches(result *[]*model.DouyinEcpmConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return d.DO.FindInBatches(result, batchSize, fc)
}
func (d douyinEcpmConfigDo) Attrs(attrs ...field.AssignExpr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Attrs(attrs...))
}
func (d douyinEcpmConfigDo) Assign(attrs ...field.AssignExpr) *douyinEcpmConfigDo {
return d.withDO(d.DO.Assign(attrs...))
}
func (d douyinEcpmConfigDo) Joins(fields ...field.RelationField) *douyinEcpmConfigDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Joins(_f))
}
return &d
}
func (d douyinEcpmConfigDo) Preload(fields ...field.RelationField) *douyinEcpmConfigDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Preload(_f))
}
return &d
}
func (d douyinEcpmConfigDo) FirstOrInit() (*model.DouyinEcpmConfig, error) {
if result, err := d.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.DouyinEcpmConfig), nil
}
}
func (d douyinEcpmConfigDo) FirstOrCreate() (*model.DouyinEcpmConfig, error) {
if result, err := d.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.DouyinEcpmConfig), nil
}
}
func (d douyinEcpmConfigDo) FindByPage(offset int, limit int) (result []*model.DouyinEcpmConfig, count int64, err error) {
result, err = d.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = d.Offset(-1).Limit(-1).Count()
return
}
func (d douyinEcpmConfigDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = d.Count()
if err != nil {
return
}
err = d.Offset(offset).Limit(limit).Scan(result)
return
}
func (d douyinEcpmConfigDo) Scan(result interface{}) (err error) {
return d.DO.Scan(result)
}
func (d douyinEcpmConfigDo) Delete(models ...*model.DouyinEcpmConfig) (result gen.ResultInfo, err error) {
return d.DO.Delete(models)
}
func (d *douyinEcpmConfigDo) withDO(do gen.Dao) *douyinEcpmConfigDo {
d.DO = *do.(*gen.DO)
return d
}

View File

@ -0,0 +1,146 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"fmt"
"testing"
"youtu_ecpm/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
func init() {
InitializeDB()
err := _gen_test_db.AutoMigrate(&model.DouyinEcpmConfig{})
if err != nil {
fmt.Printf("Error: AutoMigrate(&model.DouyinEcpmConfig{}) fail: %s", err)
}
}
func Test_douyinEcpmConfigQuery(t *testing.T) {
douyinEcpmConfig := newDouyinEcpmConfig(_gen_test_db)
douyinEcpmConfig = *douyinEcpmConfig.As(douyinEcpmConfig.TableName())
_do := douyinEcpmConfig.WithContext(context.Background()).Debug()
primaryKey := field.NewString(douyinEcpmConfig.TableName(), clause.PrimaryKey)
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
if err != nil {
t.Error("clean table <douyin_ecpm_config> fail:", err)
return
}
_, ok := douyinEcpmConfig.GetFieldByName("")
if ok {
t.Error("GetFieldByName(\"\") from douyinEcpmConfig success")
}
err = _do.Create(&model.DouyinEcpmConfig{})
if err != nil {
t.Error("create item in table <douyin_ecpm_config> fail:", err)
}
err = _do.Save(&model.DouyinEcpmConfig{})
if err != nil {
t.Error("create item in table <douyin_ecpm_config> fail:", err)
}
err = _do.CreateInBatches([]*model.DouyinEcpmConfig{{}, {}}, 10)
if err != nil {
t.Error("create item in table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Select(douyinEcpmConfig.ALL).Take()
if err != nil {
t.Error("Take() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.First()
if err != nil {
t.Error("First() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Last()
if err != nil {
t.Error("First() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatch() on table <douyin_ecpm_config> fail:", err)
}
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*model.DouyinEcpmConfig{}, 10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatches() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Select(douyinEcpmConfig.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
if err != nil {
t.Error("Find() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Distinct(primaryKey).Take()
if err != nil {
t.Error("select Distinct() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Select(douyinEcpmConfig.ALL).Omit(primaryKey).Take()
if err != nil {
t.Error("Omit() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Group(primaryKey).Find()
if err != nil {
t.Error("Group() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
if err != nil {
t.Error("Scopes() on table <douyin_ecpm_config> fail:", err)
}
_, _, err = _do.FindByPage(0, 1)
if err != nil {
t.Error("FindByPage() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.ScanByPage(&model.DouyinEcpmConfig{}, 0, 1)
if err != nil {
t.Error("ScanByPage() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
if err != nil {
t.Error("FirstOrInit() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
if err != nil {
t.Error("FirstOrCreate() on table <douyin_ecpm_config> fail:", err)
}
var _a _another
var _aPK = field.NewString(_a.TableName(), "id")
err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("Join() on table <douyin_ecpm_config> fail:", err)
}
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("LeftJoin() on table <douyin_ecpm_config> fail:", err)
}
_, err = _do.Not().Or().Clauses().Take()
if err != nil {
t.Error("Not/Or/Clauses on table <douyin_ecpm_config> fail:", err)
}
}

337
dao/query/game_score.gen.go Normal file
View File

@ -0,0 +1,337 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"youtu_ecpm/dao/model"
)
func newGameScore(db *gorm.DB, opts ...gen.DOOption) gameScore {
_gameScore := gameScore{}
_gameScore.gameScoreDo.UseDB(db, opts...)
_gameScore.gameScoreDo.UseModel(&model.GameScore{})
tableName := _gameScore.gameScoreDo.TableName()
_gameScore.ALL = field.NewAsterisk(tableName)
_gameScore.AppUserID = field.NewUint64(tableName, "app_user_id")
_gameScore.AppAccount = field.NewUint32(tableName, "app_account")
_gameScore.Score = field.NewUint32(tableName, "score")
_gameScore.fillFieldMap()
return _gameScore
}
type gameScore struct {
gameScoreDo gameScoreDo
ALL field.Asterisk
AppUserID field.Uint64
AppAccount field.Uint32
Score field.Uint32
fieldMap map[string]field.Expr
}
func (g gameScore) Table(newTableName string) *gameScore {
g.gameScoreDo.UseTable(newTableName)
return g.updateTableName(newTableName)
}
func (g gameScore) As(alias string) *gameScore {
g.gameScoreDo.DO = *(g.gameScoreDo.As(alias).(*gen.DO))
return g.updateTableName(alias)
}
func (g *gameScore) updateTableName(table string) *gameScore {
g.ALL = field.NewAsterisk(table)
g.AppUserID = field.NewUint64(table, "app_user_id")
g.AppAccount = field.NewUint32(table, "app_account")
g.Score = field.NewUint32(table, "score")
g.fillFieldMap()
return g
}
func (g *gameScore) WithContext(ctx context.Context) *gameScoreDo {
return g.gameScoreDo.WithContext(ctx)
}
func (g gameScore) TableName() string { return g.gameScoreDo.TableName() }
func (g gameScore) Alias() string { return g.gameScoreDo.Alias() }
func (g gameScore) Columns(cols ...field.Expr) gen.Columns { return g.gameScoreDo.Columns(cols...) }
func (g *gameScore) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := g.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (g *gameScore) fillFieldMap() {
g.fieldMap = make(map[string]field.Expr, 3)
g.fieldMap["app_user_id"] = g.AppUserID
g.fieldMap["app_account"] = g.AppAccount
g.fieldMap["score"] = g.Score
}
func (g gameScore) clone(db *gorm.DB) gameScore {
g.gameScoreDo.ReplaceConnPool(db.Statement.ConnPool)
return g
}
func (g gameScore) replaceDB(db *gorm.DB) gameScore {
g.gameScoreDo.ReplaceDB(db)
return g
}
type gameScoreDo struct{ gen.DO }
func (g gameScoreDo) Debug() *gameScoreDo {
return g.withDO(g.DO.Debug())
}
func (g gameScoreDo) WithContext(ctx context.Context) *gameScoreDo {
return g.withDO(g.DO.WithContext(ctx))
}
func (g gameScoreDo) ReadDB() *gameScoreDo {
return g.Clauses(dbresolver.Read)
}
func (g gameScoreDo) WriteDB() *gameScoreDo {
return g.Clauses(dbresolver.Write)
}
func (g gameScoreDo) Session(config *gorm.Session) *gameScoreDo {
return g.withDO(g.DO.Session(config))
}
func (g gameScoreDo) Clauses(conds ...clause.Expression) *gameScoreDo {
return g.withDO(g.DO.Clauses(conds...))
}
func (g gameScoreDo) Returning(value interface{}, columns ...string) *gameScoreDo {
return g.withDO(g.DO.Returning(value, columns...))
}
func (g gameScoreDo) Not(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Not(conds...))
}
func (g gameScoreDo) Or(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Or(conds...))
}
func (g gameScoreDo) Select(conds ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Select(conds...))
}
func (g gameScoreDo) Where(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Where(conds...))
}
func (g gameScoreDo) Order(conds ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Order(conds...))
}
func (g gameScoreDo) Distinct(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Distinct(cols...))
}
func (g gameScoreDo) Omit(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Omit(cols...))
}
func (g gameScoreDo) Join(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Join(table, on...))
}
func (g gameScoreDo) LeftJoin(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.LeftJoin(table, on...))
}
func (g gameScoreDo) RightJoin(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.RightJoin(table, on...))
}
func (g gameScoreDo) Group(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Group(cols...))
}
func (g gameScoreDo) Having(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Having(conds...))
}
func (g gameScoreDo) Limit(limit int) *gameScoreDo {
return g.withDO(g.DO.Limit(limit))
}
func (g gameScoreDo) Offset(offset int) *gameScoreDo {
return g.withDO(g.DO.Offset(offset))
}
func (g gameScoreDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *gameScoreDo {
return g.withDO(g.DO.Scopes(funcs...))
}
func (g gameScoreDo) Unscoped() *gameScoreDo {
return g.withDO(g.DO.Unscoped())
}
func (g gameScoreDo) Create(values ...*model.GameScore) error {
if len(values) == 0 {
return nil
}
return g.DO.Create(values)
}
func (g gameScoreDo) CreateInBatches(values []*model.GameScore, batchSize int) error {
return g.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (g gameScoreDo) Save(values ...*model.GameScore) error {
if len(values) == 0 {
return nil
}
return g.DO.Save(values)
}
func (g gameScoreDo) First() (*model.GameScore, error) {
if result, err := g.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Take() (*model.GameScore, error) {
if result, err := g.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Last() (*model.GameScore, error) {
if result, err := g.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Find() ([]*model.GameScore, error) {
result, err := g.DO.Find()
return result.([]*model.GameScore), err
}
func (g gameScoreDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.GameScore, err error) {
buf := make([]*model.GameScore, 0, batchSize)
err = g.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (g gameScoreDo) FindInBatches(result *[]*model.GameScore, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return g.DO.FindInBatches(result, batchSize, fc)
}
func (g gameScoreDo) Attrs(attrs ...field.AssignExpr) *gameScoreDo {
return g.withDO(g.DO.Attrs(attrs...))
}
func (g gameScoreDo) Assign(attrs ...field.AssignExpr) *gameScoreDo {
return g.withDO(g.DO.Assign(attrs...))
}
func (g gameScoreDo) Joins(fields ...field.RelationField) *gameScoreDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Joins(_f))
}
return &g
}
func (g gameScoreDo) Preload(fields ...field.RelationField) *gameScoreDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Preload(_f))
}
return &g
}
func (g gameScoreDo) FirstOrInit() (*model.GameScore, error) {
if result, err := g.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) FirstOrCreate() (*model.GameScore, error) {
if result, err := g.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) FindByPage(offset int, limit int) (result []*model.GameScore, count int64, err error) {
result, err = g.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = g.Offset(-1).Limit(-1).Count()
return
}
func (g gameScoreDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = g.Count()
if err != nil {
return
}
err = g.Offset(offset).Limit(limit).Scan(result)
return
}
func (g gameScoreDo) Scan(result interface{}) (err error) {
return g.DO.Scan(result)
}
func (g gameScoreDo) Delete(models ...*model.GameScore) (result gen.ResultInfo, err error) {
return g.DO.Delete(models)
}
func (g *gameScoreDo) withDO(do gen.Dao) *gameScoreDo {
g.DO = *do.(*gen.DO)
return g
}

View File

@ -0,0 +1,146 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"fmt"
"testing"
"youtu_ecpm/dao/model"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm/clause"
)
func init() {
InitializeDB()
err := _gen_test_db.AutoMigrate(&model.GameScore{})
if err != nil {
fmt.Printf("Error: AutoMigrate(&model.GameScore{}) fail: %s", err)
}
}
func Test_gameScoreQuery(t *testing.T) {
gameScore := newGameScore(_gen_test_db)
gameScore = *gameScore.As(gameScore.TableName())
_do := gameScore.WithContext(context.Background()).Debug()
primaryKey := field.NewString(gameScore.TableName(), clause.PrimaryKey)
_, err := _do.Unscoped().Where(primaryKey.IsNotNull()).Delete()
if err != nil {
t.Error("clean table <game_score> fail:", err)
return
}
_, ok := gameScore.GetFieldByName("")
if ok {
t.Error("GetFieldByName(\"\") from gameScore success")
}
err = _do.Create(&model.GameScore{})
if err != nil {
t.Error("create item in table <game_score> fail:", err)
}
err = _do.Save(&model.GameScore{})
if err != nil {
t.Error("create item in table <game_score> fail:", err)
}
err = _do.CreateInBatches([]*model.GameScore{{}, {}}, 10)
if err != nil {
t.Error("create item in table <game_score> fail:", err)
}
_, err = _do.Select(gameScore.ALL).Take()
if err != nil {
t.Error("Take() on table <game_score> fail:", err)
}
_, err = _do.First()
if err != nil {
t.Error("First() on table <game_score> fail:", err)
}
_, err = _do.Last()
if err != nil {
t.Error("First() on table <game_score> fail:", err)
}
_, err = _do.Where(primaryKey.IsNotNull()).FindInBatch(10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatch() on table <game_score> fail:", err)
}
err = _do.Where(primaryKey.IsNotNull()).FindInBatches(&[]*model.GameScore{}, 10, func(tx gen.Dao, batch int) error { return nil })
if err != nil {
t.Error("FindInBatches() on table <game_score> fail:", err)
}
_, err = _do.Select(gameScore.ALL).Where(primaryKey.IsNotNull()).Order(primaryKey.Desc()).Find()
if err != nil {
t.Error("Find() on table <game_score> fail:", err)
}
_, err = _do.Distinct(primaryKey).Take()
if err != nil {
t.Error("select Distinct() on table <game_score> fail:", err)
}
_, err = _do.Select(gameScore.ALL).Omit(primaryKey).Take()
if err != nil {
t.Error("Omit() on table <game_score> fail:", err)
}
_, err = _do.Group(primaryKey).Find()
if err != nil {
t.Error("Group() on table <game_score> fail:", err)
}
_, err = _do.Scopes(func(dao gen.Dao) gen.Dao { return dao.Where(primaryKey.IsNotNull()) }).Find()
if err != nil {
t.Error("Scopes() on table <game_score> fail:", err)
}
_, _, err = _do.FindByPage(0, 1)
if err != nil {
t.Error("FindByPage() on table <game_score> fail:", err)
}
_, err = _do.ScanByPage(&model.GameScore{}, 0, 1)
if err != nil {
t.Error("ScanByPage() on table <game_score> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrInit()
if err != nil {
t.Error("FirstOrInit() on table <game_score> fail:", err)
}
_, err = _do.Attrs(primaryKey).Assign(primaryKey).FirstOrCreate()
if err != nil {
t.Error("FirstOrCreate() on table <game_score> fail:", err)
}
var _a _another
var _aPK = field.NewString(_a.TableName(), "id")
err = _do.Join(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("Join() on table <game_score> fail:", err)
}
err = _do.LeftJoin(&_a, primaryKey.EqCol(_aPK)).Scan(map[string]interface{}{})
if err != nil {
t.Error("LeftJoin() on table <game_score> fail:", err)
}
_, err = _do.Not().Or().Clauses().Take()
if err != nil {
t.Error("Not/Or/Clauses on table <game_score> fail:", err)
}
}

View File

@ -17,23 +17,32 @@ import (
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
Douyin: newDouyin(db, opts...),
db: db,
AppAccount: newAppAccount(db, opts...),
AppUserInfo: newAppUserInfo(db, opts...),
DouyinEcpmConfig: newDouyinEcpmConfig(db, opts...),
GameScore: newGameScore(db, opts...),
}
}
type Query struct {
db *gorm.DB
Douyin douyin
AppAccount appAccount
AppUserInfo appUserInfo
DouyinEcpmConfig douyinEcpmConfig
GameScore gameScore
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
Douyin: q.Douyin.clone(db),
db: db,
AppAccount: q.AppAccount.clone(db),
AppUserInfo: q.AppUserInfo.clone(db),
DouyinEcpmConfig: q.DouyinEcpmConfig.clone(db),
GameScore: q.GameScore.clone(db),
}
}
@ -47,18 +56,27 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
Douyin: q.Douyin.replaceDB(db),
db: db,
AppAccount: q.AppAccount.replaceDB(db),
AppUserInfo: q.AppUserInfo.replaceDB(db),
DouyinEcpmConfig: q.DouyinEcpmConfig.replaceDB(db),
GameScore: q.GameScore.replaceDB(db),
}
}
type queryCtx struct {
Douyin *douyinDo
AppAccount *appAccountDo
AppUserInfo *appUserInfoDo
DouyinEcpmConfig *douyinEcpmConfigDo
GameScore *gameScoreDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
Douyin: q.Douyin.WithContext(ctx),
AppAccount: q.AppAccount.WithContext(ctx),
AppUserInfo: q.AppUserInfo.WithContext(ctx),
DouyinEcpmConfig: q.DouyinEcpmConfig.WithContext(ctx),
GameScore: q.GameScore.WithContext(ctx),
}
}

View File

@ -77,7 +77,10 @@ func Test_WithContext(t *testing.T) {
qCtx := query.WithContext(context.WithValue(context.Background(), key, value))
for _, ctx := range []context.Context{
qCtx.Douyin.UnderlyingDB().Statement.Context,
qCtx.AppAccount.UnderlyingDB().Statement.Context,
qCtx.AppUserInfo.UnderlyingDB().Statement.Context,
qCtx.DouyinEcpmConfig.UnderlyingDB().Statement.Context,
qCtx.GameScore.UnderlyingDB().Statement.Context,
} {
if v := ctx.Value(key); v != value {
t.Errorf("get value from context fail, expect %q, got %q", value, v)

View File

@ -13,7 +13,7 @@ services:
environment:
MYSQL_ROOT_PASSWORD: youtu!0113
MYSQL_INITDB_SKIP_TZINFO: "Asia/Shanghai"
#MYSQL_DATABASE: data_sys
MYSQL_DATABASE: ecpm
volumes:
#数据目录,要确保先创建好
- ./data/mysql/data:/var/lib/mysql

65
go.mod
View File

@ -12,61 +12,72 @@ require (
github.com/spf13/viper v1.19.0
go.uber.org/zap v1.27.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gorm.io/driver/mysql v1.4.4
gorm.io/driver/sqlite v1.4.3
gorm.io/driver/mysql v1.5.7
gorm.io/driver/sqlite v1.5.7
gorm.io/gen v0.3.26
gorm.io/gorm v1.25.9
gorm.io/plugin/dbresolver v1.5.0
gorm.io/gorm v1.25.12
gorm.io/plugin/dbresolver v1.5.3
)
require (
github.com/bytedance/sonic v1.12.1 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect
github.com/bytedance/sonic v1.12.7 // indirect
github.com/bytedance/sonic/loader v0.2.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v1.0.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/go-playground/validator/v10 v10.24.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/silenceper/wechat/v2 v2.1.7 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/gjson v1.14.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/arch v0.13.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/tools v0.29.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
gorm.io/datatypes v1.2.5 // indirect
gorm.io/hints v1.1.2 // indirect
)

267
go.sum
View File

@ -1,26 +1,43 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
gitea.youtukeji.com.cn/xiabin/douyin-openapi v0.0.4 h1:xQmWix8yK+OlCJQlpNl5RiLRwbh+kli8YCcStZfdWCU=
gitea.youtukeji.com.cn/xiabin/douyin-openapi v0.0.4/go.mod h1:7d5OkLrsgX/iI4E9nVi2hYC2vvLrDi/QKCuTF4S/k6g=
github.com/bytedance/sonic v1.12.1 h1:jWl5Qz1fy7X1ioY74WqO0KjAMtAGQs4sYnjiEBiyX24=
github.com/bytedance/sonic v1.12.1/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.30.0/go.mod h1:84TWKZlxYkfgMucPBf5SOQBYJceZeQRFIaQgNMiCX6Q=
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q=
github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM=
github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.3 h1:yctD0Q3v2NOGfSWPLPvG2ggA2kV6TS6s4wioyEqssH0=
github.com/bytedance/sonic/loader v0.2.3/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
github.com/gin-contrib/zap v1.1.4 h1:xvxTybg6XBdNtcQLH3Tf0lFr4vhDkwzgLLrIGlNTqIo=
github.com/gin-contrib/zap v1.1.4/go.mod h1:7lgEpe91kLbeJkwBTPgtVBy4zMa6oSBEcvj662diqKQ=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
@ -31,53 +48,65 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI=
github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys=
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y=
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w=
github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E=
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@ -85,15 +114,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE=
github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA=
github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -101,23 +131,40 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/silenceper/wechat/v2 v2.1.7 h1:v4AC4pa6NRm7Pa2FJnmWABOxZ9hx3IIo20xKT4t1msY=
github.com/silenceper/wechat/v2 v2.1.7/go.mod h1:7Iu3EhQYVtDUJAj+ZVRy8yom75ga7aDWv8RurLkVm0s=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
@ -126,45 +173,65 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/arch v0.9.0 h1:ub9TgUInamJ8mrZIGlBG6/4TqWeMszd4N8lNorbrr6k=
golang.org/x/arch v0.9.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/arch v0.13.0 h1:KCkqVVV1kGg0X87TFysjCJ8MxtZEIU4Ja/yXGeoECdA=
golang.org/x/arch v0.13.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
@ -172,17 +239,32 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -199,6 +281,7 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
@ -208,48 +291,64 @@ golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c h1:jWdr7cHgl8c/ua5vYbR2WhSp+NQmzhsj0xoY3foTzW8=
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c/go.mod h1:SH2K9R+2RMjuX1CkCONrPwoe9JzVv2hkQvEu4bXGojE=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/mysql v1.4.4 h1:MX0K9Qvy0Na4o7qSC/YI7XxqUw5KDw01umqgID+svdQ=
gorm.io/driver/mysql v1.4.4/go.mod h1:BCg8cKI+R0j/rZRQxeKis/forqRwRSYOR8OM3Wo6hOM=
gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc=
gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg=
gorm.io/driver/sqlite v1.1.6/go.mod h1:W8LmC/6UvVbHKah0+QOC7Ja66EaZXHwUTjgXY8YNWX8=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig=
gorm.io/datatypes v1.2.5 h1:9UogU3jkydFVW1bIVVeoYsTpLRgwDVW3rHfJG6/Ek9I=
gorm.io/datatypes v1.2.5/go.mod h1:I5FUdlKpLb5PMqeMQhm30CQ6jXP8Rj89xkTeCSAaAD4=
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U=
gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A=
gorm.io/driver/sqlite v1.5.0/go.mod h1:kDMDfntV9u/vuMmz8APHtHF0b4nyBB7sfCieC6G8k8I=
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
gorm.io/driver/sqlserver v1.5.4 h1:xA+Y1KDNspv79q43bPyjDMUgHoYHLhXYmdFcYPobg8g=
gorm.io/driver/sqlserver v1.5.4/go.mod h1:+frZ/qYmuna11zHPlh5oc2O6ZA/lS88Keb0XSH1Zh/g=
gorm.io/gen v0.3.26 h1:sFf1j7vNStimPRRAtH4zz5NiHM+1dr6eA9aaRdplyhY=
gorm.io/gen v0.3.26/go.mod h1:a5lq5y3w4g5LMxBcw0wnO6tYUCdNutWODq5LrIt75LE=
gorm.io/gorm v1.21.15/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/hints v1.1.0 h1:Lp4z3rxREufSdxn4qmkK3TLDltrM10FLTHiuqwDPvXw=
gorm.io/hints v1.1.0/go.mod h1:lKQ0JjySsPBj3uslFzY3JhYDtqEwzm+G1hv8rWujB6Y=
gorm.io/plugin/dbresolver v1.5.0 h1:XVHLxh775eP0CqVh3vcfJtYqja3uFl5Wr3cKlY8jgDY=
gorm.io/plugin/dbresolver v1.5.0/go.mod h1:l4Cn87EHLEYuqUncpEeTC2tTJQkjngPSD+lo8hIvcT0=
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gorm.io/hints v1.1.2 h1:b5j0kwk5p4+3BtDtYqqfY+ATSxjj+6ptPgVveuynn9o=
gorm.io/hints v1.1.2/go.mod h1:/ARdpUHAtyEMCh5NNi3tI7FsGh+Cj/MIUlvNxCNCFWg=
gorm.io/plugin/dbresolver v1.5.3 h1:wFwINGZZmttuu9h7XpvbDHd8Lf9bb8GNzp/NpAMV2wU=
gorm.io/plugin/dbresolver v1.5.3/go.mod h1:TSrVhaUg2DZAWP3PrHlDlITEJmNOkL0tFTjvTEsQ4XE=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=

View File

@ -1,13 +0,0 @@
package model
type Douyin struct {
Id uint `gorm:"column:id;type:int(11) unsigned;primary_key;AUTO_INCREMENT" json:"id"`
AppId string `gorm:"column:app_id;type:varchar(20);NOT NULL" json:"app_id"`
Secret string `gorm:"column:secret;type:varchar(40);NOT NULL" json:"secret"`
EcpmValue int `gorm:"column:ecpm_value;type:int(11);NOT NULL" json:"ecpm_value"`
EcpmView int `gorm:"column:ecpm_view;type:int(11);NOT NULL" json:"ecpm_view"`
}
func (m *Douyin) TableName() string {
return "douyin"
}

View File

@ -7,6 +7,7 @@ import (
"gitea.youtukeji.com.cn/xiabin/douyin-openapi/cache"
"gorm.io/gorm"
"sync"
errors2 "youtu_ecpm/pkg/errors"
)
type DouYinOpenApiClient struct {
@ -37,7 +38,7 @@ func NewDouYinOpenApiClient() *DouYinOpenApiClient {
// appId: 小程序id
func (d *DouYinOpenApiClient) GetDouYinOpenApi(appId string) (api *DouYinApi, err error) {
if v, ok := d.m.Load(appId); !ok {
err = ErrCacheNotFound
err = errors2.ErrCacheNotFound
return
} else {
api = v.(*DouYinApi)

View File

@ -1,4 +1,4 @@
package douyinapi
package errors
import "errors"

62
pkg/wechat_api/client.go Normal file
View File

@ -0,0 +1,62 @@
package wechat_api
import (
"gitea.youtukeji.com.cn/xiabin/douyin-openapi/cache"
"github.com/silenceper/wechat/v2"
"github.com/silenceper/wechat/v2/miniprogram"
miniConfig "github.com/silenceper/wechat/v2/miniprogram/config"
"gorm.io/gorm"
"sync"
"youtu_ecpm/pkg/errors"
)
type WechatApi struct {
db *gorm.DB
m *sync.Map
wc *wechat.Wechat
}
var WechatCli *WechatApi
func NewWechatOpenApiClient() *WechatApi {
return &WechatApi{
m: &sync.Map{},
wc: wechat.NewWechat(),
}
}
// GetWechatOpenApi 获取微信client
// appId: 小程序id
func (d *WechatApi) GetWechatOpenApi(appId string) (api *miniprogram.MiniProgram, err error) {
if v, ok := d.m.Load(appId); !ok {
err = errors.ErrCacheNotFound
return
} else {
api = v.(*miniprogram.MiniProgram)
return
}
}
// SetWechatOpenApi 存储微信client
// appId: 小程序id
func (d *WechatApi) SetWechatOpenApi(appId string, api *miniprogram.MiniProgram) {
d.m.Store(appId, api)
}
// NewAndStoreWechatOpenApi 创建微信client并存储
// appId: 小程序id
// appSecret: 小程序secret
// cache: 缓存
func (d *WechatApi) NewAndStoreWechatOpenApi(appId, appSecret string, cache cache.Cache) {
cfg := &miniConfig.Config{
AppID: appId,
AppSecret: appSecret,
//Token: "xxx",
// EncodingAESKey: "xxxx",
Cache: cache,
}
mini := d.wc.GetMiniProgram(cfg)
d.SetWechatOpenApi(appId, mini)
}