正在显示
14 个修改的文件
包含
48 行增加
和
25 行删除
@@ -20,7 +20,7 @@ func RetCustomizeMenu(menus []*domain.Menu, customizeMenus []*domain.CustomizeMe | @@ -20,7 +20,7 @@ func RetCustomizeMenu(menus []*domain.Menu, customizeMenus []*domain.CustomizeMe | ||
20 | } | 20 | } |
21 | 21 | ||
22 | for i := range menus { | 22 | for i := range menus { |
23 | - fieldMenu := utils.LoadCustomFieldToMap(menus[i], "MenuId", "ParentId", "MenuName", "Code", "Icon", "MenuAlias", "MenuType", "Remark", "Sort") | 23 | + fieldMenu := utils.LoadCustomFieldToMap(menus[i], "MenuId", "ParentId", "MenuName", "Code", "Icon", "MenuAlias", "MenuType", "Remark", "Sort", "EnableStatus") |
24 | fieldMenu["parentMenuName"] = "" | 24 | fieldMenu["parentMenuName"] = "" |
25 | if menu, ok := menusMap[menus[i].ParentId]; ok { | 25 | if menu, ok := menusMap[menus[i].ParentId]; ok { |
26 | fieldMenu["parentMenuName"] = menu.MenuName | 26 | fieldMenu["parentMenuName"] = menu.MenuName |
@@ -7,7 +7,9 @@ var ( | @@ -7,7 +7,9 @@ var ( | ||
7 | REDIS_PORT = "6379" | 7 | REDIS_PORT = "6379" |
8 | REDIS_AUTH = "" | 8 | REDIS_AUTH = "" |
9 | // 是否启用仓储层缓存 | 9 | // 是否启用仓储层缓存 |
10 | - ENABLE_REPOSITORY_CACHE = true | 10 | + DISABLE_REPOSITORY_CACHE = false |
11 | + // 缓存过期时间 单位秒 | ||
12 | + REPOSITORY_CACHE_EXPIRE = 30 * 60 | ||
11 | ) | 13 | ) |
12 | 14 | ||
13 | func init() { | 15 | func init() { |
@@ -22,9 +24,9 @@ func init() { | @@ -22,9 +24,9 @@ func init() { | ||
22 | REDIS_AUTH = os.Getenv("REDIS_AUTH") | 24 | REDIS_AUTH = os.Getenv("REDIS_AUTH") |
23 | } | 25 | } |
24 | if os.Getenv("ENABLE_REPOSITORY_CACHE") != "" { | 26 | if os.Getenv("ENABLE_REPOSITORY_CACHE") != "" { |
25 | - ENABLE_REPOSITORY_CACHE = true | 27 | + DISABLE_REPOSITORY_CACHE = false |
26 | } | 28 | } |
27 | if os.Getenv("DISABLE_REPOSITORY_CACHE") != "" { | 29 | if os.Getenv("DISABLE_REPOSITORY_CACHE") != "" { |
28 | - ENABLE_REPOSITORY_CACHE = false | 30 | + DISABLE_REPOSITORY_CACHE = true |
29 | } | 31 | } |
30 | } | 32 | } |
@@ -61,15 +61,15 @@ func (company *Company) Update(data map[string]interface{}) error { | @@ -61,15 +61,15 @@ func (company *Company) Update(data map[string]interface{}) error { | ||
61 | if industryCategory, ok := data["industryCategory"]; ok { | 61 | if industryCategory, ok := data["industryCategory"]; ok { |
62 | company.CompanyInfo.IndustryCategory = industryCategory.(string) | 62 | company.CompanyInfo.IndustryCategory = industryCategory.(string) |
63 | } | 63 | } |
64 | - if contacts, ok := data["contacts"]; ok { | ||
65 | - company.CompanyInfo.Contacts = contacts.(string) | ||
66 | - } | 64 | + //if contacts, ok := data["contacts"]; ok { |
65 | + // company.CompanyInfo.Contacts = contacts.(string) | ||
66 | + //} | ||
67 | if registTime, ok := data["registTime"]; ok { | 67 | if registTime, ok := data["registTime"]; ok { |
68 | company.CompanyInfo.RegisteredTime = registTime.(time.Time) | 68 | company.CompanyInfo.RegisteredTime = registTime.(time.Time) |
69 | } | 69 | } |
70 | - if registStatus, ok := data["registStatus"]; ok { | ||
71 | - company.CompanyInfo.status = registStatus.(int) | ||
72 | - } | 70 | + //if registStatus, ok := data["registStatus"]; ok { |
71 | + // company.CompanyInfo.Status = registStatus.(int) | ||
72 | + //} | ||
73 | if status, ok := data["status"]; ok { | 73 | if status, ok := data["status"]; ok { |
74 | company.Status = status.(int) | 74 | company.Status = status.(int) |
75 | } | 75 | } |
@@ -15,9 +15,9 @@ type CompanyInfo struct { | @@ -15,9 +15,9 @@ type CompanyInfo struct { | ||
15 | // 所属行业 | 15 | // 所属行业 |
16 | IndustryCategory string `json:"industryCategory"` | 16 | IndustryCategory string `json:"industryCategory"` |
17 | // 联系人 | 17 | // 联系人 |
18 | - Contacts string `json:"contacts"` | 18 | + //Contacts string `json:"contacts"` |
19 | // 注册时间 | 19 | // 注册时间 |
20 | RegisteredTime time.Time `json:"registeredTime"` | 20 | RegisteredTime time.Time `json:"registeredTime"` |
21 | // 状态 1:已注册 2:待认证 3:已认证 | 21 | // 状态 1:已注册 2:待认证 3:已认证 |
22 | - status int `json:"status"` | 22 | + //Status int `json:"status"` |
23 | } | 23 | } |
@@ -3,6 +3,7 @@ package domain | @@ -3,6 +3,7 @@ package domain | ||
3 | import ( | 3 | import ( |
4 | "errors" | 4 | "errors" |
5 | "fmt" | 5 | "fmt" |
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/constant" | ||
6 | "strconv" | 7 | "strconv" |
7 | "strings" | 8 | "strings" |
8 | ) | 9 | ) |
@@ -170,10 +171,23 @@ func (menu *Menu) ValidMenuType() bool { | @@ -170,10 +171,23 @@ func (menu *Menu) ValidMenuType() bool { | ||
170 | return false | 171 | return false |
171 | } | 172 | } |
172 | 173 | ||
173 | -// 实现 TreeNode | 174 | +/***** 1.实现树 *****/ |
175 | +/*1.1 实现树的方法*/ | ||
174 | func (menu *Menu) PID() string { | 176 | func (menu *Menu) PID() string { |
175 | return menu.ParentPath | 177 | return menu.ParentPath |
176 | } | 178 | } |
177 | func (menu *Menu) ID() string { | 179 | func (menu *Menu) ID() string { |
178 | return menu.GetFullPath() | 180 | return menu.GetFullPath() |
179 | } | 181 | } |
182 | + | ||
183 | +/***** 2.缓存 *****/ | ||
184 | +/*2.1 缓存键值*/ | ||
185 | +func (m *Menu) CacheKeyFunc() string { | ||
186 | + if constant.DISABLE_REPOSITORY_CACHE { | ||
187 | + return "" | ||
188 | + } | ||
189 | + if m.MenuId == 0 { | ||
190 | + return "" | ||
191 | + } | ||
192 | + return fmt.Sprintf("%v:cache:menu:id:%v", constant.CACHE_PREFIX, m.MenuId) | ||
193 | +} |
@@ -80,9 +80,9 @@ func (user *User) Update(data map[string]interface{}) error { | @@ -80,9 +80,9 @@ func (user *User) Update(data map[string]interface{}) error { | ||
80 | if userBaseId, ok := data["userBaseId"]; ok { | 80 | if userBaseId, ok := data["userBaseId"]; ok { |
81 | user.UserBaseId = userBaseId.(int64) | 81 | user.UserBaseId = userBaseId.(int64) |
82 | } | 82 | } |
83 | - if userType, ok := data["userType"]; ok { | ||
84 | - user.UserType = userType.(int) | ||
85 | - } | 83 | + //if userType, ok := data["userType"]; ok { |
84 | + // user.UserType = userType.(int) | ||
85 | + //} | ||
86 | if userCode, ok := data["userCode"]; ok { | 86 | if userCode, ok := data["userCode"]; ok { |
87 | user.UserCode = userCode.(string) | 87 | user.UserCode = userCode.(string) |
88 | } | 88 | } |
@@ -31,6 +31,11 @@ func init() { | @@ -31,6 +31,11 @@ func init() { | ||
31 | for _, model := range []interface{}{ | 31 | for _, model := range []interface{}{ |
32 | (*models.Menu)(nil), | 32 | (*models.Menu)(nil), |
33 | (*models.CustomizeMenu)(nil), | 33 | (*models.CustomizeMenu)(nil), |
34 | + (*models.Company)(nil), | ||
35 | + (*models.Org)(nil), | ||
36 | + (*models.Role)(nil), | ||
37 | + (*models.User)(nil), | ||
38 | + (*models.UserBase)(nil), | ||
34 | //(*models.User)(nil), | 39 | //(*models.User)(nil), |
35 | } { | 40 | } { |
36 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 41 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type Company struct { | 8 | type Company struct { |
9 | - tableName string `pg:"users.company,alias:company" comment:"企业"` | 9 | + tableName string `pg:"users.company" comment:"企业"` |
10 | // 企业id | 10 | // 企业id |
11 | CompanyId int64 `pg:",pk" comment:"企业id"` | 11 | CompanyId int64 `pg:",pk" comment:"企业id"` |
12 | // 企业配置信息 | 12 | // 企业配置信息 |
1 | package models | 1 | package models |
2 | 2 | ||
3 | type Menu struct { | 3 | type Menu struct { |
4 | - tableName string `pg:"users.menu,alias:menu" comment:"菜单"` | 4 | + tableName string `pg:"users.menu" comment:"菜单"` |
5 | // 菜单编号 | 5 | // 菜单编号 |
6 | MenuId int64 `pg:",pk" comment:"菜单编号"` | 6 | MenuId int64 `pg:",pk" comment:"菜单编号"` |
7 | // 父级id | 7 | // 父级id |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type Org struct { | 8 | type Org struct { |
9 | - tableName string `pg:"users.org,alias:org" comment:"组织"` | 9 | + tableName string `pg:"users.org" comment:"组织"` |
10 | // 组织ID | 10 | // 组织ID |
11 | OrgId int64 `pg:",pk" comment:"组织ID"` | 11 | OrgId int64 `pg:",pk" comment:"组织ID"` |
12 | // 企业id | 12 | // 企业id |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type Role struct { | 8 | type Role struct { |
9 | - tableName string `pg:"users.role,alias:role" comment:"角色"` | 9 | + tableName string `pg:"users.role" comment:"角色"` |
10 | // 角色ID | 10 | // 角色ID |
11 | RoleId int64 `pg:",pk" comment:"角色ID"` | 11 | RoleId int64 `pg:",pk" comment:"角色ID"` |
12 | // 企业id | 12 | // 企业id |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type User struct { | 8 | type User struct { |
9 | - tableName string `pg:"users.user,alias:user"` | 9 | + tableName string `pg:"users.user"` |
10 | // 用户Id 用户唯一标识 | 10 | // 用户Id 用户唯一标识 |
11 | UserId int64 `pg:",pk" comment:"用户Id"` | 11 | UserId int64 `pg:",pk" comment:"用户Id"` |
12 | // 企业id | 12 | // 企业id |
@@ -24,11 +24,11 @@ type User struct { | @@ -24,11 +24,11 @@ type User struct { | ||
24 | // 用户信息 (冗余,数据存在userBase里面) | 24 | // 用户信息 (冗余,数据存在userBase里面) |
25 | //UserInfo *domain.UserInfo | 25 | //UserInfo *domain.UserInfo |
26 | // 用户关联的组织 | 26 | // 用户关联的组织 |
27 | - UserOrg []*domain.Org `pg:",array" comment:"用户关联的组织"` | 27 | + UserOrg []*domain.Org `comment:"用户关联的组织"` |
28 | // 用户关联的角色 | 28 | // 用户关联的角色 |
29 | - UserRole []*domain.Role `pg:",array" comment:"用户关联的角色"` | 29 | + UserRole []*domain.Role `comment:"用户关联的角色"` |
30 | // 收藏的菜单(工作台)(菜单编码列表) | 30 | // 收藏的菜单(工作台)(菜单编码列表) |
31 | - FavoriteMenus []string `pg:",array" comment:"收藏的菜单"` | 31 | + FavoriteMenus []string `comment:"收藏的菜单"` |
32 | // 共创信息 (共创用户有效) | 32 | // 共创信息 (共创用户有效) |
33 | CooperationInfo *domain.CooperationInfo `comment:"共创信息 (共创用户有效)"` | 33 | CooperationInfo *domain.CooperationInfo `comment:"共创信息 (共创用户有效)"` |
34 | // 状态(1:启用 2:禁用 3:注销) | 34 | // 状态(1:启用 2:禁用 3:注销) |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | type UserBase struct { | 8 | type UserBase struct { |
9 | - tableName string `pg:"users.user_base,alias:user_base" comment:"用户基础"` | 9 | + tableName string `pg:"users.user_base" comment:"用户基础"` |
10 | // 用户基础数据id | 10 | // 用户基础数据id |
11 | UserBaseId int64 `pg:",pk" comment:"用户基础数据id"` | 11 | UserBaseId int64 `pg:",pk" comment:"用户基础数据id"` |
12 | // 用户信息 | 12 | // 用户信息 |
@@ -79,6 +79,7 @@ func (controller *CompanyController) SearchCompanyCustomizeMenus() { | @@ -79,6 +79,7 @@ func (controller *CompanyController) SearchCompanyCustomizeMenus() { | ||
79 | companyService := service.NewCompanyService(nil) | 79 | companyService := service.NewCompanyService(nil) |
80 | listCompanyCustomizeMenusCommand := &command.ListCompanyCustomizeMenusCommand{} | 80 | listCompanyCustomizeMenusCommand := &command.ListCompanyCustomizeMenusCommand{} |
81 | controller.Unmarshal(listCompanyCustomizeMenusCommand) | 81 | controller.Unmarshal(listCompanyCustomizeMenusCommand) |
82 | + // TODO:待移除 | ||
82 | listCompanyCustomizeMenusCommand.CompanyId = 1 | 83 | listCompanyCustomizeMenusCommand.CompanyId = 1 |
83 | data, err := companyService.ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand) | 84 | data, err := companyService.ListCompanyCustomizeMenus(listCompanyCustomizeMenusCommand) |
84 | controller.Response(data, err) | 85 | controller.Response(data, err) |
@@ -88,6 +89,7 @@ func (controller *CompanyController) AdapterUpdateCompanyCustomizeMenus() { | @@ -88,6 +89,7 @@ func (controller *CompanyController) AdapterUpdateCompanyCustomizeMenus() { | ||
88 | companyService := service.NewCompanyService(nil) | 89 | companyService := service.NewCompanyService(nil) |
89 | updateCompanyCustomizeMenusCommand := &command.UpdateCompanyCustomizeMenusCommand{} | 90 | updateCompanyCustomizeMenusCommand := &command.UpdateCompanyCustomizeMenusCommand{} |
90 | controller.Unmarshal(updateCompanyCustomizeMenusCommand) | 91 | controller.Unmarshal(updateCompanyCustomizeMenusCommand) |
92 | + // TODO:待移除 | ||
91 | updateCompanyCustomizeMenusCommand.CompanyId = 1 | 93 | updateCompanyCustomizeMenusCommand.CompanyId = 1 |
92 | data, err := companyService.UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand) | 94 | data, err := companyService.UpdateCompanyCustomizeMenus(updateCompanyCustomizeMenusCommand) |
93 | controller.Response(data, err) | 95 | controller.Response(data, err) |
-
请 注册 或 登录 后发表评论