This commit is contained in:
laodaming
2023-11-08 15:17:48 +08:00
parent 3641a40a69
commit 1b77cb2ec2
13 changed files with 0 additions and 593 deletions

View File

@@ -1,44 +0,0 @@
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"` //
JoinTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"join_time"` //
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"}
}

View File

@@ -1,31 +0,0 @@
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
}
data.Ctime = nil
return u.Update(ctx, data)
}

View File

@@ -49,7 +49,6 @@ type AllModelsGen struct {
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
FsFaq *FsFaqModel // fs_faq 常见问题
FsFeishuUser *FsFeishuUserModel // fs_feishu_user 飞书用户信息表
FsFeishuWebhookLog *FsFeishuWebhookLogModel // fs_feishu_webhook_log 飞书webhook记录表
FsFont *FsFontModel // fs_font 字体配置
FsGerent *FsGerentModel // fs_gerent 管理员表
@@ -169,7 +168,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsFactoryProduct: NewFsFactoryProductModel(gdb),
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
FsFaq: NewFsFaqModel(gdb),
FsFeishuUser: NewFsFeishuUserModel(gdb),
FsFeishuWebhookLog: NewFsFeishuWebhookLogModel(gdb),
FsFont: NewFsFontModel(gdb),
FsGerent: NewFsGerentModel(gdb),