Browse Source

Merge remote-tracking branch 'origin/dev0.2' into dev0.2

master
wangchao 5 years ago
parent
commit
3e1d7b1626
  1. 25
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 5
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/service/impl/ResiRegisterServiceImpl.java
  3. 30
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/constant/PartyMemberConstant.java
  4. 7
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/redis/PartymemberInfoRedis.java
  5. 8
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  6. 14
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java
  7. 84
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/InfoSubmitFromDTO.java
  8. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ResiInfoSubmitFormDTO.java
  9. 42
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/WxUserInfoFormDTO.java
  10. 11
      epmet-user/epmet-user-server/Dockerfile
  11. 6
      epmet-user/epmet-user-server/docker-compose.yml
  12. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java
  13. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java
  14. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java
  15. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java
  16. 29
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java
  17. 3
      epmet-user/epmet-user-server/src/main/resources/mapper/UserWechatDao.xml

25
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -135,6 +135,18 @@ public class RedisKeys {
return rootPrefix.concat("party:member:confirm:").concat(userId).concat("-").concat(mobile).concat("-").concat(code);
}
/**
*
* 党员认证手机验证码key模糊查询
*
* @param userId 用户id
* @param mobile 手机号
* @return String
*/
public static String getUserMobileCodeKey(String userId, String mobile) {
return rootPrefix.concat("party:member:confirm:").concat(userId).concat("-").concat(mobile).concat("-*");
}
/**
*
* 居民注册手机验证码key
@ -149,4 +161,17 @@ public class RedisKeys {
return rootPrefix.concat("resiregister:confirm:").concat(userId).concat("-").concat(mobile).concat("-").concat(code);
}
/**
*
* 居民注册手机验证码key模糊检索Key
*
* @param userId 用户id
* @param mobile 手机号
* @return String
* @author sun
*/
public static String getResiRegisterMobileCodeKey(String userId, String mobile) {
return rootPrefix.concat("resiregister:confirm:").concat(userId).concat("-").concat(mobile).concat("-*");
}
}

5
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/service/impl/ResiRegisterServiceImpl.java

@ -1,8 +1,10 @@
package com.epmet.modules.resiregister.service.impl;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserResiInfoDTO;
import com.epmet.dto.form.InfoSubmitFromDTO;
import com.epmet.dto.form.ResiInfoSubmitFormDTO;
import com.epmet.dto.form.ResiRegisterFormDTO;
import com.epmet.dto.form.VerificationCodeFormDTO;
@ -46,7 +48,8 @@ public class ResiRegisterServiceImpl implements ResiRegisterService {
**/
@Override
public Result submit(TokenDto tokenDTO, ResiInfoSubmitFormDTO resiInfoSubmitFormDTO) {
UserResiInfoDTO userResiInfoDTO = resiInfoSubmitFormDTO.getResiInfo();
InfoSubmitFromDTO infoSubmitFromDTO = resiInfoSubmitFormDTO.getResiInfo();
UserResiInfoDTO userResiInfoDTO = ConvertUtils.sourceToTarget(infoSubmitFromDTO, UserResiInfoDTO.class);
userResiInfoDTO.setUserId(tokenDTO.getUserId());
userResiInfoDTO.setApp(tokenDTO.getApp());
userResiInfoDTO.setCustomerId(resiInfoSubmitFormDTO.getCustomerId());

30
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/constant/PartyMemberConstant.java

@ -44,7 +44,7 @@ public interface PartyMemberConstant {
/**
* 党员自动认证是否成功基准
*/
String BENCHMARK = "110010";
String BENCHMARK = "101011";
/**
* 比对结果相同
@ -52,14 +52,34 @@ public interface PartyMemberConstant {
Double EQUALS = 1.0;
/**
* 比对结果大部分相同最低值
* 身份证比对结果大部分相同最低值
*/
Double MOST = 0.8;
Double ID_MOST = 0.88;
/**
* 比对结果小部分相同最低值
* 身份证比对结果小部分相同最低值
*/
Double SMALL = 0.5;
Double ID_SMALL = 0.5;
/**
* 手机号比对结果大部分相同最低值
*/
Double MOBILE_MOST = 0.81;
/**
* 手机号比对结果小部分相同最低值
*/
Double MOBILE_SMALL = 0.5;
/**
* 姓名比对结果大部分相同最低值
*/
Double NAME_MOST = 0.66;
/**
* 姓名比对结果小部分相同最低值
*/
Double NAME_SMALL = 0.5;
/**
* 比对结果相同

7
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/redis/PartymemberInfoRedis.java

@ -47,7 +47,7 @@ public class PartymemberInfoRedis {
public void setUserMobileCode(String userId, String mobile, String code){
String key = RedisKeys.getUserMobileCodeKey(userId, mobile, code);
redisUtils.set(key, code, RedisUtils.MINUTE_TEN_EXPIRE);
redisUtils.set(key, code, RedisUtils.MINUTE_THIRTY_EXPIRE);
}
public String getUserMobileCode(String userId, String mobile, String code){
@ -60,4 +60,9 @@ public class PartymemberInfoRedis {
redisUtils.delete(key);
}
public void deleteUserMobileCodeByPattern(String userId, String mobile){
String key = RedisKeys.getUserMobileCodeKey(userId, mobile);
redisUtils.deleteByPattern(key);
}
}

8
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java

@ -105,6 +105,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
//手机是否可用
PartymemberInfoEntity partyMemberInfoParam = new PartymemberInfoEntity();
partyMemberInfoParam.setMobile(fromDTO.getMobile());
partyMemberInfoParam.setCustomerId(fromDTO.getCustomerId());
PartymemberInfoDTO partyMemberInfoResult = partymemberInfoService.getPartyMemberInfoByMobile(partyMemberInfoParam);
if (null != partyMemberInfoResult) {
result.setCode(EpmetErrorCode.MOBILE_HAS_BEEN_USED.getValue());
@ -119,6 +120,8 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
result.setMsg(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getName());
return result;
}
//删除旧验证码
partyMemberInfoRedis.deleteUserMobileCodeByPattern(fromDTO.getUserId(), fromDTO.getMobile());
//将验证码存入Redis
partyMemberInfoRedis.setUserMobileCode(fromDTO.getUserId(), fromDTO.getMobile(), message.get("code"));
@ -144,10 +147,6 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
result.setCode(EpmetErrorCode.MOBILE_CODE_ERROR.getValue());
result.setMsg(EpmetErrorCode.MOBILE_CODE_ERROR.getName());
return result;
} else {
partyMemberInfoRedis.delUserMobileCode(partyMemberInfoDTO.getUserId(),
partyMemberInfoDTO.getMobile(),
partyMemberInfoDTO.getCode());
}
//获取党员基本信息
@ -201,6 +200,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result partyMemberInfoExtra(PartymemberInfoDTO infoDTO) {
//将访问记录更新到热心居民申请行为记录表
saveOrUpdateVisit(infoDTO.getPartymemberVisitId(), null, PartyMemberConstant.OPERATE_EXTRA);

14
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberBaseInfoServiceImpl.java

@ -241,23 +241,23 @@ public class PartymemberBaseInfoServiceImpl extends BaseServiceImpl<PartymemberB
double idCardResult = jw.similarity(baseInfo.getIdCard(), info.getIdCard());
double mobileResult = jw.similarity(baseInfo.getMobile(), info.getMobile());
double nameResult = jw.similarity(baseInfo.getName(), info.getSurname() + info.getName());
result = getString(result, idCardResult);
result = getString(result, idCardResult, PartyMemberConstant.ID_MOST, PartyMemberConstant.ID_SMALL);
result = getString(result, mobileResult);
result = getString(result, mobileResult, PartyMemberConstant.MOBILE_MOST, PartyMemberConstant.MOBILE_SMALL);
result = getString(result, nameResult);
result = getString(result, nameResult, PartyMemberConstant.NAME_MOST, PartyMemberConstant.NAME_SMALL);
return result;
}
@NotNull
private String getString(String result, double comparisonResult) {
if(comparisonResult == PartyMemberConstant.EQUALS) {
private String getString(String result, double comparisonResult, double most, double small) {
if (comparisonResult == PartyMemberConstant.EQUALS) {
result = result + "11";
} else if (comparisonResult > PartyMemberConstant.MOST) {
} else if (comparisonResult > most) {
result = result + "10";
} else if (comparisonResult < PartyMemberConstant.SMALL) {
} else if (comparisonResult < small) {
result = result + "00";
} else {
result = result + "01";

84
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/InfoSubmitFromDTO.java

@ -0,0 +1,84 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 用户居民端注册信息表 用户在居民端完善的个人信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-30
*/
@Data
public class InfoSubmitFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 手机号(注册手机号)
*/
@NotBlank(message = "手机号不能为空")
private String regMobile;
/**
* 姓氏
*/
@NotBlank(message = "姓氏不能为空")
private String surname;
/**
* 名称
*/
@NotBlank(message = "名称不能为空")
private String name;
/**
* 街道
*/
@NotBlank(message = "所在街道不能为空")
private String street;
/**
* 小区名称
*/
private String district;
/**
* 楼栋单元
*/
private String buildingAddress;
/**
* 居民注册行为记录表Id resi_visit.id
*/
private String resiVisitId;
/**
* 手机验证码
*/
@NotBlank(message = "手机验证码不能为空")
private String mobileCode;
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ResiInfoSubmitFormDTO.java

@ -20,6 +20,7 @@ package com.epmet.dto.form;
import com.epmet.dto.UserResiInfoDTO;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
@ -58,8 +59,8 @@ public class ResiInfoSubmitFormDTO implements Serializable {
/**
* 用户在居民端完善的个人信息
*/
@NotBlank(message = "个人信息不能为空")
private UserResiInfoDTO resiInfo;
@Valid
private InfoSubmitFromDTO resiInfo;
}

42
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/WxUserInfoFormDTO.java

@ -0,0 +1,42 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 同步用户微信信息接口入参DTO
* @Author sun
*/
@Data
public class WxUserInfoFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
//@NotBlank(message = "用户Id不能为空")
private String userId;
//@NotBlank(message = "昵称不能为空")
private String nickName;
/**
* 性别0未知1男性2女性
*/
@NotBlank(message = "性别不能为空")
private String gender;
@NotBlank(message = "头像不能为空")
private String avatarUrl;
//@NotBlank(message = "所在省份不能为空")
private String province;
//@NotBlank(message = "所在国家不能为空")
private String country;
//@NotBlank(message = "所在城市不能为空")
private String city;
}

11
epmet-user/epmet-user-server/Dockerfile

@ -0,0 +1,11 @@
FROM java:8
RUN export LANG="zh_CN.UTF-8"
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone
COPY ./target/*.jar ./app.jar
EXPOSE 8087
ENTRYPOINT ["java","-jar","./app.jar"]

6
epmet-user/epmet-user-server/docker-compose.yml

@ -0,0 +1,6 @@
version: "3.7"
services:
web:
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud/epmet-user-server:2.0.0
ports:
- "8087:8087"

16
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

@ -1,5 +1,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
@ -8,6 +10,7 @@ import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,4 +73,17 @@ public class UserController {
Result<PasswordLoginUserInfoResultDTO> result= userService.selectLoginUserInfoByPassword(passwordLoginUserInfoFormDTO);
return result;
}
/**
* @param wxUserInfoFormDTO
* @Author sun
* @Description 居民端个人信息-同步用户微信信息
**/
@PostMapping("updatewxuserinfo")
public Result updateWxUserInfo(@LoginUser TokenDto tokenDTO, @RequestBody WxUserInfoFormDTO wxUserInfoFormDTO) {
wxUserInfoFormDTO.setUserId(tokenDTO.getUserId());
ValidatorUtils.validateEntity(wxUserInfoFormDTO);
return userService.updateWxUserInfo(wxUserInfoFormDTO);
}
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserResiInfoRedis.java

@ -56,4 +56,9 @@ public class UserResiInfoRedis {
return (String) redisUtils.get(key);
}
public void deleteOldUserMobileCode(String userId, String mobile){
String key = RedisKeys.getResiRegisterMobileCodeKey(userId, mobile);
redisUtils.deleteByPattern(key);
}
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java

@ -7,6 +7,7 @@ import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.UserEntity;
@ -47,4 +48,11 @@ public interface UserService extends BaseService<UserEntity> {
* @Date 2020/3/16 15:49
**/
Result<PasswordLoginUserInfoResultDTO> selectLoginUserInfoByPassword(PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO);
/**
* @param wxUserInfoFormDTO
* @Author sun
* @Description 居民端个人信息-同步用户微信信息
**/
Result updateWxUserInfo(WxUserInfoFormDTO wxUserInfoFormDTO);
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java

@ -212,8 +212,15 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us
}
//3:调用短信服务 生成验证码发送短信
result = messageFeignClient.sendSmsCaptcha(verificationCodeFormDTO.getMobile());
//4:将验证码存入redis
Map<String,Object> map = (Map<String, Object>) result.getData();
if(null == map) {
result.setCode(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getValue());
result.setMsg(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getName());
return result;
}
//4:删除缓存中可能存在的旧验证码
userResiInfoRedis.deleteOldUserMobileCode(verificationCodeFormDTO.getUserId(), verificationCodeFormDTO.getMobile());
//5:将验证码存入redis
userResiInfoRedis.setUserResiMobileCode(verificationCodeFormDTO.getUserId(),verificationCodeFormDTO.getMobile(),map.get("code").toString());
return result;
}

29
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

@ -11,6 +11,7 @@ import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.form.WxLoginUserInfoFormDTO;
import com.epmet.dto.form.WxUserInfoFormDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.entity.UserEntity;
import com.epmet.entity.UserWechatEntity;
@ -19,6 +20,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @Description
@ -33,7 +36,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
/**
* 根据openIdapp查询对应终端用户信息
*
* <p>
* 居民端用户与政府端用户都在一张表内且都有微信登录的入口
* user_wechat表保存每一个用户和微信(openId)的绑定关系
*
@ -43,7 +46,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
*/
@Override
public Result<UserDTO> selecWxLoginUserInfo(WxLoginUserInfoFormDTO formDTO) {
UserDTO userDTO=userWechatDao.selectUserDTOByOpenId(formDTO);
UserDTO userDTO = userWechatDao.selectUserDTOByOpenId(formDTO);
return new Result<UserDTO>().ok(userDTO);
}
@ -90,4 +93,26 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
}
return new Result<PasswordLoginUserInfoResultDTO>().ok(passwordLoginUserInfoResultDTO);
}
/**
* @param wxUserInfoFormDTO
* @Author sun
* @Description 居民端个人信息-同步用户微信信息
**/
@Override
public Result updateWxUserInfo(WxUserInfoFormDTO wxUserInfoFormDTO) {
UserWechatDTO userWechatDTO = new UserWechatDTO();
//前台和后台已有实体字段不对于 需要挨个赋值
userWechatDTO.setUserId(wxUserInfoFormDTO.getUserId());
userWechatDTO.setNickname(wxUserInfoFormDTO.getNickName() == null ? null : wxUserInfoFormDTO.getNickName());
userWechatDTO.setSex(Integer.parseInt(wxUserInfoFormDTO.getGender()));
userWechatDTO.setHeadImgUrl(wxUserInfoFormDTO.getAvatarUrl());
userWechatDTO.setCountry(wxUserInfoFormDTO.getCountry() == null ? null : wxUserInfoFormDTO.getCountry());
userWechatDTO.setProvince(wxUserInfoFormDTO.getProvince() == null ? null : wxUserInfoFormDTO.getProvince());
userWechatDTO.setCity(wxUserInfoFormDTO.getCity() == null ? null : wxUserInfoFormDTO.getCity());
userWechatDTO.setUpdatedTime(new Date());
userWechatDTO.setUpdatedBy(wxUserInfoFormDTO.getUserId());
userWechatDao.updateByUserId(userWechatDTO);
return new Result();
}
}

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

@ -31,7 +31,8 @@
<if test='null != sex and "" != sex '>
SEX = #{sex},
</if>
UPDATED_TIME = sysdate
UPDATED_BY = #{updatedBy},
UPDATED_TIME = #{updatedTime}
</set>
WHERE
USER_ID = #{userId}

Loading…
Cancel
Save