Browse Source

公众号服务-查询我的信息

dev_shibei_match
sunyuchao 5 years ago
parent
commit
c553699663
  1. 26
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java
  2. 53
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java
  3. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java
  4. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java
  5. 13
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java
  6. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java
  7. 17
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  8. 43
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  9. 15
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  10. 18
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml

26
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MyInfoFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author sun
* @Description 公众号-查询我的信息-接口入参
*/
@Data
public class MyInfoFormDTO implements Serializable {
private static final long serialVersionUID = -6547893374373422628L;
public interface AddUserInternalGroup {
}
/**
* 客户Id
*/
@NotBlank(message = "客户Id不能为空", groups = {MyInfoFormDTO.AddUserInternalGroup.class})
private String customerId;
}

53
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/MyInfoResultDTO.java

@ -0,0 +1,53 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author sun
* @Description 公众号-查询我的信息-接口返参
*/
@Data
public class MyInfoResultDTO implements Serializable {
private static final long serialVersionUID = 3253989119352850315L;
/**
* 客户Id
*/
private String customerId = "";
/**
* 组织名称
*/
private String agencyName = "";
/**
* 新增客户Id
*/
private String level = "";
/**
* 包含customerId的token
*/
private String province = "";
/**
* 新增客户Id
*/
private String city = "";
/**
* 包含customerId的token
*/
private String district = "";
/**
* 新增客户Id
*/
private Integer partyBranchNum;
/**
* 包含customerId的token
*/
private Integer resiAuthorization;
/**
* 新增客户Id
*/
private Integer workAuthorization;
}

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/PaConstant.java

@ -34,4 +34,19 @@ public interface PaConstant {
String RESI_CLIENT = "resi"; String RESI_CLIENT = "resi";
String WORK_CLIENT = "work"; String WORK_CLIENT = "work";
/**
* 查询客户组织信息失败
*/
String SELECT_AGENCY_EXCEPTION = "获取客户组织信息失败";
/**
* 查询客户小程序授权信息失败
*/
String CUSTOMER_MP_EXCEPTION = "获取客户小程序授权信息失败";
/**
* 客户小程序所属端key值
*/
String CLIENT_RESI = "resi";
String CLIENT_WORK = "work";
} }

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java

@ -6,9 +6,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.MyInfoFormDTO;
import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.service.*; import com.epmet.service.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -82,9 +84,9 @@ public class PaCustomerController {
* @Description 公众号-查询我的信息 * @Description 公众号-查询我的信息
**/ **/
@PostMapping("myinfo") @PostMapping("myinfo")
public Result<CreateAgencyResultDTO> myInfo(@LoginUser TokenDto tokenDTO, @RequestBody CreateAgencyFormDTO formDTO) { public Result<MyInfoResultDTO> myInfo(@LoginUser TokenDto tokenDTO, @RequestBody MyInfoFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, DefaultGroup.class); ValidatorUtils.validateEntity(formDTO, MyInfoFormDTO.AddUserInternalGroup.class);
return new Result<CreateAgencyResultDTO>().ok(paCustomerService.myInfo(formDTO)); return new Result<MyInfoResultDTO>().ok(paCustomerService.myInfo(formDTO));
} }

13
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java

@ -18,8 +18,12 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerMpDTO;
import com.epmet.entity.CustomerMpEntity; import com.epmet.entity.CustomerMpEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 客户小程序关系表 * 客户小程序关系表
@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface CustomerMpDao extends BaseDao<CustomerMpEntity> { public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
/**
* @param customerId
* @return
* @Author sun
* @Description 查询客户小程序授权结果信息
**/
List<CustomerMpDTO> selectByCustomerId(@Param("customerId") String customerId);
} }

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerAgencyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PaCustomerAgencyDTO;
import com.epmet.entity.PaCustomerAgencyEntity; import com.epmet.entity.PaCustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -38,4 +39,11 @@ public interface PaCustomerAgencyDao extends BaseDao<PaCustomerAgencyEntity> {
*/ */
String getCustomerIdByUserId(@Param("userId")String userId); String getCustomerIdByUserId(@Param("userId")String userId);
/**
* @param customerId
* @return
* @Author sun
* @Description 公众号-查询客户组织信息
**/
PaCustomerAgencyDTO selectCustomerAgency(@Param("customerId") String customerId);
} }

17
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java

@ -22,9 +22,11 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.MyInfoFormDTO;
import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.entity.PaCustomerEntity; import com.epmet.entity.PaCustomerEntity;
import java.util.List; import java.util.List;
@ -107,25 +109,26 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
void register(RegisterFormDTO formDTO); void register(RegisterFormDTO formDTO);
/** /**
* @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-创建组织 * @Description 公众号-查询组织级别
**/ **/
CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO); List<AgencyLevelListResultDTO> agencyLevelList();
/** /**
* @param formDTO * @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-查询我的信息 * @Description 公众号-创建组织
**/ **/
CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO); CreateAgencyResultDTO createAgency(TokenDto tokenDTO, CreateAgencyFormDTO formDTO);
/** /**
* @param formDTO
* @return * @return
* @Author sun * @Author sun
* @Description 公众号-查询组织级别 * @Description 公众号-查询我的信息
**/ **/
List<AgencyLevelListResultDTO> agencyLevelList(); MyInfoResultDTO myInfo(MyInfoFormDTO formDTO);
} }

43
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java

@ -32,17 +32,14 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.constant.PaConstant; import com.epmet.constant.PaConstant;
import com.epmet.dao.PaCustomerDao; import com.epmet.dao.*;
import com.epmet.dao.PaUserDao; import com.epmet.dto.*;
import com.epmet.dao.PaUserVisitedDao;
import com.epmet.dao.PaUserWechatDao;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.PaUserDTO;
import com.epmet.dto.PaUserWechatDTO;
import com.epmet.dto.form.CreateAgencyFormDTO; import com.epmet.dto.form.CreateAgencyFormDTO;
import com.epmet.dto.form.MyInfoFormDTO;
import com.epmet.dto.form.RegisterFormDTO; import com.epmet.dto.form.RegisterFormDTO;
import com.epmet.dto.result.AgencyLevelListResultDTO; import com.epmet.dto.result.AgencyLevelListResultDTO;
import com.epmet.dto.result.CreateAgencyResultDTO; import com.epmet.dto.result.CreateAgencyResultDTO;
import com.epmet.dto.result.MyInfoResultDTO;
import com.epmet.entity.*; import com.epmet.entity.*;
import com.epmet.redis.PaCustomerRedis; import com.epmet.redis.PaCustomerRedis;
import com.epmet.service.CustomerMpService; import com.epmet.service.CustomerMpService;
@ -80,6 +77,10 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
@Autowired @Autowired
private PaUserVisitedDao paUserVisitedDao; private PaUserVisitedDao paUserVisitedDao;
@Autowired @Autowired
private PaCustomerAgencyDao paCustomerAgencyDao;
@Autowired
private CustomerMpDao customerMpDao;
@Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private PaCustomerAgencyService paCustomerAgencyService; private PaCustomerAgencyService paCustomerAgencyService;
@ -289,8 +290,32 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
* @Description 公众号-查询我的信息 * @Description 公众号-查询我的信息
**/ **/
@Override @Override
public CreateAgencyResultDTO myInfo(CreateAgencyFormDTO formDTO) { public MyInfoResultDTO myInfo(MyInfoFormDTO formDTO) {
return null;
//1.查询客户组织信息
PaCustomerAgencyDTO agencyDTO = paCustomerAgencyDao.selectCustomerAgency(formDTO.getCustomerId());
if (null == agencyDTO) {
throw new RenException(PaConstant.SELECT_AGENCY_EXCEPTION);
}
//2.查询客户小程序授权结果信息
List<CustomerMpDTO> listMpDTO = customerMpDao.selectByCustomerId(formDTO.getCustomerId());
if (null == agencyDTO || listMpDTO.size() != NumConstant.TWO) {
throw new RenException(PaConstant.CUSTOMER_MP_EXCEPTION);
}
//3.封装结果信息
MyInfoResultDTO resultDTO = ConvertUtils.sourceToTarget(agencyDTO, MyInfoResultDTO.class);
for (CustomerMpDTO mp : listMpDTO) {
if (PaConstant.CLIENT_RESI.equals(mp.getClient())) {
resultDTO.setResiAuthorization(mp.getAuthorizationFlag());
}
if (PaConstant.CLIENT_WORK.equals(mp.getClient())) {
resultDTO.setWorkAuthorization(mp.getAuthorizationFlag());
}
}
return resultDTO;
} }

15
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

@ -3,5 +3,20 @@
<mapper namespace="com.epmet.dao.CustomerMpDao"> <mapper namespace="com.epmet.dao.CustomerMpDao">
<select id="selectByCustomerId" resultType="com.epmet.dto.CustomerMpDTO">
SELECT
id,
customer_id,
client,
app_id,
authorization_flag
FROM
customer_mp
WHERE
del_flag = '0'
AND customer_id = #{customerId}
ORDER BY
client ASC
</select>
</mapper> </mapper>

18
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerAgencyDao.xml

@ -15,4 +15,22 @@
AND pcua.user_id = #{userId} AND pcua.user_id = #{userId}
</select> </select>
<select id="selectCustomerAgency" resultType="com.epmet.dto.PaCustomerAgencyDTO">
SELECT
id,
customer_id,
agency_name,
`level`,
area_code,
province,
city,
district,
partybranchnum
FROM
pa_customer_agency
WHERE del_flag = '0'
AND customer_id = #{customerId}
LIMIT 1
</select>
</mapper> </mapper>
Loading…
Cancel
Save