You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
3 years ago
|
// Code generated by goctl. DO NOT EDIT!
|
||
|
|
||
|
package model
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"strings"
|
||
|
|
||
|
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
|
||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
zhgUserDetailsFieldNames = builder.RawFieldNames(&ZhgUserDetails{})
|
||
|
zhgUserDetailsRows = strings.Join(zhgUserDetailsFieldNames, ",")
|
||
|
zhgUserDetailsRowsExpectAutoSet = strings.Join(stringx.Remove(zhgUserDetailsFieldNames, "`create_time`", "`update_time`"), ",")
|
||
|
zhgUserDetailsRowsWithPlaceHolder = strings.Join(stringx.Remove(zhgUserDetailsFieldNames, "`user_id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
zhgUserDetailsModel interface {
|
||
|
gormx.TxModel
|
||
|
Insert(ctx context.Context, tx *gorm.DB, data *ZhgUserDetails) error
|
||
|
FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*ZhgUserDetails, error)
|
||
|
Update(ctx context.Context, tx *gorm.DB, data *ZhgUserDetails) error
|
||
|
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
|
||
|
}
|
||
|
|
||
|
defaultZhgUserDetailsModel struct {
|
||
|
gormx.GormConn
|
||
|
table string
|
||
|
}
|
||
|
|
||
|
ZhgUserDetails struct {
|
||
|
UserId int64 `gorm:"column:user_id;primaryKey"` // 用户ID
|
||
|
Elite int64 `gorm:"column:elite"` // 当前使用的精英单位ID
|
||
|
Title int64 `gorm:"column:title"` // 当前佩戴的称号ID
|
||
|
}
|
||
|
)
|
||
|
|
||
|
var ZhgUserDetailsTableName = "`zhg_user_details`"
|
||
|
|
||
|
func newZhgUserDetailsModel(conn *gorm.DB) *defaultZhgUserDetailsModel {
|
||
|
return &defaultZhgUserDetailsModel{
|
||
|
GormConn: gormx.NewConn(conn),
|
||
|
table: ZhgUserDetailsTableName,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *defaultZhgUserDetailsModel) Insert(ctx context.Context, tx *gorm.DB, data *ZhgUserDetails) error {
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultZhgUserDetailsModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*ZhgUserDetails, error) {
|
||
|
var resp ZhgUserDetails
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&ZhgUserDetails{}).Where("`user_id` = ?", userId).Take(&resp).Error
|
||
|
if err = gormx.WrapSelectErr(err); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &resp, nil
|
||
|
}
|
||
|
|
||
|
func (m *defaultZhgUserDetailsModel) Update(ctx context.Context, tx *gorm.DB, data *ZhgUserDetails) error {
|
||
|
|
||
|
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
|
||
|
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
|
||
|
|
||
|
}
|
||
|
|
||
|
func (m *defaultZhgUserDetailsModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
|
||
|
err := gormx.WithTx(ctx, m.DB, tx).Delete(&ZhgUserDetails{}, userId).Error
|
||
|
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultZhgUserDetailsModel) tableName() string {
|
||
|
return m.table
|
||
|
}
|
||
|
|
||
|
func (ZhgUserDetails) TableName() string {
|
||
|
return ZhgUserDetailsTableName
|
||
|
}
|