From 6b8bb6c308ee162132f223b2a57e5d5057c570f0 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Wed, 24 Nov 2021 18:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=AD=97?= =?UTF-8?q?=E5=85=B8mongo=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=85=94=E5=B1=95=E5=B1=9E=E6=80=A7=E5=85=A8=E9=83=A8=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 18 ++++++ .../userexpand/UserExpandAppController.java | 10 +++ .../userexpand/IUserExpandService.java | 7 +++ .../impl/UserExpandServiceImpl.java | 63 ++++++++++++++----- .../resources/templates/enterprise/save.html | 2 +- .../templates/enterprise/update.html | 2 +- .../templates/organization/save.html | 2 +- .../templates/organization/update.html | 2 +- 8 files changed, 86 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 9c8d578..d10e59a 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,12 @@ ink.wgink login-app 1.0-SNAPSHOT + + + ink.wgink + module-dictionary + + @@ -105,6 +111,18 @@ ink.wgink login-oauth2-server 1.0-SNAPSHOT + + + ink.wgink + login-base + + + + + + ink.wgink + mongo-module-dictionary + 1.0-SNAPSHOT diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/app/api/userexpand/UserExpandAppController.java b/src/main/java/cn/com/tenlion/usercenter/controller/app/api/userexpand/UserExpandAppController.java index 54a2812..bb91055 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/app/api/userexpand/UserExpandAppController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/app/api/userexpand/UserExpandAppController.java @@ -49,4 +49,14 @@ public class UserExpandAppController extends DefaultBaseController { return userExpandService.get(userId); } + @ApiOperation(value = "拓展属性(全部)详情", notes = "拓展属性(全部)详情接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("get-whole/{userId}") + public UserExpandDTO getWhole(@PathVariable("userId") String userId) { + return userExpandService.getWhole(userId); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java index bca73ea..5475c80 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java @@ -59,4 +59,11 @@ public interface IUserExpandService extends IUserExpandBaseService listWholeByRoleIdAndAreaCode(String roleId, String areaCode); + /** + * 详情全部 + * + * @param userId + * @return + */ + UserExpandDTO getWhole(String userId); } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java index b024c44..68585ac 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -191,6 +192,25 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx return userExpandDTOs; } + @Override + public UserExpandDTO getWhole(String userId) { + UserExpandDTO userExpandDTO = get(userId); + if (userExpandDTO == null) { + return null; + } + + List departmentUserDTOs = departmentUserBaseService.listByUserIds(Arrays.asList(userId)); + if (departmentUserDTOs.isEmpty()) { + return userExpandDTO; + } + List departmentPOs = departmentBaseService.listPO(ArrayListUtil.listBeanStringIdValue(departmentUserDTOs, "departmentId", DepartmentUserDTO.class)); + if (departmentPOs.isEmpty()) { + return userExpandDTO; + } + setDepartment(userExpandDTO, departmentUserDTOs, departmentPOs); + return userExpandDTO; + } + /** * 设置用户 * @@ -255,22 +275,33 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx } // 合并内容 for (UserExpandDTO userExpandDTO : userExpandDTOs) { - List departmentDTOs = new ArrayList<>(); - for (DepartmentUserDTO departmentUserDTO : departmentUserDTOs) { - if (!StringUtils.equals(userExpandDTO.getUserId(), departmentUserDTO.getUserId())) { - continue; - } - for (DepartmentPO departmentPO : departmentPOs) { - if (!StringUtils.equals(departmentUserDTO.getDepartmentId(), departmentPO.getDepartmentId())) { - continue; - } - DepartmentDTO departmentDTO = new DepartmentDTO(); - BeanUtils.copyProperties(departmentPO, departmentDTO); - departmentDTOs.add(departmentDTO); - break; - } - } - userExpandDTO.setDepartments(departmentDTOs); + setDepartment(userExpandDTO, departmentUserDTOs, departmentPOs); } } + + /** + * 设置部门 + * + * @param userExpandDTO + * @param departmentUserDTOs + * @param departmentPOs + */ + private void setDepartment(UserExpandDTO userExpandDTO, List departmentUserDTOs, List departmentPOs) { + List departmentDTOs = new ArrayList<>(); + for (DepartmentUserDTO departmentUserDTO : departmentUserDTOs) { + if (!StringUtils.equals(userExpandDTO.getUserId(), departmentUserDTO.getUserId())) { + continue; + } + for (DepartmentPO departmentPO : departmentPOs) { + if (!StringUtils.equals(departmentUserDTO.getDepartmentId(), departmentPO.getDepartmentId())) { + continue; + } + DepartmentDTO departmentDTO = new DepartmentDTO(); + BeanUtils.copyProperties(departmentPO, departmentDTO); + departmentDTOs.add(departmentDTO); + break; + } + } + userExpandDTO.setDepartments(departmentDTOs); + } } diff --git a/src/main/resources/templates/enterprise/save.html b/src/main/resources/templates/enterprise/save.html index aeda5ee..12f085b 100644 --- a/src/main/resources/templates/enterprise/save.html +++ b/src/main/resources/templates/enterprise/save.html @@ -660,7 +660,7 @@ // 初始化证件类型ID下拉选择 function initLegalPersonIdCardCodeSelect() { - top.restAjax.get(top.restAjax.path('api/data/listbyparentid/d3cbf2d8-d3b7-4530-b1e1-f2b35996999c', []), {}, null, function(code, data, args) { + top.restAjax.get(top.restAjax.path('api/data/listbyparentid/76c5044f-805a-4313-b1e8-79e966b97c0d', []), {}, null, function(code, data, args) { laytpl(document.getElementById('legalPersonIdCardCodeSelectTemplate').innerHTML).render(data, function(html) { document.getElementById('legalPersonIdCardCodeSelectTemplateBox').innerHTML = html; }); diff --git a/src/main/resources/templates/enterprise/update.html b/src/main/resources/templates/enterprise/update.html index eb7d446..194deb8 100644 --- a/src/main/resources/templates/enterprise/update.html +++ b/src/main/resources/templates/enterprise/update.html @@ -666,7 +666,7 @@ // 初始化类型ID下拉选择 function initLegalPersonIdCardCodeSelect(selectValue) { - top.restAjax.get(top.restAjax.path('api/data/listbyparentid/d3cbf2d8-d3b7-4530-b1e1-f2b35996999c', []), {}, null, function(code, data, args) { + top.restAjax.get(top.restAjax.path('api/data/listbyparentid/76c5044f-805a-4313-b1e8-79e966b97c0d', []), {}, null, function(code, data, args) { laytpl(document.getElementById('legalPersonIdCardCodeSelectTemplate').innerHTML).render(data, function(html) { document.getElementById('legalPersonIdCardCodeSelectTemplateBox').innerHTML = html; }); diff --git a/src/main/resources/templates/organization/save.html b/src/main/resources/templates/organization/save.html index 2cb44e7..f80c657 100644 --- a/src/main/resources/templates/organization/save.html +++ b/src/main/resources/templates/organization/save.html @@ -598,7 +598,7 @@ } function initMasterIdCardCodeSelect() { - top.restAjax.get(top.restAjax.path('api/data/listbyparentid/d3cbf2d8-d3b7-4530-b1e1-f2b35996999c', []), {}, null, function(code, data, args) { + top.restAjax.get(top.restAjax.path('api/data/listbyparentid/76c5044f-805a-4313-b1e8-79e966b97c0d', []), {}, null, function(code, data, args) { laytpl(document.getElementById('masterIdCardCodeSelectTemplate').innerHTML).render(data, function(html) { document.getElementById('masterIdCardCodeSelectTemplateBox').innerHTML = html; }); diff --git a/src/main/resources/templates/organization/update.html b/src/main/resources/templates/organization/update.html index 7df6621..ec23d62 100644 --- a/src/main/resources/templates/organization/update.html +++ b/src/main/resources/templates/organization/update.html @@ -604,7 +604,7 @@ } function initMasterIdCardCodeSelect(selectValue) { - top.restAjax.get(top.restAjax.path('api/data/listbyparentid/d3cbf2d8-d3b7-4530-b1e1-f2b35996999c', []), {}, null, function(code, data, args) { + top.restAjax.get(top.restAjax.path('api/data/listbyparentid/76c5044f-805a-4313-b1e8-79e966b97c0d', []), {}, null, function(code, data, args) { laytpl(document.getElementById('masterIdCardCodeSelectTemplate').innerHTML).render(data, function(html) { document.getElementById('masterIdCardCodeSelectTemplateBox').innerHTML = html; });