refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
337 lines
8.9 KiB
Go
337 lines
8.9 KiB
Go
// 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 dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
)
|
|
|
|
func newOrderCoupons(db *gorm.DB, opts ...gen.DOOption) orderCoupons {
|
|
_orderCoupons := orderCoupons{}
|
|
|
|
_orderCoupons.orderCouponsDo.UseDB(db, opts...)
|
|
_orderCoupons.orderCouponsDo.UseModel(&model.OrderCoupons{})
|
|
|
|
tableName := _orderCoupons.orderCouponsDo.TableName()
|
|
_orderCoupons.ALL = field.NewAsterisk(tableName)
|
|
_orderCoupons.ID = field.NewInt64(tableName, "id")
|
|
_orderCoupons.OrderID = field.NewInt64(tableName, "order_id")
|
|
_orderCoupons.UserCouponID = field.NewInt64(tableName, "user_coupon_id")
|
|
_orderCoupons.AppliedAmount = field.NewInt64(tableName, "applied_amount")
|
|
_orderCoupons.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
|
_orderCoupons.fillFieldMap()
|
|
|
|
return _orderCoupons
|
|
}
|
|
|
|
// orderCoupons 订单-优惠券使用明细
|
|
type orderCoupons struct {
|
|
orderCouponsDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
OrderID field.Int64
|
|
UserCouponID field.Int64
|
|
AppliedAmount field.Int64 // 本次抵扣金额(分)
|
|
CreatedAt field.Time
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (o orderCoupons) Table(newTableName string) *orderCoupons {
|
|
o.orderCouponsDo.UseTable(newTableName)
|
|
return o.updateTableName(newTableName)
|
|
}
|
|
|
|
func (o orderCoupons) As(alias string) *orderCoupons {
|
|
o.orderCouponsDo.DO = *(o.orderCouponsDo.As(alias).(*gen.DO))
|
|
return o.updateTableName(alias)
|
|
}
|
|
|
|
func (o *orderCoupons) updateTableName(table string) *orderCoupons {
|
|
o.ALL = field.NewAsterisk(table)
|
|
o.ID = field.NewInt64(table, "id")
|
|
o.OrderID = field.NewInt64(table, "order_id")
|
|
o.UserCouponID = field.NewInt64(table, "user_coupon_id")
|
|
o.AppliedAmount = field.NewInt64(table, "applied_amount")
|
|
o.CreatedAt = field.NewTime(table, "created_at")
|
|
|
|
o.fillFieldMap()
|
|
|
|
return o
|
|
}
|
|
|
|
func (o *orderCoupons) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := o.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (o *orderCoupons) fillFieldMap() {
|
|
o.fieldMap = make(map[string]field.Expr, 5)
|
|
o.fieldMap["id"] = o.ID
|
|
o.fieldMap["order_id"] = o.OrderID
|
|
o.fieldMap["user_coupon_id"] = o.UserCouponID
|
|
o.fieldMap["applied_amount"] = o.AppliedAmount
|
|
o.fieldMap["created_at"] = o.CreatedAt
|
|
}
|
|
|
|
func (o orderCoupons) clone(db *gorm.DB) orderCoupons {
|
|
o.orderCouponsDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return o
|
|
}
|
|
|
|
func (o orderCoupons) replaceDB(db *gorm.DB) orderCoupons {
|
|
o.orderCouponsDo.ReplaceDB(db)
|
|
return o
|
|
}
|
|
|
|
type orderCouponsDo struct{ gen.DO }
|
|
|
|
func (o orderCouponsDo) Debug() *orderCouponsDo {
|
|
return o.withDO(o.DO.Debug())
|
|
}
|
|
|
|
func (o orderCouponsDo) WithContext(ctx context.Context) *orderCouponsDo {
|
|
return o.withDO(o.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (o orderCouponsDo) ReadDB() *orderCouponsDo {
|
|
return o.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (o orderCouponsDo) WriteDB() *orderCouponsDo {
|
|
return o.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (o orderCouponsDo) Session(config *gorm.Session) *orderCouponsDo {
|
|
return o.withDO(o.DO.Session(config))
|
|
}
|
|
|
|
func (o orderCouponsDo) Clauses(conds ...clause.Expression) *orderCouponsDo {
|
|
return o.withDO(o.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Returning(value interface{}, columns ...string) *orderCouponsDo {
|
|
return o.withDO(o.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Not(conds ...gen.Condition) *orderCouponsDo {
|
|
return o.withDO(o.DO.Not(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Or(conds ...gen.Condition) *orderCouponsDo {
|
|
return o.withDO(o.DO.Or(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Select(conds ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Select(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Where(conds ...gen.Condition) *orderCouponsDo {
|
|
return o.withDO(o.DO.Where(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Order(conds ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Order(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Distinct(cols ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Omit(cols ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Omit(cols...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Join(table schema.Tabler, on ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Join(table, on...))
|
|
}
|
|
|
|
func (o orderCouponsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (o orderCouponsDo) RightJoin(table schema.Tabler, on ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Group(cols ...field.Expr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Group(cols...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Having(conds ...gen.Condition) *orderCouponsDo {
|
|
return o.withDO(o.DO.Having(conds...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Limit(limit int) *orderCouponsDo {
|
|
return o.withDO(o.DO.Limit(limit))
|
|
}
|
|
|
|
func (o orderCouponsDo) Offset(offset int) *orderCouponsDo {
|
|
return o.withDO(o.DO.Offset(offset))
|
|
}
|
|
|
|
func (o orderCouponsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *orderCouponsDo {
|
|
return o.withDO(o.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Unscoped() *orderCouponsDo {
|
|
return o.withDO(o.DO.Unscoped())
|
|
}
|
|
|
|
func (o orderCouponsDo) Create(values ...*model.OrderCoupons) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return o.DO.Create(values)
|
|
}
|
|
|
|
func (o orderCouponsDo) CreateInBatches(values []*model.OrderCoupons, batchSize int) error {
|
|
return o.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 (o orderCouponsDo) Save(values ...*model.OrderCoupons) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return o.DO.Save(values)
|
|
}
|
|
|
|
func (o orderCouponsDo) First() (*model.OrderCoupons, error) {
|
|
if result, err := o.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.OrderCoupons), nil
|
|
}
|
|
}
|
|
|
|
func (o orderCouponsDo) Take() (*model.OrderCoupons, error) {
|
|
if result, err := o.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.OrderCoupons), nil
|
|
}
|
|
}
|
|
|
|
func (o orderCouponsDo) Last() (*model.OrderCoupons, error) {
|
|
if result, err := o.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.OrderCoupons), nil
|
|
}
|
|
}
|
|
|
|
func (o orderCouponsDo) Find() ([]*model.OrderCoupons, error) {
|
|
result, err := o.DO.Find()
|
|
return result.([]*model.OrderCoupons), err
|
|
}
|
|
|
|
func (o orderCouponsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.OrderCoupons, err error) {
|
|
buf := make([]*model.OrderCoupons, 0, batchSize)
|
|
err = o.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 (o orderCouponsDo) FindInBatches(result *[]*model.OrderCoupons, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return o.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (o orderCouponsDo) Attrs(attrs ...field.AssignExpr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Assign(attrs ...field.AssignExpr) *orderCouponsDo {
|
|
return o.withDO(o.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (o orderCouponsDo) Joins(fields ...field.RelationField) *orderCouponsDo {
|
|
for _, _f := range fields {
|
|
o = *o.withDO(o.DO.Joins(_f))
|
|
}
|
|
return &o
|
|
}
|
|
|
|
func (o orderCouponsDo) Preload(fields ...field.RelationField) *orderCouponsDo {
|
|
for _, _f := range fields {
|
|
o = *o.withDO(o.DO.Preload(_f))
|
|
}
|
|
return &o
|
|
}
|
|
|
|
func (o orderCouponsDo) FirstOrInit() (*model.OrderCoupons, error) {
|
|
if result, err := o.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.OrderCoupons), nil
|
|
}
|
|
}
|
|
|
|
func (o orderCouponsDo) FirstOrCreate() (*model.OrderCoupons, error) {
|
|
if result, err := o.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.OrderCoupons), nil
|
|
}
|
|
}
|
|
|
|
func (o orderCouponsDo) FindByPage(offset int, limit int) (result []*model.OrderCoupons, count int64, err error) {
|
|
result, err = o.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 = o.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (o orderCouponsDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = o.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = o.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (o orderCouponsDo) Scan(result interface{}) (err error) {
|
|
return o.DO.Scan(result)
|
|
}
|
|
|
|
func (o orderCouponsDo) Delete(models ...*model.OrderCoupons) (result gen.ResultInfo, err error) {
|
|
return o.DO.Delete(models)
|
|
}
|
|
|
|
func (o *orderCouponsDo) withDO(do gen.Dao) *orderCouponsDo {
|
|
o.DO = *do.(*gen.DO)
|
|
return o
|
|
}
|