fix
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_feishu_config 飞书app配置表
|
||||
type FsFeishuConfig struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
AppId *string `gorm:"default:'';" json:"app_id"` //
|
||||
AppName *string `gorm:"default:'';" json:"app_name"` // 项目名称
|
||||
AppSecret *string `gorm:"default:'';" json:"app_secret"` // app密钥
|
||||
EncryptKey *string `gorm:"default:'';" json:"encrypt_key"` //
|
||||
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type FsFeishuConfigModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsFeishuConfigModel(db *gorm.DB) *FsFeishuConfigModel {
|
||||
return &FsFeishuConfigModel{db: db, name: "fs_feishu_config"}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
43
model/gmodel/fs_feishu_user_gen.go
Normal file
43
model/gmodel/fs_feishu_user_gen.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_feishu_user 飞书用户信息表
|
||||
type FsFeishuUser struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
AppId *string `gorm:"default:'';" json:"app_id"` //
|
||||
OpenId *string `gorm:"default:'';" json:"open_id"` //
|
||||
UnionId *string `gorm:"default:'';" json:"union_id"` //
|
||||
Name *string `gorm:"default:'';" json:"name"` //
|
||||
EnName *string `gorm:"default:'';" json:"en_name"` //
|
||||
Nickname *string `gorm:"default:'';" json:"nickname"` //
|
||||
Email *string `gorm:"default:'';" json:"email"` //
|
||||
EnterpriseEmail *string `gorm:"default:'';" json:"enterprise_email"` //
|
||||
JobTitle *string `gorm:"default:'';" json:"job_title"` //
|
||||
Mobile *string `gorm:"default:'';" json:"mobile"` //
|
||||
Gender *int64 `gorm:"default:0;" json:"gender"` // 性别 0未知 1男 2女
|
||||
Avatar *[]byte `gorm:"default:'';" json:"avatar"` //
|
||||
IsFrozen *int64 `gorm:"default:0;" json:"is_frozen"` // 是否冻结
|
||||
IsResigned *int64 `gorm:"default:0;" json:"is_resigned"` // 是否离职
|
||||
IsActivated *int64 `gorm:"default:0;" json:"is_activated"` // 是否激活
|
||||
IsExited *int64 `gorm:"default:0;" json:"is_exited"` // 是否主动退出
|
||||
IsUnjoin *int64 `gorm:"default:0;" json:"is_unjoin"` // 是否未加入
|
||||
DepartmentIds *[]byte `gorm:"default:'';" json:"department_ids"` //
|
||||
WorkStation *string `gorm:"default:'';" json:"work_station"` //
|
||||
EmployeeNo *string `gorm:"default:'';" json:"employee_no"` //
|
||||
EmployeeType *int64 `gorm:"default:0;" json:"employee_type"` // 0:未设置 1:正式员工 2:实习生 3:外包 4:劳务 5:顾问
|
||||
Orders *[]byte `gorm:"default:'';" json:"orders"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type FsFeishuUserModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsFeishuUserModel(db *gorm.DB) *FsFeishuUserModel {
|
||||
return &FsFeishuUserModel{db: db, name: "fs_feishu_user"}
|
||||
}
|
||||
30
model/gmodel/fs_feishu_user_logic.go
Normal file
30
model/gmodel/fs_feishu_user_logic.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
func (u *FsFeishuUserModel) Create(ctx context.Context, data *FsFeishuUser) error {
|
||||
return u.db.WithContext(ctx).Model(&FsFeishuUser{}).Create(&data).Error
|
||||
}
|
||||
func (u *FsFeishuUserModel) Update(ctx context.Context, data *FsFeishuUser) error {
|
||||
return u.db.WithContext(ctx).Model(&FsFeishuUser{}).Where("`app_id` = ? and `open_id` = ?", data.AppId, data.OpenId).Updates(&data).Error
|
||||
}
|
||||
func (u *FsFeishuUserModel) Find(ctx context.Context, appId, openId string) (resp *FsFeishuUser, err error) {
|
||||
err = u.db.WithContext(ctx).Model(&FsFeishuUser{}).Where("`app_id` = ? and `open_id` = ?", appId, openId).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (u *FsFeishuUserModel) CreateOrUpdate(ctx context.Context, appId, openId string, data *FsFeishuUser) error {
|
||||
_, err := u.Find(ctx, appId, openId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return u.Create(ctx, data)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return u.Update(ctx, data)
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package gmodel
|
||||
|
||||
import "context"
|
||||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
func (w *FsFeishuWebhookLogModel) Create(data *FsFeishuWebhookLog) error {
|
||||
return w.db.Model(&FsFeishuWebhookLog{}).Create(&data).Error
|
||||
func (w *FsFeishuWebhookLogModel) Create(ctx context.Context, data *FsFeishuWebhookLog) error {
|
||||
return w.db.WithContext(ctx).Model(&FsFeishuWebhookLog{}).Create(&data).Error
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ type AllModelsGen struct {
|
||||
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
|
||||
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
|
||||
FsFaq *FsFaqModel // fs_faq 常见问题
|
||||
FsFeishuConfig *FsFeishuConfigModel // fs_feishu_config 飞书app配置表
|
||||
FsFeishuUser *FsFeishuUserModel // fs_feishu_user 飞书用户信息表
|
||||
FsFeishuWebhookLog *FsFeishuWebhookLogModel // fs_feishu_webhook_log 飞书webhook记录表
|
||||
FsFont *FsFontModel // fs_font 字体配置
|
||||
FsGerent *FsGerentModel // fs_gerent 管理员表
|
||||
@@ -169,7 +169,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
||||
FsFactoryProduct: NewFsFactoryProductModel(gdb),
|
||||
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
|
||||
FsFaq: NewFsFaqModel(gdb),
|
||||
FsFeishuConfig: NewFsFeishuConfigModel(gdb),
|
||||
FsFeishuUser: NewFsFeishuUserModel(gdb),
|
||||
FsFeishuWebhookLog: NewFsFeishuWebhookLogModel(gdb),
|
||||
FsFont: NewFsFontModel(gdb),
|
||||
FsGerent: NewFsGerentModel(gdb),
|
||||
|
||||
Reference in New Issue
Block a user