From 036641a77af53b9cc1ded26dbfe89554454804ca Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 21 May 2020 20:34:12 +0800 Subject: [PATCH 1/9] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AE=A2=E6=88=B7=202.=E6=96=B0=E5=A2=9E=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7=E6=A0=B9=E7=BA=A7=E7=BB=84?= =?UTF-8?q?=E7=BB=87=203.=E6=96=B0=E5=A2=9E=EF=BC=9A=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=9A=84=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 7 +- .../epmet/service/impl/AccessServiceImpl.java | 6 ++ .../epmet/dto/form/AddRootAgencyFormDTO.java | 90 +++++++++++++++++++ .../epmet/controller/AgencyController.java | 15 ++++ .../com/epmet/controller/StaffController.java | 6 +- .../java/com/epmet/service/AgencyService.java | 2 + .../java/com/epmet/service/StaffService.java | 2 +- .../epmet/service/impl/AgencyServiceImpl.java | 19 ++++ .../epmet/service/impl/StaffServiceImpl.java | 6 +- .../main/java/com/epmet/dto/CustomerDTO.java | 9 +- .../com/epmet/dto/form/CustomerFormDTO.java | 19 +++- .../dto/form/CustomerManagerFormDTO.java | 38 ++++++++ .../epmet/controller/CustomerController.java | 53 +++++++++++ .../main/java/com/epmet/dao/CustomerDao.java | 7 ++ .../java/com/epmet/entity/CustomerEntity.java | 13 ++- .../com/epmet/feign/EpmetUserFeignClient.java | 21 ++++- .../com/epmet/feign/GovOrgFeignClient.java | 44 ++++++++- .../EpmetUserFeignClientFallBack.java | 12 +++ .../fallback/GovOrgFeignClientFallBack.java | 24 +++++ .../com/epmet/service/CustomerService.java | 15 ++++ .../service/impl/CustomerServiceImpl.java | 90 ++++++++++++++++++- .../src/main/resources/mapper/CustomerDao.xml | 7 ++ .../com/epmet/constant/RoleKeyConstants.java | 17 ++++ .../java/com/epmet/constant/UserWorkType.java | 8 ++ .../epmet/dto/form/CustomerRoleFormDTO.java | 18 ++++ .../dto/result/GovStaffRoleTemplateDTO.java | 86 ++++++++++++++++++ .../epmet/controller/StaffRoleController.java | 30 ++++++- .../java/com/epmet/dao/GovStaffRoleDao.java | 8 ++ .../epmet/dao/GovStaffRoleTemplateDao.java | 41 +++++++++ .../entity/GovStaffRoleTemplateEntity.java | 56 ++++++++++++ .../epmet/service/GovStaffRoleService.java | 14 +++ .../service/impl/GovStaffRoleServiceImpl.java | 25 ++++++ .../service/impl/StaffRoleServiceImpl.java | 6 ++ .../main/resources/mapper/GovStaffRoleDao.xml | 9 ++ .../mapper/GovStaffRoleTemplateDao.xml | 27 ++++++ 35 files changed, 828 insertions(+), 22 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddRootAgencyFormDTO.java create mode 100644 epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerManagerFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/constant/RoleKeyConstants.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/constant/UserWorkType.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerRoleFormDTO.java create mode 100755 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java create mode 100755 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java create mode 100755 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.java create mode 100755 epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml 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 243367637a..dbe9e88573 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 @@ -48,7 +48,12 @@ public enum EpmetErrorCode { PROJECT_IS_CLOSED(8601,"项目已结案"), // 该错误不会提示给前端,只是后端传输错误信息用。 - ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"); + ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), + OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR(8702, "添加客户根级组织失败"), + OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS(8703, "添加客户根级组织失败,根级组织已存在"), + OPER_CUSTOMER_EXISTS(8704, "客户已存在"), + OPER_ADD_CUSTOMER_ERROR(8705, "新增客户失败"), + OPER_ADD_CUSTOMER_MANAGER_ERROR(8706, "新增客户管理员失败"); private int code; private String msg; 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 28c9535f83..b5ec4bd689 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 @@ -2,6 +2,7 @@ package com.epmet.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.epmet.bean.OpeScopeFilterResultBean; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.OpeScopeConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -122,6 +123,11 @@ public class AccessServiceImpl implements AccessService { @Override public Boolean hasPermission(String operationKey, String userId, String app, String client) { + if (!AppClientConstant.APP_GOV.equals(app)) { + // 如果不是gov,那么不判断权限,放行 + return true; + } + GovTokenDto userDetails = getUserDetails(app, client, userId); if (userDetails == null) { return false; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddRootAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddRootAgencyFormDTO.java new file mode 100644 index 0000000000..d4fffc6ef3 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddRootAgencyFormDTO.java @@ -0,0 +1,90 @@ +/** + * 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 org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 添加组织-接口入参 + * + * @author sun + */ +@Data +public class AddRootAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + //=====分组校验======== + public interface AddRootAgencyGroup {} + + /** + * 客户ID + */ + @NotBlank(message = "客户ID不能为空", groups = AddRootAgencyGroup.class) + private String customerId; + + /** + * 机构组织名称 + */ + @NotBlank(message = "组织名称不能为空" , groups = AddRootAgencyGroup.class) + @Length(max=50,message = "机构名称不能超过50个字" , groups = AddRootAgencyGroup.class) + private String agencyName; + + /** + * 机关级别(社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + @NotBlank(message = "机关级别不能为空" , groups = AddRootAgencyGroup.class) + @Length(max=30,message = "机关类别不能超过30个字" , groups = AddRootAgencyGroup.class) + private String level; + + /** + * 地区编码 + */ + @NotBlank(message = "地区编码不能为空", groups = AddRootAgencyGroup.class) + @Length(max=10,message = "地区编码不能超过10位", groups = AddRootAgencyGroup.class) + private String areaCode; + + /** + * 省份 + */ + @NotBlank(message = "省级机关名称不能为空", groups = AddRootAgencyGroup.class) + @Length(max=30,message = "省级机关名称不能超过30个字", groups = AddRootAgencyGroup.class) + private String province; + + /** + * 城市 + */ + @Length(max=30,message = "市级机关名称不能超过30个字", groups = AddRootAgencyGroup.class) + private String city; + + /** + * 区县 + */ + @Length(max=30,message = "区县级机关名称不能超过30个字", groups = AddRootAgencyGroup.class) + private String district; + +} \ 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 babbdf49b9..a5c6f56580 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 @@ -38,6 +38,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.xml.validation.Validator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -81,6 +82,20 @@ public class AgencyController { return agencyService.addAgency(formDTO); } + /** + * 添加根级组织 + * @param form + * @return + */ + @PostMapping("addrootagency") + public Result> addRootAgency(@RequestBody AddRootAgencyFormDTO form) { + ValidatorUtils.validateEntity(form, AddRootAgencyFormDTO.AddRootAgencyGroup.class); + String agencyId = agencyService.addRootAgency(form); + HashMap resultMap = new HashMap<>(); + resultMap.put("agencyId", agencyId); + return new Result>().ok(resultMap); + } + /** * @param formDTO * @return 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 72d682688d..fa441eb40b 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 @@ -87,9 +87,11 @@ public class StaffController { */ @PostMapping("addstaff") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE) - public Result addStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){ + public Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO){ + fromDTO.setApp("gov"); + fromDTO.setClient("wxmp"); ValidatorUtils.validateEntity(fromDTO); - return staffService.addStaff(tokenDto, fromDTO); + return staffService.addStaff(fromDTO); } /** 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 6ebd81f812..a3cf56ec89 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 @@ -97,4 +97,6 @@ public interface AgencyService { * @param customerId */ CustomerAgencyDTO getCustomerRootAgency(String customerId); + + String addRootAgency(AddRootAgencyFormDTO form); } \ 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 index 5f36f85c12..d30549e58f 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 @@ -56,7 +56,7 @@ public interface StaffService { * @param fromDTO 参数 * @return Result */ - Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO); + Result addStaff(StaffSubmitFromDTO fromDTO); /** * 人员编辑 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 f5f97eea0d..46b5bc90d1 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 @@ -254,4 +254,23 @@ public class AgencyServiceImpl implements AgencyService { public CustomerAgencyDTO getCustomerRootAgency(String customerId) { return customerAgencyDao.getCustomerRootAgency(customerId); } + + @Override + public String addRootAgency(AddRootAgencyFormDTO form) { + + CustomerAgencyDTO rootAgencyExists = customerAgencyDao.getCustomerRootAgency(form.getCustomerId()); + if (rootAgencyExists != null) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_EXISTS.getCode()); + } + + CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(form, CustomerAgencyEntity.class); + entity.setAllParentName(""); + entity.setOrganizationName(form.getAgencyName()); + entity.setPids("0"); + entity.setPid("0"); + entity.setTotalUser(0); + entity.setCustomerId(form.getCustomerId()); + customerAgencyDao.insert(entity); + return entity.getId(); + } } \ 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 index 6db7038395..aa3d328a57 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 @@ -101,10 +101,10 @@ public class StaffServiceImpl implements StaffService { @Override @Transactional(rollbackFor = Exception.class) - public Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) { + public Result addStaff(StaffSubmitFromDTO fromDTO) { CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); - fromDTO.setApp(tokenDto.getApp()); - fromDTO.setClient(tokenDto.getClient()); + //fromDTO.setApp(tokenDto.getApp()); + //fromDTO.setClient(tokenDto.getClient()); fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); Result result = epmetUserFeignClient.addStaff(fromDTO); diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerDTO.java index f2f9c61891..bd9ba0afa3 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerDTO.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerDTO.java @@ -74,9 +74,14 @@ public class CustomerDTO implements Serializable { private String customerPassword; /** - * 客户组织级别:0.省级,1市级,2.区县级,3.乡镇街道级 字典表key:organizationlevel + * 客户组织级别:机关级别 + * (社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) */ - private Integer organizationLevel; + private String organizationLevel; /** * 删除标识:0.未删除 1.已删除 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 index b4fbbeff49..3d0c210087 100644 --- 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 @@ -2,6 +2,7 @@ package com.epmet.dto.form; import lombok.Data; +import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.List; @@ -12,9 +13,25 @@ import java.util.List; */ @Data public class CustomerFormDTO implements Serializable { + + public interface AddCustomerGroup { + } + /** * 客户id集合 - * */ + */ private List customerIdList; + + /** + * 客户名称 + */ + @NotBlank(message = "客户名称不能为空", groups = {AddCustomerGroup.class}) + private String customerName; + + /** + * 组织级别 + */ + @NotBlank(message = "客户的级别", groups = {AddCustomerGroup.class}) + private String organizationLevel; } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerManagerFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerManagerFormDTO.java new file mode 100644 index 0000000000..8cc2b660cb --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerManagerFormDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * { + * "customerId": "100824", + * "realName": "XF9wxEFMfi", + * "gender": "Vxa8GNrMfb", + * "mobile": "54RyjPWtwh", + * "agencyId": "101259" + * } + */ +@Data +public class CustomerManagerFormDTO { + + public interface AddManagerGroup {} + + @NotBlank(message = "客户ID不能为空", groups = { AddManagerGroup.class }) + private String customerId; + + @NotBlank(message = "管理员名字不能为空", groups = { AddManagerGroup.class }) + private String realName; + + @NotNull(message = "管理员性别不能为空", groups = { AddManagerGroup.class }) + private Integer gender; + + @NotBlank(message = "管理员手机号不能为空", groups = { AddManagerGroup.class }) + private String mobile; + + // 根据customerId查询rootAgency即可获得 + //@NotBlank(message = "管理员所属组织ID不能为空", groups = { AddManagerGroup.class }) + //private String agencyId; + +} 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 1605fd6c80..5132a84c38 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 @@ -17,6 +17,8 @@ package com.epmet.controller; +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.ExcelUtils; import com.epmet.commons.tools.utils.Result; @@ -26,16 +28,22 @@ 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.AddRootAgencyFormDTO; import com.epmet.dto.form.CustomerFormDTO; +import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; +import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.CustomerService; +import org.apache.ibatis.mapping.ResultMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.xml.validation.Validator; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,6 +62,9 @@ public class CustomerController { @Autowired private CustomerService customerService; + @Autowired + private GovOrgFeignClient govOrgFeignClient; + @GetMapping("page") public Result> page(@RequestParam Map params) { PageData page = customerService.page(params); @@ -156,4 +167,46 @@ public class CustomerController { public Result> queryCustomerList(@RequestBody CustomerFormDTO formDTO) { return customerService.queryCustomerList(formDTO); } + + /** + * 添加客户 + * @param form + * @return + */ + @PostMapping("add") + public Result> addCustomer(@RequestBody CustomerFormDTO form) { + ValidatorUtils.validateEntity(form, CustomerFormDTO.AddCustomerGroup.class); + String customerId = customerService.addCustomer(form.getCustomerName(), form.getOrganizationLevel()); + Map resultmap = new HashMap<>(); + resultmap.put("customerId", customerId); + return new Result>().ok(resultmap); + } + + /** + * 添加客户根级组织 + * @param form + * @return + */ + @PostMapping("addrootagency") + public Result> addRootAgency(@RequestBody AddRootAgencyFormDTO form) { + Result> result = govOrgFeignClient.addRootAgency(form); + if (!result.success()) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR.getCode(), + EpmetErrorCode.OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR.getMsg().concat(",错误信息:").concat(result.getMsg())); + } + return result; + } + + /** + * + * 添加管理员 + * @param form + * @return + */ + @PostMapping("addmanager") + public Result addManager(@RequestBody CustomerManagerFormDTO form) { + ValidatorUtils.validateEntity(form, CustomerManagerFormDTO.AddManagerGroup.class); + customerService.addManager(form); + return new Result(); + } } 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 6a958cc6d2..2d15ea214a 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 @@ -51,4 +51,11 @@ public interface CustomerDao extends BaseDao { * @Date 2020/4/24 9:21 **/ List selectListByIds(@Param("customerIdList") List customerIdList); + + /** + * 根据名字查询客户 + * @param customerName + * @return + */ + CustomerDTO selectByCustomerName(@Param("customerName") String customerName); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java index 76df0cdd70..41ec253b2c 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerEntity.java @@ -73,9 +73,14 @@ public class CustomerEntity extends BaseEpmetEntity { */ private String customerPassword; - /** - * 客户组织级别:0.省级,1市级,2.区县级,3.乡镇街道级 字典表key:organizationlevel - */ - private Integer organizationLevel; + /** + * 客户组织级别:机关级别 + * (社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + private String organizationLevel; } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 047782a221..4e4b1633b6 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -2,10 +2,13 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.CustomerRoleFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; 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; @@ -13,7 +16,7 @@ import java.util.List; import java.util.Map; //, url = "localhost:8087" -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class) +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class, url = "localhost:8087") public interface EpmetUserFeignClient { /** @@ -32,4 +35,20 @@ public interface EpmetUserFeignClient { */ @PostMapping("/epmetuser/staffrole/staffsinroleoforgs") Result>> getStaffsInRoleOfOrgs(@RequestBody StaffRoleFormDTO staffRoleFormDTO); + + /** + * 为客户初始化政府端工作人员角色 + * @param customerId + * @return + */ + @PostMapping("/epmetuser/staffrole/initrolesforcustomer/{customerId}") + Result initGovStaffRolesForCustomer(@PathVariable String customerId); + + /** + * 根据客户ID和角色key查询角色信息 + * @param form + * @return + */ + @PostMapping("/epmetuser/staffrole/roleofcustomer") + Result getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 10a05d5547..9a09647ad2 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -1,10 +1,20 @@ package com.epmet.feign; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.AddAgencyFormDTO; +import com.epmet.dto.form.AddRootAgencyFormDTO; +import com.epmet.dto.form.StaffSubmitFromDTO; +import com.epmet.dto.result.AddAgencyResultDTO; import com.epmet.feign.fallback.GovOrgFeignClientFallBack; +import oracle.jdbc.proxy.annotation.Post; 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; @@ -12,9 +22,17 @@ import java.util.List; import java.util.Map; //, url = "localhost:8092" -@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url = "localhost:8092") public interface GovOrgFeignClient { + /** + * 查询客户根级组织 + * @param customerId + * @return + */ + @PostMapping("/gov/org/agency/customerrootagency/{customerId}") + Result getCustomerRootAgency(@PathVariable String customerId); + /** * 批量查询客户根级组织 * @param customerIds @@ -23,4 +41,28 @@ public interface GovOrgFeignClient { @PostMapping("/gov/org/agency/customerrootagencybatch") Result> getCustomerRootAgencyBatch(List customerIds); + /** + * 添加组织 + * @param formDTO + * @return + */ + @PostMapping("/gov/org/agency/addagency") + Result addAgency(@RequestBody AddAgencyFormDTO formDTO); + + /** + * 添加根级组织 + * @param form + * @return + */ + @PostMapping("/gov/org/agency/addrootagency") + Result> addRootAgency(@RequestBody AddRootAgencyFormDTO form); + + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/gov/org/staff/addstaff") + Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 4df7aedb61..5bd2671206 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -3,6 +3,8 @@ 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.GovStaffRoleDTO; +import com.epmet.dto.form.CustomerRoleFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.feign.EpmetUserFeignClient; @@ -22,4 +24,14 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result>> getStaffsInRoleOfOrgs(StaffRoleFormDTO staffRoleFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffsInRoleOfOrgs", staffRoleFormDTO); } + + @Override + public Result initGovStaffRolesForCustomer(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "initGovStaffRolesForCustomer", customerId); + } + + @Override + public Result getRoleOfCustomer(CustomerRoleFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRoleOfCustomer", form); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java index b24bc5a7f1..d88b87ce9f 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -4,6 +4,10 @@ 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.CustomerAgencyDTO; +import com.epmet.dto.form.AddAgencyFormDTO; +import com.epmet.dto.form.AddRootAgencyFormDTO; +import com.epmet.dto.form.StaffSubmitFromDTO; +import com.epmet.dto.result.AddAgencyResultDTO; import com.epmet.feign.GovOrgFeignClient; import org.springframework.stereotype.Component; @@ -13,8 +17,28 @@ import java.util.Map; @Component public class GovOrgFeignClientFallBack implements GovOrgFeignClient { + @Override + public Result getCustomerRootAgency(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCustomerRootAgency", customerId); + } + @Override public Result> getCustomerRootAgencyBatch(List customerIds) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCustomerRootAgencyBatch", customerIds); } + + @Override + public Result addAgency(AddAgencyFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "addAgency", formDTO); + } + + @Override + public Result> addRootAgency(AddRootAgencyFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "addRootAgency", form); + } + + @Override + public Result addStaff(StaffSubmitFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "addStaff", fromDTO); + } } 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 a50c87a138..03ec98b7b2 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 @@ -22,6 +22,7 @@ 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.form.CustomerManagerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -130,4 +131,18 @@ public interface CustomerService extends BaseService { * @Date 2020/4/24 9:13 **/ Result> queryCustomerList(CustomerFormDTO formDTO); + + /** + * 新增客户 + * @param customerName + * @param organizationLevel + * @return + */ + String addCustomer(String customerName, String organizationLevel); + + /** + * 添加管理员 + * @param form + */ + void addManager(CustomerManagerFormDTO form); } 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 708deb0894..33a9ee0781 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 @@ -20,15 +20,20 @@ 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.EpmetRoleKeyConstant; +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.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.RoleKeyConstants; +import com.epmet.constant.UserWorkType; import com.epmet.dao.CustomerDao; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerDTO; -import com.epmet.dto.form.CustomerFormDTO; -import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -197,4 +202,85 @@ public class CustomerServiceImpl extends BaseServiceImpl>().ok(customerDTOList); } + @Override + @Transactional + public String addCustomer(String customerName, String organizationLevel) { + + // 校验 + CustomerDTO customerExists = baseDao.selectByCustomerName(customerName); + if (customerExists != null) { + throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); + } + + // 1. 本地新增客户信息 + CustomerEntity customerEntity = new CustomerEntity(); + customerEntity.setCustomerName(customerName); + customerEntity.setTitle(""); + customerEntity.setOrganizationNumber(""); + customerEntity.setOrganizationImg(""); + customerEntity.setValidityTime(getValidityTime()); + customerEntity.setOrganizationLevel(organizationLevel); + int insert = baseDao.insert(customerEntity); + if (insert == 0) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode()); + } + + // 2. 给客户初始化角色列表 + Result initResult = epmetUserFeignClient.initGovStaffRolesForCustomer(customerEntity.getId()); + if (!initResult.success()) { + throw new RenException("客户新增:为客户初始化角色调用user服务失败:".concat(initResult.toString())); + } + + return customerEntity.getId(); + } + + @Override + public void addManager(CustomerManagerFormDTO form) { + + // 查询客户具有指定RoleKey的角色信息 + CustomerRoleFormDTO customerRoleForm = new CustomerRoleFormDTO(); + customerRoleForm.setCustomerId(form.getCustomerId()); + customerRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER); + Result getRoleResult = epmetUserFeignClient.getRoleOfCustomer(customerRoleForm); + if (!getRoleResult.success()) { + throw new RenException("查询客户具有指定RoleKey的角色信息失败:".concat(getRoleResult.toString())); + } + + if (getRoleResult.getData() == null) { + throw new RenException("未查询到客户具有指定RoleKey的角色信息:".concat(getRoleResult.toString())); + } + + // 查询客户根级组织 + Result customerRootAgencyResult = govOrgFeignClient.getCustomerRootAgency(form.getCustomerId()); + if (!customerRootAgencyResult.success()) { + throw new RenException("查询客户根级组织失败:".concat(getRoleResult.toString())); + } + + if (customerRootAgencyResult.getData() == null) { + throw new RenException("没有查询到客户根级组织,无法设置管理员:".concat(getRoleResult.toString())); + } + + StaffSubmitFromDTO staffSubmitFrom = new StaffSubmitFromDTO(); + staffSubmitFrom.setCustomerId(form.getCustomerId()); + staffSubmitFrom.setAgencyId(customerRootAgencyResult.getData().getId()); + staffSubmitFrom.setGender(form.getGender()); + staffSubmitFrom.setMobile(form.getMobile()); + staffSubmitFrom.setName(form.getRealName()); + staffSubmitFrom.setWorkType(UserWorkType.FULL_TIME); + staffSubmitFrom.setRoles(Arrays.asList(getRoleResult.getData().getId())); + Result result = govOrgFeignClient.addStaff(staffSubmitFrom); + if (!result.success()) { + throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_MANAGER_ERROR.getCode()); + } + } + + /** + * 获取客户的有效时长 + * @return + */ + private Date getValidityTime() { + int life = 3600 * 1000 * 24 * 365 * 10; + return new Date(new Date().getTime() + Long.valueOf(life)); + } + } 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 340883f472..6f16fec155 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 @@ -48,4 +48,11 @@ #{customerId} + + + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/RoleKeyConstants.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/RoleKeyConstants.java new file mode 100644 index 0000000000..1bc1e03a24 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/RoleKeyConstants.java @@ -0,0 +1,17 @@ +package com.epmet.constant; + +/** + * 角色key常量 + */ +public class RoleKeyConstants { + + public static final String ROLE_KEY_MANAGER = "manager"; + public static final String ROLE_KEY_PARTY_PRINCIPALS = "party_principals"; + public static final String ROLE_KEY_GRID_MANAGER = "grid_manager"; + public static final String ROLE_KEY_AGENCY_LEADER = "agency_leader"; + public static final String ROLE_KEY_GRID_PARTY_DIRECTOR = "grid_party_director"; + public static final String ROLE_KEY_DEPT_LEADER = "dept_leader"; + public static final String ROLE_KEY_STAFF = "staff"; + public static final String ROLE_KEY_GRID_MEMBER = "grid_member"; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/UserWorkType.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/UserWorkType.java new file mode 100644 index 0000000000..5eb25fce69 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/UserWorkType.java @@ -0,0 +1,8 @@ +package com.epmet.constant; + +public class UserWorkType { + + public static final String FULL_TIME="fulltime"; + public static final String PART_TIME="parttime"; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerRoleFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerRoleFormDTO.java new file mode 100644 index 0000000000..72a6c7d96b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerRoleFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class CustomerRoleFormDTO { + + public interface GetRoleByCustomerAndKey{} + + @NotBlank(message = "客户ID不能为空", groups = { GetRoleByCustomerAndKey.class }) + private String customerId; + + @NotBlank(message = "角色Key不能为空", groups = { GetRoleByCustomerAndKey.class }) + private String roleKey; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java new file mode 100755 index 0000000000..5427012aba --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleTemplateDTO.java @@ -0,0 +1,86 @@ +/** + * 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 java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 政府端角色模板表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Data +public class GovStaffRoleTemplateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 角色所属体系类型:org,dept,grid + */ + private String orgType; + + /** + * + */ + private Integer delFlag; + + /** + * + */ + private Integer revision; + + /** + * + */ + private String createdBy; + + /** + * + */ + private Date createdTime; + + /** + * + */ + private String updatedBy; + + /** + * + */ + private Date updatedTime; + +} \ 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 209e8fd251..7b9424076f 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 @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.CommonUserFormDTO; +import com.epmet.dto.form.CustomerRoleFormDTO; import com.epmet.dto.form.RolesUsersListFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; @@ -13,12 +14,10 @@ import com.epmet.dto.result.StaffRolesResultDTO; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; +import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.BeanUtils; 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 org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.HashMap; @@ -120,4 +119,27 @@ public class StaffRoleController { public Result> specificRolesStaffs(@RequestBody RolesUsersListFormDTO rolesUsersListFormDTO) { return staffRoleService.getSpecificRolesStaffs(rolesUsersListFormDTO); } + + /** + * 为客户初始化政府端工作人员角色 + * @param customerId + * @return + */ + @PostMapping("initrolesforcustomer/{customerId}") + public Result initGovStaffRolesForCustomer(@PathVariable String customerId) { + govStaffRoleService.initGovStaffRolesForCustomer(customerId); + return new Result(); + } + + /** + * 根据客户ID和角色key查询角色信息 + * @param form + * @return + */ + @PostMapping("roleofcustomer") + public Result getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form) { + ValidatorUtils.validateEntity(form, CustomerRoleFormDTO.GetRoleByCustomerAndKey.class); + GovStaffRoleDTO role = govStaffRoleService.getRoleByCustomerIdAndRoleKey(form.getCustomerId(), form.getRoleKey()); + return new Result().ok(role); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java index 3220c70604..907bb84ea1 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java @@ -48,4 +48,12 @@ public interface GovStaffRoleDao extends BaseDao { * @return */ List selectGovStaffRoleList(GovStaffRoleDTO params); + + /** + * 查询客户的指定roleKey的角色信息 + * @param customerId + * @param roleKey + * @return + */ + GovStaffRoleDTO getRoleByCustomerIdAndRoleKey(@Param("customerId") String customerId, @Param("roleKey") String roleKey); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java new file mode 100755 index 0000000000..4622b81f79 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleTemplateDao.java @@ -0,0 +1,41 @@ +/** + * 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.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.GovStaffRoleTemplateDTO; +import com.epmet.entity.GovStaffRoleTemplateEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 政府端角色模板表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Mapper +public interface GovStaffRoleTemplateDao extends BaseDao { + + /** + * 列出有效的角色字典 + * @return + */ + List listValidateRoles(); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.java new file mode 100755 index 0000000000..7e843810dc --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleTemplateEntity.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.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 政府端角色模板表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_staff_role_template") +public class GovStaffRoleTemplateEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 角色所属体系类型:org,dept,grid + */ + private String orgType; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java index 80b04fa5a6..d7985c8758 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.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.GovStaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.entity.GovStaffRoleEntity; import java.util.List; @@ -106,4 +107,17 @@ public interface GovStaffRoleService extends BaseService { * @return */ List getGovStaffRoleList(GovStaffRoleDTO dto); + + /** + * 为客户初始化角色列表 + * @param customerId + */ + void initGovStaffRolesForCustomer(String customerId); + + /** + * 根据客户ID和角色key查询角色信息 + * @param customerId + * @param roleKey + */ + GovStaffRoleDTO getRoleByCustomerIdAndRoleKey(String customerId, String roleKey); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java index cd26eaa0a4..6e0860f82e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java @@ -24,7 +24,9 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.GovStaffRoleDao; +import com.epmet.dao.GovStaffRoleTemplateDao; import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleTemplateDTO; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.redis.GovStaffRoleRedis; import com.epmet.service.GovStaffRoleService; @@ -49,6 +51,12 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -115,4 +123,21 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl getGovStaffRoleList(GovStaffRoleDTO dto) { return baseDao.selectGovStaffRoleList(dto); } + + @Override + @Transactional + public void initGovStaffRolesForCustomer(String customerId) { + List validRoles = govStaffRoleTemplateDao.listValidateRoles(); + for (GovStaffRoleTemplateDTO validRole : validRoles) { + GovStaffRoleEntity entity = ConvertUtils.sourceToTarget(validRole, GovStaffRoleEntity.class); + entity.setCustomerId(customerId); + entity.setId(null); + baseDao.insert(entity); + } + } + + @Override + public GovStaffRoleDTO getRoleByCustomerIdAndRoleKey(String customerId, String roleKey) { + return govStaffRoleDao.getRoleByCustomerIdAndRoleKey(customerId, roleKey); + } } \ 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 01a44db29a..a38188f700 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 @@ -27,12 +27,15 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.GovStaffRoleTemplateDao; import com.epmet.dao.StaffRoleDao; import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.RolesUsersListFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.dto.result.GovStaffRoleTemplateDTO; import com.epmet.dto.result.StaffRolesResultDTO; +import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.StaffRoleEntity; import com.epmet.redis.StaffRoleRedis; import com.epmet.service.StaffRoleService; @@ -58,6 +61,9 @@ public class StaffRoleServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( 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 d3de570592..4cd4ff5b2b 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 @@ -41,4 +41,13 @@ AND ORG_TYPE = 'agency' ORDER BY SORT ASC + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml new file mode 100755 index 0000000000..263d76beec --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleTemplateDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8d12001217a3e398a2920da95c8016d9490c36c5 Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 21 May 2020 20:35:33 +0800 Subject: [PATCH 2/9] =?UTF-8?q?1.=E6=BC=8F=E6=8E=89=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/feign/EpmetUserFeignClient.java | 2 +- .../src/main/java/com/epmet/feign/GovOrgFeignClient.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 4e4b1633b6..1942525951 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.Map; //, url = "localhost:8087" -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class, url = "localhost:8087") +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class) public interface EpmetUserFeignClient { /** diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 9a09647ad2..b35a29c1d5 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; //, url = "localhost:8092" -@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url = "localhost:8092") +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) public interface GovOrgFeignClient { /** From fdd93eb15024800217a24b7429d325e532f881ba Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 21 May 2020 21:04:19 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E5=8F=91=E5=B8=83=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi-partymember-server/deploy/docker-compose-dev.yml | 2 +- epmet-module/resi-partymember/resi-partymember-server/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-dev.yml b/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-dev.yml index f37e3e8913..4ed2656eec 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-dev.yml +++ b/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: resi-partymember-server: container_name: resi-partymember-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/resi-partymember-server:0.3.30 + image: 192.168.1.130:10080/epmet-cloud-dev/resi-partymember-server:0.3.31 ports: - "8096:8096" network_mode: host # 使用现有网络 diff --git a/epmet-module/resi-partymember/resi-partymember-server/pom.xml b/epmet-module/resi-partymember/resi-partymember-server/pom.xml index 2b0cd8cb8e..f2fb266285 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/pom.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.30 + 0.3.31 com.epmet resi-partymember From 648eb4c55a7e88b8aa2488abb5584152a79590e8 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 21 May 2020 21:05:42 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E5=8F=91=E5=B8=83=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi-partymember-server/deploy/docker-compose-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-test.yml b/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-test.yml index bcb31b4122..7d9151492e 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-test.yml +++ b/epmet-module/resi-partymember/resi-partymember-server/deploy/docker-compose-test.yml @@ -2,7 +2,7 @@ version: "3.7" services: resi-partymember-server: container_name: resi-partymember-server-test - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/resi-partymember-server:0.3.30 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/resi-partymember-server:0.3.31 ports: - "8096:8096" network_mode: host # 使用现有网络 From 4683157e5ae9f89cd9869c908fd631aaa4788fe3 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 22 May 2020 01:11:09 +0800 Subject: [PATCH 5/9] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/RoleOperationDefaultDTO.java | 51 ++++++++++++ .../com/epmet/controller/RoleController.java | 3 +- .../epmet/dao/RoleOperationDefaultDao.java | 33 ++++++++ .../entity/RoleOperationDefaultEntity.java | 41 ++++++++++ .../mapper/RoleOperationDefaultDao.xml | 19 +++++ .../com/epmet/dto/form/CustomerFormDTO.java | 8 +- .../dto/result/CustomerDetailResultDTO.java | 17 ++++ .../com/epmet/dto/result/CustomerInfoDTO.java | 9 +++ .../java/com/epmet/dto/result/ManagerDTO.java | 12 +++ .../com/epmet/dto/result/RootAgencyDTO.java | 13 +++ .../epmet/controller/CustomerController.java | 14 ++++ .../com/epmet/service/CustomerService.java | 3 + .../service/impl/CustomerServiceImpl.java | 80 ++++++++++++++++++- .../dto/result/GovStaffRoleResultDTO.java | 8 ++ .../main/resources/mapper/StaffRoleDao.xml | 3 +- 15 files changed, 307 insertions(+), 7 deletions(-) create mode 100755 epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultDTO.java create mode 100755 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java create mode 100755 epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java create mode 100755 epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml create mode 100644 epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerDetailResultDTO.java create mode 100644 epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerInfoDTO.java create mode 100644 epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ManagerDTO.java create mode 100644 epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/RootAgencyDTO.java diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultDTO.java new file mode 100755 index 0000000000..d39f405e29 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultDTO.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 java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 角色默认的可操作功能列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Data +public class RoleOperationDefaultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色KEY + */ + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java index 8e9778734b..0cf13fdfb8 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java @@ -3,6 +3,7 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.RoleOperationResultDTO; import com.epmet.service.RoleOperationService; +import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -28,6 +29,4 @@ public class RoleController { List roleOperationResultDTOS = roleOperationService.listOperationsByRoleId(roleId); return new Result>().ok(roleOperationResultDTOS); } - - } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java new file mode 100755 index 0000000000..0417991bb5 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java @@ -0,0 +1,33 @@ +/** + * 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.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.RoleOperationDefaultEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 角色默认的可操作功能列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Mapper +public interface RoleOperationDefaultDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java new file mode 100755 index 0000000000..b19c7e08e0 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java @@ -0,0 +1,41 @@ +/** + * 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.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +public class RoleOperationDefaultEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色KEY + */ + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml new file mode 100755 index 0000000000..d7d7532ca6 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 index 3d0c210087..daab4602dc 100644 --- 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 @@ -17,6 +17,9 @@ public class CustomerFormDTO implements Serializable { public interface AddCustomerGroup { } + public interface GetCustomerDetailGroup { + } + /** * 客户id集合 */ @@ -31,7 +34,10 @@ public class CustomerFormDTO implements Serializable { /** * 组织级别 */ - @NotBlank(message = "客户的级别", groups = {AddCustomerGroup.class}) + @NotBlank(message = "客户的组织级别", groups = {AddCustomerGroup.class}) private String organizationLevel; + + @NotBlank(message = "客户ID", groups = {GetCustomerDetailGroup.class}) + private String customerId; } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerDetailResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerDetailResultDTO.java new file mode 100644 index 0000000000..cb2730f9aa --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerDetailResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class CustomerDetailResultDTO { + + private RootAgencyDTO rootAgencyDTO; + + private CustomerInfoDTO customerInfoDTO; + + private List managers = new ArrayList<>(); + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerInfoDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerInfoDTO.java new file mode 100644 index 0000000000..6c2bd282bf --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerInfoDTO.java @@ -0,0 +1,9 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class CustomerInfoDTO { + private String customerName; + private String organizationLevel; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ManagerDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ManagerDTO.java new file mode 100644 index 0000000000..6b0cfb619d --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ManagerDTO.java @@ -0,0 +1,12 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class ManagerDTO { + + private String realName; + private String gender; + private String mobile; + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/RootAgencyDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/RootAgencyDTO.java new file mode 100644 index 0000000000..27a924084e --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/RootAgencyDTO.java @@ -0,0 +1,13 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class RootAgencyDTO { + private String agencyName; + private String level; + private String areaCode; + private String province; + private String city; + private String district; +} 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 5132a84c38..be507662b6 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 @@ -31,6 +31,7 @@ import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.AddRootAgencyFormDTO; import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; +import com.epmet.dto.result.CustomerDetailResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; import com.epmet.feign.GovOrgFeignClient; @@ -209,4 +210,17 @@ public class CustomerController { customerService.addManager(form); return new Result(); } + + /** + * + * 客户详情 + * @param form + * @return + */ + @PostMapping("detail") + public Result getCustomerDetail(@RequestBody CustomerFormDTO form) { + ValidatorUtils.validateEntity(form, CustomerFormDTO.GetCustomerDetailGroup.class); + CustomerDetailResultDTO customerDetailResultDto = customerService.getcustomerDetail(form.getCustomerId()); + return new Result().ok(customerDetailResultDto); + } } 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 03ec98b7b2..28b47d4af0 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 @@ -23,6 +23,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; +import com.epmet.dto.result.CustomerDetailResultDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -145,4 +146,6 @@ public interface CustomerService extends BaseService { * @param form */ void addManager(CustomerManagerFormDTO form); + + CustomerDetailResultDTO getcustomerDetail(String customerId); } 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 33a9ee0781..14f5ff4bcb 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 @@ -20,7 +20,6 @@ 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.EpmetRoleKeyConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -34,8 +33,7 @@ import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerDTO; import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.GovStaffRoleResultDTO; -import com.epmet.dto.result.ValidCustomerResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerEntity; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.GovOrgFeignClient; @@ -274,6 +272,82 @@ public class CustomerServiceImpl extends BaseServiceImpl customerRootAgencyRst = govOrgFeignClient.getCustomerRootAgency(customerId); + if (!customerRootAgencyRst.success()) { + throw new RenException("查询客户详情:查询客户根级组织失败:".concat(customerRootAgencyRst.toString())); + } + + CustomerAgencyDTO customerRootAgency = customerRootAgencyRst.getData(); + + // 管理员 + List managers = new ArrayList<>(); + if (customerRootAgency != null) { + StaffRoleFormDTO staffsInRoleForm = new StaffRoleFormDTO(); + staffsInRoleForm.setOrgId(customerRootAgency.getId()); + staffsInRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER); + Result> managersResult = epmetUserFeignClient.getStaffsInRole(staffsInRoleForm); + if (!managersResult.success()) { + throw new RenException("查询客户详情:查询客户管理员失败:".concat(managersResult.toString())); + } + managers = managersResult.getData(); + } + + + + return constructCustomerDetail(customerInfo, customerRootAgency, managers); + } + + /** + * 构造客户详情dto + * @param customerInfo + * @param customerRootAgency + * @param managers + * @return + */ + public CustomerDetailResultDTO constructCustomerDetail(CustomerInfoDTO customerInfo, + CustomerAgencyDTO customerRootAgency, + List managers) { + + CustomerDetailResultDTO customerDetail = new CustomerDetailResultDTO(); + // 构造管理员 + if (!CollectionUtils.isEmpty(managers)) { + for (GovStaffRoleResultDTO manager : managers) { + ManagerDTO managerDTO = new ManagerDTO(); + managerDTO.setRealName(manager.getRealName()); + managerDTO.setMobile(manager.getMobile()); + managerDTO.setGender(manager.getGender()); + customerDetail.getManagers().add(managerDTO); + } + } + + // 客户信息 + customerDetail.setCustomerInfoDTO(customerInfo); + + // 根级组织 + if (customerRootAgency != null) { + RootAgencyDTO rootAgencyDTO = new RootAgencyDTO(); + rootAgencyDTO.setAgencyName(customerRootAgency.getOrganizationName()); + rootAgencyDTO.setAreaCode(customerRootAgency.getAreaCode()); + rootAgencyDTO.setCity(customerRootAgency.getCity()); + rootAgencyDTO.setDistrict(customerRootAgency.getDistrict()); + rootAgencyDTO.setLevel(customerRootAgency.getLevel()); + rootAgencyDTO.setProvince(customerRootAgency.getProvince()); + customerDetail.setRootAgencyDTO(rootAgencyDTO); + } + return customerDetail; + } + /** * 获取客户的有效时长 * @return 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 index 6123f16677..51586242da 100644 --- 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 @@ -53,4 +53,12 @@ public class GovStaffRoleResultDTO implements Serializable { * 角色名称 */ private String roleName; + + /** + * 姓名 + */ + private String realName; + + private String mobile; + private String gender; } \ No newline at end of file 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 e7a2ce2fa9..808b7669e1 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 @@ -27,10 +27,11 @@