Browse Source

提交徽章认证

dev_shibei_match
zxc 5 years ago
parent
commit
1c8eca02dd
  1. 16
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java
  2. 10
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java
  3. 17
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java
  4. 44
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java
  5. 22
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java
  6. 67
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java
  7. 3
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  8. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  9. 28
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java
  10. 18
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java
  11. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java
  12. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java
  13. 79
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java
  14. 59
      epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml

16
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java

@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.modules.badege.service.BadgeService;
import com.epmet.resi.mine.dto.from.BadgeListFormDTO;
import com.epmet.dto.form.CertificationAddFormDTO;
import com.epmet.resi.mine.dto.from.OperListFormDTO;
import com.epmet.resi.mine.dto.result.BadgeListResultDTO;
import com.epmet.resi.mine.dto.result.OperListResultDTO;
@ -52,4 +53,19 @@ public class BadgeController {
return new Result<List<OperListResultDTO>>().ok(badgeService.getOperList(tokenDto,operListFormDTO));
}
/**
* @Description 个人中心-提交徽章认证
* @Param tokenDto
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 11:16 上午
*/
@PostMapping("certification/add")
public Result certificationAdd(@LoginUser TokenDto tokenDto,@RequestBody CertificationAddFormDTO certificationAddFormDTO){
ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class);
badgeService.certificationAdd(tokenDto,certificationAddFormDTO);
return new Result();
}
}

10
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java

@ -2,6 +2,7 @@ package com.epmet.modules.badege.service;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.resi.mine.dto.from.BadgeListFormDTO;
import com.epmet.dto.form.CertificationAddFormDTO;
import com.epmet.resi.mine.dto.from.OperListFormDTO;
import com.epmet.resi.mine.dto.result.BadgeListResultDTO;
import com.epmet.resi.mine.dto.result.OperListResultDTO;
@ -30,4 +31,13 @@ public interface BadgeService {
*/
List<OperListResultDTO> getOperList(TokenDto tokenDto,OperListFormDTO operListFormDTO);
/**
* @Description 个人中心-提交徽章认证
* @Param tokenDto
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 11:16 上午
*/
void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO);
}

17
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java

@ -11,6 +11,7 @@ import com.epmet.dto.result.UserOperListResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.modules.badege.service.BadgeService;
import com.epmet.resi.mine.dto.from.BadgeListFormDTO;
import com.epmet.dto.form.CertificationAddFormDTO;
import com.epmet.resi.mine.dto.from.OperListFormDTO;
import com.epmet.resi.mine.dto.result.BadgeListResultDTO;
import com.epmet.resi.mine.dto.result.OperListResultDTO;
@ -75,4 +76,20 @@ public class BadgeServiceImpl implements BadgeService {
List<OperListResultDTO> result = ConvertUtils.sourceToTarget(listResult.getData(), OperListResultDTO.class);
return result;
}
/**
* @Description 个人中心-提交徽章认证
* @Param tokenDto
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 11:16 上午
*/
@Override
public void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO) {
certificationAddFormDTO.setUserId(tokenDto.getUserId());
Result result = epmetUserOpenFeignClient.authBadgeRecord(certificationAddFormDTO);
if (!result.success()){
throw new RenException("提交徽章认证失败......");
}
}
}

44
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java

@ -0,0 +1,44 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author zxc
* @DateTime 2020/11/4 1:46 下午
*/
@Data
public class UserBadgeCertificateRecordDTO implements Serializable {
private static final long serialVersionUID = 3207509834642386145L;
private String customerId;
private String gridId;
private String userId;
private String badgeId;
private String surname;
private String name;
private String idNum;
private String certificationImg;
private String remark;
private String auditStatus;
private String auditRemark;
private String staffId;
private Date auditTime;
private String isLast;
private String delFlag;
private Integer revision;
private String createdBy;
private String updatedBy;
public UserBadgeCertificateRecordDTO() {
this.auditStatus = "auditing";
this.isLast = "yes";
this.delFlag = "0";
this.revision = 0;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

22
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/11/4 3:11 下午
*/
@Data
public class BadgeSendCodeFormDTO implements Serializable {
private static final long serialVersionUID = -3926070129364657241L;
public interface BadgeSendCode{}
@NotBlank(message = "手机号不能为空", groups = {BadgeSendCode.class})
private String mobile;
}

67
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java

@ -0,0 +1,67 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/11/4 11:05 上午
*/
@Data
public class CertificationAddFormDTO implements Serializable {
private static final long serialVersionUID = 1330773325803513330L;
public interface CertificationAdd{}
private String userId;
/**
* 客户ID
*/
@NotBlank(message = "客户ID不能为空",groups = {CertificationAdd.class})
private String customerId;
/**
* 徽章ID
*/
private String badgeId;
/**
* 手机号
*/
private String mobile;
/**
*
*/
private String subName;
/**
*
*/
private String name;
/**
* 身份证号
*/
private String idCard;
/**
* 认证证件图片url
*/
private String certificate;
/**
* 认证说明
*/
private String remark;
/**
* 验证码
*/
private String code;
}

3
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -355,4 +355,7 @@ public interface EpmetUserOpenFeignClient {
*/
@PostMapping("/epmetuser/badge/badgeoperlist")
Result<List<UserOperListResultDTO>> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO);
@PostMapping("/epmetuser/badge/authbadgerecord")
Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO);
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -235,4 +235,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
public Result<List<UserOperListResultDTO>> selectOperList(UserOperListFormDTO userOperListFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectOperList", userOperListFormDTO);
}
@Override
public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "authBadgeRecord", certificationAddFormDTO);
}
}

28
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java

@ -1,6 +1,9 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.BadgeSendCodeFormDTO;
import com.epmet.dto.form.CertificationAddFormDTO;
import com.epmet.dto.form.UserBadgeListFormDTO;
import com.epmet.dto.form.UserOperListFormDTO;
import com.epmet.dto.result.UserBadgeListResultDTO;
@ -47,4 +50,29 @@ public class UserBadgeController {
return new Result<List<UserOperListResultDTO>>().ok(userBadgeService.selectOperList(userOperListFormDTO));
}
/**
* @Description 个人中心-提交徽章认证
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 1:36 下午
*/
@PostMapping("authbadgerecord")
public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){
userBadgeService.authBadgeRecord(certificationAddFormDTO);
return new Result();
}
/**
* @Description 发送验证码
* @Param badgeSendCodeFormDTO
* @author zxc
* @date 2020/11/4 3:14 下午
*/
@PostMapping("badgesendcode")
public Result badgeSendCode(@RequestBody BadgeSendCodeFormDTO badgeSendCodeFormDTO){
ValidatorUtils.validateEntity(badgeSendCodeFormDTO, BadgeSendCodeFormDTO.BadgeSendCode.class);
userBadgeService.badgeSendCode(badgeSendCodeFormDTO);
return new Result();
}
}

18
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java

@ -1,5 +1,6 @@
package com.epmet.dao;
import com.epmet.dto.UserBadgeCertificateRecordDTO;
import com.epmet.dto.form.UserBadgeListFormDTO;
import com.epmet.dto.result.UserBadgeListResultDTO;
import com.epmet.dto.result.UserOperListResultDTO;
@ -47,4 +48,21 @@ public interface UserBadgeDao {
*/
List<UserOperListResultDTO> selectBadgeByUserId(@Param("userId")String userId);
/**
* @Description 用户认证徽章记录表插入
* @Param userBadgeCertificateRecordDTO
* @author zxc
* @date 2020/11/4 2:13 下午
*/
void insertUserBadgeCertificateRecord(UserBadgeCertificateRecordDTO userBadgeCertificateRecordDTO);
/**
* @Description 更新认证徽章记录最新
* @Param badgeId
* @Param userId
* @author zxc
* @date 2020/11/4 2:16 下午
*/
void updateCertificateRecordIsLast(@Param("badgeId")String badgeId,@Param("userId")String userId);
}

15
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java

@ -1,6 +1,8 @@
package com.epmet.redis;
import com.alibaba.fastjson.JSON;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.BadgeConstant;
@ -12,6 +14,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE;
/**
* @Author zxc
* @DateTime 2020/11/3 2:21 下午
@ -44,4 +48,15 @@ public class UserBadgeRedis {
redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1);
}
public void saveBadgeSmsCode(String mobile, String smsCode) {
String smsCodeKey = "epmet:smsCode:badge:" + mobile;
redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE);
}
public String getBadgeSmsCode(String mobile) {
String smsCodeKey = "epmet:smsCode:badge:" + mobile;
String smsCode = (String) redisUtils.get(smsCodeKey);
return smsCode;
}
}

20
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java

@ -1,9 +1,13 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.BadgeSendCodeFormDTO;
import com.epmet.dto.form.CertificationAddFormDTO;
import com.epmet.dto.form.UserBadgeListFormDTO;
import com.epmet.dto.form.UserOperListFormDTO;
import com.epmet.dto.result.UserBadgeListResultDTO;
import com.epmet.dto.result.UserOperListResultDTO;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -29,4 +33,20 @@ public interface UserBadgeService {
*/
List<UserOperListResultDTO> selectOperList(UserOperListFormDTO userOperListFormDTO);
/**
* @Description 个人中心-提交徽章认证
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 1:36 下午
*/
Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO);
/**
* @Description 发送验证码
* @Param badgeSendCodeFormDTO
* @author zxc
* @date 2020/11/4 3:14 下午
*/
void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO);
}

79
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java

@ -2,16 +2,27 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.PhoneValidatorUtils;
import com.epmet.constant.BadgeConstant;
import com.epmet.constant.SmsTemplateConstant;
import com.epmet.dao.UserBadgeDao;
import com.epmet.dto.form.UserBadgeListFormDTO;
import com.epmet.dto.form.UserOperListFormDTO;
import com.epmet.dto.UserBadgeCertificateRecordDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.SendVerificationCodeResultDTO;
import com.epmet.dto.result.UserBadgeListResultDTO;
import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.dto.result.UserOperListResultDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.redis.UserBadgeRedis;
import com.epmet.service.CustomerStaffService;
import com.epmet.service.UserBadgeService;
import com.epmet.service.UserBaseInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -34,6 +45,12 @@ public class UserBadgeServiceImpl implements UserBadgeService {
private UserBadgeDao userBadgeDao;
@Autowired
private UserBadgeRedis userBadgeRedis;
@Autowired
private UserBaseInfoService userBaseInfoService;
@Autowired
private CustomerStaffService customerStaffService;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
/**
* @Description 查询已经点亮的徽章
@ -123,4 +140,62 @@ public class UserBadgeServiceImpl implements UserBadgeService {
});
return userOperListResultDTOS;
}
/**
* @Description 个人中心-提交徽章认证
* @Param certificationAddFormDTO
* @author zxc
* @date 2020/11/4 1:36 下午
*/
@Override
public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) {
if (StringUtils.isNotBlank(certificationAddFormDTO.getMobile())){
String smsCode = userBadgeRedis.getBadgeSmsCode(certificationAddFormDTO.getMobile());
if (!StringUtils.isNotBlank(smsCode)){
return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
}
UserBadgeCertificateRecordDTO form = ConvertUtils.sourceToTarget(certificationAddFormDTO, UserBadgeCertificateRecordDTO.class);
List<String> userIds = new ArrayList<>();
userIds.add(certificationAddFormDTO.getUserId());
List<UserBaseInfoResultDTO> userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds);
if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)){
throw new RenException("查询用户基本信息集合为空......");
}
userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId());
form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId());
form.setIdNum(certificationAddFormDTO.getIdCard());
form.setCertificationImg(certificationAddFormDTO.getCertificate());
form.setSurname(certificationAddFormDTO.getSubName());
userBadgeDao.insertUserBadgeCertificateRecord(form);
return new Result();
}
/**
* @Description 发送验证码
* @Param badgeSendCodeFormDTO
* @author zxc
* @date 2020/11/4 3:14 下午
*/
@Override
public void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO) {
//1、校验手机号是否符合规范
if (!PhoneValidatorUtils.isMobile(badgeSendCodeFormDTO.getMobile())) {
log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg()));
throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode());
}
//3、发送短信验证码
SendVerificationCodeFormDTO sendVerificationCodeFormDTO=new SendVerificationCodeFormDTO();
sendVerificationCodeFormDTO.setMobile(badgeSendCodeFormDTO.getMobile());
sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.LGOIN_CONFIRM);
Result<SendVerificationCodeResultDTO> smsCodeResult=epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO);
if (!smsCodeResult.success()) {
log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg()));
throw new RenException(smsCodeResult.getCode());
}
//4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis)
userBadgeRedis.saveBadgeSmsCode(badgeSendCodeFormDTO.getMobile(),smsCodeResult.getData().getCode());
log.info(String.format("发送短信验证码成功,手机号[%s]", badgeSendCodeFormDTO.getMobile()));
}
}

59
epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml

@ -3,6 +3,15 @@
<mapper namespace="com.epmet.dao.UserBadgeDao">
<!-- 更新认证徽章记录最新 -->
<update id="updateCertificateRecordIsLast">
UPDATE user_badge_certificate_record
SET is_last = 'no'
WHERE DEL_FLAG = '0'
AND BADGE_ID = #{badgeId}
AND USER_ID = #{userId}
</update>
<!-- 查询已经点亮的徽章 -->
<select id="selectBadgeList" resultType="com.epmet.dto.result.UserBadgeListResultDTO">
SELECT
@ -58,5 +67,55 @@
AND USER_ID = #{userId}
</select>
<!-- 徽章审核记录表插入 -->
<insert id="insertUserBadgeCertificateRecord">
INSERT INTO user_badge_certificate_record (
ID,
CUSTOMER_ID,
GRID_ID,
USER_ID,
BADGE_ID,
SURNAME,
NAME,
ID_NUM,
CERTIFICATION_IMG,
REMAEK,
AUDIT_STATUS,
AUDIT_REMARK,
STAFF_ID,
AUDIT_TIME,
IS_LAST,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
)
VALUES
(
REPLACE ( UUID(), '-', '' ),
#{customerId},
#{gridId},
#{userId},
#{badgeId},
#{surname},
#{name},
#{idNum},
#{certificationImg},
#{remark},
#{auditStatus},
#{auditRemark},
#{staffId},
#{auditTime},
#{isLast},
#{delFlag},
#{revision},
#{createdBy},
NOW(),
#{updatedBy},
NOW()
)
</insert>
</mapper>

Loading…
Cancel
Save