From d6a25673bc40ca845f404209d8cbaf18e4799d5d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 10 Nov 2023 15:24:25 +0800 Subject: [PATCH] fix --- model/gmodel/casbin_rule_gen.go | 17 ++++--- model/gmodel/fs_message_log_gen.go | 33 +++++++++++++ model/gmodel/fs_message_log_logic.go | 2 + model/gmodel/fs_shopping_cart_logic.go | 7 ++- model/gmodel/ldap_apis_gen.go | 25 ++++++++++ model/gmodel/ldap_apis_logic.go | 2 + model/gmodel/ldap_casbin_rule_gen.go | 25 ++++++++++ model/gmodel/ldap_casbin_rule_logic.go | 2 + model/gmodel/ldap_department_gen.go | 22 +++++++++ model/gmodel/ldap_department_logic.go | 2 + model/gmodel/ldap_group_users_gen.go | 19 ++++++++ model/gmodel/ldap_group_users_logic.go | 2 + model/gmodel/ldap_groups_gen.go | 32 +++++++++++++ model/gmodel/ldap_groups_logic.go | 2 + model/gmodel/ldap_menus_gen.go | 29 ++++++++++++ model/gmodel/ldap_menus_logic.go | 2 + model/gmodel/ldap_role_menus_gen.go | 19 ++++++++ model/gmodel/ldap_role_menus_logic.go | 2 + model/gmodel/ldap_roles_gen.go | 28 +++++++++++ model/gmodel/ldap_roles_logic.go | 2 + model/gmodel/ldap_user_roles_gen.go | 19 ++++++++ model/gmodel/ldap_user_roles_logic.go | 2 + model/gmodel/ldap_users_gen.go | 46 +++++++++++++++++++ model/gmodel/ldap_users_logic.go | 21 +++++++++ model/gmodel/var_gen.go | 22 +++++++++ server/feishu-sync/internal/handler/routes.go | 5 -- .../handler/syncfeishugroupshandler.go | 35 -------------- .../internal/logic/syncfeishugroupslogic.go | 39 ---------------- .../internal/logic/user_webhook.go | 28 +++++++---- .../internal/logic/deletecartlogic.go | 2 +- server/shopping-cart/internal/types/types.go | 2 +- server_api/feishu-sync.api | 3 -- server_api/shopping-cart.api | 2 +- 33 files changed, 394 insertions(+), 106 deletions(-) create mode 100644 model/gmodel/fs_message_log_gen.go create mode 100644 model/gmodel/fs_message_log_logic.go create mode 100644 model/gmodel/ldap_apis_gen.go create mode 100644 model/gmodel/ldap_apis_logic.go create mode 100644 model/gmodel/ldap_casbin_rule_gen.go create mode 100644 model/gmodel/ldap_casbin_rule_logic.go create mode 100644 model/gmodel/ldap_department_gen.go create mode 100644 model/gmodel/ldap_department_logic.go create mode 100644 model/gmodel/ldap_group_users_gen.go create mode 100644 model/gmodel/ldap_group_users_logic.go create mode 100644 model/gmodel/ldap_groups_gen.go create mode 100644 model/gmodel/ldap_groups_logic.go create mode 100644 model/gmodel/ldap_menus_gen.go create mode 100644 model/gmodel/ldap_menus_logic.go create mode 100644 model/gmodel/ldap_role_menus_gen.go create mode 100644 model/gmodel/ldap_role_menus_logic.go create mode 100644 model/gmodel/ldap_roles_gen.go create mode 100644 model/gmodel/ldap_roles_logic.go create mode 100644 model/gmodel/ldap_user_roles_gen.go create mode 100644 model/gmodel/ldap_user_roles_logic.go create mode 100644 model/gmodel/ldap_users_gen.go create mode 100644 model/gmodel/ldap_users_logic.go delete mode 100644 server/feishu-sync/internal/handler/syncfeishugroupshandler.go delete mode 100644 server/feishu-sync/internal/logic/syncfeishugroupslogic.go diff --git a/model/gmodel/casbin_rule_gen.go b/model/gmodel/casbin_rule_gen.go index df295df8..57bd8599 100644 --- a/model/gmodel/casbin_rule_gen.go +++ b/model/gmodel/casbin_rule_gen.go @@ -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 diff --git a/model/gmodel/fs_message_log_gen.go b/model/gmodel/fs_message_log_gen.go new file mode 100644 index 00000000..cb9b8fe5 --- /dev/null +++ b/model/gmodel/fs_message_log_gen.go @@ -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"} +} diff --git a/model/gmodel/fs_message_log_logic.go b/model/gmodel/fs_message_log_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_message_log_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_shopping_cart_logic.go b/model/gmodel/fs_shopping_cart_logic.go index 5361e195..3c978e6c 100644 --- a/model/gmodel/fs_shopping_cart_logic.go +++ b/model/gmodel/fs_shopping_cart_logic.go @@ -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 } // 更新 diff --git a/model/gmodel/ldap_apis_gen.go b/model/gmodel/ldap_apis_gen.go new file mode 100644 index 00000000..659107f3 --- /dev/null +++ b/model/gmodel/ldap_apis_gen.go @@ -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"} } diff --git a/model/gmodel/ldap_apis_logic.go b/model/gmodel/ldap_apis_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_apis_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_casbin_rule_gen.go b/model/gmodel/ldap_casbin_rule_gen.go new file mode 100644 index 00000000..86bd35f5 --- /dev/null +++ b/model/gmodel/ldap_casbin_rule_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_casbin_rule_logic.go b/model/gmodel/ldap_casbin_rule_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_casbin_rule_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_department_gen.go b/model/gmodel/ldap_department_gen.go new file mode 100644 index 00000000..a8e77c6e --- /dev/null +++ b/model/gmodel/ldap_department_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_department_logic.go b/model/gmodel/ldap_department_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_department_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_group_users_gen.go b/model/gmodel/ldap_group_users_gen.go new file mode 100644 index 00000000..8e75b9af --- /dev/null +++ b/model/gmodel/ldap_group_users_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_group_users_logic.go b/model/gmodel/ldap_group_users_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_group_users_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_groups_gen.go b/model/gmodel/ldap_groups_gen.go new file mode 100644 index 00000000..b0874791 --- /dev/null +++ b/model/gmodel/ldap_groups_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_groups_logic.go b/model/gmodel/ldap_groups_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_groups_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_menus_gen.go b/model/gmodel/ldap_menus_gen.go new file mode 100644 index 00000000..ffdc6e6e --- /dev/null +++ b/model/gmodel/ldap_menus_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_menus_logic.go b/model/gmodel/ldap_menus_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_menus_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_role_menus_gen.go b/model/gmodel/ldap_role_menus_gen.go new file mode 100644 index 00000000..1bf604a3 --- /dev/null +++ b/model/gmodel/ldap_role_menus_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_role_menus_logic.go b/model/gmodel/ldap_role_menus_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_role_menus_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_roles_gen.go b/model/gmodel/ldap_roles_gen.go new file mode 100644 index 00000000..0e6949d2 --- /dev/null +++ b/model/gmodel/ldap_roles_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_roles_logic.go b/model/gmodel/ldap_roles_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_roles_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_user_roles_gen.go b/model/gmodel/ldap_user_roles_gen.go new file mode 100644 index 00000000..16798ca4 --- /dev/null +++ b/model/gmodel/ldap_user_roles_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_user_roles_logic.go b/model/gmodel/ldap_user_roles_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/ldap_user_roles_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/ldap_users_gen.go b/model/gmodel/ldap_users_gen.go new file mode 100644 index 00000000..ded0104d --- /dev/null +++ b/model/gmodel/ldap_users_gen.go @@ -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"} +} diff --git a/model/gmodel/ldap_users_logic.go b/model/gmodel/ldap_users_logic.go new file mode 100644 index 00000000..629ae6dc --- /dev/null +++ b/model/gmodel/ldap_users_logic.go @@ -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 +} diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index 570c33ef..0228d80f 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -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 } diff --git a/server/feishu-sync/internal/handler/routes.go b/server/feishu-sync/internal/handler/routes.go index db0c1419..db0e1b4c 100644 --- a/server/feishu-sync/internal/handler/routes.go +++ b/server/feishu-sync/internal/handler/routes.go @@ -17,11 +17,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/feishu/webhook", Handler: WebhookHandler(serverCtx), }, - { - Method: http.MethodGet, - Path: "/api/feishu/sync_feishu_departments", - Handler: SyncFeiShuGroupsHandler(serverCtx), - }, }, ) } diff --git a/server/feishu-sync/internal/handler/syncfeishugroupshandler.go b/server/feishu-sync/internal/handler/syncfeishugroupshandler.go deleted file mode 100644 index 4c97aee1..00000000 --- a/server/feishu-sync/internal/handler/syncfeishugroupshandler.go +++ /dev/null @@ -1,35 +0,0 @@ -package handler - -import ( - "net/http" - "reflect" - - "fusenapi/utils/basic" - - "fusenapi/server/feishu-sync/internal/logic" - "fusenapi/server/feishu-sync/internal/svc" - "fusenapi/server/feishu-sync/internal/types" -) - -func SyncFeiShuGroupsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - - var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx, &req) - if err != nil { - return - } - - // 创建一个业务逻辑层实例 - l := logic.NewSyncFeiShuGroupsLogic(r.Context(), svcCtx) - - rl := reflect.ValueOf(l) - basic.BeforeLogic(w, r, rl) - - resp := l.SyncFeiShuGroups(&req, userinfo) - - if !basic.AfterLogic(w, r, rl, resp) { - basic.NormalAfterLogic(w, r, resp) - } - } -} diff --git a/server/feishu-sync/internal/logic/syncfeishugroupslogic.go b/server/feishu-sync/internal/logic/syncfeishugroupslogic.go deleted file mode 100644 index 63adddde..00000000 --- a/server/feishu-sync/internal/logic/syncfeishugroupslogic.go +++ /dev/null @@ -1,39 +0,0 @@ -package logic - -import ( - "context" - "fusenapi/utils/auth" - "fusenapi/utils/basic" - - "fusenapi/server/feishu-sync/internal/svc" - "fusenapi/server/feishu-sync/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type SyncFeiShuGroupsLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewSyncFeiShuGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncFeiShuGroupsLogic { - return &SyncFeiShuGroupsLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -// 处理进入前逻辑w,r -// func (l *SyncFeiShuGroupsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { -// } - -func (l *SyncFeiShuGroupsLogic) SyncFeiShuGroups(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { - return resp.SetStatus(basic.CodeOK) -} - -// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 -// func (l *SyncFeiShuGroupsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { -// // httpx.OkJsonCtx(r.Context(), w, resp) -// } diff --git a/server/feishu-sync/internal/logic/user_webhook.go b/server/feishu-sync/internal/logic/user_webhook.go index a4f45e67..96647ea3 100644 --- a/server/feishu-sync/internal/logic/user_webhook.go +++ b/server/feishu-sync/internal/logic/user_webhook.go @@ -1,5 +1,13 @@ package logic +import ( + "encoding/json" + "fusenapi/model/gmodel" + "strconv" + "strings" + "time" +) + type UserWebhookMsg struct { Schema string `json:"schema"` Header struct { @@ -76,12 +84,10 @@ type UserWebhookMsg struct { // 员工增删改信息 func (l *WebhookLogic) OnUserChange(data []byte) error { - return nil - /*var msg UserWebhookMsg + var msg UserWebhookMsg if err := json.Unmarshal(data, &msg); err != nil { return err } - avatar, _ := json.Marshal(msg.Event.Object.Avatar) isFrozen := int64(0) if msg.Event.Object.Status.IsFrozen { isFrozen = 1 @@ -102,14 +108,16 @@ func (l *WebhookLogic) OnUserChange(data []byte) error { if msg.Event.Object.Status.IsUnjoin { isUnjoin = 1 } - departmentIds, _ := json.Marshal(msg.Event.Object.DepartmentIds) - orders, _ := json.Marshal(msg.Event.Object.Orders) feiShuMsgCreateTimeInt64, err := strconv.ParseInt(msg.Header.CreateTime, 10, 64) if err != nil { return err } feiShuMsgCreateTime := time.UnixMilli(feiShuMsgCreateTimeInt64) - return l.svcCtx.AllModels.FsFeishuUser.CreateOrUpdate(l.ctx, msg.Header.AppId, msg.Event.Object.OpenId, &gmodel.FsFeishuUser{ + departmentIds := strings.Join(msg.Event.Object.DepartmentIds, ",") + joinTime := time.Unix(msg.Event.Object.Joint64ime, 0) + source := int64(1) + return l.svcCtx.AllModels.LdapUsers.CreateOrUpdate(l.ctx, msg.Header.AppId, msg.Event.Object.OpenId, &gmodel.LdapUsers{ + Source: &source, AppId: &msg.Header.AppId, OpenId: &msg.Event.Object.OpenId, UnionId: &msg.Event.Object.UnionId, @@ -121,18 +129,18 @@ func (l *WebhookLogic) OnUserChange(data []byte) error { JobTitle: &msg.Event.Object.JobTitle, Mobile: &msg.Event.Object.Mobile, Gender: &msg.Event.Object.Gender, - Avatar: &avatar, + Avatar: &msg.Event.Object.Avatar.AvatarOrigin, IsFrozen: &isFrozen, IsResigned: &isResigned, IsActivated: &isActivated, IsExited: &isExited, IsUnjoin: &isUnjoin, - DepartmentIds: &departmentIds, + Departmentids: &departmentIds, WorkStation: &msg.Event.Object.WorkStation, EmployeeNo: &msg.Event.Object.EmployeeNo, EmployeeType: &msg.Event.Object.EmployeeType, - Orders: &orders, + JoinTime: &joinTime, Ctime: &feiShuMsgCreateTime, Utime: &feiShuMsgCreateTime, - })*/ + }) } diff --git a/server/shopping-cart/internal/logic/deletecartlogic.go b/server/shopping-cart/internal/logic/deletecartlogic.go index 4c1bc37b..2c7f7f64 100644 --- a/server/shopping-cart/internal/logic/deletecartlogic.go +++ b/server/shopping-cart/internal/logic/deletecartlogic.go @@ -35,7 +35,7 @@ func (l *DeleteCartLogic) DeleteCart(req *types.DeleteCartReq, userinfo *auth.Us return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in") } //删除购物车 - if err := l.svcCtx.AllModels.FsShoppingCart.Delete(l.ctx, userinfo.UserId, req.Id); err != nil { + if err := l.svcCtx.AllModels.FsShoppingCart.Delete(l.ctx, userinfo.UserId, req.IdList); err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to delete shopping cart") } diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index d19cbf50..00585e13 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -35,7 +35,7 @@ type DiyInfo struct { } type DeleteCartReq struct { - Id int64 `json:"id"` //购物车id + IdList []int64 `json:"id"` //购物车id } type GetCartsReq struct { diff --git a/server_api/feishu-sync.api b/server_api/feishu-sync.api index 4528b483..31db4bea 100644 --- a/server_api/feishu-sync.api +++ b/server_api/feishu-sync.api @@ -13,7 +13,4 @@ service feishu-sync { //飞书ticket webhook事件接口 @handler WebhookHandler post /api/feishu/webhook(request) returns (response); - //同步飞书分组(现在是get请求) - @handler SyncFeiShuGroupsHandler - get /api/feishu/sync_feishu_departments(request) returns (response); } \ No newline at end of file diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index e568a7c8..40de8729 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -55,7 +55,7 @@ type DiyInfo { } //删除购物车 type DeleteCartReq { - Id int64 `json:"id"` //购物车id + IdList []int64 `json:"id"` //购物车id } //获取购物车列表