From 845d1bd2330b09e3489b3d012fa7d2664cdff9c6 Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Tue, 23 Jul 2024 11:25:31 +0800 Subject: [PATCH] fix: tip for tenant management --- database/install/sys_dict_data1_i18n_zh.sql | 9 +++++++++ database/install/sys_dict_data2_i18n_en.sql | 8 ++++++++ database/upgrade/upg_sys_dict_data1_i18n_zh.sql | 8 ++++++++ database/upgrade/upg_sys_dict_data2_i18n_en.sql | 9 +++++++++ src/modules/system/controller/sys_tenant.go | 8 ++++---- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/database/install/sys_dict_data1_i18n_zh.sql b/database/install/sys_dict_data1_i18n_zh.sql index d7965e9f..18ff8047 100644 --- a/database/install/sys_dict_data1_i18n_zh.sql +++ b/database/install/sys_dict_data1_i18n_zh.sql @@ -692,5 +692,14 @@ INSERT INTO `sys_dict_data` VALUES (11028, 11000, 'dictData.match.prefix', '前 INSERT INTO `sys_dict_data` VALUES (11029, 11000, 'dictData.match.suffix', '后缀匹配', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (11030, 11000, 'menu.tenant.cdr', '话单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (11031, 11000, 'menu.tenant.onlineIMS', '在线语音会话', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11032, 11000, 'tenant.noData', '没有可访问的租户数据!', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11033, 11000, 'tenant.errParentDelFlag', '上级租户【{name}】已删除,不允许新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11034, 11000, 'tenant.errParentStatus', '上级租户【{name}】停用,不允许新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11035, 11000, 'tenant.errNameExists', '操作租户【{name}】失败,租户名称已存在', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11036, 11000, 'tenant.errParentID', '操作租户【{name}】失败,上级租户不能是自己', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11037, 11000, 'tenant.errHasChildUse', '操作失败,该租户包含未停用的租赁资产数量:{num}', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11038, 11000, 'tenant.errHasUserUse', '不允许删除,租户已分配用户数:{num}', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (11039, 11000, 'tenant.errAssetExists', '租赁资产[{type}:{key}]与现有的资产有冲突', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); + SET FOREIGN_KEY_CHECKS = 1; diff --git a/database/install/sys_dict_data2_i18n_en.sql b/database/install/sys_dict_data2_i18n_en.sql index 9a63ad41..a7e24e41 100644 --- a/database/install/sys_dict_data2_i18n_en.sql +++ b/database/install/sys_dict_data2_i18n_en.sql @@ -692,5 +692,13 @@ INSERT INTO `sys_dict_data` VALUES (14028, 14000, 'dictData.match.prefix', 'Pref INSERT INTO `sys_dict_data` VALUES (14029, 14000, 'dictData.match.suffix', 'Suffix Match', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (14030, 14000, 'menu.tenant.cdr', 'CDR', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); INSERT INTO `sys_dict_data` VALUES (14031, 14000, 'menu.tenant.onlineIMS', 'Online Voice Sessions', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14032, 14000, 'tenant.noData', 'There is no accessible tenant data', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14033, 14000, 'tenant.errParentDelFlag', 'The parent tenant [{name}] has been deleted and is not allowed to be added', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14034, 14000, 'tenant.errParentStatus', 'Parent tenant [{name}] is deactivated, additions are not allowed', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14035, 14000, 'tenant.errNameExists', 'Manipulate tenant [{name}] failed, tenant name already exists', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14036, 14000, 'tenant.errParentID', 'Failed to operate tenant [{name}], the parent tenant cannot be itself', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14037, 14000, 'tenant.errHasChildUse', 'Operation failed, the tenant contains active asset number: {num}', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14038, 14000, 'tenant.errHasUserUse', 'Deletion is not allowed, number of users the tenant has been assigned to: {num}', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +INSERT INTO `sys_dict_data` VALUES (14039, 14000, 'tenant.errAssetExists', 'There is a conflict between tenancy asset[{type}:{key}] and a existing asset', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); SET FOREIGN_KEY_CHECKS = 1; diff --git a/database/upgrade/upg_sys_dict_data1_i18n_zh.sql b/database/upgrade/upg_sys_dict_data1_i18n_zh.sql index 23b812db..448cd2eb 100644 --- a/database/upgrade/upg_sys_dict_data1_i18n_zh.sql +++ b/database/upgrade/upg_sys_dict_data1_i18n_zh.sql @@ -699,5 +699,13 @@ REPLACE INTO `sys_dict_data` VALUES (11028, 11000, 'dictData.match.prefix', '前 REPLACE INTO `sys_dict_data` VALUES (11029, 11000, 'dictData.match.suffix', '后缀匹配', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (11030, 11000, 'menu.tenant.cdr', '话单', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (11031, 11000, 'menu.tenant.onlineIMS', '在线语音会话', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11032, 11000, 'tenant.noData', '没有可访问的租户数据!', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11033, 11000, 'tenant.errParentDelFlag', '上级租户【{name}】已删除,不允许新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11034, 11000, 'tenant.errParentStatus', '上级租户【{name}】停用,不允许新增', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11035, 11000, 'tenant.errNameExists', '操作租户【{name}】失败,租户名称已存在', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11036, 11000, 'tenant.errParentID', '操作租户【{name}】失败,上级租户不能是自己', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11037, 11000, 'tenant.errHasChildUse', '操作失败,该租户包含未停用的租赁资产数量:{num}', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11038, 11000, 'tenant.errHasUserUse', '不允许删除,租户已分配用户数:{num}', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (11039, 11000, 'tenant.errAssetExists', '租赁资产[{type}:{key}]与现有的资产有冲突', 'i18n_zh', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); SET FOREIGN_KEY_CHECKS = 1; diff --git a/database/upgrade/upg_sys_dict_data2_i18n_en.sql b/database/upgrade/upg_sys_dict_data2_i18n_en.sql index e604b3d3..0506f6d5 100644 --- a/database/upgrade/upg_sys_dict_data2_i18n_en.sql +++ b/database/upgrade/upg_sys_dict_data2_i18n_en.sql @@ -694,5 +694,14 @@ REPLACE INTO `sys_dict_data` VALUES (14028, 14000, 'dictData.match.prefix', 'Pre REPLACE INTO `sys_dict_data` VALUES (14029, 14000, 'dictData.match.suffix', 'Suffix Match', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (14030, 14000, 'menu.tenant.cdr', 'CDR', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); REPLACE INTO `sys_dict_data` VALUES (14031, 14000, 'menu.tenant.onlineIMS', 'Online Voice Sessions', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14032, 14000, 'tenant.noData', 'There is no accessible tenant data', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14033, 14000, 'tenant.errParentDelFlag', 'The parent tenant [{name}] has been deleted and is not allowed to be added', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14034, 14000, 'tenant.errParentStatus', 'Parent tenant [{name}] is deactivated, additions are not allowed', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14035, 14000, 'tenant.errNameExists', 'Manipulate tenant [{name}] failed, tenant name already exists', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14036, 14000, 'tenant.errParentID', 'Failed to operate tenant [{name}], the parent tenant cannot be itself', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14037, 14000, 'tenant.errHasChildUse', 'Operation failed, the tenant contains active asset number: {num}', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14038, 14000, 'tenant.errHasUserUse', 'Deletion is not allowed, number of users the tenant has been assigned to: {num}', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); +REPLACE INTO `sys_dict_data` VALUES (14039, 14000, 'tenant.errAssetExists', 'There is a conflict between tenancy asset[{type}:{key}] and a existing asset', 'i18n_en', NULL, NULL, '1', 'supervisor', 1700000000000, NULL, 0, NULL); + SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/modules/system/controller/sys_tenant.go b/src/modules/system/controller/sys_tenant.go index e02dae12..2dcfe66b 100644 --- a/src/modules/system/controller/sys_tenant.go +++ b/src/modules/system/controller/sys_tenant.go @@ -137,7 +137,7 @@ func (s *SysTenantController) Add(c *gin.Context) { uniqueTenantName := s.sysTenantService.CheckUniqueTenantName(body.TenantName, body.ParentID, "") if !uniqueTenantName { // 租户新增【%s】失败,租户名称已存在 - msg := i18n.TTemplate(language, "ERROR: tenant name already exists", map[string]any{"name": body.TenantName}) + msg := i18n.TTemplate(language, "tenant.errNameExists", map[string]any{"name": body.TenantName}) c.JSON(200, result.ErrMsg(msg)) return } @@ -145,7 +145,7 @@ func (s *SysTenantController) Add(c *gin.Context) { uniqueTenancy := s.sysTenantService.IsUniqueTenancy(body.TenantID, body.TenancyType, body.TenancyKey) if !uniqueTenancy { // 租赁对象添加失败,租赁对象已存在 - msg := i18n.TTemplate(language, "ERROR: tenancy asset already exists", map[string]any{"key": body.TenancyKey}) + msg := i18n.TTemplate(language, "tenant.errAssetExists", map[string]any{"type": body.TenancyType, "key": body.TenancyKey}) c.JSON(200, result.ErrMsg(msg)) return } @@ -209,7 +209,7 @@ func (s *SysTenantController) Edit(c *gin.Context) { uniqueTenantName := s.sysTenantService.CheckUniqueTenantName(body.TenantName, body.ParentID, body.TenantID) if !uniqueTenantName { // 租户修改【%s】失败,租户名称已存在 - msg := i18n.TTemplate(language, "ERROR: tenant name already exists", map[string]any{"name": body.TenantName}) + msg := i18n.TTemplate(language, "tenant.errNameExists", map[string]any{"name": body.TenantName}) c.JSON(200, result.ErrMsg(msg)) return } @@ -217,7 +217,7 @@ func (s *SysTenantController) Edit(c *gin.Context) { uniqueTenancy := s.sysTenantService.IsUniqueTenancy(body.TenantID, body.TenancyType, body.TenancyKey) if !uniqueTenancy { // 租赁对象添加失败,租赁对象已存在 - msg := i18n.TTemplate(language, "ERROR: tenancy asset already exists", map[string]any{"key": body.TenancyKey}) + msg := i18n.TTemplate(language, "tenant.errAssetExists", map[string]any{"type": body.TenancyType, "key": body.TenancyKey}) c.JSON(200, result.ErrMsg(msg)) return }