From 276f4d26fea4d96c0a8bf9f52a80023fde032330 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 23 Apr 2020 17:06:51 +0800 Subject: [PATCH 01/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=B8=80=E6=AC=A1=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpmetUserFeignClientFallBack.java | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java deleted file mode 100644 index 05b26449b3..0000000000 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.epmet.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.feign.EpmetUserFeignClient; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @Auther zxc - * @Create 2020-04-23 14:10 - */ -@Component -public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { - @Override - public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); - } - @Override - public Result> getStaffGridList(List customerStaffGridDTOS) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); - } -} From 507d3ed8f6c1ca05eeb4b9885c96d5661c174429 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 23 Apr 2020 17:09:58 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=B8=80=E6=AC=A1=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpmetUserFeignClientFallBack.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java new file mode 100644 index 0000000000..05b26449b3 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -0,0 +1,28 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Auther zxc + * @Create 2020-04-23 14:10 + */ +@Component +public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { + @Override + public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); + } + @Override + public Result> getStaffGridList(List customerStaffGridDTOS) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); + } +} From 2309bc135f12b7dc7538841cceb6e6d4917a1c07 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 23 Apr 2020 17:28:30 +0800 Subject: [PATCH 03/26] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=BB=BAcontrolle?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/AgencyController.java | 100 ++++++++++ .../controller/CustomerAgencyController.java | 61 +----- .../src/main/java/com/epmet/feign/.gitkeep | 0 .../java/com/epmet/service/AgencyService.java | 80 ++++++++ .../epmet/service/CustomerAgencyService.java | 40 ---- .../epmet/service/impl/AgencyServiceImpl.java | 185 ++++++++++++++++++ .../impl/CustomerAgencyServiceImpl.java | 125 ------------ 7 files changed, 366 insertions(+), 225 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java new file mode 100644 index 0000000000..501e6c05bd --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -0,0 +1,100 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddAgencyResultDTO; +import com.epmet.dto.result.AgencydetailResultDTO; +import com.epmet.dto.result.SubAgencyResultDTO; +import com.epmet.service.AgencyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 组织机构 + * + * @author generator generator@elink-cn.com + */ +@RestController +@RequestMapping("agency") +public class AgencyController { + + @Autowired + private AgencyService agencyService; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加组织 + */ + @PostMapping("addagency") + public Result addAgency(@RequestBody AddAgencyFormDTO formDTO) { + return agencyService.addAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织名称编辑 + */ + @PostMapping("editagency") + public Result editAgency(@RequestBody EditAgencyFormDTO formDTO) { + return agencyService.editAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除组织机关 + */ + @PostMapping("removeagency") + public Result removeAgency(@RequestBody RemoveAgencyFormDTO formDTO) { + return agencyService.removeAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取组织机构信息 + */ + @PostMapping("agencydetail") + public Result agencyDetail(@RequestBody AgencydetailFormDTO formDTO) { + return agencyService.agencyDetail(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + @PostMapping("subagencylist") + public Result subAgencyList(@RequestBody SubAgencyFormDTO formDTO) { + return agencyService.subAgencyList(formDTO); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 9caad715cc..9de0e27f8e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -26,11 +26,8 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.form.*; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.dto.result.AgencydetailResultDTO; +import com.epmet.dto.form.StaffOrgFormDTO; import com.epmet.dto.result.StaffOrgsResultDTO; -import com.epmet.dto.result.SubAgencyResultDTO; import com.epmet.excel.CustomerAgencyExcel; import com.epmet.service.CustomerAgencyService; import org.springframework.beans.factory.annotation.Autowired; @@ -107,60 +104,4 @@ public class CustomerAgencyController { public Result> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO) { return customerAgencyService.getStaffOrgList(staffOrgsFormDTO); } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 添加组织 - */ - @PostMapping("addagency") - public Result addAgency(@RequestBody AddAgencyFormDTO formDTO) { - return customerAgencyService.addAgency(formDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织名称编辑 - */ - @PostMapping("editagency") - public Result editAgency(@RequestBody EditAgencyFormDTO formDTO) { - return customerAgencyService.editAgency(formDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 删除组织机关 - */ - @PostMapping("removeagency") - public Result removeAgency(@RequestBody RemoveAgencyFormDTO formDTO) { - return customerAgencyService.removeAgency(formDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-获取组织机构信息 - */ - @PostMapping("agencydetail") - public Result agencyDetail(@RequestBody AgencydetailFormDTO formDTO) { - return customerAgencyService.agencyDetail(formDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-下级机关列表 - */ - @PostMapping("subagencylist") - public Result subAgencyList(@RequestBody SubAgencyFormDTO formDTO) { - return customerAgencyService.subAgencyList(formDTO); - } - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java new file mode 100644 index 0000000000..3df8e719d4 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -0,0 +1,80 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddAgencyResultDTO; +import com.epmet.dto.result.AgencydetailResultDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.dto.result.SubAgencyResultDTO; +import com.epmet.entity.CustomerAgencyEntity; + +import java.util.List; +import java.util.Map; + +/** + * 机关单位信息 + * + * @author generator generator@elink-cn.com + */ +public interface AgencyService { + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加组织 + */ + Result addAgency(AddAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织名称编辑 + */ + Result editAgency(EditAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除组织机关 + */ + Result removeAgency(RemoveAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取组织机构信息 + */ + Result agencyDetail(AgencydetailFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + Result subAgencyList(SubAgencyFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 7076fe6d2d..24a4e17b35 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -107,44 +107,4 @@ public interface CustomerAgencyService extends BaseService * @Date 2020/4/20 21:45 **/ Result> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 添加组织 - */ - Result addAgency(AddAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织名称编辑 - */ - Result editAgency(EditAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 删除组织机关 - */ - Result removeAgency(RemoveAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-获取组织机构信息 - */ - Result agencyDetail(AgencydetailFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-下级机关列表 - */ - Result subAgencyList(SubAgencyFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java new file mode 100644 index 0000000000..c03526f6cd --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -0,0 +1,185 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerAgencyConstant; +import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.redis.CustomerAgencyRedis; +import com.epmet.service.AgencyService; +import com.epmet.service.CustomerAgencyService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 机关单位信息 + * + * @author generator generator@elink-cn.com + */ +@Service +public class AgencyServiceImpl implements AgencyService { + + private static final Logger log = LoggerFactory.getLogger(AgencyServiceImpl.class); + @Autowired + private CustomerAgencyDao customerAgencyDao; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加组织 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result addAgency(AddAgencyFormDTO formDTO) { + Result result = new Result(); + AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO(); + //0:属性映射赋值 + CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); + entity.setOrganizationName(formDTO.getAgencyName()); + entity.setTotalUser(NumConstant.ZERO); + //1:查询上级机关信息 + CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getPid()); + entity.setCustomerId(parentEntity.getCustomerId()); + if (null == parentEntity.getPid()) { + entity.setPids(parentEntity.getId()); + entity.setAllParentName(parentEntity.getOrganizationName()); + } else { + entity.setPids(":" + parentEntity.getId()); + entity.setAllParentName("-" + parentEntity.getOrganizationName()); + } + //2:保存组织信息 + if (customerAgencyDao.insert(entity) < NumConstant.ONE) { + log.error(CustomerAgencyConstant.SAVE_EXCEPTION); + throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION); + } + //3:返回新组织Id + addAgencyResultDTO.setAgencyId(entity.getId()); + return result.ok(addAgencyResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织名称编辑 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result editAgency(EditAgencyFormDTO formDTO) { + Result result = new Result(); + CustomerAgencyEntity entity = new CustomerAgencyEntity(); + entity.setId(formDTO.getAgencyId()); + entity.setOrganizationName(formDTO.getAgencyName()); + if (customerAgencyDao.updateById(entity) < NumConstant.ONE) { + log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); + throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); + } + return result; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除组织机关 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result removeAgency(RemoveAgencyFormDTO formDTO) { + Result result = new Result(); + //1:查询当前机关是否存在所属下级机关,存在下级的不能删除 + List agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId()); + if (null != agencyList && agencyList.size() > NumConstant.ZERO) { + result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode()); + result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg()); + return result; + } + //2:删除当前机关组织(逻辑删) + if (customerAgencyDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { + log.error(CustomerAgencyConstant.DEL_EXCEPTION); + throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); + } + return result; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取组织机构信息 + */ + @Override + public Result agencyDetail(AgencydetailFormDTO formDTO) { + AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO(); + //1:查询本机关详细信息 + CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId()); + if (null == entity) { + return new Result().ok(agencydetailResultDTO); + } + agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class); + agencydetailResultDTO.setAgencyId(entity.getId()); + agencydetailResultDTO.setAgencyName(entity.getOrganizationName()); + //2:查询本机关的所有上级机关,按自上而下层级顺序 + if (null == entity.getPids()) { + return new Result().ok(agencydetailResultDTO); + } + List listStr = Arrays.asList(entity.getPids().split(":")); + List parentList = customerAgencyDao.selectPAgencyById(listStr); + agencydetailResultDTO.setParentList(parentList); + return new Result().ok(agencydetailResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + @Override + public Result subAgencyList(SubAgencyFormDTO formDTO) { + SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); + //1:根据当前机关Id查询直属下一级机关列表 + List agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId()); + subAgencyResultDTO.setAgencyList(agencyList); + //2:统计下一级机关数 + subAgencyResultDTO.setSubAgencyCount(agencyList.size()); + return new Result().ok(subAgencyResultDTO); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index 3bbd8631c0..c9b963b20d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -55,7 +55,6 @@ import java.util.Map; @Service public class CustomerAgencyServiceImpl extends BaseServiceImpl implements CustomerAgencyService { - private static final Logger log = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class); @Autowired private CustomerAgencyRedis customerAgencyRedis; @@ -119,128 +118,4 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList()); return new Result>().ok(list); } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 添加组织 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result addAgency(AddAgencyFormDTO formDTO) { - Result result = new Result(); - AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO(); - //0:属性映射赋值 - CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); - entity.setOrganizationName(formDTO.getAgencyName()); - entity.setTotalUser(NumConstant.ZERO); - //1:查询上级机关信息 - CustomerAgencyEntity parentEntity = baseDao.selectById(formDTO.getPid()); - entity.setCustomerId(parentEntity.getCustomerId()); - if (null == parentEntity.getPid()) { - entity.setPids(parentEntity.getId()); - entity.setAllParentName(parentEntity.getOrganizationName()); - } else { - entity.setPids(":" + parentEntity.getId()); - entity.setAllParentName("-" + parentEntity.getOrganizationName()); - } - //2:保存组织信息 - if (baseDao.insert(entity) < NumConstant.ONE) { - log.error(CustomerAgencyConstant.SAVE_EXCEPTION); - throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION); - } - //3:返回新组织Id - addAgencyResultDTO.setAgencyId(entity.getId()); - return result.ok(addAgencyResultDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织名称编辑 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result editAgency(EditAgencyFormDTO formDTO) { - Result result = new Result(); - CustomerAgencyEntity entity = new CustomerAgencyEntity(); - entity.setId(formDTO.getAgencyId()); - entity.setOrganizationName(formDTO.getAgencyName()); - if (baseDao.updateById(entity) < NumConstant.ONE) { - log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); - throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); - } - return result; - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 删除组织机关 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result removeAgency(RemoveAgencyFormDTO formDTO) { - Result result = new Result(); - //1:查询当前机关是否存在所属下级机关,存在下级的不能删除 - List agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); - if (null != agencyList && agencyList.size() > NumConstant.ZERO) { - result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode()); - result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg()); - return result; - } - //2:删除当前机关组织(逻辑删) - if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { - log.error(CustomerAgencyConstant.DEL_EXCEPTION); - throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); - } - return result; - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-获取组织机构信息 - */ - @Override - public Result agencyDetail(AgencydetailFormDTO formDTO) { - AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO(); - //1:查询本机关详细信息 - CustomerAgencyEntity entity = baseDao.selectById(formDTO.getAgencyId()); - if (null == entity) { - return new Result().ok(agencydetailResultDTO); - } - agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class); - agencydetailResultDTO.setAgencyId(entity.getId()); - agencydetailResultDTO.setAgencyName(entity.getOrganizationName()); - //2:查询本机关的所有上级机关,按自上而下层级顺序 - if (null == entity.getPids()) { - return new Result().ok(agencydetailResultDTO); - } - List listStr = Arrays.asList(entity.getPids().split(":")); - List parentList = baseDao.selectPAgencyById(listStr); - agencydetailResultDTO.setParentList(parentList); - return new Result().ok(agencydetailResultDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-下级机关列表 - */ - @Override - public Result subAgencyList(SubAgencyFormDTO formDTO) { - SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); - //1:根据当前机关Id查询直属下一级机关列表 - List agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); - subAgencyResultDTO.setAgencyList(agencyList); - //2:统计下一级机关数 - subAgencyResultDTO.setSubAgencyCount(agencyList.size()); - return new Result().ok(subAgencyResultDTO); - } } \ No newline at end of file From a48ed358b06a590900207b40325130d4d3716121 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 23 Apr 2020 17:31:44 +0800 Subject: [PATCH 04/26] =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/service/impl/GovLoginServiceImpl.java | 8 ++++---- .../epmet/controller/CustomerGridController.java | 2 +- .../main/resources/mapper/CustomerAgencyDao.xml | 14 +++++++------- .../main/resources/mapper/CustomerGridDao.xml | 3 +-- .../java/com/epmet/constant/UserConstant.java | 10 ++++++++++ .../java/com/epmet/dao/CustomerStaffDao.java | 9 +++++++++ .../service/impl/StaffWechatServiceImpl.java | 16 +++++++++++++++- .../main/resources/mapper/CustomerStaffDao.xml | 11 +++++++++++ 8 files changed, 58 insertions(+), 15 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 1d06b689fa..f77b7747ef 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -193,13 +193,13 @@ public class GovLoginServiceImpl implements GovLoginService { CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); //2、解析微信用户 WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode()); - //3、记录staff_wechat + //3、记录staff_wechat,并记录用户激活状态,激活时间 this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); - //5、记录登录日志 + //4、记录登录日志 this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); - //1、获取用户token + //5.1、获取用户token String token = this.generateGovWxmpToken(customerStaff.getUserId()); - //2、保存到redis + //5.2、保存到redis this.saveGovTokenDto(formDTO.getAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); userTokenResultDTO.setToken(token); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index 1e565d5b76..6daed0e8a4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -132,7 +132,7 @@ public class CustomerGridController { * @Description 根据userId查询该用户涉及的所有网格列表 * @Author sun */ - @PostMapping("getmygrids/{userId}") + @GetMapping("getmygrids/{userId}") public Result> getMyGrids(@PathVariable("userId") String userId) { return customerGridService.getMyGrids(userId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index a80b7334c4..f6118df149 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -24,15 +24,15 @@ diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java index 640d5079ea..16fb79e8fd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java @@ -57,4 +57,14 @@ public interface UserConstant { * 未禁用enable,已禁用diabled */ String DISABLED="disabled"; + + /** + * inactive未激活,active已激活 + */ + String INACTIVE="inactive"; + + /** + * inactive未激活,active已激活 + */ + String ACTIVE="active"; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index 14d91f75e9..ef1a5955eb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -62,4 +62,13 @@ public interface CustomerStaffDao extends BaseDao { * @return */ List selectStaffGridListByUserId(List customerStaffGridDTOS); + + /** + * @return com.epmet.entity.CustomerStaffEntity + * @param userId + * @Author yinzuomei + * @Description 根据staffid查询用户基本信息 + * @Date 2020/4/23 16:46 + **/ + CustomerStaffEntity selectByUserId(String userId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java index 04fe972274..b50daab444 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java @@ -24,18 +24,23 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.UserConstant; +import com.epmet.dao.CustomerStaffDao; import com.epmet.dao.StaffWechatDao; import com.epmet.dto.StaffWechatDTO; import com.epmet.dto.form.StaffWechatFormDTO; +import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.StaffWechatEntity; import com.epmet.service.StaffWechatService; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -48,7 +53,8 @@ import java.util.Map; @Service public class StaffWechatServiceImpl extends BaseServiceImpl implements StaffWechatService { private Logger logger = LogManager.getLogger(getClass()); - + @Autowired + private CustomerStaffDao customerStaffDao; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -119,6 +125,14 @@ public class StaffWechatServiceImpl extends BaseServiceImpl AND cs.del_flag = 0 + + + \ No newline at end of file From 60435a2c8280b322bddb713eeb88db8589487e3e Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 23 Apr 2020 18:00:55 +0800 Subject: [PATCH 05/26] =?UTF-8?q?=E6=94=BF=E5=BA=9C=E7=AB=AF-=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=BB=84=E7=BB=87=E6=9C=BA=E6=9E=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/AgencyListFormDTO.java | 43 ++++++++++++++++ .../epmet/dto/result/AgencyListResultDTO.java | 51 +++++++++++++++++++ .../epmet/controller/AgencyController.java | 13 +++++ .../java/com/epmet/dao/CustomerAgencyDao.java | 9 ++++ .../java/com/epmet/service/AgencyService.java | 13 +++-- .../epmet/service/impl/AgencyServiceImpl.java | 12 +++++ .../resources/mapper/CustomerAgencyDao.xml | 11 ++++ 7 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java new file mode 100644 index 0000000000..1a05afb589 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 获取组织列表-接口入参 + * + * @author sun + */ +@Data +public class AgencyListFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "组织机构ID不能为空") + private String agencyId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java new file mode 100644 index 0000000000..9673700fcc --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 获取组织列表-接口返参 + * + * @author sun + */ +@Data +public class AgencyListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + private String agencyId; + + /** + * 机关组织名称 + */ + private String agencyName; + + /** + * 总人数 + */ + private Integer totalUser; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 501e6c05bd..82cd76e7c3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -20,6 +20,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.AddAgencyResultDTO; +import com.epmet.dto.result.AgencyListResultDTO; import com.epmet.dto.result.AgencydetailResultDTO; import com.epmet.dto.result.SubAgencyResultDTO; import com.epmet.service.AgencyService; @@ -29,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * 组织机构 @@ -97,4 +100,14 @@ public class AgencyController { return agencyService.subAgencyList(formDTO); } + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + @PostMapping("agencylist") + public Result> agencyList(@RequestBody AgencyListFormDTO formDTO) { + return agencyService.agencyList(formDTO); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 0dc66e7bdd..8a4c14548b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AgencyListResultDTO; import com.epmet.dto.result.ParentListResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.SubListResultDTO; @@ -59,4 +60,12 @@ public interface CustomerAgencyDao extends BaseDao { * @Description 组织首页-下级机关列表 **/ List selectSubAgencyById(@Param("pId") String pId); + + /** + * @param pId + * @return + * @Author sun + * @Description 获取组织列表 + **/ + List selectAgencyList(@Param("pId") String pId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index 3df8e719d4..f811f71f80 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -22,10 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.dto.result.AgencydetailResultDTO; -import com.epmet.dto.result.StaffOrgsResultDTO; -import com.epmet.dto.result.SubAgencyResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import java.util.List; @@ -77,4 +74,12 @@ public interface AgencyService { * @Description 组织首页-下级机关列表 */ Result subAgencyList(SubAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + Result> agencyList(AgencyListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index c03526f6cd..ae13436d6a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -182,4 +182,16 @@ public class AgencyServiceImpl implements AgencyService { subAgencyResultDTO.setSubAgencyCount(agencyList.size()); return new Result().ok(subAgencyResultDTO); } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + @Override + public Result> agencyList(AgencyListFormDTO formDTO) { + List agencyList = customerAgencyDao.selectAgencyList(formDTO.getAgencyId()); + return new Result>().ok(agencyList); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index a80b7334c4..1740a0c0ea 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -59,4 +59,15 @@ AND pid = #{pId} ORDER BY CREATED_TIME DESC + + \ No newline at end of file From 87f2b17d5a3d9295bb9fbc12725f48b3caa36be9 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 23 Apr 2020 18:04:26 +0800 Subject: [PATCH 06/26] =?UTF-8?q?=E5=88=A0=E9=99=A4gov-org=E4=B8=8B?= =?UTF-8?q?=E7=9A=84feign=E5=AE=9E=E7=8E=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpmetUserFeignClientFallBack.java | 23 --------------- .../EpmetUserFeignClientFallback.java | 29 ------------------- .../fallback/OperCrmFeignClientFallBack.java | 21 -------------- 3 files changed, 73 deletions(-) delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java delete mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java deleted file mode 100644 index 029f1a968f..0000000000 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.epmet.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.feign.EpmetUserFeignClient; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @Auther zxc - * @Create 2020-04-23 14:10 - */ -@Component -public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { - @Override - public Result> getStaffGridList(List customerStaffGridDTOS) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); - } -} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java deleted file mode 100644 index cb70ad18d3..0000000000 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.epmet.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.feign.EpmetUserFeignClient; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @Auther zxc - * @Create 2020-04-23 14:10 - */ -@Component -public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { - @Override - public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); - } - - @Override - public Result> getStaffGridList(List customerStaffGridDTOS) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); - } -} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java deleted file mode 100644 index d40619a04c..0000000000 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.epmet.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerDTO; -import com.epmet.feign.OperCrmFeignClient; -import org.springframework.stereotype.Component; - -/** - * @author zhaoqifeng - * @dscription - * @date 2020/4/22 10:43 - */ -@Component -public class OperCrmFeignClientFallBack implements OperCrmFeignClient { - @Override - public Result getCustomerInfo(CustomerDTO dto) { - return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto); - } -} From 5b7abe5da256a174d1f6f128ac208188cecb0cec Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 23 Apr 2020 18:06:40 +0800 Subject: [PATCH 07/26] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8F=90=E4=BA=A4gov-o?= =?UTF-8?q?rg=E4=B8=8B=E7=9A=84feign=E5=AE=9E=E7=8E=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpmetUserFeignClientFallBack.java | 28 +++++++++++++++++++ .../fallback/OperCrmFeignClientFallBack.java | 21 ++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index e69de29bb2..05b26449b3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -0,0 +1,28 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Auther zxc + * @Create 2020-04-23 14:10 + */ +@Component +public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { + @Override + public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); + } + @Override + public Result> getStaffGridList(List customerStaffGridDTOS) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java new file mode 100644 index 0000000000..d40619a04c --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java @@ -0,0 +1,21 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerDTO; +import com.epmet.feign.OperCrmFeignClient; +import org.springframework.stereotype.Component; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/22 10:43 + */ +@Component +public class OperCrmFeignClientFallBack implements OperCrmFeignClient { + @Override + public Result getCustomerInfo(CustomerDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto); + } +} From fa0410e63335bf63450b1f6343a8f12617454575 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 23 Apr 2020 18:25:42 +0800 Subject: [PATCH 08/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E7=BB=84=E7=BB=87-?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=BA=BA=E5=91=98=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/StaffsInAgencyFromDTO.java | 28 ++++++++++ .../epmet/dto/result/StaffInfoResultDTO.java | 38 +++++++++++++ .../dto/result/StaffsInAgencyResultDTO.java | 27 ++++++++++ .../CustomerStaffAgencyController.java | 5 ++ .../com/epmet/controller/StaffController.java | 36 +++++++++++++ .../com/epmet/dao/CustomerStaffAgencyDao.java | 9 ++++ .../com/epmet/feign/EpmetUserFeignClient.java | 10 ++++ .../EpmetUserFeignClientFallBack.java | 7 +++ .../service/CustomerStaffAgencyService.java | 10 ++++ .../java/com/epmet/service/StaffService.java | 22 ++++++++ .../impl/CustomerStaffAgencyServiceImpl.java | 19 ++++++- .../epmet/service/impl/StaffServiceImpl.java | 54 +++++++++++++++++++ .../mapper/CustomerStaffAgencyDao.xml | 10 ++++ .../java/com/epmet/dto/CustomerStaffDTO.java | 5 ++ .../controller/CustomerStaffController.java | 12 +++++ .../java/com/epmet/dao/CustomerStaffDao.java | 19 ++++++- .../epmet/service/CustomerStaffService.java | 10 +++- .../impl/CustomerStaffServiceImpl.java | 9 +++- .../resources/mapper/CustomerStaffDao.xml | 27 ++++++++++ 19 files changed, 352 insertions(+), 5 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java new file mode 100644 index 0000000000..dc0deddc9d --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/23 15:45 + */ +@Data +public class StaffsInAgencyFromDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + /** + * 机关ID + */ + private String agencyId; + /** + * 用户ID + */ + private List staffList; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java new file mode 100644 index 0000000000..2859c1171a --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/23 16:08 + */ +@Data +public class StaffInfoResultDTO implements Serializable { + /** + * 用户ID + */ + private String staffId; + /** + * 用户姓名 + */ + private String staffName; + /** + * 头像 + */ + private String staffHeadPhoto; + /** + * 性别 + */ + private Integer gender; + /** + * 是否禁用(未禁用enable,已禁用disabled) + */ + private String enableFlag; + /** + * 权限名 + */ + private String roleName; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java new file mode 100644 index 0000000000..4c9352466b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/23 15:58 + */ +@NoArgsConstructor +@Data +public class StaffsInAgencyResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 人员总数 + */ + private Integer staffCount; + /** + * 人员列表 + */ + private List staffList; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java index fa1976bf6d..3bfc887aec 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java @@ -26,7 +26,9 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.excel.CustomerStaffAgencyExcel; import com.epmet.service.CustomerStaffAgencyService; import org.springframework.beans.factory.annotation.Autowired; @@ -104,4 +106,7 @@ public class CustomerStaffAgencyController { return customerStaffAgencyService.getLatestCustomer(userId); } + + + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java new file mode 100644 index 0000000000..7d57bb3a71 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java @@ -0,0 +1,36 @@ +package com.epmet.controller; + + + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffsInAgencyResultDTO; +import com.epmet.service.StaffService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 组织结构-工作人员 + * @author zhaoqifeng + * @date 2020/4/23 17:59 + */ +@RestController +@RequestMapping("staff") +public class StaffController { + @Autowired + private StaffService staffService; + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("staffsinagency") + public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + return staffService.getStaffInfoForHome(fromDTO); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java index 828c6cdd98..533c97b2a5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java @@ -22,6 +22,8 @@ import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.entity.CustomerStaffAgencyEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 人员-机关单位关系表 * @@ -37,5 +39,12 @@ public interface CustomerStaffAgencyDao extends BaseDao selectCustomerStaffAgencyList(String agencyId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 1774a21c15..217d37c0bb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -5,6 +5,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -33,4 +35,12 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/selectstaffgridlistbyuserid") Result> getStaffGridList(@RequestBody List customerStaffGridDTOS); + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("/epmetuser/customerstaff/staffsinagency") + Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 05b26449b3..a4cf20b805 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -6,6 +6,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; @@ -25,4 +27,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result> getStaffGridList(List customerStaffGridDTOS) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); } + + @Override + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffInfoForHome", fromDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java index 2aaee92578..c713dbde52 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.LatestCustomerResultDTO; import com.epmet.entity.CustomerStaffAgencyEntity; @@ -102,4 +103,13 @@ public interface CustomerStaffAgencyService extends BaseService getLatestCustomer(String userId); + + /** + * 获取组织下关联人员 + * @param fromDTO + * @return + */ + Result> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO); + + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java new file mode 100644 index 0000000000..6d5b37c11f --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -0,0 +1,22 @@ +package com.epmet.service; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffsInAgencyResultDTO; + +/** + * 组织结构-工作人员 + * + * @author zhaoqifeng + * @date 2020/4/23 18:00 + */ +public interface StaffService { + /** + * 组织首页-工作人员列表 + * + * @param fromDTO 参数 + * @return Result + * @author zhaoqifeng + */ + Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java index 212e5246a1..77292f2710 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java @@ -28,11 +28,16 @@ import com.epmet.dao.CustomerStaffAgencyDao; import com.epmet.dto.CustomerDTO; import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffsInAgencyResultDTO; +import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerStaffAgencyEntity; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.OperCrmFeignClient; import com.epmet.redis.CustomerStaffAgencyRedis; +import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerStaffAgencyService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -42,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 人员-机关单位关系表 @@ -58,6 +64,8 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl page(Map params) { @@ -121,8 +129,7 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl staffInfo = - epmetUserFeignClient.getCustomerStaffInfoByUserId(customerStaffParam); + Result staffInfo = epmetUserFeignClient.getCustomerStaffInfoByUserId(customerStaffParam); resultDTO.setStaffHeadPhoto(staffInfo.getData().getHeadPhoto()); resultDTO.setGender(staffInfo.getData().getGender()); //获取客户名称 @@ -133,4 +140,12 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl().ok(resultDTO); } + @Override + public Result> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO) { + + List customerStaffAgencyList = baseDao.selectCustomerStaffAgencyList(fromDTO.getAgencyId()); + + return new Result>().ok(customerStaffAgencyList); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java new file mode 100644 index 0000000000..6f3108abd7 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -0,0 +1,54 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffsInAgencyResultDTO; +import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.OperCrmFeignClient; +import com.epmet.service.CustomerAgencyService; +import com.epmet.service.CustomerStaffAgencyService; +import com.epmet.service.StaffService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/23 18:05 + */ +@Service +public class StaffServiceImpl implements StaffService { + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private OperCrmFeignClient operCrmFeignClient; + @Autowired + private CustomerAgencyService customerAgencyService; + @Autowired + private CustomerStaffAgencyService customerStaffAgencyService; + @Override + public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO(); + //获取机关所在客户ID和人员总数 + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + resultDTO.setStaffCount(customerAgencyEntity.getTotalUser()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + List customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData(); + if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) { + return new Result().ok(null); + } + //提取所有userID + List staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); + fromDTO.setStaffList(staffIds); + //获取用户信息 + Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); + resultDTO.setStaffList(staffInfoListResult.getData()); + return new Result().ok(resultDTO); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml index 016f75962a..a9b8baea0d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml @@ -28,5 +28,15 @@ CREATED_TIME DESC LIMIT 1 + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java index 6fbd80dd49..a247d4e450 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java @@ -128,4 +128,9 @@ public class CustomerStaffDTO implements Serializable { * 客户id */ private String customerId; + + /** + * 角色名称 + */ + private String roleName; } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 103d4163fc..42c39a6022 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -30,6 +30,8 @@ import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; import org.springframework.beans.factory.annotation.Autowired; @@ -143,4 +145,14 @@ public class CustomerStaffController { public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { return customerStaffService.getCustomerStaffInfoByUserId(formDTO); } + + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("staffsinagency") + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + return customerStaffService.getStaffInfoForHome(fromDTO); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index ef1a5955eb..ea050b7501 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -22,6 +22,8 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; @@ -54,8 +56,23 @@ public interface CustomerStaffDao extends BaseDao { **/ CustomerStaffDTO selectListCustomerStaffInfo(CustomerStaffFormDTO formDTO); - CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO); + CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO); + /** + * 根据userId查询查询网格下的用户信息 + * + * @param customerStaffGridDTOS + * @return + */ + List selectStaffGridListByUserId(List customerStaffGridDTOS); + + /** + * 根据用户ID列表获取用户信息 + * + * @param fromDTO + * @return + */ + List selectCustomerStaffList(StaffsInAgencyFromDTO fromDTO); /** * 根据userId查询查询网格下的用户信息 * @param customerStaffGridDTOS diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index 3775510742..4a7ceb335f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -23,8 +23,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import java.util.List; @@ -132,4 +133,11 @@ public interface CustomerStaffService extends BaseService { * @return */ Result> selectStaffGridListByUserId(List customerStaffGridDTOS); + + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 4ac6f5a529..560fe0008c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -30,8 +30,9 @@ import com.epmet.dao.CustomerStaffDao; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.redis.CustomerStaffRedis; import com.epmet.service.CustomerStaffService; @@ -149,4 +150,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl>().ok(staffGridListDTOS); } + @Override + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + List list = baseDao.selectCustomerStaffList(fromDTO); + return new Result>().ok(list); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 8528391aac..ab8ad974a5 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -41,6 +41,33 @@ AND cs.del_flag = 0 + SELECT - ca.pid AS orgId, - ca.CUSTOMER_ID AS customerId, - ca.ORGANIZATION_NAME AS orgName + ca.pid AS agencyId, + ca.ORGANIZATION_NAME AS agencyName, + ca.CUSTOMER_ID AS customerId FROM customer_agency ca WHERE diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java new file mode 100644 index 0000000000..b4fbbeff49 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据客户id查询客户信息 + * @Author yinzuomei + * @Date 2020/4/24 9:09 + */ +@Data +public class CustomerFormDTO implements Serializable { + /** + * 客户id集合 + * */ + private List customerIdList; +} + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 4e683e3ffc..1605fd6c80 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; import com.epmet.service.CustomerService; @@ -144,4 +145,15 @@ public class CustomerController { return customerService.getCustomerInfo(dto); } + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:13 + **/ + @PostMapping("queryCustomerList") + public Result> queryCustomerList(@RequestBody CustomerFormDTO formDTO) { + return customerService.queryCustomerList(formDTO); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java index 661cc151c4..6a958cc6d2 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java @@ -18,9 +18,11 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -40,4 +42,13 @@ public interface CustomerDao extends BaseDao { * @date 2020-03-11 */ List selectListValidCustomerResultDTO(); + + /** + * @return java.util.List + * @param customerIdList + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:21 + **/ + List selectListByIds(@Param("customerIdList") List customerIdList); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index b36bd6f5b2..a50c87a138 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -120,4 +121,13 @@ public interface CustomerService extends BaseService { * @return */ Result getCustomerInfo(CustomerDTO dto); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:13 + **/ + Result> queryCustomerList(CustomerFormDTO formDTO); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index 5384193128..89bab2936a 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerDao; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; import com.epmet.redis.CustomerRedis; @@ -135,4 +136,10 @@ public class CustomerServiceImpl extends BaseServiceImpl().ok(ConvertUtils.sourceToTarget(entity, CustomerDTO.class)); } + @Override + public Result> queryCustomerList(CustomerFormDTO formDTO) { + List customerDTOList = baseDao.selectListByIds(formDTO.getCustomerIdList()); + return new Result>().ok(customerDTOList); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml index 2a7e3c22ab..340883f472 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml @@ -34,4 +34,18 @@ ORDER BY CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC + + + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java index 126dfd728c..11fb4702ca 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java @@ -112,7 +112,7 @@ public class StaffAgencyVisitedServiceImpl extends BaseServiceImpl getLatestStaffWechatLoginRecord(String openId) { - if (StringUtils.isNotBlank(openId)) { + if (StringUtils.isBlank(openId)) { logger.error("openId 不能为空"); return new Result(); } From 055520dd82718664b41904cc38dc90e08020ffe3 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 24 Apr 2020 10:07:23 +0800 Subject: [PATCH 11/26] =?UTF-8?q?=E5=86=B2=E7=AA=81=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/security/dto/GovTokenDto.java | 6 +++ .../epmet/service/CustomerAgencyService.java | 40 +++++++++++++++++++ .../java/com/epmet/dao/CustomerStaffDao.java | 6 --- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java index 2a8fd7c05b..bfb7e6dc67 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serializable; import java.util.List; +import java.util.Set; /** * @Description 政府端登录信息 @@ -62,5 +63,10 @@ public class GovTokenDto extends BaseTokenDto implements Serializable { * 最后一次更新时间 */ private long updateTime; + + /** + * 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey + */ + private List permissions; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 24a4e17b35..7076fe6d2d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -107,4 +107,44 @@ public interface CustomerAgencyService extends BaseService * @Date 2020/4/20 21:45 **/ Result> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加组织 + */ + Result addAgency(AddAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织名称编辑 + */ + Result editAgency(EditAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除组织机关 + */ + Result removeAgency(RemoveAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取组织机构信息 + */ + Result agencyDetail(AgencydetailFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + Result subAgencyList(SubAgencyFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index ea050b7501..b552832c2d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -73,12 +73,6 @@ public interface CustomerStaffDao extends BaseDao { * @return */ List selectCustomerStaffList(StaffsInAgencyFromDTO fromDTO); - /** - * 根据userId查询查询网格下的用户信息 - * @param customerStaffGridDTOS - * @return - */ - List selectStaffGridListByUserId(List customerStaffGridDTOS); /** * @return com.epmet.entity.CustomerStaffEntity From 30849f12da06f80c9c6790b89b289d224880239d Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 24 Apr 2020 10:24:29 +0800 Subject: [PATCH 12/26] =?UTF-8?q?gov=E7=AB=AF=E7=82=B9=E7=99=BB=E5=BD=95to?= =?UTF-8?q?ken=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/GovLoginServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 0928771668..35ce90b25c 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -255,9 +255,9 @@ public class GovLoginServiceImpl implements GovLoginService { Map map = new HashMap<>(); map.put("app", LoginConstant.APP_GOV); map.put("client", LoginConstant.CLIENT_WXMP); - map.put("staffId", staffId); + map.put("userId", staffId); String token = jwtTokenUtils.createToken(map); - logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";staffId:" + staffId + ";生成token[" + token + "]"); + logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";userId:" + staffId + ";生成token[" + token + "]"); return token; } From 167facfd7b8ef82e1ee8af42cb7d91e8a20c576b Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 10:38:01 +0800 Subject: [PATCH 13/26] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E8=A1=A8=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9=EF=BC=88=E5=9B=BD?= =?UTF-8?q?=E5=AE=B6=E6=94=B9=E4=B8=BA=E5=8C=BA=E5=8E=BF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/CustomerAgencyDTO.java | 10 +++++----- .../java/com/epmet/entity/CustomerAgencyEntity.java | 10 +++++----- .../main/java/com/epmet/excel/CustomerAgencyExcel.java | 6 ++---- .../src/main/resources/db/migration/epmet_gov_org.sql | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java index d1e6c3f40a..7b9abc9de6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java @@ -112,11 +112,6 @@ public class CustomerAgencyDTO implements Serializable { */ private Integer totalUser; - /** - * 国家 - */ - private String country; - /** * 省份 */ @@ -126,5 +121,10 @@ public class CustomerAgencyDTO implements Serializable { * 城市 */ private String city; + + /** + * 区县 + */ + private String district; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java index 84f0e78f1c..5549845d66 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java @@ -82,11 +82,6 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { */ private Integer totalUser; - /** - * 国家 - */ - private String country; - /** * 省份 */ @@ -97,4 +92,9 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { */ private String city; + /** + * 区县 + */ + private String district; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java index 61ea84eb40..346963be94 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java @@ -76,14 +76,12 @@ public class CustomerAgencyExcel { @Excel(name = "总人数") private Integer totalUser; - @Excel(name = "国家") - private String country; - @Excel(name = "省份") private String province; @Excel(name = "城市") private String city; - + @Excel(name = "区县") + private String district; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql index 2dc0bba345..f4d0e47dc7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql @@ -107,7 +107,7 @@ alter table customer_grid add column ORG_ID varchar(64) NOT NULL COMMENT '所属 alter table customer_grid add column MANAGE_DISTRICT varchar(255) DEFAULT "" NOT NULL COMMENT '管辖区域'; alter table customer_grid add column TOTAL_USER INT(11) DEFAULT 0 NOT NULL COMMENT '当前网格总人数'; ALTER TABLE customer_agency ADD ( - COUNTRY VARCHAR (32) DEFAULT NULL COMMENT '国家', PROVINCE VARCHAR (32) DEFAULT NULL COMMENT '省份', - CITY VARCHAR (32) DEFAULT NULL COMMENT '城市' + CITY VARCHAR (32) DEFAULT NULL COMMENT '城市', + DISTRICT VARCHAR (32) DEFAULT NULL COMMENT '区县' ); \ No newline at end of file From 8320ac3028eae7685a95a97779f343dad5097bfa Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 24 Apr 2020 13:53:47 +0800 Subject: [PATCH 14/26] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0DataFilter=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=B7=A5=E5=85=B7=202.=E5=AE=9E=E7=8E=B0=E4=BA=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=BA=A7RBAC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/service/impl/NewsServiceImpl.java | 2 +- .../src/test/java/com/epmet/TokenGenTest.java | 63 +++++++ .../mybatis/annotation/DataFilter.java | 20 -- .../mybatis/aspect/DataFilterAspect.java | 172 ++++++++++++------ .../mybatis/aspect/DataFilterAspectBak.java | 106 +++++++++++ .../dto/form/StaffPermissionFormDTO.java | 26 +++ .../commons/mybatis/entity/DataScope.java | 9 +- .../mybatis/feign/GovAccessFeignClient.java | 26 +++ .../GovAccessFeignClientFallback.java | 25 +++ .../handler/FieldMetaObjectHandler.java | 8 +- .../interceptor/DataFilterInterceptor.java | 6 + .../interceptor/DataFilterInterceptorBak.java | 100 ++++++++++ .../tools/annotation/RequirePermission.java | 36 ++++ .../commons/tools/aspect/AccessOpeAspect.java | 46 +++++ .../tools/exception/EpmetErrorCode.java | 3 +- .../tools/exception/RenExceptionHandler.java | 4 +- .../tools/security/dto/GovTokenDto.java | 2 +- .../tools/security/user/LoginUserUtil.java | 61 ++++++- epmet-gateway/pom.xml | 8 +- .../com/epmet/filter/FeignRequestFilter.java | 3 +- .../epmet/dto/form/StaffPermCacheFormDTO.java | 15 +- .../epmet/controller/AccessController.java | 15 +- .../java/com/epmet/service/AccessService.java | 10 +- .../epmet/service/impl/AccessServiceImpl.java | 15 +- .../db.migration/epmet_gov_access.sql | 2 +- .../epmet/controller/AccessController.java | 11 +- .../com/epmet/feign/GovAccessFeignClient.java | 18 +- .../GovAccessFeignClientFallback.java | 17 +- .../java/com/epmet/service/AccessService.java | 3 +- .../epmet/service/impl/AccessServiceImpl.java | 16 +- .../epmet/controller/StaffRoleController.java | 1 + .../service/impl/StaffRoleServiceImpl.java | 1 + 32 files changed, 728 insertions(+), 122 deletions(-) create mode 100644 epmet-auth/src/test/java/com/epmet/TokenGenTest.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java index 31d7c6c310..220cf7d171 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java @@ -31,7 +31,7 @@ public class NewsServiceImpl extends BaseServiceImpl implem * mybatis数据权限演示 */ @Override - @DataFilter(prefix = "AND", isPendingCreator = false) + //@DataFilter(prefix = "AND", isPendingCreator = false) public PageData page(Map params) { paramsToLike(params, "title"); diff --git a/epmet-auth/src/test/java/com/epmet/TokenGenTest.java b/epmet-auth/src/test/java/com/epmet/TokenGenTest.java new file mode 100644 index 0000000000..3368e2d1cf --- /dev/null +++ b/epmet-auth/src/test/java/com/epmet/TokenGenTest.java @@ -0,0 +1,63 @@ +package com.epmet; + +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.jwt.JwtTokenProperties; +import com.epmet.jwt.JwtTokenUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.Map; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class TokenGenTest { + + @Autowired + private JwtTokenProperties jwtTokenProperties; + + @Autowired + private JwtTokenUtils jwtTokenUtils; + + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + + @Test + public void genToken() { + String staffId = "wxz"; + String tokenStr = generateGovWxmpToken(staffId); + int expire = jwtTokenProperties.getExpire(); + GovTokenDto govTokenDto = new GovTokenDto(); + govTokenDto.setApp(LoginConstant.APP_GOV); + govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setUserId(staffId); + govTokenDto.setOpenId(""); + govTokenDto.setSessionKey(""); + govTokenDto.setUnionId(""); + govTokenDto.setToken(tokenStr); + govTokenDto.setUpdateTime(System.currentTimeMillis()); + govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(tokenStr).getTime()); + govTokenDto.setAgencyId("1"); + govTokenDto.setCustomerId("f76def116c9c2dc0269cc17867af122c"); + cpUserDetailRedis.set(govTokenDto, expire); + } + + /** + * @Description 生成token + * @Date 2020/4/18 23:04 + **/ + private String generateGovWxmpToken(String staffId) { + Map map = new HashMap<>(); + map.put("app", LoginConstant.APP_GOV); + map.put("client", LoginConstant.CLIENT_WXMP); + map.put("userId", staffId); + String token = jwtTokenUtils.createToken(map); + return token; + } + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java index dd1d3aee3b..96b7691f22 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java @@ -25,24 +25,4 @@ public @interface DataFilter { */ String tableAlias() default ""; - /** - * 查询条件前缀,可选值有:[where、and] - */ - String prefix() default ""; - - /** - * 用户ID - */ - String userId() default "creator"; - - /** - * 部门ID - */ - String deptId() default "dept_id"; - - /** - * 是否拼接用户ID - */ - boolean isPendingCreator() default true; - } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java index f322f631f9..14ce3af0a1 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java @@ -8,25 +8,28 @@ package com.epmet.commons.mybatis.aspect; -import cn.hutool.core.collection.CollUtil; -import com.epmet.commons.mybatis.annotation.DataFilter; +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; import com.epmet.commons.mybatis.entity.DataScope; -import com.epmet.commons.tools.constant.Constant; -import com.epmet.commons.tools.enums.SuperAdminEnum; +import com.epmet.commons.mybatis.feign.GovAccessFeignClient; +import com.epmet.commons.tools.aspect.AccessOpeAspect; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.security.user.SecurityUser; -import com.epmet.commons.tools.security.user.UserDetail; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.Result; import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import java.util.Arrays; import java.util.List; -import java.util.Map; +import java.util.Set; /** * 数据过滤,切面处理类 @@ -37,69 +40,124 @@ import java.util.Map; @Aspect @Component public class DataFilterAspect { - @Pointcut("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)") - public void dataFilterCut() { - } + private static final Logger log = LoggerFactory.getLogger(DataFilterAspect.class); + + @Autowired + private LoginUserUtil loginUserUtil; + + @Autowired + private GovAccessFeignClient govAccessFeignClient; - @Before("dataFilterCut()") + @Before("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)") public void dataFilter(JoinPoint point) { - Object params = point.getArgs()[0]; - if(params != null && params instanceof Map){ - UserDetail user = SecurityUser.getUser(); - - //如果不是超级管理员,则进行数据过滤 - if(user.getSuperAdmin() == SuperAdminEnum.NO.value()){ - Map map = (Map)params; - String sqlFilter = getSqlFilter(user, point); - map.put(Constant.SQL_FILTER, new DataScope(sqlFilter)); - } + // 反射的方式 + //MethodSignature signature = (MethodSignature) point.getSignature(); + //Class[] parameterTypes = signature.getParameterTypes(); + //for (Class parameterType : parameterTypes) { + // if (parameterType == DataScope.class) { + // + // } + //} + + String reqiurePermission = AccessOpeAspect.requirePermissionTl.get(); + // 没有配置所需权限,不做操作,打印提示日志 + if (StringUtils.isBlank(reqiurePermission)) { + log.warn("Api编码需要指定所需权限,请在Api上使用@RequirePermission注解完成所需权限配置"); + return; + } - return ; + // 校验操作权限 + validateOpePermission(reqiurePermission); + + Object[] methodArgs = point.getArgs(); + for (Object methodArg : methodArgs) { + if (methodArg instanceof DataScope) { + ((DataScope) methodArg).setSqlFilter(getSqlFilterSegment()); + return; + } } - throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); + //throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); } /** - * 获取数据过滤的SQL + * 校验操作权限 */ - private String getSqlFilter(UserDetail user, JoinPoint point){ - MethodSignature signature = (MethodSignature) point.getSignature(); - DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class); - //获取表的别名 - String tableAlias = dataFilter.tableAlias(); - if(StringUtils.isNotBlank(tableAlias)){ - tableAlias += "."; + private void validateOpePermission(String requirePermission) { + StaffPermissionFormDTO staffPermissionFormDTO = new StaffPermissionFormDTO(); + staffPermissionFormDTO.setApp(loginUserUtil.getLoginUserApp()); + staffPermissionFormDTO.setClient(loginUserUtil.getLoginUserClient()); + staffPermissionFormDTO.setStaffId(loginUserUtil.getLoginUserId()); + Result> permissions = govAccessFeignClient.getStaffCurrPermissions(staffPermissionFormDTO); + if (permissions.getCode() != 0) { + // 查询不到权限,记录日志,抛出8000异常 + log.error("调用Access查询权限失败:{}", permissions.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } - StringBuilder sqlFilter = new StringBuilder(); - - //查询条件前缀 - String prefix = dataFilter.prefix(); - if(StringUtils.isNotBlank(prefix)){ - sqlFilter.append(" ").append(prefix); + if (!CollectionUtils.isEmpty(permissions.getData()) && StringUtils.isNotBlank(requirePermission) + && permissions.getData().contains(requirePermission)) { + // 权限允许,正常结束 + return; } + // 权限不足抛出异常 + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } - sqlFilter.append(" ("); - - //部门ID列表 - List deptIdList = user.getDeptIdList(); - if(CollUtil.isNotEmpty(deptIdList)){ - sqlFilter.append(tableAlias).append(dataFilter.deptId()); - - sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")"); - } + /** + * 生成过滤sql片段 + * @return + */ + private String getSqlFilterSegment() { + // 根据角色列表查询操作范围列表 - //查询本人数据 - if (dataFilter.isPendingCreator()) { - if(CollUtil.isNotEmpty(deptIdList)){ - sqlFilter.append(" or "); - } - sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId()); - } - sqlFilter.append(")"); + // 拼接sql语句 - return sqlFilter.toString(); + // TODO + return "dept_id in (1,2,3)"; } + + ///** + // * 获取数据过滤的SQL + // */ + //@Deprecated + //private String getSqlFilter(UserDetail user, JoinPoint point){ + // MethodSignature signature = (MethodSignature) point.getSignature(); + // DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class); + // //获取表的别名 + // String tableAlias = dataFilter.tableAlias(); + // if(StringUtils.isNotBlank(tableAlias)){ + // tableAlias += "."; + // } + // + // StringBuilder sqlFilter = new StringBuilder(); + // + // //查询条件前缀 + // String prefix = dataFilter.prefix(); + // if(StringUtils.isNotBlank(prefix)){ + // sqlFilter.append(" ").append(prefix); + // } + // + // sqlFilter.append(" ("); + // + // //部门ID列表 + // List deptIdList = user.getDeptIdList(); + // if(CollUtil.isNotEmpty(deptIdList)){ + // sqlFilter.append(tableAlias).append(dataFilter.deptId()); + // + // sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")"); + // } + // + // //查询本人数据 + // if (dataFilter.isPendingCreator()) { + // if(CollUtil.isNotEmpty(deptIdList)){ + // sqlFilter.append(" or "); + // } + // sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId()); + // } + // sqlFilter.append(")"); + // + // return sqlFilter.toString(); + //} } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java new file mode 100644 index 0000000000..2c4c532bda --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java @@ -0,0 +1,106 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// * +// * https://www.renren.io +// * +// * 版权所有,侵权必究! +// */ +// +//package com.epmet.commons.mybatis.aspect; +// +//import cn.hutool.core.collection.CollUtil; +//import com.epmet.commons.mybatis.annotation.DataFilter; +//import com.epmet.commons.mybatis.entity.DataScope; +//import com.epmet.commons.tools.constant.Constant; +//import com.epmet.commons.tools.enums.SuperAdminEnum; +//import com.epmet.commons.tools.exception.ErrorCode; +//import com.epmet.commons.tools.exception.RenException; +//import com.epmet.commons.tools.security.user.SecurityUser; +//import com.epmet.commons.tools.security.user.UserDetail; +//import org.apache.commons.lang3.StringUtils; +//import org.aspectj.lang.JoinPoint; +//import org.aspectj.lang.annotation.Aspect; +//import org.aspectj.lang.annotation.Before; +//import org.aspectj.lang.annotation.Pointcut; +//import org.aspectj.lang.reflect.MethodSignature; +//import org.springframework.stereotype.Component; +// +//import java.util.Arrays; +//import java.util.List; +//import java.util.Map; +// +///** +// * 数据过滤,切面处理类 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//@Aspect +//@Component +//public class DataFilterAspectBak { +// @Pointcut("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)") +// public void dataFilterCut() { +// +// } +// +// @Before("dataFilterCut()") +// public void dataFilter(JoinPoint point) { +// Object params = point.getArgs()[0]; +// if(params != null && params instanceof Map){ +// UserDetail user = SecurityUser.getUser(); +// +// //如果不是超级管理员,则进行数据过滤 +// if(user.getSuperAdmin() == SuperAdminEnum.NO.value()){ +// Map map = (Map)params; +// String sqlFilter = getSqlFilter(user, point); +// map.put(Constant.SQL_FILTER, new DataScope(sqlFilter)); +// } +// +// return ; +// } +// +// throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); +// } +// +// /** +// * 获取数据过滤的SQL +// */ +// private String getSqlFilter(UserDetail user, JoinPoint point){ +// MethodSignature signature = (MethodSignature) point.getSignature(); +// DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class); +// //获取表的别名 +// String tableAlias = dataFilter.tableAlias(); +// if(StringUtils.isNotBlank(tableAlias)){ +// tableAlias += "."; +// } +// +// StringBuilder sqlFilter = new StringBuilder(); +// +// //查询条件前缀 +// String prefix = dataFilter.prefix(); +// if(StringUtils.isNotBlank(prefix)){ +// sqlFilter.append(" ").append(prefix); +// } +// +// sqlFilter.append(" ("); +// +// //部门ID列表 +// List deptIdList = user.getDeptIdList(); +// if(CollUtil.isNotEmpty(deptIdList)){ +// sqlFilter.append(tableAlias).append(dataFilter.deptId()); +// +// sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")"); +// } +// +// //查询本人数据 +// if (dataFilter.isPendingCreator()) { +// if(CollUtil.isNotEmpty(deptIdList)){ +// sqlFilter.append(" or "); +// } +// sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId()); +// } +// sqlFilter.append(")"); +// +// return sqlFilter.toString(); +// } +//} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java new file mode 100644 index 0000000000..3bc88d6fb1 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Set; + +@Data +public class StaffPermissionFormDTO { + + /** + * 工作人员 id + */ + private String staffId; + + /** + * 登录头信息app + */ + private String app; + + /** + * 登录头信息client + */ + private String client; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java index 43d3ca1619..59dd035fac 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -15,8 +15,13 @@ package com.epmet.commons.mybatis.entity; * @since 1.0.0 */ public class DataScope { + private String sqlFilter; + public static DataScope getDefault() { + return new DataScope(""); + } + public DataScope(String sqlFilter) { this.sqlFilter = sqlFilter; } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java new file mode 100644 index 0000000000..198d996bc9 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java @@ -0,0 +1,26 @@ +package com.epmet.commons.mybatis.feign; + +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.feign.fallback.GovAccessFeignClientFallback; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.Set; + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) +public interface GovAccessFeignClient { + + /** + * 查询用户当前权限列表(DataFilterAspect中用到) + * @return + */ + @PostMapping("/gov/access/access/getcurrpermissions") + Result> getStaffCurrPermissions(StaffPermissionFormDTO dto); + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java new file mode 100644 index 0000000000..3c5ccd599b --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java @@ -0,0 +1,25 @@ +package com.epmet.commons.mybatis.feign.fallback; + +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.feign.GovAccessFeignClient; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import org.springframework.stereotype.Component; + +import java.util.Set; + +/** + * 调用政府端权限 + * @Author wxz + * @Description + * @Date 2020/4/24 11:17 + **/ +@Component +public class GovAccessFeignClientFallback implements GovAccessFeignClient { + + @Override + public Result> getStaffCurrPermissions(StaffPermissionFormDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getStaffCurrPermissions", dto); + } +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java index bd7d0619fd..fcd85b0c0e 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.security.user.SecurityUser; import com.epmet.commons.tools.security.user.UserDetail; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.reflection.MetaObject; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; @@ -40,11 +41,14 @@ public class FieldMetaObjectHandler implements MetaObjectHandler { private final static String UPDATER = "updater"; private final static String DEPT_ID = "deptId"; + @Autowired + private LoginUserUtil loginUserUtil; + @Override public void insertFill(MetaObject metaObject) { Date date = new Date(); if (metaObject.getOriginalObject() instanceof BaseEpmetEntity) { - String loginUserId = LoginUserUtil.getLoginUserId(); + String loginUserId = loginUserUtil.getLoginUserId(); // epmet项目新增的 loginUserId = StringUtils.isBlank(loginUserId) ? Constant.APP_USER_FLAG : loginUserId; //Long deptId = user == null ? null : user.getDeptId(); @@ -107,7 +111,7 @@ public class FieldMetaObjectHandler implements MetaObjectHandler { //更新时间 setFieldValByName(UPDATE_DATE, new Date(), metaObject); } else if (fillEsuaEntity) { - String loginUserId = LoginUserUtil.getLoginUserId(); + String loginUserId = loginUserUtil.getLoginUserId(); String userId = StringUtils.isBlank(loginUserId) ? Constant.APP_USER_FLAG : loginUserId; setFieldValByName(FieldConstant.UPDATED_BY_HUMP, userId, metaObject); setFieldValByName(FieldConstant.UPDATED_TIME_HUMP, new Date(), metaObject); diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java index eea6262cd4..046c012da4 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java @@ -8,6 +8,7 @@ package com.epmet.commons.mybatis.interceptor; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.PluginUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler; @@ -55,12 +56,17 @@ public class DataFilterInterceptor extends AbstractSqlParserHandler implements I // 判断参数里是否有DataScope对象 DataScope scope = null; if (paramObj instanceof DataScope) { + // 直接传入DataScope,不分页? scope = (DataScope) paramObj; } else if (paramObj instanceof Map) { + // 入参是一个Map for (Object arg : ((Map) paramObj).values()) { if (arg instanceof DataScope) { scope = (DataScope) arg; break; + } else if (arg instanceof QueryWrapper) { + // 通过Mybatis-plus封装的通用方法进行查询 + break; } } } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java new file mode 100644 index 0000000000..1a3445f0f5 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java @@ -0,0 +1,100 @@ +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// *

+// * https://www.renren.io +// *

+// * 版权所有,侵权必究! +// */ +// +//package com.epmet.commons.mybatis.interceptor; +// +//import com.baomidou.mybatisplus.core.toolkit.PluginUtils; +//import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler; +//import com.epmet.commons.mybatis.entity.DataScope; +//import org.apache.ibatis.executor.statement.StatementHandler; +//import org.apache.ibatis.mapping.BoundSql; +//import org.apache.ibatis.mapping.MappedStatement; +//import org.apache.ibatis.mapping.SqlCommandType; +//import org.apache.ibatis.plugin.*; +//import org.apache.ibatis.reflection.MetaObject; +//import org.apache.ibatis.reflection.SystemMetaObject; +// +//import java.sql.Connection; +//import java.util.Map; +//import java.util.Properties; +// +///** +// * 数据过滤 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) +//public class DataFilterInterceptorBak extends AbstractSqlParserHandler implements Interceptor { +// +// @Override +// public Object intercept(Invocation invocation) throws Throwable { +// StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget()); +// MetaObject metaObject = SystemMetaObject.forObject(statementHandler); +// +// // SQL解析 +// this.sqlParser(metaObject); +// +// // 先判断是不是SELECT操作 +// MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); +// if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) { +// return invocation.proceed(); +// } +// +// // 针对定义了rowBounds,做为mapper接口方法的参数 +// BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql"); +// String originalSql = boundSql.getSql(); +// Object paramObj = boundSql.getParameterObject(); +// +// // 判断参数里是否有DataScope对象 +// DataScope scope = null; +// if (paramObj instanceof DataScope) { +// scope = (DataScope) paramObj; +// } else if (paramObj instanceof Map) { +// for (Object arg : ((Map) paramObj).values()) { +// if (arg instanceof DataScope) { +// scope = (DataScope) arg; +// break; +// } +// } +// } +// +// // 不用数据过滤 +// if (scope == null) { +// return invocation.proceed(); +// } +// +// // 拼接新SQL +// String orderBy = "ORDER BY"; +// String groupBy = "GROUP BY"; +// if (originalSql.indexOf(groupBy) > -1) { +// originalSql = originalSql.replace(groupBy, scope.getSqlFilter() + groupBy); +// } else if (originalSql.indexOf(orderBy) > -1) { +// originalSql = originalSql.replace(orderBy, scope.getSqlFilter() + orderBy); +// } else { +// originalSql = originalSql + scope.getSqlFilter(); +// } +// +// // 重写SQL +// metaObject.setValue("delegate.boundSql.sql", originalSql); +// return invocation.proceed(); +// } +// +// @Override +// public Object plugin(Object target) { +// if (target instanceof StatementHandler) { +// return Plugin.wrap(target, this); +// } +// return target; +// } +// +// @Override +// public void setProperties(Properties properties) { +// +// } +//} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java new file mode 100644 index 0000000000..3a5fe74459 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java @@ -0,0 +1,36 @@ +/** + * Copyright 2018 人人开源 http://www.renren.io + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.epmet.commons.tools.annotation; + +import java.lang.annotation.*; + +/** + * 权限注解 + * @Author wxz + * @Description + * @Date 2020/4/23 16:17 + **/ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RequirePermission { + + String key() default ""; + + String desc() default ""; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java new file mode 100644 index 0000000000..eeeedc6508 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.aspect; + +import com.epmet.commons.tools.annotation.RequirePermission; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; + +/** + * 每次请求,过滤Api中配置的权限key出来 + * @Author wxz + * @Description + * @Date 2020/4/23 16:16 + **/ +@Aspect +@Component +public class AccessOpeAspect { + + /** + * 存储所需操作权限的 ThreadLocal + */ + public static final ThreadLocal requirePermissionTl = new ThreadLocal<>(); + + @Before("@annotation(com.epmet.commons.tools.annotation.RequirePermission)") + public void before(JoinPoint point) throws Throwable { + // 取RequirePermission注解 + MethodSignature methodSignature = (MethodSignature) point.getSignature(); + RequirePermission requirePermissionAnno = methodSignature.getMethod().getAnnotation(RequirePermission.class); + String key = requirePermissionAnno.key(); + String desc = requirePermissionAnno.desc(); + System.out.println(key); + System.out.println(desc); + + // 放入ThreadLocal,供DataFilterAspect中使用 + requirePermissionTl.set(key); + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index d07777427a..6fc0a1cbf5 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -27,7 +27,8 @@ public enum EpmetErrorCode { MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"), CANNOT_AUDIT_WARM(8201, "请完善居民信息"), - NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"); + NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), + REQUIRE_PERMISSION(8203, "没有足够的操作权限"); private int code; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java index 5a035ffa80..e49e03d52d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java @@ -44,6 +44,8 @@ public class RenExceptionHandler { private ModuleConfig moduleConfig; @Autowired private LogProducer logProducer; + @Autowired + private LoginUserUtil loginUserUtil; /** * 处理自定义异常 @@ -120,7 +122,7 @@ public class RenExceptionHandler { //登录用户ID - log.setCreator(LoginUserUtil.getLoginUserId()); + log.setCreator(loginUserUtil.getLoginUserId()); //异常信息 log.setErrorInfo(ExceptionUtils.getErrorStackTrace(ex)); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java index bfb7e6dc67..7088bb10a3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java @@ -67,6 +67,6 @@ public class GovTokenDto extends BaseTokenDto implements Serializable { /** * 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey */ - private List permissions; + private Set permissions; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java index 2b249bee22..088a26eb73 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java @@ -1,33 +1,82 @@ package com.epmet.commons.tools.security.user; -import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.utils.HttpContextUtils; import org.apache.commons.lang3.StringUtils; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; +import java.util.List; /** * 登录用户相关工具 */ +@Component public class LoginUserUtil { + //@Autowired + //private + /** * 查询登录用户的id * @return */ - public static String getLoginUserId() { + public String getLoginUserId() { HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); if (request == null) { return null; } - String userId = request.getHeader(Constant.USER_KEY); + String userId = request.getHeader(AppClientConstant.USER_ID); if (StringUtils.isBlank(userId)) { return null; } return userId; } + + /** + * 登录用户的App头信息 + * @return + */ + public String getLoginUserApp() { + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + if (request == null) { + return null; + } + + String app = request.getHeader(AppClientConstant.APP); + if (StringUtils.isBlank(app)) { + return null; + } + return app; + } + + /** + * 获取登录用户client头信息 + * @return + */ + public String getLoginUserClient() { + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + if (request == null) { + return null; + } + + String client = request.getHeader(AppClientConstant.CLIENT); + if (StringUtils.isBlank(client)) { + return null; + } + return client; + } + + /** + * 获取用户的部门ID列表 + * @return + */ + public List getLoginUserDepartments() { + String loginUserId = getLoginUserId(); + String loginUserApp = getLoginUserApp(); + String loginUserClient = getLoginUserClient(); + // todo + return null; + } } diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 57d6203598..7ccab3e048 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -157,12 +157,12 @@ lb://resi-partymember-server - - lb://gov-access-server + http://127.0.0.1:8099 + - - lb://gov-mine-server + http://127.0.0.1:8098 + diff --git a/epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java b/epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java index 1b98025d7c..1da14ce7ef 100644 --- a/epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java +++ b/epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java @@ -1,5 +1,6 @@ package com.epmet.filter; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.security.dto.BaseTokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; @@ -54,7 +55,7 @@ public class FeignRequestFilter implements GlobalFilter, UserTokenFilter { if (baseTokenDto != null) { ServerHttpRequest build = exchange.getRequest().mutate() - .header(Constant.USER_KEY, new String[]{baseTokenDto.getUserId()}).build(); + .header(AppClientConstant.USER_ID, new String[]{baseTokenDto.getUserId()}).build(); return chain.filter(exchange.mutate().request(build).build()); } diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java index b800d6bc1a..56907e52af 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java @@ -3,7 +3,7 @@ package com.epmet.dto.form; import lombok.Data; import javax.validation.constraints.NotBlank; -import java.util.List; +import java.util.Set; @Data public class StaffPermCacheFormDTO { @@ -13,27 +13,32 @@ public class StaffPermCacheFormDTO { */ public interface UpdatePermissionCache {} + /** + * 查询当前权限列表 + */ + public interface GetStaffCurrPermissions {} + /** * 工作人员 id */ - @NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class}) + @NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) private String staffId; /** * 登录头信息app */ - @NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class}) + @NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) private String app; /** * 登录头信息client */ - @NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class}) + @NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) private String client; /** * 权限列表 */ - private List permissions; + private Set permissions; } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java index 0f7eaf4920..aa954dc584 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; +import java.util.Set; /** * 权限相关Api @@ -36,8 +36,19 @@ public class AccessController { String staffId = staffPermCacheFormDTO.getStaffId(); String app = staffPermCacheFormDTO.getApp(); String client = staffPermCacheFormDTO.getClient(); - List permissions = staffPermCacheFormDTO.getPermissions(); + Set permissions = staffPermCacheFormDTO.getPermissions(); accessService.updatePermissionCache(staffId, app, client, permissions); return new Result(); } + + /** + * 查询用户当前权限列表(DataFilterAspect中用到) + * @return + */ + @PostMapping("getcurrpermissions") + public Result> getStaffCurrPermissions(@RequestBody StaffPermCacheFormDTO dto) { + ValidatorUtils.validateEntity(dto, StaffPermCacheFormDTO.GetStaffCurrPermissions.class); + Set permissions = accessService.listStaffCurrPermissions(dto.getApp(), dto.getClient(), dto.getStaffId()); + return new Result>().ok(permissions); + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java index cbf51355d1..a9e5150db8 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java @@ -1,6 +1,6 @@ package com.epmet.service; -import java.util.List; +import java.util.Set; public interface AccessService { /** @@ -8,5 +8,11 @@ public interface AccessService { * @param staffId * @param permissions */ - void updatePermissionCache(String staffId, String app, String client, List permissions); + void updatePermissionCache(String staffId, String app, String client, Set permissions); + + /** + * 查询用户当前权限列表 + * @return + */ + Set listStaffCurrPermissions(String app, String client, String staffId); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index e391283e94..cd846aa3b8 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -7,8 +7,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; -import java.util.List; +import java.util.HashSet; +import java.util.Set; @Service public class AccessServiceImpl implements AccessService { @@ -24,7 +26,7 @@ public class AccessServiceImpl implements AccessService { * @param permissions */ @Override - public void updatePermissionCache(String staffId, String app, String client, List permissions) { + public void updatePermissionCache(String staffId, String app, String client, Set permissions) { GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); if (govTokenDto == null) { logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); @@ -37,4 +39,13 @@ public class AccessServiceImpl implements AccessService { cpUserDetailRedis.set(govTokenDto, expire); logger.warn("更新[{}]用户缓存成功。", staffId); } + + @Override + public Set listStaffCurrPermissions(String app, String client, String staffId) { + GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); + if (govTokenDto == null || CollectionUtils.isEmpty(govTokenDto.getPermissions())) { + return new HashSet<>(); + } + return new HashSet<>(govTokenDto.getPermissions()); + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql index 67e7a5c7b2..bcc1d74a5d 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql @@ -61,7 +61,7 @@ CREATE TABLE `role_operation` ( CREATE TABLE `role_scope` ( `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID', - `PERMISSION_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限key', + `SCOPE_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围Key', `DEL_FLAG` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除,0:未删除,1:已删除', `REVISION` int(10) NULL DEFAULT NULL COMMENT '乐观锁', `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者id', diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java index 9cef45a3b4..173e19243a 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java @@ -29,14 +29,21 @@ public class AccessController { @Autowired private AccessService accessService; + /** + * 查询用户可操作功能列表(包含缓存) + * @param tokenDto + * @param staffOperationDTO + * @return + */ @PostMapping("getstaffoperations") public Result> getStaffOperations(@LoginUser TokenDto tokenDto, @RequestBody StaffOperationDTO staffOperationDTO) { //public Result> getStaffOperations(@RequestBody StaffOperationDTO staffOperationDTO) { String agencyId = staffOperationDTO.getAgencyId(); String gridId = staffOperationDTO.getGridId(); String staffId = tokenDto.getUserId(); - Set opeKeys = accessService.listOpeKeysByStaffId(staffId, agencyId, gridId); + String app = tokenDto.getApp(); + String client = tokenDto.getClient(); + Set opeKeys = accessService.listOpeKeysByStaffId(app, client, staffId,agencyId, gridId); return new Result>().ok(opeKeys); } - } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java index facacdb301..8cb514ad3f 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -2,14 +2,13 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.form.StaffPermCacheFormDTO; import com.epmet.dto.result.RoleOperationResultDTO; import com.epmet.feign.fallback.GovAccessFeignClientFallback; -import com.epmet.feign.fallback.GovOrgFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -20,6 +19,19 @@ import java.util.List; @FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) public interface GovAccessFeignClient { + /** + * 根据角色ID查询角色权限列表 + * @param roleId + * @return + */ @PostMapping("/gov/access/role/operations/{roleId}") Result> listOperationsByRoleId(@PathVariable("roleId") String roleId); + + /** + * 刷新用户权限缓存 + * @param staffPermCacheFormDTO + * @return + */ + @PostMapping("/gov/access/access/updatepermissioncache") + Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO); } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java index 0fc5df6a94..3e9fc8e415 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java @@ -3,14 +3,11 @@ package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.StaffRoleDTO; -import com.epmet.dto.form.StaffRoleFormDTO; -import com.epmet.dto.result.CustomerGridByUserIdResultDTO; -import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.dto.form.StaffPermCacheFormDTO; import com.epmet.dto.result.RoleOperationResultDTO; -import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.GovAccessFeignClient; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -25,4 +22,14 @@ public class GovAccessFeignClientFallback implements GovAccessFeignClient { public Result> listOperationsByRoleId(String roleId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listOperationsByRoleId"); } + + /** + * 刷新用户权限缓存 + * @param staffPermCacheFormDTO + * @return + */ + @Override + public Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "updatePermissionCache"); + } } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java index bb213bd94d..9866ea9ffd 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java @@ -12,8 +12,7 @@ import java.util.Set; public interface AccessService { /** * 根据staffId查询角色Key列表 - * @param staffId * @return */ - Set listOpeKeysByStaffId(String staffId, String agencyId, String gridId); + Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId); } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index c7823cd335..1da258978a 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -1,8 +1,9 @@ package com.epmet.service.impl; +import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.form.StaffPermCacheFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.RoleOperationResultDTO; import com.epmet.feign.EpmetUserFeignClient; @@ -26,8 +27,11 @@ public class AccessServiceImpl implements AccessService { @Autowired private GovAccessFeignClient govAccessFeignClient; + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + @Override - public Set listOpeKeysByStaffId(String staffId, String agencyId, String gridId) { + public Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId) { List roleDTOS = new ArrayList<>(); // 查询机关单位权限 StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); @@ -56,6 +60,14 @@ public class AccessServiceImpl implements AccessService { } }); }); + + // 将最新权限缓存到redis,为了尽量统一操作入口,调用gov-access接口实现 + StaffPermCacheFormDTO staffPermCacheFormDTO = new StaffPermCacheFormDTO(); + staffPermCacheFormDTO.setApp(app); + staffPermCacheFormDTO.setClient(client); + staffPermCacheFormDTO.setStaffId(staffId); + staffPermCacheFormDTO.setPermissions(opeKeys); + govAccessFeignClient.updatePermissionCache(staffPermCacheFormDTO); return opeKeys; } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java index 1c13ea4518..884db53afd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -60,6 +60,7 @@ public class StaffRoleController { * @return */ @PostMapping("staffsinrole") + //@RequirePermission(key = "org_staff_list") public Result> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class); String roleKey = staffRoleFormDTO.getRoleKey(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index ddcd8abe3b..739d20e945 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -108,6 +108,7 @@ public class StaffRoleServiceImpl extends BaseServiceImpl listStaffsInRole(String roleKey, String orgId) { return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId); } From d5b49c215836dc9b2e38d855934d1d1f464db231 Mon Sep 17 00:00:00 2001 From: zxc <954985705@qq.com> Date: Fri, 24 Apr 2020 14:09:33 +0800 Subject: [PATCH 15/26] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E3=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 1 + .../java/com/epmet/dto/GridStaffCountDTO.java | 21 ++++++ .../main/java/com/epmet/dto/UserIdDTO.java | 21 ++++++ .../com/epmet/dto/form/AddGridFormDTO.java | 31 ++++++++ .../com/epmet/dto/form/DeleteGridFormDTO.java | 30 ++++++++ .../com/epmet/dto/form/EditGridFormDTO.java | 31 ++++++++ .../epmet/dto/result/AddGridResultDTO.java | 21 ++++++ .../com/epmet/controller/GridController.java | 37 +++++++++- .../java/com/epmet/dao/CustomerGridDao.java | 38 ++++++++++ .../com/epmet/feign/EpmetUserFeignClient.java | 5 ++ .../EpmetUserFeignClientFallBack.java | 6 ++ .../epmet/service/CustomerGridService.java | 27 ++++++- .../service/impl/CustomerGridServiceImpl.java | 74 ++++++++++++++++--- .../main/resources/mapper/CustomerGridDao.xml | 56 ++++++++++++++ .../controller/CustomerStaffController.java | 9 ++- .../java/com/epmet/dao/CustomerStaffDao.java | 12 ++- .../epmet/service/CustomerStaffService.java | 9 +++ .../impl/CustomerStaffServiceImpl.java | 15 ++++ .../resources/mapper/CustomerStaffDao.xml | 12 +++ 19 files changed, 436 insertions(+), 20 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 6fc0a1cbf5..01d63ec781 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -25,6 +25,7 @@ public enum EpmetErrorCode { AUTO_CONFIRM_FAILED(8103, "党员注册失败"), MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"), MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"), + NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"), CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java new file mode 100644 index 0000000000..fcdbe3ed04 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-24 9:13 + */ +@Data +public class GridStaffCountDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 网格下未被禁用的工作人员数量 + */ + private Integer enableCount; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java new file mode 100644 index 0000000000..65ed41cab6 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-24 9:06 + */ +@Data +public class UserIdDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * userId + */ + private String userId; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java new file mode 100644 index 0000000000..95df5fca15 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-23 16:42 + */ +@Data +public class AddGridFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机构id + */ + private String agencyId; + + /** + * 新建网格名称 + */ + private String gridName; + + /** + * 管辖区域 + */ + private String manageDistrict; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java new file mode 100644 index 0000000000..ed266210ba --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-23 19:18 + */ +@Data +public class DeleteGridFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 网格id + */ + private String gridId; + + /** + * 工作人员id + */ + private String staffId; + + /** + * userId + */ + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java new file mode 100644 index 0000000000..2c5556f7a3 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-23 19:12 + */ +@Data +public class EditGridFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * gridId 网格id + */ + private String gridId; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 管理区域 + */ + private String manageDistrict; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java new file mode 100644 index 0000000000..eedf5c895a --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Auther zxc + * @Create 2020-04-23 16:45 + */ +@Data +public class AddGridResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * gridId 网格id + */ + private String gridId; + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index 2f2b919b20..f3b19c5027 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -1,7 +1,13 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AddGridFormDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.DeleteGridFormDTO; +import com.epmet.dto.form.EditGridFormDTO; +import com.epmet.dto.result.AddGridResultDTO; import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.service.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -21,16 +27,41 @@ public class GridController { @Autowired private CustomerGridService customerGridService; + /** + * 获取网格详情 + * @param customerGridFormDTO + * @return + */ @PostMapping("griddetail") - public Result griddetail(@RequestBody CustomerGridFormDTO customerGridFormDTO){ + public Result gridDetail(@LoginUser TokenDto tokenDto,@RequestBody CustomerGridFormDTO customerGridFormDTO){ Result griddetail = customerGridService.griddetail(customerGridFormDTO); return griddetail; } - /*@PostMapping("addgrid") + /** + * 新建当前机关下的所属网格 + */ + @PostMapping("addgrid") + public Result addGrid(@LoginUser TokenDto tokenDto, @RequestBody AddGridFormDTO addGridFormDTO){ + return customerGridService.addGrid(tokenDto,addGridFormDTO); + } + + /** + * 管理员修改网格信息 + */ @PostMapping("editgrid") + public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){ + return customerGridService.editGrid(tokenDto,editGridFormDTO); - @PostMapping("deletegrid")*/ + } + + /** + * 删除网格 + */ + @PostMapping("deletegrid") + public Result deleteGrid(@LoginUser TokenDto tokenDto, @RequestBody DeleteGridFormDTO deleteGridFormDTO){ + return customerGridService.deleteGrid(tokenDto,deleteGridFormDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index d387278ec5..d15a7c7032 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -18,15 +18,19 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.DeleteGridFormDTO; import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.AddGridResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -86,4 +90,38 @@ public interface CustomerGridDao extends BaseDao { */ List selectUserIdByGridId(CustomerGridFormDTO customerGridFormDTO); + /** + * 根据userId查询customerId + * @param userId + * @return + */ + String selectCustomerIdByUserId(@Param("userId") String userId); + + /** + * 根据pid查询pids + * @param pid + * @return + */ + String selectPidsByPid(@Param("pid")String pid); + + /** + * 根据gridName查询gridId + * @param gridName + * @return + */ + String selectGridIdByGridName(@Param("gridName")String gridName); + + /** + * 编辑网格信息 + * @param customerGridDTO + */ + void editGrid(CustomerGridDTO customerGridDTO); + + /** + * 删除网格 + * @param deleteGridFormDTO + */ + void deleteGrid(DeleteGridFormDTO deleteGridFormDTO); + + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 217d37c0bb..42465e7055 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -2,6 +2,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; @@ -9,6 +10,7 @@ import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -43,4 +45,7 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/staffsinagency") Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + @PostMapping(value = "/epmetuser/customerstaff/selectgridstaffcountbyuserid") + Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index a4cf20b805..aa0149a726 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -3,6 +3,7 @@ package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; @@ -32,4 +33,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffInfoForHome", fromDTO); } + + @Override + public Result selectGridStaffCountByUserId(UserIdDTO userIdDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectGridStaffCountByUserId", userIdDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 5d427e434a..41390fe5e5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -18,15 +18,18 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddGridResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerGridEntity; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; @@ -130,4 +133,24 @@ public interface CustomerGridService extends BaseService { * @return */ Result griddetail(CustomerGridFormDTO customerGridFormDTO); + + /** + * 新建当前机关下的所属网格 + */ + Result addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO); + + /** + * 修改网格信息 + * @param tokenDto + * @param editGridFormDTO + */ + Result editGrid(TokenDto tokenDto,EditGridFormDTO editGridFormDTO); + + /** + * 删除网格 + * @param tokenDto + * @param deleteGridFormDTO + * @return + */ + Result deleteGrid(TokenDto tokenDto,DeleteGridFormDTO deleteGridFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index da136fb56a..a53a6bac1c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -21,15 +21,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerGridDao; -import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.*; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddGridResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.GridDetailResultDTO; @@ -43,10 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 客户网格表 @@ -169,6 +168,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl>().ok(baseDao.getMyGrids(userId)); } + /** + * 查询网格详情 + * @param customerGridFormDTO + * @return + */ @Override public Result griddetail(CustomerGridFormDTO customerGridFormDTO) { GridDetailResultDTO griddetail = baseDao.griddetail(customerGridFormDTO); @@ -178,4 +182,56 @@ public class CustomerGridServiceImpl extends BaseServiceImpl().ok(griddetail); } + @Override + @Transactional(rollbackFor = Exception.class) + public Result addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) { + CustomerGridEntity customerGridEntity = new CustomerGridEntity(); + customerGridEntity.setCustomerId(baseDao.selectCustomerIdByUserId(tokenDto.getUserId())); + customerGridEntity.setGridName(addGridFormDTO.getGridName()); + customerGridEntity.setDelFlag("0"); + customerGridEntity.setCreatedBy(tokenDto.getUserId()); + customerGridEntity.setUpdatedBy(tokenDto.getUserId()); + customerGridEntity.setTotalUser(0); + customerGridEntity.setManageDistrict(addGridFormDTO.getManageDistrict()); + customerGridEntity.setPid(addGridFormDTO.getAgencyId()); + customerGridEntity.setPids(baseDao.selectPidsByPid(addGridFormDTO.getAgencyId())); + baseDao.insert(customerGridEntity); + String gridId = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName()); + AddGridResultDTO addGridResultDTO = new AddGridResultDTO(); + addGridResultDTO.setGridId(gridId); + return new Result().ok(addGridResultDTO); + } + + /** + * 修改网格信息 + * @param tokenDto + * @param editGridFormDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result editGrid(TokenDto tokenDto, EditGridFormDTO editGridFormDTO) { + CustomerGridDTO customerGridDTO = new CustomerGridDTO(); + customerGridDTO.setManageDistrict(editGridFormDTO.getManageDistrict()); + customerGridDTO.setGridName(editGridFormDTO.getGridName()); + customerGridDTO.setUpdatedBy(tokenDto.getUserId()); + customerGridDTO.setId(editGridFormDTO.getGridId()); + baseDao.editGrid(customerGridDTO); + return new Result(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result deleteGrid(TokenDto tokenDto,DeleteGridFormDTO deleteGridFormDTO) { + UserIdDTO userIdDTO = new UserIdDTO(); + userIdDTO.setUserId(tokenDto.getUserId()); + deleteGridFormDTO.setUserId(tokenDto.getUserId()); + Result gridStaffCountDTOResult = epmetUserFeignClient.selectGridStaffCountByUserId(userIdDTO); + if (gridStaffCountDTOResult.getData().getEnableCount()==0){ + baseDao.deleteGrid(deleteGridFormDTO); + }else { + return new Result().error(EpmetErrorCode.NOT_DEL_GRID.getCode()); + } + return new Result(); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 574084079e..c7a54db7b9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -138,4 +138,60 @@ AND grid_id = #{gridId} + + + + + + + + + + + + update + customer_grid + set + grid_name = #{gridName}, + manage_district = #{manageDistrict}, + updated_by = #{updatedBy} + where + id = #{id} + + + + + update + customer_grid + set + updated_by = #{userId}, + del_flag = 1 + where + id = #{gridId} + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 42c39a6022..b3aa12f74a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -25,9 +25,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.*; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; @@ -155,4 +153,9 @@ public class CustomerStaffController { public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { return customerStaffService.getStaffInfoForHome(fromDTO); } + + @PostMapping(value = "selectgridstaffcountbyuserid") + public Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO){ + return customerStaffService.selectGridStaffCountByUserId(userIdDTO); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index b552832c2d..3026894e00 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -18,14 +18,14 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -58,6 +58,12 @@ public interface CustomerStaffDao extends BaseDao { CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO); + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ + GridStaffCountDTO selectGridStaffCountByUserId(UserIdDTO userIdDTO); /** * 根据userId查询查询网格下的用户信息 * diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index 4a7ceb335f..1fe7ce3442 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -20,6 +20,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; @@ -140,4 +142,11 @@ public interface CustomerStaffService extends BaseService { * @return */ Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ + Result selectGridStaffCountByUserId(UserIdDTO userIdDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 560fe0008c..5756cb4fce 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -27,6 +27,8 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserConstant; import com.epmet.dao.CustomerStaffDao; +import com.epmet.dto.*; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; @@ -156,4 +158,17 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl>().ok(list); } + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ + @Override + public Result selectGridStaffCountByUserId(UserIdDTO userIdDTO) { + Result gridStaffCountDTOResult = new Result(); + GridStaffCountDTO gridStaffCountDTO = baseDao.selectGridStaffCountByUserId(userIdDTO); + gridStaffCountDTOResult.setData(gridStaffCountDTO); + return gridStaffCountDTOResult; + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index ab8ad974a5..a98e30cf86 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -41,6 +41,18 @@ AND cs.del_flag = 0 + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml index 8259bfb9a8..14fe8a45ca 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml @@ -23,9 +23,20 @@ r.* FROM staff_role sr - INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) + INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) AND r.DEL_FLAG = '0' WHERE sr.STAFF_ID = #{staffId} AND sr.ORG_ID = #{orgId} + AND sr.DEL_FLAG = '0' + + \ No newline at end of file From 97a9c6f1f80ed09198a9157588d6d3a6b9059ccc Mon Sep 17 00:00:00 2001 From: zxc <954985705@qq.com> Date: Fri, 24 Apr 2020 15:34:19 +0800 Subject: [PATCH 17/26] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E6=80=A7=E5=88=AB=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/StaffGridListDTO.java | 5 ++++ .../controller/DepartmentController.java | 30 +++++++++++++++++++ .../resources/mapper/CustomerStaffDao.xml | 3 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java index dc25ece228..263405df0c 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java @@ -31,4 +31,9 @@ public class StaffGridListDTO { */ private String roleName; + /** + * 性别 + */ + private String gender; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java new file mode 100644 index 0000000000..9a0a04187b --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -0,0 +1,30 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AddDepartmentFormDTO; +import com.epmet.service.CustomerStaffDepartmentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Auther zxc + * @Create 2020-04-24 14:48 + */ +@RestController +@RequestMapping(value = "/department") +public class DepartmentController { + + @Autowired + private CustomerStaffDepartmentService customerStaffDepartmentService; + + @PostMapping(value = "adddepartmentstaff") + public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentFormDTO addDepartmentFormDTO){ + return null; + } + +} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 0e596339f9..33c42ff406 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -30,7 +30,8 @@ cs.id AS staffId, cs.real_name AS staffName, cs.head_photo AS staffHeadPhoto, - gsr.role_name AS roleName + gsr.role_name AS roleName, + cs.gender FROM customer_staff cs LEFT JOIN gov_staff_role gsr ON cs.user_id = gsr.id From e359eafb8050097f320b92c7c614c5baf208e331 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 24 Apr 2020 15:47:40 +0800 Subject: [PATCH 18/26] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=92=8CorgId=E6=9F=A5=E8=AF=A2=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=90=8D=E7=A7=B0=EF=BC=8C=E8=A7=92=E8=89=B2?= =?UTF-8?q?key=E7=9A=84=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/GovStaffRoleResultDTO.java | 56 +++++++++++++++++++ .../epmet/controller/StaffRoleController.java | 8 +-- .../main/java/com/epmet/dao/StaffRoleDao.java | 4 +- .../com/epmet/service/StaffRoleService.java | 3 +- .../service/impl/StaffRoleServiceImpl.java | 3 +- .../main/resources/mapper/StaffRoleDao.xml | 5 +- 6 files changed, 68 insertions(+), 11 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java new file mode 100644 index 0000000000..6123f16677 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class GovStaffRoleResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 人员id + */ + private String staffId; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java index 884db53afd..795b0a34d9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -3,8 +3,8 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; @@ -61,12 +61,12 @@ public class StaffRoleController { */ @PostMapping("staffsinrole") //@RequirePermission(key = "org_staff_list") - public Result> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { + public Result> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class); String roleKey = staffRoleFormDTO.getRoleKey(); String orgId = staffRoleFormDTO.getOrgId(); - List staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId); - return new Result>().ok(staffRoleDTOS); + List staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId); + return new Result>().ok(staffRoleDTOS); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index 40d4b47b00..309068b1c8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -18,7 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.StaffRoleEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -39,5 +39,5 @@ public interface StaffRoleDao extends BaseDao { * @param orgId * @return */ - List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java index 7ba2d5e83b..f4f15edf0c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java @@ -20,6 +20,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.StaffRoleEntity; import java.util.List; @@ -99,5 +100,5 @@ public interface StaffRoleService extends BaseService { * @param orgId * @return */ - List listStaffsInRole(String roleKey, String orgId); + List listStaffsInRole(String roleKey, String orgId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index 739d20e945..db7d154b22 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.StaffRoleDao; import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.StaffRoleEntity; import com.epmet.redis.StaffRoleRedis; import com.epmet.service.StaffRoleService; @@ -109,7 +110,7 @@ public class StaffRoleServiceImpl extends BaseServiceImpl listStaffsInRole(String roleKey, String orgId) { + public List listStaffsInRole(String roleKey, String orgId) { return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId); } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml index 0cbdc611f6..45937ae7f1 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml @@ -18,9 +18,8 @@ - + SELECT sr.STAFF_ID, sr.ROLE_ID, r.ROLE_NAME, r.ROLE_KEY FROM staff_role sr INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) From 2ee793e872b6243e8a5acf2092e89f755c3613f1 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 16:02:39 +0800 Subject: [PATCH 19/26] =?UTF-8?q?=E6=94=BF=E5=BA=9C=E7=AB=AF-=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A8=A1=E5=9D=97=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 4 +- .../epmet/dto/form/AddDepartmentFormDTO.java | 53 +++++ .../dto/form/DepartmentInAgencyFormDTO.java | 43 ++++ .../epmet/dto/form/DepartmentListFormDTO.java | 43 ++++ .../dto/form/DepartmentdetailFormDTO.java | 43 ++++ .../epmet/dto/form/EditDepartmentFormDTO.java | 54 +++++ .../dto/form/RemoveDepartmentFormDTO.java | 42 ++++ .../dto/result/AddDepartmentResultDTO.java | 40 ++++ .../result/DepartInStaffListResultDTO.java | 60 ++++++ .../dto/result/DepartmentDetailResultDTO.java | 57 +++++ .../result/DepartmentInAgencyResultDTO.java | 47 ++++ .../dto/result/DepartmentListResultDTO.java | 49 +++++ .../constant/CustomerDepartmentConstant.java | 30 +++ .../controller/DepartmentController.java | 110 ++++++++++ .../com/epmet/dao/CustomerDepartmentDao.java | 21 +- .../epmet/dao/CustomerStaffDepartmentDao.java | 6 +- .../com/epmet/feign/EpmetUserFeignClient.java | 11 + .../EpmetUserFeignClientFallBack.java | 8 + .../com/epmet/service/DepartmentService.java | 80 +++++++ .../service/impl/DepartmentServiceImpl.java | 200 ++++++++++++++++++ .../resources/mapper/CustomerAgencyDao.xml | 5 +- .../mapper/CustomerStaffDepartmentDao.xml | 10 + .../dto/form/DepartmentInStaffFormDTO.java | 33 +++ .../com/epmet/constant/UserRoleConstant.java | 6 + .../controller/CustomerStaffController.java | 14 +- .../java/com/epmet/dao/CustomerStaffDao.java | 10 + .../epmet/service/CustomerStaffService.java | 10 + .../impl/CustomerStaffServiceImpl.java | 18 ++ .../resources/mapper/CustomerStaffDao.xml | 17 ++ 29 files changed, 1118 insertions(+), 6 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index d07777427a..fab7dfae57 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -27,7 +27,9 @@ public enum EpmetErrorCode { MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"), CANNOT_AUDIT_WARM(8201, "请完善居民信息"), - NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"); + NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), + NOT_DEL_AGENCY_PER(8203, "该机关存在工作人员,不允许删除"), + NOT_DEL_DEPARTMENT(8204, "该部门存在工作人员,不允许删除"); private int code; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java new file mode 100644 index 0000000000..07e5b1f0f4 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java @@ -0,0 +1,53 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 添加部门-接口入参 + * + * @author sun + */ +@Data +public class AddDepartmentFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 所属组织机构ID(customer_agency.id) + */ + @NotBlank(message = "组织机构Id不能为空") + private String agencyId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门职责 + */ + private String departmentDuty; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java new file mode 100644 index 0000000000..bb70330a2c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 组织首页-获取机关下部门列表-接口入参 + * + * @author sun + */ +@Data +public class DepartmentInAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "组织机构ID不能为空") + private String agencyId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java new file mode 100644 index 0000000000..a651dad1c3 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 获取部门列表-接口入参 + * + * @author sun + */ +@Data +public class DepartmentListFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "组织机构ID不能为空") + private String agencyId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java new file mode 100644 index 0000000000..8e01785bf2 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 获取部门详情-接口入参 + * + * @author sun + */ +@Data +public class DepartmentdetailFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + @NotBlank(message = "部门ID不能为空") + private String departmentId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java new file mode 100644 index 0000000000..949ac45ace --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java @@ -0,0 +1,54 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 部门信息修改-接口入参 + * + * @author sun + */ +@Data +public class EditDepartmentFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + @NotBlank(message = "部门ID不能为空") + private String departmentId; + + /** + * 部门名称 + */ + @NotBlank(message = "部门名称不能为空") + private String departmentName; + + /** + * 部门职责 + */ + @NotBlank(message = "部门职责不能为空") + private String departmentDuty; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java new file mode 100644 index 0000000000..749a157deb --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 删除部门-接口入参 + * + * @author sun + */ +@Data +public class RemoveDepartmentFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + @NotBlank(message = "部门ID不能为空") + private String departmentId; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java new file mode 100644 index 0000000000..b6206d0c6d --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 添加部门-接口返参 + * + * @author sun + */ +@Data +public class AddDepartmentResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 新增部门Id + */ + private String departmentId; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java new file mode 100644 index 0000000000..e63020a209 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java @@ -0,0 +1,60 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 获取部门详情-部门下工作人员列表 + * + * @author sun + */ +@Data +public class DepartInStaffListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + private String staffId; + + /** + * 用户姓名 + */ + private String staffName; + + /** + * 用户头像 + */ + private String staffHeadPhoto; + + /** + * 性别 + */ + private Integer gender; + + /** + * 角色名称 + */ + private String roleName; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java new file mode 100644 index 0000000000..d36a4222ee --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java @@ -0,0 +1,57 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +/** + * 获取部门详情-接口返参 + * + * @author sun + */ +@Data +public class DepartmentDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + private String departmentId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门职责 + */ + private String departmentDuty; + + /** + * 部门下工作人员列表 + */ + private List staffList; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java new file mode 100644 index 0000000000..33880e5c1b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +/** + * 组织首页-获取机关下部门列表-接口返参 + * + * @author sun + */ +@Data +public class DepartmentInAgencyResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关下总部门数 + */ + private Integer departmentCount; + + /** + * 机关下部门列表 + */ + private List departmentList; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java new file mode 100644 index 0000000000..7fafa0238d --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java @@ -0,0 +1,49 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 组织首页-获取机关下部门列表-部门详情数据 + * + * @author sun + */ +@Data +public class DepartmentListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + private String departmentId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门下总人数 + */ + private Integer totalUser; +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java new file mode 100644 index 0000000000..2a530cba0b --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java @@ -0,0 +1,30 @@ +package com.epmet.constant; + +/** + * @author sun + * @dscription + */ +public interface CustomerDepartmentConstant { + + /** + * 部门信息编辑修改失败 + */ + String UPDATE_EXCEPTION = "部门信息更新失败"; + /** + * 添加部门失败 + */ + String SAVE_EXCEPTION = "添加部门失败"; + /** + * 部门删除失败 + */ + String DEL_EXCEPTION = "删除部门失败"; + /** + * 查询用户基本信息失败 + */ + String SELECT_STAFFINFO_EXCEPTION = "根据用户Id未查询到用户基本信息"; + + /** + * 查询部门人员角色 + */ + String SELECT_ROLE_EXCEPTION = "查询部门人员角色失败"; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java new file mode 100644 index 0000000000..05189cdc57 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.service.DepartmentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 部门 + * + * @author sun + */ +@RestController +@RequestMapping("department") +public class DepartmentController { + + @Autowired + private DepartmentService departmentService; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加部门 + */ + @PostMapping("adddepartment") + public Result addDepartment(@RequestBody AddDepartmentFormDTO formDTO) { + return departmentService.addDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 部门信息修改 + */ + @PostMapping("editdepartment") + public Result editDepartment(@RequestBody EditDepartmentFormDTO formDTO) { + return departmentService.editDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除部门 + */ + @PostMapping("removedepartment") + public Result removeDepartment(@RequestBody RemoveDepartmentFormDTO formDTO) { + return departmentService.removeDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取部门详情 + */ + @PostMapping("departmentdetail") + public Result departmentDetail(@RequestBody DepartmentdetailFormDTO formDTO) { + return departmentService.departmentDetail(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + @PostMapping("departmentinagencylist") + public Result departmentInAgencyList(@RequestBody DepartmentInAgencyFormDTO formDTO) { + return departmentService.departmentInAgencyList(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + @PostMapping("departmentlist") + public Result> departmentList(@RequestBody DepartmentListFormDTO formDTO) { + return departmentService.departmentList(formDTO); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java index bd188f8351..b7569a1396 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java @@ -18,8 +18,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.DepartmentListResultDTO; +import com.epmet.dto.result.SubListResultDTO; import com.epmet.entity.CustomerDepartmentEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 客户部门表 @@ -29,5 +34,19 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerDepartmentDao extends BaseDao { - + + /** + * @param agencyId + * @return + * @Author sun + * @Description 根据当前机关Id查询该机关下的直属部门列表,只查询前十条 + **/ + List selectDepartmentListByAgencyId(@Param("agencyId") String agencyId); + /** + * @param agencyId + * @return + * @Author sun + * @Description 根据当前机关Id查询该机关下的直属部门列表 + **/ + List selectDepartmentList(@Param("agencyId") String agencyId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java index 8a79a0dd2e..dfdba500d7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java @@ -20,6 +20,9 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.CustomerStaffDepartmentEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 部门人员关系表 @@ -29,5 +32,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerStaffDepartmentDao extends BaseDao { - + + List selectUserIdByDepartmentId(@Param("departmentId") String departmentId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 217d37c0bb..c9e67f87ff 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -5,7 +5,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; @@ -43,4 +45,13 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/staffsinagency") Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + /** + * @param departmentInStaffFormDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + @PostMapping("/epmetuser/customerstaff/getdepartmentstafflist") + Result> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index a4cf20b805..dd508f6f12 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -6,7 +6,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; @@ -32,4 +34,10 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffInfoForHome", fromDTO); } + + @Override + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getDepartmentStaffList", departmentInStaffFormDTO); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java new file mode 100644 index 0000000000..48fe029fb0 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java @@ -0,0 +1,80 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; + +import java.util.List; + +/** + * 机关单位信息 + * + * @author sun + */ +public interface DepartmentService { + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加部门 + */ + Result addDepartment(AddDepartmentFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 部门信息修改 + */ + Result editDepartment(EditDepartmentFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除部门 + */ + Result removeDepartment(RemoveDepartmentFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取部门详情 + */ + Result departmentDetail(DepartmentdetailFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + Result departmentInAgencyList(DepartmentInAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + Result> departmentList(DepartmentListFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java new file mode 100644 index 0000000000..263daff4ac --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,200 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerDepartmentConstant; +import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dao.CustomerDepartmentDao; +import com.epmet.dao.CustomerStaffDepartmentDao; +import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.entity.CustomerDepartmentEntity; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.service.DepartmentService; +import com.epmet.util.ModuleConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; + +/** + * 机关单位信息 + * + * @author sun + */ +@Service +public class DepartmentServiceImpl implements DepartmentService { + + private static final Logger log = LoggerFactory.getLogger(DepartmentServiceImpl.class); + @Autowired + private CustomerAgencyDao customerAgencyDao; + @Autowired + private CustomerDepartmentDao customerDepartmentDao; + @Autowired + private CustomerStaffDepartmentDao customerStaffDepartmentDao; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加部门 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result addDepartment(AddDepartmentFormDTO formDTO) { + Result result = new Result(); + AddDepartmentResultDTO addDepartmentResultDTO = new AddDepartmentResultDTO(); + CustomerDepartmentEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerDepartmentEntity.class); + entity.setTotalUser(NumConstant.ZERO); + //1:查询当前组织机构信息,获取客户Id + CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getAgencyId()); + entity.setCustomerId(parentEntity.getCustomerId()); + //2:保存部门信息 + if (customerDepartmentDao.insert(entity) < NumConstant.ONE) { + log.error(CustomerDepartmentConstant.SAVE_EXCEPTION); + throw new RenException(CustomerDepartmentConstant.SAVE_EXCEPTION); + } + //3:返回新部门Id + addDepartmentResultDTO.setDepartmentId(entity.getId()); + return result.ok(addDepartmentResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 部门信息修改 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result editDepartment(EditDepartmentFormDTO formDTO) { + Result result = new Result(); + CustomerDepartmentEntity entity = new CustomerDepartmentEntity(); + entity.setId(formDTO.getDepartmentId()); + entity.setDepartmentName(formDTO.getDepartmentName()); + entity.setDepartmentDuty(formDTO.getDepartmentDuty()); + if (customerDepartmentDao.updateById(entity) < NumConstant.ONE) { + log.error(CustomerDepartmentConstant.UPDATE_EXCEPTION); + throw new RenException(CustomerDepartmentConstant.UPDATE_EXCEPTION); + } + return result; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除部门 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result removeDepartment(RemoveDepartmentFormDTO formDTO) { + Result result = new Result(); + //1:判断当前部门下是否存在工作人员,不存在的可以删除 + CustomerDepartmentEntity entity = customerDepartmentDao.selectById(formDTO.getDepartmentId()); + if (null != entity && entity.getTotalUser() > NumConstant.ZERO) { + result.setCode(EpmetErrorCode.NOT_DEL_DEPARTMENT.getCode()); + result.setMsg(EpmetErrorCode.NOT_DEL_DEPARTMENT.getMsg()); + return result; + } + //2:删除部门信息(逻辑删) + if (customerDepartmentDao.deleteById(formDTO.getDepartmentId()) < NumConstant.ONE) { + log.error(CustomerDepartmentConstant.DEL_EXCEPTION); + throw new RenException(CustomerDepartmentConstant.DEL_EXCEPTION); + } + return result; + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取部门详情 + */ + @Override + public Result departmentDetail(DepartmentdetailFormDTO formDTO) { + Result result = new Result(); + DepartmentDetailResultDTO departmentDetailResultDTO = new DepartmentDetailResultDTO(); + //1:根据部门Id查询部门详情信息 + CustomerDepartmentEntity entity = customerDepartmentDao.selectById(formDTO.getDepartmentId()); + departmentDetailResultDTO = ConvertUtils.sourceToTarget(entity, DepartmentDetailResultDTO.class); + departmentDetailResultDTO.setDepartmentId(entity.getId()); + //2:查询部门下工作人员的用户Id集合 + List userIdList = customerStaffDepartmentDao.selectUserIdByDepartmentId(formDTO.getDepartmentId()); + if (null == userIdList || userIdList.size() < NumConstant.ONE) { + return result.ok(departmentDetailResultDTO); + } + DepartmentInStaffFormDTO departmentInStaffFormDTO = new DepartmentInStaffFormDTO(); + //部门Id用于查询部门领导角色使用 + departmentInStaffFormDTO.setDepartmentId(formDTO.getDepartmentId()); + departmentInStaffFormDTO.setCustomerId(entity.getCustomerId()); + departmentInStaffFormDTO.setUserIdList(userIdList); + //3:调用epmet_user服务,查询人员基本信息,按姓名对应的拼音升序 + Result> resultList = epmetUserFeignClient.getDepartmentStaffList(departmentInStaffFormDTO); + if (!resultList.success() || null == resultList.getData()) { + log.error(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION); + throw new RenException(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION); + } + //部门下所有工作人员基本信息 + List staffList = resultList.getData(); + departmentDetailResultDTO.setStaffList(staffList); + return new Result().ok(departmentDetailResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + @Override + public Result departmentInAgencyList(DepartmentInAgencyFormDTO formDTO) { + DepartmentInAgencyResultDTO departmentInAgencyResultDTO = new DepartmentInAgencyResultDTO(); + //1:根据当前机关Id查询该机关下的直属部门列表 + List departmentList = customerDepartmentDao.selectDepartmentListByAgencyId(formDTO.getAgencyId()); + departmentInAgencyResultDTO.setDepartmentList(departmentList); + //2:统计下一级机关数 + departmentInAgencyResultDTO.setDepartmentCount(departmentList.size()); + return new Result().ok(departmentInAgencyResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + @Override + public Result> departmentList(DepartmentListFormDTO formDTO) { + List departmentList = customerDepartmentDao.selectDepartmentList(formDTO.getAgencyId()); + return new Result>().ok(departmentList); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 50ff491aa3..90b926b729 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -57,7 +57,8 @@ FROM customer_agency WHERE del_flag = '0' AND pid = #{pId} - ORDER BY CREATED_TIME DESC + ORDER BY created_time DESC + LIMIT 10 \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml index 5ab8b90e9c..86c597d402 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml @@ -15,6 +15,16 @@ + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java new file mode 100644 index 0000000000..5810659515 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据客户Id和用户Id查询用户基本信息 + * @Author sun + */ +@Data +public class DepartmentInStaffFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + private String departmentId; + + /** + * 客户Id CUSTOMER.id + */ + private String customerId; + + /** + * 用户Id集合 + */ + private List userIdList; + +} + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java index ce710319bd..48b3e77940 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java @@ -11,4 +11,10 @@ public interface UserRoleConstant { * 角色表对应的是居民角色时grid_id的默认值 */ String DEFAULT_GRID_ID = "all"; + + /** + * 部门领导角色值 + */ + String DEPT_LEADER = "dept_leader"; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 42c39a6022..38fa2fcc45 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -28,9 +28,10 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; @@ -155,4 +156,15 @@ public class CustomerStaffController { public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { return customerStaffService.getStaffInfoForHome(fromDTO); } + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + @PostMapping("getdepartmentstafflist") + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO fromDTO) { + return customerStaffService.getDepartmentStaffList(fromDTO); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index b552832c2d..c6c000bf3c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -22,7 +22,9 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; @@ -82,4 +84,12 @@ public interface CustomerStaffDao extends BaseDao { * @Date 2020/4/23 16:46 **/ CustomerStaffEntity selectByUserId(String userId); + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + List selectDepartmentStaffList(DepartmentInStaffFormDTO fromDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index 4a7ceb335f..1388b741b9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -24,7 +24,9 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; @@ -140,4 +142,12 @@ public interface CustomerStaffService extends BaseService { * @return */ Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + Result> getDepartmentStaffList(DepartmentInStaffFormDTO fromDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 560fe0008c..5d8ef70ba5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -22,16 +22,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserConstant; +import com.epmet.constant.UserRoleConstant; import com.epmet.dao.CustomerStaffDao; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.redis.CustomerStaffRedis; @@ -156,4 +162,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl>().ok(list); } + @Override + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO formDTO) { + //1:根据userId集合查询人员基本信息 + List list = baseDao.selectDepartmentStaffList(formDTO); + //2:根据部门Id查询部门下是领导角色的用户 + StaffRoleFormDTO staffRoleFormDTO = new StaffRoleFormDTO(); + staffRoleFormDTO.setOrgId(formDTO.getDepartmentId()); + staffRoleFormDTO.setRoleKey(UserRoleConstant.DEPT_LEADER); + + return new Result>().ok(list); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index ab8ad974a5..d8d149da1f 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -79,4 +79,21 @@ cs.DEL_FLAG = '0' AND CS.USER_ID =#{userId} + \ No newline at end of file From bfa6577b539ede7b267a689b35cc8aaff10820d9 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 16:19:56 +0800 Subject: [PATCH 20/26] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 6 ++-- .../controller/DepartmentController.java | 33 +++++-------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index e8c528e2ea..161c9cd9ef 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -29,10 +29,10 @@ public enum EpmetErrorCode { CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), - REQUIRE_PERMISSION(8203, "没有足够的操作权限"), - NOT_DEL_AGENCY(8204, "该机关存在下级机关,不允许删除"), NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), - NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"); + NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"), + + REQUIRE_PERMISSION(8301, "没有足够的操作权限"); private int code; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index 9a36b7399a..33a1d7fe87 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -2,13 +2,12 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.AddDepartmentFormDTO; -import com.epmet.service.CustomerStaffDepartmentService; - import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; -import com.epmet.dto.result.*; +import com.epmet.dto.result.AddDepartmentResultDTO; +import com.epmet.dto.result.DepartmentDetailResultDTO; +import com.epmet.dto.result.DepartmentInAgencyResultDTO; +import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.service.DepartmentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -16,27 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** - * @Auther zxc - * @Create 2020-04-24 14:48 - */ -@RestController -@RequestMapping(value = "/department") -public class DepartmentController { - - @Autowired - private CustomerStaffDepartmentService customerStaffDepartmentService; - - @PostMapping(value = "adddepartmentstaff") - public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentFormDTO addDepartmentFormDTO){ - return null; - } - -} - import java.util.List; - /** * 部门 * @@ -49,6 +29,11 @@ public class DepartmentController { @Autowired private DepartmentService departmentService; + @PostMapping(value = "adddepartmentstaff") + public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentFormDTO addDepartmentFormDTO){ + return null; + } + /** * @param formDTO * @return From 93ebde2984365eabe250414e9f016f2e43d30b05 Mon Sep 17 00:00:00 2001 From: zxc <954985705@qq.com> Date: Fri, 24 Apr 2020 16:27:14 +0800 Subject: [PATCH 21/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E4=BA=BA=E5=91=98dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/AddDepartmentFormDTO.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java index 07e5b1f0f4..1188979f4a 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java @@ -1,3 +1,4 @@ +package com.epmet.dto.form; /** * Copyright 2018 人人开源 https://www.renren.io *

@@ -15,12 +16,19 @@ * along with this program. If not, see . */ -package com.epmet.dto.form; import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; + +/** + * 添加部门人员DTO + * @Auther zxc + * @Create 2020-04-24 14:51 +import javax.validation.constraints.NotBlank; +import java.io.Serializable; /** @@ -33,6 +41,16 @@ public class AddDepartmentFormDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + *部门id + */ + private String departmentId; + + /** + * 选中人员id + */ + private List selectedList; + /** * 所属组织机构ID(customer_agency.id) */ From 71bb41f1da6f2079fa854a99ccd74a7126fd8ab3 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 16:45:12 +0800 Subject: [PATCH 22/26] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ilResultDTO.java => AgencysResultDTO.java} | 7 +- .../epmet/controller/AgencyController.java | 4 +- .../java/com/epmet/service/AgencyService.java | 12 +- .../epmet/service/CustomerAgencyService.java | 45 +------ .../epmet/service/impl/AgencyServiceImpl.java | 28 ++-- .../impl/CustomerAgencyServiceImpl.java | 124 ------------------ 6 files changed, 19 insertions(+), 201 deletions(-) rename epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/{AgencydetailResultDTO.java => AgencysResultDTO.java} (91%) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java similarity index 91% rename from epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java rename to epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java index 4fed7005d9..e372d86d8d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java @@ -19,18 +19,17 @@ package com.epmet.dto.result; import lombok.Data; -import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.List; /** - * 组织首页-获取组织机构信息接口返参 + * 添加组织-接口返参 * * @author sun */ @Data -public class AgencydetailResultDTO implements Serializable { +public class AgencysResultDTO implements Serializable { private static final long serialVersionUID = 1L; @@ -77,6 +76,4 @@ public class AgencydetailResultDTO implements Serializable { * 本机关的所有上级机关 */ private List parentList; - - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 82cd76e7c3..b8b8300489 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -21,7 +21,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.AddAgencyResultDTO; import com.epmet.dto.result.AgencyListResultDTO; -import com.epmet.dto.result.AgencydetailResultDTO; +import com.epmet.dto.result.AgencysResultDTO; import com.epmet.dto.result.SubAgencyResultDTO; import com.epmet.service.AgencyService; import org.springframework.beans.factory.annotation.Autowired; @@ -85,7 +85,7 @@ public class AgencyController { * @Description 组织首页-获取组织机构信息 */ @PostMapping("agencydetail") - public Result agencyDetail(@RequestBody AgencydetailFormDTO formDTO) { + public Result agencyDetail(@RequestBody AgencydetailFormDTO formDTO) { return agencyService.agencyDetail(formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index f811f71f80..f2edc0c462 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -17,16 +17,14 @@ package com.epmet.service; -import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.*; -import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.dto.result.AddAgencyResultDTO; +import com.epmet.dto.result.AgencyListResultDTO; +import com.epmet.dto.result.AgencysResultDTO; +import com.epmet.dto.result.SubAgencyResultDTO; import java.util.List; -import java.util.Map; /** * 机关单位信息 @@ -65,7 +63,7 @@ public interface AgencyService { * @Author sun * @Description 组织首页-获取组织机构信息 */ - Result agencyDetail(AgencydetailFormDTO formDTO); + Result agencyDetail(AgencydetailFormDTO formDTO); /** * @param formDTO diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 7076fe6d2d..62892b4576 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -21,11 +21,8 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.form.*; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.dto.result.AgencydetailResultDTO; +import com.epmet.dto.form.StaffOrgFormDTO; import com.epmet.dto.result.StaffOrgsResultDTO; -import com.epmet.dto.result.SubAgencyResultDTO; import com.epmet.entity.CustomerAgencyEntity; import java.util.List; @@ -107,44 +104,4 @@ public interface CustomerAgencyService extends BaseService * @Date 2020/4/20 21:45 **/ Result> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 添加组织 - */ - Result addAgency(AddAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织名称编辑 - */ - Result editAgency(EditAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 删除组织机关 - */ - Result removeAgency(RemoveAgencyFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-获取组织机构信息 - */ - Result agencyDetail(AgencydetailFormDTO formDTO); - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-下级机关列表 - */ - Result subAgencyList(SubAgencyFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index ae13436d6a..a71c53e80a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -17,26 +17,17 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.dao.CustomerAgencyDao; -import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; -import com.epmet.redis.CustomerAgencyRedis; import com.epmet.service.AgencyService; -import com.epmet.service.CustomerAgencyService; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -45,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; -import java.util.Map; /** * 机关单位信息 @@ -146,24 +136,24 @@ public class AgencyServiceImpl implements AgencyService { * @Description 组织首页-获取组织机构信息 */ @Override - public Result agencyDetail(AgencydetailFormDTO formDTO) { - AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO(); + public Result agencyDetail(AgencydetailFormDTO formDTO) { + AgencysResultDTO agencysResultDTO = new AgencysResultDTO(); //1:查询本机关详细信息 CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId()); if (null == entity) { - return new Result().ok(agencydetailResultDTO); + return new Result().ok(agencysResultDTO); } - agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class); - agencydetailResultDTO.setAgencyId(entity.getId()); - agencydetailResultDTO.setAgencyName(entity.getOrganizationName()); + agencysResultDTO = ConvertUtils.sourceToTarget(entity, AgencysResultDTO.class); + agencysResultDTO.setAgencyId(entity.getId()); + agencysResultDTO.setAgencyName(entity.getOrganizationName()); //2:查询本机关的所有上级机关,按自上而下层级顺序 if (null == entity.getPids()) { - return new Result().ok(agencydetailResultDTO); + return new Result().ok(agencysResultDTO); } List listStr = Arrays.asList(entity.getPids().split(":")); List parentList = customerAgencyDao.selectPAgencyById(listStr); - agencydetailResultDTO.setParentList(parentList); - return new Result().ok(agencydetailResultDTO); + agencysResultDTO.setParentList(parentList); + return new Result().ok(agencysResultDTO); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index eb1d83a8ae..06f83a0d25 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -138,128 +138,4 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl>().ok(list); } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 添加组织 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result addAgency(AddAgencyFormDTO formDTO) { - Result result = new Result(); - AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO(); - //0:属性映射赋值 - CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); - entity.setOrganizationName(formDTO.getAgencyName()); - entity.setTotalUser(NumConstant.ZERO); - //1:查询上级机关信息 - CustomerAgencyEntity parentEntity = baseDao.selectById(formDTO.getPid()); - entity.setCustomerId(parentEntity.getCustomerId()); - if (null == parentEntity.getPid()) { - entity.setPids(parentEntity.getId()); - entity.setAllParentName(parentEntity.getOrganizationName()); - } else { - entity.setPids(":" + parentEntity.getId()); - entity.setAllParentName("-" + parentEntity.getOrganizationName()); - } - //2:保存组织信息 - if (baseDao.insert(entity) < NumConstant.ONE) { - logger.error(CustomerAgencyConstant.SAVE_EXCEPTION); - throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION); - } - //3:返回新组织Id - addAgencyResultDTO.setAgencyId(entity.getId()); - return result.ok(addAgencyResultDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织名称编辑 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result editAgency(EditAgencyFormDTO formDTO) { - Result result = new Result(); - CustomerAgencyEntity entity = new CustomerAgencyEntity(); - entity.setId(formDTO.getAgencyId()); - entity.setOrganizationName(formDTO.getAgencyName()); - if (baseDao.updateById(entity) < NumConstant.ONE) { - logger.error(CustomerAgencyConstant.UPDATE_EXCEPTION); - throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); - } - return result; - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 删除组织机关 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public Result removeAgency(RemoveAgencyFormDTO formDTO) { - Result result = new Result(); - //1:查询当前机关是否存在所属下级机关,存在下级的不能删除 - List agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); - if (null != agencyList && agencyList.size() > NumConstant.ZERO) { - result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode()); - result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg()); - return result; - } - //2:删除当前机关组织(逻辑删) - if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { - logger.error(CustomerAgencyConstant.DEL_EXCEPTION); - throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); - } - return result; - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-获取组织机构信息 - */ - @Override - public Result agencyDetail(AgencydetailFormDTO formDTO) { - AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO(); - //1:查询本机关详细信息 - CustomerAgencyEntity entity = baseDao.selectById(formDTO.getAgencyId()); - if (null == entity) { - return new Result().ok(agencydetailResultDTO); - } - agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class); - agencydetailResultDTO.setAgencyId(entity.getId()); - agencydetailResultDTO.setAgencyName(entity.getOrganizationName()); - //2:查询本机关的所有上级机关,按自上而下层级顺序 - if (null == entity.getPids()) { - return new Result().ok(agencydetailResultDTO); - } - List listStr = Arrays.asList(entity.getPids().split(":")); - List parentList = baseDao.selectPAgencyById(listStr); - agencydetailResultDTO.setParentList(parentList); - return new Result().ok(agencydetailResultDTO); - } - - /** - * @param formDTO - * @return - * @Author sun - * @Description 组织首页-下级机关列表 - */ - @Override - public Result subAgencyList(SubAgencyFormDTO formDTO) { - SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); - //1:根据当前机关Id查询直属下一级机关列表 - List agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); - subAgencyResultDTO.setAgencyList(agencyList); - //2:统计下一级机关数 - subAgencyResultDTO.setSubAgencyCount(agencyList.size()); - return new Result().ok(subAgencyResultDTO); - } } \ No newline at end of file From 75d662aabc233e3f0afa3a9f031e552edb354aa9 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Fri, 24 Apr 2020 16:51:22 +0800 Subject: [PATCH 23/26] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E7=BB=84=E7=BB=87-?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=BA=BA=E5=91=98=E7=9B=B8=E5=85=B3=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/StaffSubmitFromDTO.java | 8 ++ .../dto/result/StaffDetailResultDTO.java | 3 +- .../com/epmet/controller/StaffController.java | 23 ++--- .../com/epmet/feign/EpmetUserFeignClient.java | 67 +++++++++++++- .../EpmetUserFeignClientFallBack.java | 39 ++++++++ .../java/com/epmet/service/StaffService.java | 5 +- .../epmet/service/impl/StaffServiceImpl.java | 39 +++++--- .../epmet/constant/CustomerStaffConstant.java | 34 +++++++ .../controller/CustomerStaffController.java | 88 +++++++++++++++--- .../main/java/com/epmet/dao/StaffRoleDao.java | 8 ++ .../com/epmet/service/StaffRoleService.java | 6 ++ .../impl/CustomerStaffServiceImpl.java | 89 +++++++++++++++++-- .../service/impl/StaffRoleServiceImpl.java | 6 ++ .../main/resources/mapper/StaffRoleDao.xml | 8 ++ 14 files changed, 381 insertions(+), 42 deletions(-) create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java index 2ac8a066b0..87ffa6f26b 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java @@ -50,4 +50,12 @@ public class StaffSubmitFromDTO implements Serializable { */ @NotBlank(message = "角色不能为空") private List roles; + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java index 34a6aa6fb3..c6cf9ea90e 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; +import java.util.Date; import java.util.List; /** @@ -38,7 +39,7 @@ public class StaffDetailResultDTO implements Serializable { /** * 激活时间 */ - private String activeTime; + private Date activeTime; /** * 性别 */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java index b8450650aa..6964cffec3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java @@ -2,6 +2,8 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.StaffInfoFromDTO; import com.epmet.dto.form.StaffSubmitFromDTO; @@ -13,6 +15,7 @@ import com.epmet.dto.result.StaffsInAgencyResultDTO; import com.epmet.service.StaffService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -34,7 +37,7 @@ public class StaffController { * @return */ @PostMapping("staffsinagency") - public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + public Result getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) { return staffService.getStaffInfoForHome(fromDTO); } @@ -46,7 +49,7 @@ public class StaffController { * @author zhaoqifeng */ @PostMapping("stafflist") - public Result> getStaffList(StaffsInAgencyFromDTO fromDTO){ + public Result> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO){ return staffService.getStaffList(fromDTO); } @@ -58,7 +61,7 @@ public class StaffController { * @return Result */ @PostMapping("rolelist") - public Result addStaffInit(StaffInfoFromDTO fromDTO){ + public Result addStaffInit(@RequestBody StaffInfoFromDTO fromDTO){ return staffService.addStaffInit(fromDTO); } @@ -69,7 +72,7 @@ public class StaffController { * @return Result */ @PostMapping("editstaffinit") - public Result editStaffInit(StaffInfoFromDTO fromDTO){ + public Result editStaffInit(@RequestBody StaffInfoFromDTO fromDTO){ return staffService.editStaffInit(fromDTO); } @@ -80,8 +83,8 @@ public class StaffController { * @return Result */ @PostMapping("addstaff") - public Result addStaff(StaffSubmitFromDTO fromDTO){ - return staffService.addStaff(fromDTO); + public Result addStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){ + return staffService.addStaff(tokenDto, fromDTO); } /** @@ -91,8 +94,8 @@ public class StaffController { * @return Result */ @PostMapping("editstaff") - public Result editStaff(StaffSubmitFromDTO fromDTO){ - return staffService.editStaff(fromDTO); + public Result editStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){ + return staffService.editStaff(tokenDto, fromDTO); } /** @@ -102,7 +105,7 @@ public class StaffController { * @return Result */ @PostMapping("staffdetail") - public Result getStaffDetail(StaffInfoFromDTO fromDTO){ + public Result getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO){ return staffService.getStaffDetail(fromDTO); } @@ -113,7 +116,7 @@ public class StaffController { * @return Result */ @PostMapping("disabledstaff") - public Result disabledStaff(StaffInfoFromDTO fromDTO){ + public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){ return staffService.disabledStaff(fromDTO); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 5ba8ee81f1..98d20c5939 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -7,9 +7,13 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.DepartmentInStaffFormDTO; +import com.epmet.dto.form.StaffInfoFromDTO; +import com.epmet.dto.form.StaffSubmitFromDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; @@ -34,7 +38,7 @@ public interface EpmetUserFeignClient { * @date 2020/4/22 10:05 **/ @PostMapping(value = "/epmetuser/customerstaff/getstaffinfobyuserid") - Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO); + Result getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO); @PostMapping("/epmetuser/customerstaff/selectstaffgridlistbyuserid") Result> getStaffGridList(@RequestBody List customerStaffGridDTOS); @@ -50,6 +54,67 @@ public interface EpmetUserFeignClient { @PostMapping(value = "/epmetuser/customerstaff/selectgridstaffcountbyuserid") Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO); + /** + * 工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("/epmetuser/customerstaff/stafflist") + Result> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO); + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/rolelist") + Result addStaffInit(@RequestBody StaffInfoFromDTO fromDTO); + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/editstaffinit") + Result editStaffInit(@RequestBody StaffInfoFromDTO fromDTO); + + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/addstaff") + Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO); + + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/editstaff") + Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO); + + /** + * 人员详情 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/staffdetail") + Result getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO); + + /** + * 人员禁用 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/disabledstaff") + Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO); + /** * @param departmentInStaffFormDTO * @return diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index e36abef073..0177e9a6bc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -7,10 +7,14 @@ import com.epmet.dto.*; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.StaffInfoFromDTO; +import com.epmet.dto.form.StaffSubmitFromDTO; import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; @@ -46,4 +50,39 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getDepartmentStaffList", departmentInStaffFormDTO); } + + @Override + public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "StaffsInAgencyFromDTO", fromDTO); + } + + @Override + public Result addStaffInit(StaffInfoFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaffInit", fromDTO); + } + + @Override + public Result editStaffInit(StaffInfoFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaffInit", fromDTO); + } + + @Override + public Result addStaff(StaffSubmitFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaff", fromDTO); + } + + @Override + public Result editStaff(StaffSubmitFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaff", fromDTO); + } + + @Override + public Result getStaffDetail(StaffInfoFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffDetail", fromDTO); + } + + @Override + public Result disabledStaff(StaffInfoFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "disabledStaff", fromDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java index ba5f227b95..e11e8edecb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -1,5 +1,6 @@ package com.epmet.service; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.StaffInfoFromDTO; import com.epmet.dto.form.StaffSubmitFromDTO; @@ -58,7 +59,7 @@ public interface StaffService { * @param fromDTO 参数 * @return Result */ - Result addStaff(StaffSubmitFromDTO fromDTO); + Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO); /** * 人员编辑 @@ -66,7 +67,7 @@ public interface StaffService { * @param fromDTO 参数 * @return Result */ - Result editStaff(StaffSubmitFromDTO fromDTO); + Result editStaff(TokenDto tokenDto,StaffSubmitFromDTO fromDTO); /** * 人员详情 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index 3ef22a3cf6..db4e263508 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.service.impl; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.form.StaffInfoFromDTO; @@ -36,6 +37,7 @@ public class StaffServiceImpl implements StaffService { private CustomerAgencyService customerAgencyService; @Autowired private CustomerStaffAgencyService customerStaffAgencyService; + @Override public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO(); @@ -51,7 +53,7 @@ public class StaffServiceImpl implements StaffService { List staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); fromDTO.setStaffList(staffIds); //获取用户信息 - Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); + Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); resultDTO.setStaffList(staffInfoListResult.getData()); return new Result().ok(resultDTO); } @@ -69,37 +71,54 @@ public class StaffServiceImpl implements StaffService { List staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); fromDTO.setStaffList(staffIds); //获取用户列表 - Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); + Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); return null; } @Override public Result addStaffInit(StaffInfoFromDTO fromDTO) { - return null; + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + return epmetUserFeignClient.addStaffInit(fromDTO); } @Override public Result editStaffInit(StaffInfoFromDTO fromDTO) { - return null; + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + return epmetUserFeignClient.editStaffInit(fromDTO); } @Override - public Result addStaff(StaffSubmitFromDTO fromDTO) { - return null; + public Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) { + fromDTO.setApp(tokenDto.getApp()); + fromDTO.setClient(tokenDto.getClient()); + Result result = epmetUserFeignClient.addStaff(fromDTO); + //机关总人数加一 + if (result.success()) { + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1); + customerAgencyService.updateById(customerAgencyEntity); + } + return new Result(); } @Override - public Result editStaff(StaffSubmitFromDTO fromDTO) { - return null; + public Result editStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) { + fromDTO.setApp(tokenDto.getApp()); + fromDTO.setClient(tokenDto.getClient()); + return epmetUserFeignClient.editStaff(fromDTO); } @Override public Result getStaffDetail(StaffInfoFromDTO fromDTO) { - return null; + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + return epmetUserFeignClient.getStaffDetail(fromDTO); } @Override public Result disabledStaff(StaffInfoFromDTO fromDTO) { - return null; + return epmetUserFeignClient.disabledStaff(fromDTO); } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java new file mode 100644 index 0000000000..f823247843 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java @@ -0,0 +1,34 @@ +package com.epmet.constant; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/24 15:42 + */ +public interface CustomerStaffConstant { + + /** + * 专职 + */ + String FULL_TIME ="fulltime"; + /** + * 兼职 + */ + String PART_TIME ="parttime"; + /** + * 已激活 + */ + String INACTIVE ="inactive"; + /** + * 未激活 + */ + String ACTIVE ="active"; + /** + * 已禁用 + */ + String DISABLED ="disabled"; + /** + * 未禁用 + */ + String ENABLE ="enable"; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index 7daee8f457..f1ed7bd6ba 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -26,15 +26,11 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.*; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.CustomerStaffFormDTO; -import com.epmet.dto.form.DepartmentInStaffFormDTO; -import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; import org.springframework.beans.factory.annotation.Autowired; @@ -145,17 +141,22 @@ public class CustomerStaffController { * @date 2020/4/22 10:05 **/ @PostMapping(value = "getstaffinfobyuserid") - public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + public Result getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO) { return customerStaffService.getCustomerStaffInfoByUserId(formDTO); } + @PostMapping(value = "selectgridstaffcountbyuserid") + public Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO){ + return customerStaffService.selectGridStaffCountByUserId(userIdDTO); + } + /** * 组织首页-工作人员列表 * @param fromDTO * @return */ @PostMapping("staffsinagency") - public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + public Result> getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) { return customerStaffService.getStaffInfoForHome(fromDTO); } @@ -165,13 +166,74 @@ public class CustomerStaffController { * @return */ @PostMapping("stafflist") - public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + public Result> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO) { return customerStaffService.getStaffList(fromDTO); } - @PostMapping(value = "selectgridstaffcountbyuserid") - public Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO){ - return customerStaffService.selectGridStaffCountByUserId(userIdDTO); + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("rolelist") + public Result addStaffInit(@RequestBody StaffInfoFromDTO fromDTO){ + return customerStaffService.addStaffInit(fromDTO); + } + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("editstaffinit") + public Result editStaffInit(@RequestBody StaffInfoFromDTO fromDTO){ + return customerStaffService.editStaffInit(fromDTO); + } + + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("addstaff") + public Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO){ + return customerStaffService.addStaff(fromDTO); + } + + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("editstaff") + public Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO){ + return customerStaffService.editStaff(fromDTO); + } + + /** + * 人员详情 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("staffdetail") + public Result getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO){ + return customerStaffService.getStaffDetail(fromDTO); + } + + /** + * 人员禁用 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("disabledstaff") + public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){ + return customerStaffService.disabledStaff(fromDTO); } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index 309068b1c8..f1aaee18e7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -39,5 +39,13 @@ public interface StaffRoleDao extends BaseDao { * @param orgId * @return */ + List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + + /** + * 删除工作人员权限 + * @param dto + * @return + */ + boolean delStaffRoles(StaffRoleDTO dto); List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java index f4f15edf0c..88742d7400 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java @@ -101,4 +101,10 @@ public interface StaffRoleService extends BaseService { * @return */ List listStaffsInRole(String roleKey, String orgId); + + /** + * 清空工作人员权限 + * @param dto + */ + void clearStaffRoles(StaffRoleDTO dto); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index baac7bcde8..7621320bb7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerStaffConstant; import com.epmet.constant.UserConstant; import com.epmet.constant.UserRoleConstant; import com.epmet.dao.CustomerStaffDao; @@ -49,9 +50,13 @@ import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.dto.result.StaffRoleResultDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.GovStaffRoleEntity; +import com.epmet.entity.StaffRoleEntity; +import com.epmet.entity.UserEntity; import com.epmet.redis.CustomerStaffRedis; import com.epmet.service.CustomerStaffService; import com.epmet.service.GovStaffRoleService; +import com.epmet.service.StaffRoleService; +import com.epmet.service.UserService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -79,7 +84,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -240,23 +248,94 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(userEntity.getId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleService.insert(staffRoleEntity); + }); + + return new Result(); } @Override + @Transactional(rollbackFor = Exception.class) public Result editStaff(StaffSubmitFromDTO fromDTO) { - return null; + CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); + //Customer_Staff表插入数据 + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setRealName(fromDTO.getName()); + staffEntity.setMobile(fromDTO.getMobile()); + staffEntity.setGender(fromDTO.getGender()); + staffEntity.setWorkType(fromDTO.getWorkType()); + baseDao.updateById(staffEntity); + + //清空权限关联 + StaffRoleDTO staffRoleDTO = new StaffRoleDTO(); + staffRoleDTO.setStaffId(fromDTO.getStaffId()); + staffRoleDTO.setOrgId(fromDTO.getAgencyId()); + staffRoleService.clearStaffRoles(staffRoleDTO); + //重新添加角色关联 + fromDTO.getRoles().forEach(role -> { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(fromDTO.getStaffId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleService.insert(staffRoleEntity); + }); + return new Result(); } @Override public Result getStaffDetail(StaffInfoFromDTO fromDTO) { - return null; + StaffDetailResultDTO resultDTO = new StaffDetailResultDTO(); + //获取工作人员信息 + CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); + resultDTO.setStaffId(customerStaffDTO.getUserId()); + resultDTO.setName(customerStaffDTO.getRealName()); + resultDTO.setMobile(customerStaffDTO.getMobile()); + resultDTO.setHeadPhoto(customerStaffDTO.getHeadPhoto()); + resultDTO.setGender(customerStaffDTO.getGender()); + resultDTO.setActiveFlag(customerStaffDTO.getActiveFlag()); + resultDTO.setActiveTime(customerStaffDTO.getActiveTime()); + resultDTO.setEnableFlag(customerStaffDTO.getEnableFlag()); + + //获取工作人员角色 + List staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId()); + List roles = staffRoles.stream().map(GovStaffRoleEntity::getRoleName).collect(Collectors.toList()); + resultDTO.setRoles(roles); + return new Result().ok(resultDTO); } @Override public Result disabledStaff(StaffInfoFromDTO fromDTO) { - return null; + CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setEnableFlag(CustomerStaffConstant.DISABLED); + baseDao.updateById(staffEntity); + return new Result(); } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index db7d154b22..0a9d7ce90d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -114,4 +114,10 @@ public class StaffRoleServiceImpl extends BaseServiceImpl + + update + staff_role + set DEL_FLAG = '1' + where STAFF_ID = #{staffId} + and ORG_ID = #{orgId} + and DEL_FLAG = '0' + From bc851c793f0476fd72c84578d87a27088012da5f Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 24 Apr 2020 17:12:14 +0800 Subject: [PATCH 24/26] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dao/StaffRoleDao.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index f1aaee18e7..6d65865681 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.StaffRoleEntity; import org.apache.ibatis.annotations.Mapper; @@ -39,7 +40,7 @@ public interface StaffRoleDao extends BaseDao { * @param orgId * @return */ - List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); /** * 删除工作人员权限 @@ -47,5 +48,5 @@ public interface StaffRoleDao extends BaseDao { * @return */ boolean delStaffRoles(StaffRoleDTO dto); - List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + } \ No newline at end of file From c49f8d217c02e37b333ca79acaeb51813184bf9a Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 17:59:40 +0800 Subject: [PATCH 25/26] =?UTF-8?q?=E6=94=BF=E5=BA=9C=E7=AB=AF-=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/feign/EpmetUserFeignClient.java | 4 -- .../EpmetUserFeignClientFallBack.java | 7 +-- .../impl/CustomerStaffServiceImpl.java | 47 +++++++------------ 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 98d20c5939..96f51e83ec 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -3,9 +3,6 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffInfoFromDTO; import com.epmet.dto.form.StaffSubmitFromDTO; @@ -16,7 +13,6 @@ import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 0177e9a6bc..273b6172d1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -4,15 +4,12 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffInfoFromDTO; import com.epmet.dto.form.StaffSubmitFromDTO; -import com.epmet.dto.form.DepartmentInStaffFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; -import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.feign.EpmetUserFeignClient; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 7621320bb7..fdd47f560d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -22,7 +22,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -31,23 +30,8 @@ import com.epmet.constant.UserConstant; import com.epmet.constant.UserRoleConstant; import com.epmet.dao.CustomerStaffDao; import com.epmet.dto.*; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.StaffRoleDTO; -import com.epmet.dto.form.CustomerStaffFormDTO; -import com.epmet.dto.form.StaffInfoFromDTO; -import com.epmet.dto.form.StaffSubmitFromDTO; -import com.epmet.dto.form.DepartmentInStaffFormDTO; -import com.epmet.dto.form.StaffRoleFormDTO; -import com.epmet.dto.form.StaffsInAgencyFromDTO; -import com.epmet.dto.result.StaffDetailResultDTO; -import com.epmet.dto.result.DepartInStaffListResultDTO; -import com.epmet.dto.result.StaffInfoResultDTO; -import com.epmet.dto.result.StaffInitResultDTO; -import com.epmet.dto.result.StaffRoleResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.StaffRoleEntity; @@ -351,16 +335,21 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl> getDepartmentStaffList(DepartmentInStaffFormDTO formDTO) { - //1:根据userId集合查询人员基本信息 - List list = baseDao.selectDepartmentStaffList(formDTO); - //2:根据部门Id查询部门下是领导角色的用户 - StaffRoleFormDTO staffRoleFormDTO = new StaffRoleFormDTO(); - staffRoleFormDTO.setOrgId(formDTO.getDepartmentId()); - staffRoleFormDTO.setRoleKey(UserRoleConstant.DEPT_LEADER); - - return new Result>().ok(list); - } + @Override + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO formDTO) { + //1:根据userId集合查询人员基本信息 + List staffList = baseDao.selectDepartmentStaffList(formDTO); + //2:根据部门Id查询部门下是领导角色的用户 + StaffRoleFormDTO staffRoleFormDTO = new StaffRoleFormDTO(); + staffRoleFormDTO.setOrgId(formDTO.getDepartmentId()); + staffRoleFormDTO.setRoleKey(UserRoleConstant.DEPT_LEADER); + List staffRoleDTOS = staffRoleService.listStaffsInRole(UserRoleConstant.DEPT_LEADER, formDTO.getDepartmentId()); + staffRoleDTOS.forEach(roleDto -> { + staffList.stream().filter(staffDto -> + roleDto.getStaffId().equals(staffDto.getStaffId())).findAny().ifPresent(result -> + result.setRoleName(roleDto.getRoleName())); + }); + return new Result>().ok(staffList); + } } \ No newline at end of file From 23939c2cd638cdf0f0c96403615c0f6520c6cc75 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 24 Apr 2020 18:04:50 +0800 Subject: [PATCH 26/26] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java index 57c2e2939d..7cb0a69b27 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java @@ -62,7 +62,7 @@ public class AddAgencyFormDTO implements Serializable { /** * 国家 */ - private String country; + private String district; /** * 省份