Commit 92fad2e5 by xieshixiang

Merge branch 'dev' into test

parents b65cd7c8 c2d69122
......@@ -10,6 +10,8 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.UnBindReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoQueryRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,7 +36,7 @@ public class BindInfoControlller extends BaseController {
@Autowired
IBindService service;
@Autowired
DefaultConverter defaultConverter;
DefaultConverter defaultConverter;
/**
......@@ -48,8 +50,7 @@ public class BindInfoControlller extends BaseController {
@PostMapping("bind")
@BodyDecryptAnnotation
@ResponseEncryptAnnotation
public Response<String> bindInfo(@RequestBody @Validated BindInfoReq req) {
public Response<BindInfoRes> bindInfo(@RequestBody @Validated BindInfoReq req) {
ParkBindInfo bindInfo = new ParkBindInfo();
defaultConverter.getMapperFacade().map(req, bindInfo);
return service.bind(bindInfo);
......@@ -81,8 +82,8 @@ public class BindInfoControlller extends BaseController {
@PostMapping("query")
@BodyDecryptAnnotation
@ResponseEncryptAnnotation
public Response<ResultList<ParkBindInfo>> bindInfoQery( @RequestBody @Validated BindInfoQueryReq query) {
return ResponseGenerator.success(new ResultList<ParkBindInfo>(service.selectByQuery(query)));
public Response<ResultList<BindInfoQueryRes>> bindInfoQery(@RequestBody @Validated BindInfoQueryReq query) {
return ResponseGenerator.success(new ResultList<BindInfoQueryRes>(service.selectByQuery(query)));
}
}
......@@ -13,9 +13,9 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.Sms
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkVerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.CheckVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.SendVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.CheckValidityRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
......@@ -117,16 +117,17 @@ public class H5Controller {
}
/**
* 验证当前手机号是否在10天内,已通过验证
* 验证当前手机号是否在1天内,已通过验证
*
* @param query
* @return
*/
@PostMapping("checkValidity")
@HeaderDecryptAnnotation
public Response<CheckValidityRes> checkValidity( @RequestBody @Validated H5BindInfoQuery query) {
public Response<CheckValidityRes> checkValidity(@RequestBody @Validated H5BindInfoQuery query) {
ParkVerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10));
DateUtil.offsetDay(DateTime.now(), -1));
CheckValidityRes checkValidityRes = new CheckValidityRes();
defaultConverter.getMapperFacade().map(query, checkValidityRes);
......@@ -178,7 +179,7 @@ public class H5Controller {
verifyInfo.setUserId(req.getUserId());
verifyInfo.setVerifyCode(req.getVerifyCode());
verifyInfo.setPhone(req.getPhone());
verifyInfo.setPassTime(DateTime.now().toString());
verifyInfo.setPassTime(DateTime.now());
verifyInfoMapper.insert(verifyInfo);
}
return checkResult;
......
......@@ -5,7 +5,6 @@ import com.hikcreate.edl.pub.web.mobile.infra.core.configbean.SignKeyConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -19,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
**/
@Slf4j
@RestController
@RequestMapping( "/tool" )
@RequestMapping("/tool")
public class ToolController {
@Autowired
SignKeyConfigBean signKeyConfigBean;
......@@ -30,8 +29,8 @@ public class ToolController {
* @param plain 明文
* @return
*/
@GetMapping( value = "encrypt" )
public String encrypt( String plain ) {
@GetMapping(value = "encrypt")
public String encrypt(String plain) {
return EncryptStringAes.encryptAes(plain, signKeyConfigBean.getKey());
}
......@@ -41,8 +40,8 @@ public class ToolController {
* @param cipher 密文
* @return
*/
@PostMapping( value = "decrypt" )
public String decrypt( String cipher ) {
@GetMapping(value = "decrypt")
public String decrypt(String cipher) {
return EncryptStringAes.decryptAes(cipher, signKeyConfigBean.getKey());
}
......@@ -51,7 +50,7 @@ public class ToolController {
*
* @return
*/
@GetMapping( value = "timestamp" )
@GetMapping(value = "timestamp")
public String timestamp() {
return String.valueOf(System.currentTimeMillis());
}
......
......@@ -6,6 +6,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.UnBindReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoQueryRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import java.util.List;
......@@ -41,7 +42,7 @@ public interface IBindService extends IService<ParkBindInfo> {
* @param query
* @return
*/
List<ParkBindInfo> selectByQuery( BindInfoQueryReq query);
List<BindInfoQueryRes> selectByQuery(BindInfoQueryReq query);
/**
* 年检信息查询接口
......
......@@ -28,6 +28,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkVerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.BindInfoQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.UnBindReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoQueryRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes;
......@@ -111,7 +112,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
info.setUnqId(unqIdUtil.getUnqId());
info.setGmtBindTime(DateTime.now().toString());
info.setGmtBindTime(new Date());
mapper.insert(info);
return ResponseGenerator.success(new BindInfoRes(info.getUnqId()));
}
......@@ -148,8 +149,21 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
* @return
*/
@Override
public List<ParkBindInfo> selectByQuery(BindInfoQueryReq query) {
return bindCache.selectByQuery(query.getUserId());
public List<BindInfoQueryRes> selectByQuery(BindInfoQueryReq query) {
List<ParkBindInfo> parkBindInfos = bindCache.selectByQuery(query.getUserId());
List<BindInfoQueryRes> resList = new ArrayList<>(3);
if (parkBindInfos != null && !parkBindInfos.isEmpty()) {
for (ParkBindInfo item : parkBindInfos) {
BindInfoQueryRes resultItem = new BindInfoQueryRes();
resultItem.setPlateColor(item.getPlateColor());
resultItem.setPlateNum(item.getPlateNum());
resultItem.setUnqId(item.getUnqId());
resultItem.setGmtBindTime(item.getGmtBindTime().getTime());
resList.add(resultItem);
}
}
return resList;
}
@Override
......@@ -261,10 +275,10 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
}
/**
* 校验当前电话号码是否在10天内已通过验证
* 校验当前电话号码是否在1天内已通过验证
*/
ParkVerifyInfo verify = verifyInfo.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10));
DateUtil.offsetDay(DateTime.now(), -1));
if (verify == null) {
return ResponseGenerator.fail(StatusCode.PERMISSION_DENIED);
}
......@@ -295,8 +309,10 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
*/
DrivingLicenseInfoRes result = new DrivingLicenseInfoRes();
result.setDriverName(drivingLicenseRes.getXm());
result.setPlateNum(drivingLicenseRes.getSfzmhm());
result.setValidityTime(drivingLicenseRes.getYxqz());
result.setPlateNum(byPlateNumAndType.getHphm());
String validityTime = drivingLicenseRes.getYxqz();
validityTime.substring(0, validityTime.length() - 3);
result.setValidityTime(validityTime);
String status = DateUtil.compare(DateUtil.parseDate(drivingLicenseRes.getYxqz()), new Date()) >= 0 ? "有效" :
"已过期";
result.setStatus(status);
......
package com.hikcreate.edl.pub.web.mobile.infra.data.cache;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
......@@ -10,6 +9,7 @@ import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
......@@ -25,11 +25,12 @@ public class BindCache {
/**
* 获取绑定信息
*
* @param unqId
* @return
*/
@Cacheable( value = "bindinfo", key = "'id:'+#unqId", unless = "#result==null" )
public ParkBindInfo getById( String unqId ) {
@Cacheable(value = "bindinfo", key = "'id:'+#unqId", unless = "#result==null")
public ParkBindInfo getById(String unqId) {
LambdaQueryWrapper<ParkBindInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ParkBindInfo::getUnqId, unqId);
queryWrapper.eq(ParkBindInfo::getStatus, 1);
......@@ -38,30 +39,32 @@ public class BindCache {
/**
* 查询用户绑定信息
* @param userId 第三方用户ID
*
* @param userId 第三方用户ID
* @return
*/
@Cacheable( value = "bindinfo", key = "'userId:'+#userId", unless = "#result==null or #result.size()==0" )
public List<ParkBindInfo> selectByQuery( String userId) {
@Cacheable(value = "bindinfo", key = "'userId:'+#userId", unless = "#result==null or #result.size()==0")
public List<ParkBindInfo> selectByQuery(String userId) {
return mapper.selectByQuery(userId);
}
/**
* 解绑
* @param unqId 绑定唯一标识
*
* @param unqId 绑定唯一标识
* @param userId 第三方用户ID
* @return
*/
@Caching(evict = {
@CacheEvict( value = "bindinfo", key = "'id:'+#unqId", condition = "#unqId!=null"),
@CacheEvict( value = "bindinfo", key = "'userId:'+#userId", condition = "#userId!=null")
@CacheEvict(value = "bindinfo", key = "'id:'+#unqId", condition = "#unqId!=null"),
@CacheEvict(value = "bindinfo", key = "'userId:'+#userId", condition = "#userId!=null")
})
public boolean unBind(String unqId, String userId){
public boolean unBind(String unqId, String userId) {
ParkBindInfo bindInfo = new ParkBindInfo();
bindInfo.setUnqId(unqId);
bindInfo.setStatus("0");
bindInfo.setUnbindTime(DateTime.now().toString());
return mapper.unbind(bindInfo) > 0 ;
bindInfo.setUnbindTime(new Date());
return mapper.unbind(bindInfo) > 0;
}
}
......@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.infra.data.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.BindInfoQueryRes;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
......@@ -15,10 +16,10 @@ import java.util.List;
**/
public interface BindInfoMapper extends BaseMapper<ParkBindInfo> {
List<ParkBindInfo> selectByQuery( String userId);
List<ParkBindInfo> selectByQuery(String userId);
Integer bindInfoInsert( ParkBindInfo info);
Integer unbind( ParkBindInfo info);
Integer unbind(ParkBindInfo info);
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 绑定信息实体类
......@@ -47,11 +48,11 @@ public class ParkBindInfo implements Serializable {
/**
* 绑定时间
*/
private String gmtBindTime;
private Date gmtBindTime;
/**
* 解绑时间
*/
private String unbindTime;
private Date unbindTime;
}
package com.hikcreate.edl.pub.web.mobile.infra.model.entity;
import cn.hutool.core.date.DateTime;
import lombok.Data;
import java.util.Date;
/**
* 短信验证通过记录
*
......@@ -11,26 +13,26 @@ import lombok.Data;
@Data
public class ParkVerifyInfo {
/**
* 记录唯一id
*/
private int id;
/**
* 用户id
*/
private String userId;
/**
* 验证码
*/
private String verifyCode;
/**
* 电话号码
*/
private String phone;
/**
* 上次通过验证的时间
*/
private String passTime;
/**
* 记录唯一id
*/
private int id;
/**
* 用户id
*/
private String userId;
/**
* 验证码
*/
private String verifyCode;
/**
* 电话号码
*/
private String phone;
/**
* 上次通过验证的时间
*/
private Date passTime;
}
......@@ -27,5 +27,5 @@ public class UnBindReq {
* 时间戳
*/
@NotNull(message = "时间戳不能为空")
private long timestamp;
private long timestamp;
}
......@@ -2,6 +2,8 @@ package com.hikcreate.edl.pub.web.mobile.infra.model.param.response;
import lombok.Data;
import java.io.Serializable;
/**
* 公共加密返回消息类
* @author lixian
......@@ -9,7 +11,7 @@ import lombok.Data;
* @date 2020/6/19 10:44
**/
@Data
public class BaseEncryptRes {
public class BaseEncryptRes implements Serializable {
/**
* 加密字段
*/
......
package com.hikcreate.edl.pub.web.mobile.infra.model.param.response;
import lombok.Data;
import java.io.Serializable;
/**
* 绑定信息查询接口返回结果封装
*
* @author: xieshixiang
* @time:2020/6/22 19:52
**/
@Data
public class BindInfoQueryRes implements Serializable {
/**
* 绑定信息唯一标识,使用UUID
*/
private String unqId;
/**
* 车牌颜色:A:白,B:灰,C:黄,D:粉,E:红,
* F:紫,G:绿,H:蓝,I:棕,J:黑',
*/
private String plateColor;
/**
* 车牌号
*/
private String plateNum;
/**
* 绑定时间
*/
private Long gmtBindTime;
}
......@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
......@@ -15,7 +16,7 @@ import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultList<T> {
public class ResultList<T> implements Serializable {
List<T> list;
......
......@@ -10,24 +10,7 @@
<select id="selectByQuery" parameterType="java.lang.String"
resultType="com.hikcreate.edl.pub.web.mobile.infra.model.entity.ParkBindInfo">
select b.unq_id, b.user_id, b.phone,
case plate_color
when 'A' then '白'
when 'B' then '灰'
when 'C' then '黄'
when 'D' then '粉'
when 'E' then '红'
when 'F' then '紫'
when 'G' then '绿'
when 'H' then '蓝'
when 'I' then '棕'
when 'J' then '黑'
end plateColor,
case status
when '0' then '未绑定'
when '1' then '已绑定'
end status,
b.plate_num,b.plate_type,b.gmt_bind_time
select b.unq_id,b.plate_color,b.plate_num,b.gmt_bind_time
from park_bind_info as b
where b.status='1'
<if test="userId!=null and userId!=''">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment