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.

87 lines
2.4 KiB
Go

// Code generated by goctl. DO NOT EDIT!
package model
import (
"context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm"
)
var (
userCheckInFieldNames = builder.RawFieldNames(&UserCheckIn{})
userCheckInRows = strings.Join(userCheckInFieldNames, ",")
userCheckInRowsExpectAutoSet = strings.Join(stringx.Remove(userCheckInFieldNames, "`create_time`", "`update_time`"), ",")
userCheckInRowsWithPlaceHolder = strings.Join(stringx.Remove(userCheckInFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type (
userCheckInModel interface {
Insert(ctx context.Context, data *UserCheckIn) error
FindOne(ctx context.Context, id int64) (*UserCheckIn, error)
Update(ctx context.Context, data *UserCheckIn) error
Delete(ctx context.Context, id int64) error
}
defaultUserCheckInModel struct {
conn *gorm.DB
table string
}
UserCheckIn struct {
Id int64 `gorm:"column:id;primaryKey"` // ID
UserId int64 `gorm:"column:user_id"` // 用户ID
CheckInTime time.Time `gorm:"column:check_in_time;default:null"` // 签到时间
}
)
func newUserCheckInModel(conn *gorm.DB) *defaultUserCheckInModel {
return &defaultUserCheckInModel{
conn: conn,
table: "`user_check_in`",
}
}
func (m *defaultUserCheckInModel) Insert(ctx context.Context, data *UserCheckIn) error {
err := m.conn.WithContext(ctx).Create(&data).Error
return err
}
func (m *defaultUserCheckInModel) FindOne(ctx context.Context, id int64) (*UserCheckIn, error) {
var resp UserCheckIn
err := m.conn.WithContext(ctx).Model(&UserCheckIn{}).Where("`id` = ?", id).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultUserCheckInModel) Update(ctx context.Context, data *UserCheckIn) error {
err := m.conn.WithContext(ctx).Save(data).Error
return err
}
func (m *defaultUserCheckInModel) Delete(ctx context.Context, id int64) error {
err := m.conn.WithContext(ctx).Delete(&UserCheckIn{}, id).Error
return err
}
func (m *defaultUserCheckInModel) tableName() string {
return m.table
}
func (UserCheckIn) TableName() string {
model := newUserCheckInModel(nil)
return model.tableName()
}