Browse Source

1.新增:客户详情接口

dev_shibei_match
wxz 5 years ago
parent
commit
4683157e5a
  1. 51
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultDTO.java
  2. 3
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java
  3. 33
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java
  4. 41
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java
  5. 19
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml
  6. 8
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java
  7. 17
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerDetailResultDTO.java
  8. 9
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerInfoDTO.java
  9. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ManagerDTO.java
  10. 13
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/RootAgencyDTO.java
  11. 14
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  12. 3
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  13. 80
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java
  14. 8
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java
  15. 3
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

51
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

3
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<RoleOperationResultDTO> roleOperationResultDTOS = roleOperationService.listOperationsByRoleId(roleId);
return new Result<List<RoleOperationResultDTO>>().ok(roleOperationResultDTOS);
}
}

33
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<RoleOperationDefaultEntity> {
}

41
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

19
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDefaultDao.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.RoleOperationDefaultDao">
<resultMap type="com.epmet.entity.RoleOperationDefaultEntity" id="roleOperationDefaultMap">
<result property="id" column="ID"/>
<result property="roleKey" column="ROLE_KEY"/>
<result property="operationKey" column="OPERATION_KEY"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

8
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;
}

17
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<ManagerDTO> managers = new ArrayList<>();
}

9
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;
}

12
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;
}

13
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;
}

14
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);
}
}

3
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<CustomerEntity> {
* @param form
*/
void addManager(CustomerManagerFormDTO form);
CustomerDetailResultDTO getcustomerDetail(String customerId);
}

80
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<CustomerDao, CustomerEn
}
}
@Override
public CustomerDetailResultDTO getcustomerDetail(String customerId) {
// 客户信息
CustomerEntity customer = baseDao.selectById(customerId);
CustomerInfoDTO customerInfo = ConvertUtils.sourceToTarget(customer, CustomerInfoDTO.class);
if (customerInfo == null) {
return new CustomerDetailResultDTO();
}
// 根级组织
Result<CustomerAgencyDTO> customerRootAgencyRst = govOrgFeignClient.getCustomerRootAgency(customerId);
if (!customerRootAgencyRst.success()) {
throw new RenException("查询客户详情:查询客户根级组织失败:".concat(customerRootAgencyRst.toString()));
}
CustomerAgencyDTO customerRootAgency = customerRootAgencyRst.getData();
// 管理员
List<GovStaffRoleResultDTO> managers = new ArrayList<>();
if (customerRootAgency != null) {
StaffRoleFormDTO staffsInRoleForm = new StaffRoleFormDTO();
staffsInRoleForm.setOrgId(customerRootAgency.getId());
staffsInRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_MANAGER);
Result<List<GovStaffRoleResultDTO>> 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<GovStaffRoleResultDTO> 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

8
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;
}

3
epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

@ -27,10 +27,11 @@
<!--查询具有某角色的staff列表-->
<select id="listStaffIdsByRoleKeyAndOrgId" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT sr.STAFF_ID, sr.ROLE_ID, r.ROLE_NAME, r.ROLE_KEY
SELECT sr.STAFF_ID, sr.ROLE_ID, r.ROLE_NAME, r.ROLE_KEY, s.REAL_NAME, s.MOBILE, s.GENDER
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )
INNER JOIN customer_staff s ON (sr.STAFF_ID = s.USER_ID)
WHERE
r.ROLE_KEY = #{roleKey}
AND sr.ORG_ID = #{orgId}

Loading…
Cancel
Save