This commit is contained in:
laodaming
2023-11-10 15:24:25 +08:00
parent 360c19a8f5
commit d6a25673bc
33 changed files with 394 additions and 106 deletions

View File

@@ -4,16 +4,15 @@ import (
"gorm.io/gorm"
)
// casbin_rule 后台--权限规则表
// casbin_rule
type CasbinRule struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 序号
PType *string `gorm:"default:'';" json:"p_type"` //
V0 *string `gorm:"default:'';" json:"v0"` //
V1 *string `gorm:"default:'';" json:"v1"` //
V2 *string `gorm:"default:'';" json:"v2"` //
V3 *string `gorm:"default:'';" json:"v3"` //
V4 *string `gorm:"default:'';" json:"v4"` //
V5 *string `gorm:"default:'';" json:"v5"` //
PType *string `gorm:"default:'';" json:"p_type"` //
V0 *string `gorm:"default:'';" json:"v0"` //
V1 *string `gorm:"default:'';" json:"v1"` //
V2 *string `gorm:"default:'';" json:"v2"` //
V3 *string `gorm:"default:'';" json:"v3"` //
V4 *string `gorm:"default:'';" json:"v4"` //
V5 *string `gorm:"default:'';" json:"v5"` //
}
type CasbinRuleModel struct {
db *gorm.DB

View File

@@ -0,0 +1,33 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// fs_message_log 消息记录表
type FsMessageLog struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
Type *string `gorm:"default:'';" json:"type"` //
Channel *string `gorm:"default:'';" json:"channel"` // 发送途径sm=短信 email=邮件 feishu=飞书
Module *string `gorm:"default:'';" json:"module"` //
Source *string `gorm:"default:'';" json:"source"` //
Sender *string `gorm:"default:'';" json:"sender"` //
Receiver *string `gorm:"default:'';" json:"receiver"` //
TemplateSn *string `gorm:"default:'';" json:"template_sn"` //
Title *string `gorm:"default:'';" json:"title"` //
Content *[]byte `gorm:"default:'';" json:"content"` //
Status *int64 `gorm:"default:0;" json:"status"` // 状态0=未发送 1=已发送
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除
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 FsMessageLogModel struct {
db *gorm.DB
name string
}
func NewFsMessageLogModel(db *gorm.DB) *FsMessageLogModel {
return &FsMessageLogModel{db: db, name: "fs_message_log"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -113,8 +113,11 @@ func (s *FsShoppingCartModel) Create(ctx context.Context, data *FsShoppingCart)
}
// 删除
func (s *FsShoppingCartModel) Delete(ctx context.Context, userId, id int64) error {
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id = ?", userId, id).Delete(&FsShoppingCart{}).Error
func (s *FsShoppingCartModel) Delete(ctx context.Context, userId int64, ids []int64) error {
if len(ids) == 0 {
return nil
}
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id in (?)", userId, ids).Delete(&FsShoppingCart{}).Error
}
// 更新

View File

@@ -0,0 +1,25 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// ldap_apis
type LdapApis struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Method *string `gorm:"default:'';" json:"method"` //
Path *string `gorm:"default:'';" json:"path"` //
Category *string `gorm:"default:'';" json:"category"` //
Remark *string `gorm:"default:'';" json:"remark"` //
Creator *string `gorm:"default:'';" json:"creator"` //
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"` //
Dtime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"dtime"` //
}
type LdapApisModel struct {
db *gorm.DB
name string
}
func NewLdapApisModel(db *gorm.DB) *LdapApisModel { return &LdapApisModel{db: db, name: "ldap_apis"} }

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,25 @@
package gmodel
import (
"gorm.io/gorm"
)
// ldap_casbin_rule 规则权限表
type LdapCasbinRule struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Ptype *string `gorm:"default:'';" json:"ptype"` //
V0 *string `gorm:"default:'';" json:"v0"` //
V1 *string `gorm:"default:'';" json:"v1"` //
V2 *string `gorm:"default:'';" json:"v2"` //
V3 *string `gorm:"default:'';" json:"v3"` //
V4 *string `gorm:"default:'';" json:"v4"` //
V5 *string `gorm:"default:'';" json:"v5"` //
}
type LdapCasbinRuleModel struct {
db *gorm.DB
name string
}
func NewLdapCasbinRuleModel(db *gorm.DB) *LdapCasbinRuleModel {
return &LdapCasbinRuleModel{db: db, name: "ldap_casbin_rule"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,22 @@
package gmodel
import (
"gorm.io/gorm"
)
// ldap_department 部门表
type LdapDepartment struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Source *string `gorm:"default:'';" json:"source"` //
AppId *string `gorm:"default:'';" json:"app_id"` //
Name *string `gorm:"default:'';" json:"name"` //
DepartmentId *string `gorm:"default:'';" json:"department_id"` //
}
type LdapDepartmentModel struct {
db *gorm.DB
name string
}
func NewLdapDepartmentModel(db *gorm.DB) *LdapDepartmentModel {
return &LdapDepartmentModel{db: db, name: "ldap_department"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,19 @@
package gmodel
import (
"gorm.io/gorm"
)
// ldap_group_users
type LdapGroupUsers struct {
GroupId *int64 `gorm:"default:0;" json:"group_id"` // 分组id
UserId *int64 `gorm:"default:0;" json:"user_id"` // user表id
}
type LdapGroupUsersModel struct {
db *gorm.DB
name string
}
func NewLdapGroupUsersModel(db *gorm.DB) *LdapGroupUsersModel {
return &LdapGroupUsersModel{db: db, name: "ldap_group_users"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,32 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// ldap_groups
type LdapGroups struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
GroupName *string `gorm:"default:'';" json:"group_name"` //
Remark *string `gorm:"default:'';" json:"remark"` //
Creator *string `gorm:"default:'';" json:"creator"` //
GroupType *string `gorm:"default:'';" json:"group_type"` //
ParentId *int64 `gorm:"default:0;" json:"parent_id"` //
SourceDeptId *string `gorm:"default:'';" json:"source_dept_id"` //
Source *string `gorm:"default:'';" json:"source"` //
SourceDeptParentId *string `gorm:"default:'';" json:"source_dept_parent_id"` //
GroupDn *string `gorm:"default:'';" json:"group_dn"` //
SyncState *int64 `gorm:"default:0;" json:"sync_state"` //
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"` //
Dtime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"dtime"` //
}
type LdapGroupsModel struct {
db *gorm.DB
name string
}
func NewLdapGroupsModel(db *gorm.DB) *LdapGroupsModel {
return &LdapGroupsModel{db: db, name: "ldap_groups"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,29 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// ldap_menus
type LdapMenus struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Name *string `gorm:"default:'';" json:"name"` //
Title *string `gorm:"default:'';" json:"title"` //
Icon *string `gorm:"default:'';" json:"icon"` //
Path *string `gorm:"default:'';" json:"path"` //
Sort *int64 `gorm:"default:999;" json:"sort"` //
Status *int64 `gorm:"default:1;" json:"status"` //
Creator *string `gorm:"default:'';" json:"creator"` //
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"` //
Dtime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"dtime"` //
}
type LdapMenusModel struct {
db *gorm.DB
name string
}
func NewLdapMenusModel(db *gorm.DB) *LdapMenusModel {
return &LdapMenusModel{db: db, name: "ldap_menus"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,19 @@
package gmodel
import (
"gorm.io/gorm"
)
// ldap_role_menus
type LdapRoleMenus struct {
MenuId *int64 `gorm:"default:0;" json:"menu_id"` // 菜单id
RoleId *int64 `gorm:"default:0;" json:"role_id"` // 角色id
}
type LdapRoleMenusModel struct {
db *gorm.DB
name string
}
func NewLdapRoleMenusModel(db *gorm.DB) *LdapRoleMenusModel {
return &LdapRoleMenusModel{db: db, name: "ldap_role_menus"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,28 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// ldap_roles
type LdapRoles struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Name *string `gorm:"unique_key;default:'';" json:"name"` //
Keyword *string `gorm:"unique_key;default:'';" json:"keyword"` //
Remark *string `gorm:"default:'';" json:"remark"` //
Status *int64 `gorm:"default:1;" json:"status"` //
Sort *int64 `gorm:"default:999;" json:"sort"` //
Creator *string `gorm:"default:'';" json:"creator"` //
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"` //
Dtime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"dtime"` //
}
type LdapRolesModel struct {
db *gorm.DB
name string
}
func NewLdapRolesModel(db *gorm.DB) *LdapRolesModel {
return &LdapRolesModel{db: db, name: "ldap_roles"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,19 @@
package gmodel
import (
"gorm.io/gorm"
)
// ldap_user_roles
type LdapUserRoles struct {
RoleId *int64 `gorm:"default:0;" json:"role_id"` // 角色id
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
}
type LdapUserRolesModel struct {
db *gorm.DB
name string
}
func NewLdapUserRolesModel(db *gorm.DB) *LdapUserRolesModel {
return &LdapUserRolesModel{db: db, name: "ldap_user_roles"}
}

View File

@@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@@ -0,0 +1,46 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// ldap_users
type LdapUsers struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
Source *int64 `gorm:"default:0;" json:"source"` // 来源 1飞书
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 *string `gorm:"default:'';" json:"avatar"` //
IsFrozen *int64 `gorm:"default:0;" json:"is_frozen"` // 是否冻结 0否1是
IsResigned *int64 `gorm:"default:0;" json:"is_resigned"` // 是否离职 0否 1是
IsActivated *int64 `gorm:"default:0;" json:"is_activated"` // 是否激活 0否1是
IsExited *int64 `gorm:"default:0;" json:"is_exited"` // 是否退出 0否1是
IsUnjoin *int64 `gorm:"default:0;" json:"is_unjoin"` // 是否未加入 0否1是
Departmentids *string `gorm:"default:'';" json:"departmentIds"` //
WorkStation *string `gorm:"default:'';" json:"work_station"` //
EmployeeNo *string `gorm:"default:'';" json:"employee_no"` //
EmployeeType *int64 `gorm:"default:0;" json:"employee_type"` // 1正式员工 2实习生 3外包4劳务 5顾问
UserDn *string `gorm:"default:'';" json:"user_dn"` //
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"` //
Dtime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"dtime"` //
}
type LdapUsersModel struct {
db *gorm.DB
name string
}
func NewLdapUsersModel(db *gorm.DB) *LdapUsersModel {
return &LdapUsersModel{db: db, name: "ldap_users"}
}

View File

@@ -0,0 +1,21 @@
package gmodel
import (
"context"
"errors"
"gorm.io/gorm"
)
// TODO: 使用model的属性做你想做的
func (u *LdapUsersModel) CreateOrUpdate(ctx context.Context, appId string, openId string, data *LdapUsers) error {
var info LdapUsers
err := u.db.WithContext(ctx).Where("app_id = ? and open_id = ?", appId, openId).Take(&info).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return u.db.WithContext(ctx).Create(&data).Error
}
return err
}
return u.db.WithContext(ctx).Where("app_id = ? and open_id = ?", appId, openId).Updates(&data).Error
}

View File

@@ -58,6 +58,7 @@ type AllModelsGen struct {
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
FsMenu *FsMenuModel // fs_menu 后台菜单
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
FsMessageLog *FsMessageLogModel // fs_message_log 消息记录表
FsMigration *FsMigrationModel // fs_migration 版本库
FsOrder *FsOrderModel // fs_order 订单表
FsOrderAffiliateOld *FsOrderAffiliateOldModel // fs_order_affiliate_old 订单附属表-流程控制时间等
@@ -118,6 +119,16 @@ type AllModelsGen struct {
FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存
FsWebSet *FsWebSetModel // fs_web_set 网站配置表
FsZipCode *FsZipCodeModel // fs_zip_code 邮编表
LdapApis *LdapApisModel // ldap_apis
LdapCasbinRule *LdapCasbinRuleModel // ldap_casbin_rule 规则权限表
LdapDepartment *LdapDepartmentModel // ldap_department 部门表
LdapGroupUsers *LdapGroupUsersModel // ldap_group_users
LdapGroups *LdapGroupsModel // ldap_groups
LdapMenus *LdapMenusModel // ldap_menus
LdapRoleMenus *LdapRoleMenusModel // ldap_role_menus
LdapRoles *LdapRolesModel // ldap_roles
LdapUserRoles *LdapUserRolesModel // ldap_user_roles
LdapUsers *LdapUsersModel // ldap_users
}
@@ -177,6 +188,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsMapLibrary: NewFsMapLibraryModel(gdb),
FsMenu: NewFsMenuModel(gdb),
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
FsMessageLog: NewFsMessageLogModel(gdb),
FsMigration: NewFsMigrationModel(gdb),
FsOrder: NewFsOrderModel(gdb),
FsOrderAffiliateOld: NewFsOrderAffiliateOldModel(gdb),
@@ -237,6 +249,16 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsUserStock: NewFsUserStockModel(gdb),
FsWebSet: NewFsWebSetModel(gdb),
FsZipCode: NewFsZipCodeModel(gdb),
LdapApis: NewLdapApisModel(gdb),
LdapCasbinRule: NewLdapCasbinRuleModel(gdb),
LdapDepartment: NewLdapDepartmentModel(gdb),
LdapGroupUsers: NewLdapGroupUsersModel(gdb),
LdapGroups: NewLdapGroupsModel(gdb),
LdapMenus: NewLdapMenusModel(gdb),
LdapRoleMenus: NewLdapRoleMenusModel(gdb),
LdapRoles: NewLdapRolesModel(gdb),
LdapUserRoles: NewLdapUserRolesModel(gdb),
LdapUsers: NewLdapUsersModel(gdb),
}
return models
}