From ce82b6542b18c6b9c7666caa101d4b19bddcd1a3 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Wed, 24 Jan 2024 14:50:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=A4=84=E7=90=86-=E5=B7=A5=E5=8D=95=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BA=BA=E6=98=AF=E5=88=86=E7=BB=84=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E5=90=8E=EF=BC=8C=E5=BA=94=E8=AF=A5=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E7=BB=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1070994834292736]工单处理-工单处理人是分组,删除组后,应该保留组数据,提示已删除 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1070994834292736 --- .../module/tenant/api/form/FormCopyApi.java | 2 +- .../api/notify/ImportNotifyPolicyApi.java | 9 ++++--- .../api/notify/NotifyPolicyCopyApi.java | 21 +++++++++------ .../api/notify/NotifyPolicySaveApi.java | 26 +++++++++++-------- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java b/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java index 284348b4..8df28a69 100644 --- a/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java +++ b/src/main/java/neatlogic/module/tenant/api/form/FormCopyApi.java @@ -112,7 +112,7 @@ public class FormCopyApi extends PrivateApiComponentBase { } else { newFormVersionList.sort(Comparator.comparing(FormVersionVo::getVersion)); for (int i = 0; i < newFormVersionList.size(); i++) { - newFormVersionList.get(i).setVersion(i); + newFormVersionList.get(i).setVersion(i + 1); } } IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); diff --git a/src/main/java/neatlogic/module/tenant/api/notify/ImportNotifyPolicyApi.java b/src/main/java/neatlogic/module/tenant/api/notify/ImportNotifyPolicyApi.java index 90d18945..3bb7e00a 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/ImportNotifyPolicyApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/ImportNotifyPolicyApi.java @@ -1,5 +1,6 @@ package neatlogic.module.tenant.api.notify; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.exception.file.FileExtNotAllowedException; import neatlogic.framework.exception.file.FileNotUploadException; @@ -15,7 +16,7 @@ import neatlogic.framework.restful.annotation.OperationType; import neatlogic.framework.restful.annotation.Output; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateBinaryStreamApiComponentBase; -import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.util.$; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -46,7 +47,7 @@ public class ImportNotifyPolicyApi extends PrivateBinaryStreamApiComponentBase { } @Override public String getName() { - return "导入通知策略"; + return "nmtan.importnotifypolicyapi.getname"; } @Override @@ -56,7 +57,7 @@ public class ImportNotifyPolicyApi extends PrivateBinaryStreamApiComponentBase { @Input({}) @Output({}) - @Description(desc = "导入通知策略") + @Description(desc = "nmtan.importnotifypolicyapi.getname") @Override public Object myDoService(JSONObject paramObj, HttpServletRequest request, HttpServletResponse response) throws Exception { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; @@ -101,7 +102,7 @@ public class ImportNotifyPolicyApi extends PrivateBinaryStreamApiComponentBase { throw new NotifyPolicyHandlerNotFoundException(handler); } if (notifyMapper.getNotifyPolicyByHandlerLimitOne(handler) != null && notifyPolicyHandler.isAllowMultiPolicy() == 0) { - throw new NotifyPolicyMoreThanOneException(notifyPolicyHandler.getName()); + throw new NotifyPolicyMoreThanOneException($.t(notifyPolicyHandler.getName())); } int i = 1; while (notifyMapper.checkNotifyPolicyNameIsRepeat(notifyPolicyVo) > 0) { diff --git a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyCopyApi.java b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyCopyApi.java index 9b4b99b2..8f3ab877 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyCopyApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyCopyApi.java @@ -16,6 +16,8 @@ package neatlogic.module.tenant.api.notify; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.NOTIFY_POLICY_MODIFY; @@ -35,9 +37,8 @@ import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.$; import neatlogic.framework.util.RegexUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,7 +61,7 @@ public class NotifyPolicyCopyApi extends PrivateApiComponentBase { @Override public String getName() { - return "通知策略复制接口"; + return "nmtan.notifypolicycopyapi.getname"; } @Override @@ -68,10 +69,14 @@ public class NotifyPolicyCopyApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "策略id"), @Param(name = "name", - type = ApiParamType.REGEX, rule = RegexUtils.NAME, maxLength = 50, isRequired = true, desc = "策略名"),}) - @Output({@Param(explode = NotifyPolicyVo.class, desc = "策略信息")}) - @Description(desc = "通知策略复制接口") + @Input({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id"), + @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, maxLength = 50, isRequired = true, desc = "common.name"), + }) + @Output({ + @Param(explode = NotifyPolicyVo.class, desc = "common.tbodylist") + }) + @Description(desc = "nmtan.notifypolicycopyapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { Long id = jsonObj.getLong("id"); @@ -84,7 +89,7 @@ public class NotifyPolicyCopyApi extends PrivateApiComponentBase { throw new NotifyPolicyHandlerNotFoundException(notifyPolicyVo.getHandler()); } if (notifyPolicyHandler.isAllowMultiPolicy() == 0) { - throw new NotifyPolicyMoreThanOneException(notifyPolicyHandler.getName()); + throw new NotifyPolicyMoreThanOneException($.t(notifyPolicyHandler.getName())); } String name = jsonObj.getString("name"); notifyPolicyVo.setName(name); diff --git a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySaveApi.java b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySaveApi.java index 014df3bc..9a3fb9b2 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySaveApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySaveApi.java @@ -16,6 +16,9 @@ package neatlogic.module.tenant.api.notify; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.NOTIFY_POLICY_MODIFY; @@ -36,10 +39,8 @@ import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.$; import neatlogic.framework.util.RegexUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -63,7 +64,7 @@ public class NotifyPolicySaveApi extends PrivateApiComponentBase { @Override public String getName() { - return "通知策略信息保存接口"; + return "nmtan.notifypolicysaveapi.getname"; } @Override @@ -71,12 +72,15 @@ public class NotifyPolicySaveApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "id", type = ApiParamType.LONG, desc = "策略id"), - @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, maxLength = 50, - isRequired = true, desc = "策略名"), - @Param(name = "handler", type = ApiParamType.STRING, isRequired = true, desc = "通知策略处理器")}) - @Output({@Param(explode = NotifyPolicyVo.class, desc = "策略信息")}) - @Description(desc = "通知策略信息保存接口") + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"), + @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, maxLength = 50, isRequired = true, desc = "common.name"), + @Param(name = "handler", type = ApiParamType.STRING, isRequired = true, desc = "term.notify.handler") + }) + @Output({ + @Param(explode = NotifyPolicyVo.class, desc = "common.tbodylist") + }) + @Description(desc = "nmtan.notifypolicysaveapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { String handler = jsonObj.getString("handler"); @@ -104,7 +108,7 @@ public class NotifyPolicySaveApi extends PrivateApiComponentBase { paramList.sort((e1, e2) -> e1.getName().compareToIgnoreCase(e2.getName())); } else { if (notifyMapper.getNotifyPolicyByHandlerLimitOne(handler) != null && notifyPolicyHandler.isAllowMultiPolicy() == 0) { - throw new NotifyPolicyMoreThanOneException(notifyPolicyHandler.getName()); + throw new NotifyPolicyMoreThanOneException($.t(notifyPolicyHandler.getName())); } notifyPolicyVo = new NotifyPolicyVo(name, handler); if (notifyMapper.checkNotifyPolicyNameIsRepeat(notifyPolicyVo) > 0) { -- Gitee From b97dee5ea23846d3de567ea725dd7553bbd1ccc2 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Wed, 24 Jan 2024 14:56:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=A4=84=E7=90=86-=E5=B7=A5=E5=8D=95=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BA=BA=E6=98=AF=E5=88=86=E7=BB=84=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E5=90=8E=EF=BC=8C=E5=BA=94=E8=AF=A5=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E7=BB=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1070994834292736]工单处理-工单处理人是分组,删除组后,应该保留组数据,提示已删除 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1070994834292736 --- .../neatlogic/module/tenant/api/role/RoleDeleteApi.java | 9 +++++---- .../neatlogic/module/tenant/api/team/TeamDeleteApi.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/neatlogic/module/tenant/api/role/RoleDeleteApi.java b/src/main/java/neatlogic/module/tenant/api/role/RoleDeleteApi.java index 97fafdf5..6104d27d 100755 --- a/src/main/java/neatlogic/module/tenant/api/role/RoleDeleteApi.java +++ b/src/main/java/neatlogic/module/tenant/api/role/RoleDeleteApi.java @@ -35,7 +35,7 @@ public class RoleDeleteApi extends PrivateApiComponentBase { @Override public String getName() { - return "角色删除接口"; + return "nmtar.roledeleteapi.getname"; } @Override @@ -46,9 +46,9 @@ public class RoleDeleteApi extends PrivateApiComponentBase { @Input({ @Param(name = "uuidList", type = ApiParamType.JSONARRAY, - desc = "角色名称集合", + desc = "common.roleuuidlist", isRequired = true) }) - @Description(desc = "角色删除接口") + @Description(desc = "nmtar.roledeleteapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { List uuidList = JSON.parseArray(jsonObj.getString("uuidList"), String.class); @@ -56,7 +56,8 @@ public class RoleDeleteApi extends PrivateApiComponentBase { roleMapper.deleteMenuRoleByRoleUuid(uuid); roleMapper.deleteTeamRoleByRoleUuid(uuid); roleMapper.deleteRoleUser(new RoleUserVo(uuid)); - roleMapper.deleteRoleByUuid(uuid); +// roleMapper.deleteRoleByUuid(uuid); + roleMapper.updateRoleIsDeletedByUuid(uuid); roleMapper.deleteRoleAuthByRoleUuid(uuid); } return null; diff --git a/src/main/java/neatlogic/module/tenant/api/team/TeamDeleteApi.java b/src/main/java/neatlogic/module/tenant/api/team/TeamDeleteApi.java index eb0f0cc7..7c914346 100755 --- a/src/main/java/neatlogic/module/tenant/api/team/TeamDeleteApi.java +++ b/src/main/java/neatlogic/module/tenant/api/team/TeamDeleteApi.java @@ -41,7 +41,7 @@ public class TeamDeleteApi extends PrivateApiComponentBase { @Override public String getName() { - return "删除分组接口"; + return "nmtat.teamdeleteapi.getname"; } @Override @@ -49,8 +49,8 @@ public class TeamDeleteApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "uuid", type = ApiParamType.STRING, desc = "分组uuid", isRequired = true)}) - @Description(desc = "删除分组接口") + @Input({@Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid", isRequired = true)}) + @Description(desc = "nmtat.teamdeleteapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { String uuid = jsonObj.getString("uuid"); @@ -61,7 +61,8 @@ public class TeamDeleteApi extends PrivateApiComponentBase { List uuidList = teamMapper.getChildrenUuidListByLeftRightCode(team.getLft(), team.getRht()); LRCodeManager.beforeDeleteTreeNode("team", "uuid", "parent_uuid", uuid); uuidList.add(team.getUuid()); - teamMapper.deleteTeamByUuidList(uuidList); +// teamMapper.deleteTeamByUuidList(uuidList); + teamMapper.updateTeamIsDeletedByUuidList(uuidList); teamMapper.deleteTeamUserByTeamUuidList(uuidList); teamMapper.deleteTeamRoleByTeamUuidList(uuidList); //delete teamUserTitle -- Gitee From 7eb9b879a70542403cd7bef7540e24bd2209b58a Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Wed, 24 Jan 2024 15:02:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=A4=84=E7=90=86-=E5=B7=A5=E5=8D=95=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BA=BA=E6=98=AF=E5=88=86=E7=BB=84=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E5=90=8E=EF=BC=8C=E5=BA=94=E8=AF=A5=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E7=BB=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1070994834292736]工单处理-工单处理人是分组,删除组后,应该保留组数据,提示已删除 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1070994834292736 --- .../module/tenant/api/role/RoleSaveApi.java | 63 +++++++++++++------ .../module/tenant/api/team/TeamSaveApi.java | 53 +++++++++++----- 2 files changed, 83 insertions(+), 33 deletions(-) diff --git a/src/main/java/neatlogic/module/tenant/api/role/RoleSaveApi.java b/src/main/java/neatlogic/module/tenant/api/role/RoleSaveApi.java index 3de84583..f4cc4d87 100644 --- a/src/main/java/neatlogic/module/tenant/api/role/RoleSaveApi.java +++ b/src/main/java/neatlogic/module/tenant/api/role/RoleSaveApi.java @@ -1,20 +1,20 @@ package neatlogic.module.tenant.api.role; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.auth.label.ROLE_MODIFY; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.dao.mapper.RoleMapper; import neatlogic.framework.dao.mapper.UserMapper; -import neatlogic.framework.dto.RoleAuthVo; -import neatlogic.framework.dto.RoleTeamVo; -import neatlogic.framework.dto.RoleUserVo; -import neatlogic.framework.dto.RoleVo; +import neatlogic.framework.dto.*; +import neatlogic.framework.exception.role.RoleNameRepeatException; import neatlogic.framework.exception.role.RoleNotFoundException; -import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import neatlogic.framework.auth.label.ROLE_MODIFY; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -45,7 +45,7 @@ public class RoleSaveApi extends PrivateApiComponentBase { @Override public String getName() { - return "角色信息保存接口"; + return "nmtar.rolesaveapi.getname"; } @Override @@ -56,30 +56,31 @@ public class RoleSaveApi extends PrivateApiComponentBase { @Input({ @Param(name = "uuid", type = ApiParamType.STRING, - desc = "角色uuid"), + desc = "common.uuid"), @Param(name = "name", type = ApiParamType.STRING, - desc = "角色名称", + desc = "common.name", isRequired = true, xss = true), @Param(name = "description", type = ApiParamType.STRING, - desc = "角色描述", xss = true), + desc = "common.description", xss = true), @Param(name = "rule", type = ApiParamType.STRING, - desc = "规则。登录认证的请求需要携带Header做规则表达式,如果表达式执行后的值为true则该角色生效,否则不生效\\n如: ${DATA.env} == \"sit\" and ${DATA.test} == \"1\""), + desc = "common.rule", + help = "登录认证的请求需要携带Header做规则表达式,如果表达式执行后的值为true则该角色生效,否则不生效\\n如: ${DATA.env} == \"sit\" and ${DATA.test} == \"1\""), @Param(name = "userUuidList", type = ApiParamType.JSONARRAY, - desc = "用户uuid集合"), + desc = "common.useruuidlist"), @Param(name = "teamList", type = ApiParamType.JSONARRAY, - desc = "分组集合,[{\"uuid\":\"aaaaaaaaaa\", \"checkedChildren\":1}]"), + desc = "common.teamlist,[{\"uuid\":\"aaaaaaaaaa\", \"checkedChildren\":1}]"), @Param(name = "roleAuthList", - desc = "角色权限集合", + desc = "common.roleauthlist", type = ApiParamType.JSONOBJECT)}) @Output({ - @Param(name = "uuid", type = ApiParamType.STRING, desc = "uuid") + @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid") }) - @Description(desc = "角色信息保存接口") + @Description(desc = "nmtar.rolesaveapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { JSONObject resultObj = new JSONObject(); @@ -92,10 +93,24 @@ public class RoleSaveApi extends PrivateApiComponentBase { if (roleMapper.checkRoleIsExists(uuid) == 0) { throw new RoleNotFoundException(uuid); } + if (roleMapper.checkRoleNameIsIsRepeat(roleVo) > 0) { + throw new RoleNameRepeatException(roleVo.getName()); + } roleVo.setUuid(uuid); roleMapper.updateRole(roleVo); } else { - roleMapper.insertRole(roleVo); + if (roleMapper.checkRoleNameIsIsRepeat(roleVo) > 0) { + throw new RoleNameRepeatException(roleVo.getName()); + } + RoleVo oldRole = roleMapper.getRoleByName(roleVo.getName()); + if (oldRole != null) { + roleVo.setId(oldRole.getId()); + roleVo.setUuid(oldRole.getUuid()); + roleVo.setIsDelete(0); + roleMapper.updateRole(roleVo); + } else { + roleMapper.insertRole(roleVo); + } JSONArray userUuidArray = jsonObj.getJSONArray("userUuidList"); if (CollectionUtils.isNotEmpty(userUuidArray)) { List userUuidList = userUuidArray.toJavaList(String.class); @@ -142,4 +157,14 @@ public class RoleSaveApi extends PrivateApiComponentBase { resultObj.put("uuid", roleVo.getUuid()); return resultObj; } + + public IValid name() { + return value -> { + RoleVo roleVo = JSON.toJavaObject(value, RoleVo.class); + if (roleMapper.checkRoleNameIsIsRepeat(roleVo) > 0) { + return new FieldValidResultVo(new RoleNameRepeatException(roleVo.getName())); + } + return new FieldValidResultVo(); + }; + } } diff --git a/src/main/java/neatlogic/module/tenant/api/team/TeamSaveApi.java b/src/main/java/neatlogic/module/tenant/api/team/TeamSaveApi.java index 48f20de1..08646be3 100755 --- a/src/main/java/neatlogic/module/tenant/api/team/TeamSaveApi.java +++ b/src/main/java/neatlogic/module/tenant/api/team/TeamSaveApi.java @@ -1,5 +1,7 @@ package neatlogic.module.tenant.api.team; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.TEAM_MODIFY; import neatlogic.framework.common.constvalue.ApiParamType; @@ -8,15 +10,15 @@ import neatlogic.framework.dao.mapper.TeamMapper; import neatlogic.framework.dao.mapper.UserMapper; import neatlogic.framework.dto.*; import neatlogic.framework.exception.team.TeamLevelNotFoundException; +import neatlogic.framework.exception.team.TeamNameRepeatException; import neatlogic.framework.exception.team.TeamNotFoundException; import neatlogic.framework.lrcode.LRCodeManager; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; -import neatlogic.module.tenant.service.TeamService; import neatlogic.framework.service.UserService; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import neatlogic.module.tenant.service.TeamService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -51,7 +53,7 @@ public class TeamSaveApi extends PrivateApiComponentBase { @Override public String getName() { - return "保存组信息"; + return "nmtat.teamsaveapi.getname"; } @Override @@ -60,16 +62,16 @@ public class TeamSaveApi extends PrivateApiComponentBase { } @Input({ - @Param(name = "uuid", type = ApiParamType.STRING, desc = "组id", isRequired = false), - @Param(name = "name", type = ApiParamType.STRING, desc = "组名", isRequired = true, xss = true), - @Param(name = "parentUuid", type = ApiParamType.STRING, desc = "父级组id"), - @Param(name = "level", type = ApiParamType.STRING, desc = "层级"), - @Param(name = "userUuidList", type = ApiParamType.JSONARRAY, desc = "用户uuid集合"), - @Param(name = "teamUuidList", type = ApiParamType.JSONARRAY, desc = "分组uuid集合"), - @Param(name = "teamUserTitleList", type = ApiParamType.JSONARRAY, desc = "分组领导集合") + @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid", isRequired = false), + @Param(name = "name", type = ApiParamType.STRING, desc = "common.name", isRequired = true, xss = true), + @Param(name = "parentUuid", type = ApiParamType.STRING, desc = "term.diagram.parentuuid"), + @Param(name = "level", type = ApiParamType.STRING, desc = "common.level"), + @Param(name = "userUuidList", type = ApiParamType.JSONARRAY, desc = "common.useruuidlist"), + @Param(name = "teamUuidList", type = ApiParamType.JSONARRAY, desc = "common.teamuuidlist"), + @Param(name = "teamUserTitleList", type = ApiParamType.JSONARRAY, desc = "common.teamusertitlelist") }) - @Output({@Param(name = "uuid", type = ApiParamType.STRING, desc = "保存的组id")}) - @Description(desc = "保存组信息") + @Output({@Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid")}) + @Description(desc = "nmtat.teamsaveapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { String level = jsonObj.getString("level"); @@ -86,9 +88,14 @@ public class TeamSaveApi extends PrivateApiComponentBase { teamVo.setLevel(level); teamVo.setUuid(uuid); if (StringUtils.isNotBlank(uuid)) { - if (teamMapper.checkTeamIsExists(uuid) == 0) { + TeamVo oldTeam = teamMapper.getTeamByUuid(uuid); + if (oldTeam == null) { throw new TeamNotFoundException(uuid); } + teamVo.setParentUuid(oldTeam.getParentUuid()); + if (teamMapper.checkTeamNameIsIsRepeat(teamVo) > 0) { + throw new TeamNameRepeatException(teamVo.getName()); + } teamVo.setUuid(uuid); teamMapper.updateTeamNameByUuid(teamVo); teamService.deleteTeamUserTitleByTeamUuid(uuid); @@ -103,6 +110,14 @@ public class TeamSaveApi extends PrivateApiComponentBase { } } teamVo.setParentUuid(parentUuid); + if (teamMapper.checkTeamNameIsIsRepeat(teamVo) > 0) { + throw new TeamNameRepeatException(teamVo.getName()); + } + TeamVo oldTeam = teamMapper.getTeamByNameAndParentUuid(teamVo); + if (oldTeam != null) { + teamVo.setId(oldTeam.getId()); + teamVo.setUuid(oldTeam.getUuid()); + } int lft = LRCodeManager.beforeAddTreeNode("team", "uuid", "parent_uuid", parentUuid); teamVo.setLft(lft); teamVo.setRht(lft + 1); @@ -160,6 +175,16 @@ public class TeamSaveApi extends PrivateApiComponentBase { return returnObj; } + public IValid name() { + return value -> { + TeamVo teamVo = JSON.toJavaObject(value, TeamVo.class); + if (teamMapper.checkTeamNameIsIsRepeat(teamVo) > 0) { + return new FieldValidResultVo(new TeamNameRepeatException(teamVo.getName())); + } + return new FieldValidResultVo(); + }; + } + // private Object backup(JSONObject jsonObj){ // JSONObject returnObj = new JSONObject(); // String level = jsonObj.getString("level"); -- Gitee