Commit 0ba3fc03 by lixian7

调整接口

parent fe694fe2
package com.hikcreate.edl.pub.web.mobile.api.controller;
import cn.hutool.core.date.DateTime;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
......@@ -8,7 +7,9 @@ import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
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.ResultList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -59,19 +60,14 @@ public class BindInfoControlller extends BaseController {
/**
* 解绑用户信息的接口
*
* @param query
* @param req
* @return Result
* @author: xsx
* @date: 2020/6/19 10:27
*/
@PostMapping("unbind")
public Response unbindInfo(@RequestBody @Validated BindInfoQuery query) {
BindInfo bindInfo = new BindInfo();
bindInfo.setUnqId(query.getUnqId());
bindInfo.setStatus("0");
bindInfo.setUnbindTime(DateTime.now().toString());
return mapper.unbind(bindInfo) > 0 ? ResponseGenerator.success() : ResponseGenerator.fail("");
public Response unbindInfo(@RequestBody @Validated UnBindReq req) {
return service.unbindInfo(req) ? ResponseGenerator.success() : ResponseGenerator.fail("解绑失败");
}
/**
......@@ -84,10 +80,8 @@ public class BindInfoControlller extends BaseController {
*/
@PostMapping("query")
@ResponseEncryptAnnotation
public Response<ResultList<BindInfo>> bindInfoQery(@RequestBody @Validated BindInfoQuery query) {
return ResponseGenerator.success(new ResultList<BindInfo>(mapper.selectByQuery(query).getDataItems()));
public Response<ResultList<BindInfo>> bindInfoQery(@RequestBody @Validated BindInfoQueryReq query) {
return ResponseGenerator.success(new ResultList<BindInfo>(service.selectByQuery(query)));
}
}
......@@ -12,7 +12,7 @@ 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.BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.H5BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.VerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.CheckVerifyCodeReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.SendVerifyCodeReq;
......@@ -63,7 +63,7 @@ public class H5Controller {
* @date: 2020/6/19 10:32
*/
@PostMapping("yearCheckInfo")
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated BindInfoQuery query) {
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.yearCheckInfo(query);
}
......@@ -77,7 +77,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("violationInfo")
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated BindInfoQuery query) {
public Response<ResultList<ViolationInfoRes>> violationInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.violationInfo(query);
}
......@@ -91,7 +91,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("insuranceInfo")
public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated BindInfoQuery query) {
public Response<InsuranceInfoRes> insuranceInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.insuranceInfo(query);
}
......@@ -106,7 +106,7 @@ public class H5Controller {
* @date: 2020/6/19 16:28
*/
@PostMapping("drivingLicenseInfo")
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated BindInfoQuery query) {
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(@RequestBody @Validated H5BindInfoQuery query) {
return service.drivingLicenseInfo(query);
}
......@@ -117,7 +117,7 @@ public class H5Controller {
* @return
*/
@PostMapping("checkValidity")
public Response<CheckValidityRes> checkValidity( @RequestBody @Validated BindInfoQuery query) {
public Response<CheckValidityRes> checkValidity( @RequestBody @Validated H5BindInfoQuery query) {
VerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10));
......
......@@ -3,9 +3,13 @@ package com.hikcreate.edl.pub.web.mobile.domain;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
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.DrivingLicenseInfoRes;
import java.util.List;
/**
* 客户绑定服务接口
......@@ -26,19 +30,33 @@ public interface IBindService extends IService<BindInfo> {
Response bind( BindInfo info);
/**
* 信息解绑
* @param req
* @return
*/
boolean unbindInfo( UnBindReq req );
/**
* 查询用户绑定信息
* @param query
* @return
*/
List<BindInfo> selectByQuery( BindInfoQueryReq query);
/**
* 年检信息查询接口
*
* @param query
* @return
*/
Response yearCheckInfo(BindInfoQuery query);
Response yearCheckInfo( H5BindInfoQuery query);
/**
* 保险信息查询接口
* @param query
* @return
*/
Response insuranceInfo(BindInfoQuery query);
Response insuranceInfo( H5BindInfoQuery query);
/**
* 违法信息查询接口
......@@ -48,7 +66,7 @@ public interface IBindService extends IService<BindInfo> {
* @author: xsx
* @date: 2020/6/19 16:06
*/
Response violationInfo( BindInfoQuery query);
Response violationInfo( H5BindInfoQuery query);
/**
* 驾照信息查询接口
......@@ -58,6 +76,6 @@ public interface IBindService extends IService<BindInfo> {
* @author: xsx
* @date: 2020/6/19 16:29
*/
Response<DrivingLicenseInfoRes> drivingLicenseInfo(BindInfoQuery query);
Response<DrivingLicenseInfoRes> drivingLicenseInfo( H5BindInfoQuery query);
}
......@@ -11,6 +11,7 @@ import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.data.cache.BindCache;
import com.hikcreate.edl.pub.web.mobile.infra.data.cache.VechicleCache;
import com.hikcreate.edl.pub.web.mobile.infra.data.cache.ViolationCache;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.DrivingLicenseFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.VechicleFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.ViolationFeign;
......@@ -24,8 +25,10 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.par
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
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.VerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.request.UnBindReq;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
......@@ -67,6 +70,8 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
BindCache bindCache;
@Resource
VechicleCache vechicleCache;
@Resource
ViolationCache violationCache;
@Override
......@@ -103,8 +108,30 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
}
}
/**
* 信息解绑
*
* @param req
* @return
*/
@Override
public boolean unbindInfo( UnBindReq req ) {
return bindCache.unBind(req.getUnqId());
}
/**
* 查询用户绑定信息
*
* @param query
* @return
*/
@Override
public List<BindInfo> selectByQuery( BindInfoQueryReq query ) {
return bindCache.selectByQuery(query.getUserId());
}
@Override
public Response<YearCheckInfoRes> yearCheckInfo(BindInfoQuery query) {
public Response<YearCheckInfoRes> yearCheckInfo( H5BindInfoQuery query) {
BindInfo bindInfo =bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR);
......@@ -131,7 +158,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
}
@Override
public Response<InsuranceInfoRes> insuranceInfo(BindInfoQuery query) {
public Response<InsuranceInfoRes> insuranceInfo( H5BindInfoQuery query) {
BindInfo bindInfo = bindCache.getById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR);
......@@ -166,7 +193,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
@Override
public Response<ResultList<ViolationInfoRes>> violationInfo(BindInfoQuery query) {
public Response<ResultList<ViolationInfoRes>> violationInfo( H5BindInfoQuery query) {
/**
* 校验当前的绑定信息是否存在
*/
......@@ -181,7 +208,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
ViolationPlateNumAndTypeQueryReq req = new ViolationPlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType());
List<ViolationRes> byPlateNumAndType = violatio.getByPlateNumAndType(req);
List<ViolationRes> byPlateNumAndType = violationCache.getByPlateNumAndType(req);
/**
* 构建违章信息返回列表
......@@ -200,7 +227,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
}
@Override
public Response<DrivingLicenseInfoRes> drivingLicenseInfo(BindInfoQuery query) {
public Response<DrivingLicenseInfoRes> drivingLicenseInfo( H5BindInfoQuery query) {
/**
* 校验当前的绑定信息是否存在
*/
......
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.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author lixian
......@@ -18,6 +22,11 @@ public class BindCache {
@Resource
private BindInfoMapper mapper;
/**
* 获取绑定信息
* @param unqId
* @return
*/
@Cacheable( value = "bindinfo", key = "'id:'+#unqId", unless = "#result==null" )
public BindInfo getById( String unqId ) {
LambdaQueryWrapper<BindInfo> queryWrapper = new LambdaQueryWrapper<>();
......@@ -25,4 +34,28 @@ public class BindCache {
queryWrapper.eq(BindInfo::getStatus, 1);
return mapper.selectOne(queryWrapper);
}
/**
* 查询用户绑定信息
* @param userId 第三方用户ID
* @return
*/
@Cacheable( value = "bindinfo", key = "'userId:'+#userId", unless = "#result==null or #result.size()==0" )
public List<BindInfo> selectByQuery( String userId) {
return mapper.selectByQuery(userId);
}
/**
* 解绑
* @param unqId
* @return
*/
@CacheEvict( value = "bindinfo", key = "'id:'+#unqId", condition = "#unqId!=null")
public boolean unBind(String unqId){
BindInfo bindInfo = new BindInfo();
bindInfo.setUnqId(unqId);
bindInfo.setStatus("0");
bindInfo.setUnbindTime(DateTime.now().toString());
return mapper.unbind(bindInfo) > 0 ;
}
}
......@@ -29,7 +29,7 @@ public class VechicleCache {
* @return
* @param号牌号码
*/
@Cacheable(value = "vehicles", key = "'platenum:'+#req.plateNum", unless = "#result==null or #result.size()==0")
@Cacheable(value = "vehicles", key = "'plateNum:'+#req.plateNum", unless = "#result==null or #result.size()==0")
public List<VehicleRes> getByPlateNum( @RequestBody PlateNumQueryReq req){
return vechicle.getByPlateNum(req);
}
......
package com.hikcreate.edl.pub.web.mobile.infra.data.cache;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.ViolationFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.ViolationIdCardQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.ViolationPlateNumAndTypeQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.ViolationRes;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author lixian
* @description
* @date 2020/6/21 16:46
**/
@Component
public class ViolationCache {
@Resource
ViolationFeign violatio;
/**
* 查询违法数据
*
* @param req 号牌+号牌类型,时间开始-结束
* @return
*/
@Cacheable(value = "violations", key = "'plateNum:'+#req.plateNum+':plateType:'+req.plateType+':timeStart:'+#req.timeStart+':timeEnd:'+#req.timeEnd", unless = "#result==null or #result.size()==0")
public List<ViolationRes> getByPlateNumAndType( ViolationPlateNumAndTypeQueryReq req ) {
return violatio.getByPlateNumAndType(req);
}
}
......@@ -18,16 +18,6 @@ import java.util.List;
@FeignClient(url = "http://10.197.236.100:40204",name = "dcp-service-vehicle", path = "violation",contextId ="dcp" +
"-service-vehicle-violation")
public interface ViolationFeign {
/**
* 查询违法数据
*
* @param req 身份证号,时间开始-结束
* @return
*/
@PostMapping("/getByIdCard")
List<ViolationRes> getByIdCard(@RequestBody ViolationIdCardQueryReq req);
/**
* 查询违法数据
*
......
......@@ -4,7 +4,10 @@ import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hikcreate.edl.pub.web.mobile.infra.core.page.PageResult;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
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 java.util.List;
/**
* description:
......@@ -14,7 +17,7 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
**/
public interface BindInfoMapper extends BaseMapper<BindInfo> {
PageResult<BindInfo> selectByQuery(BindInfoQuery query);
List<BindInfo> selectByQuery( String userId);
Integer clearPast(DateTime dateTime);
......
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author lixian
* @description
* @date 2020/6/21 17:00
**/
@Data
public class BindInfoQueryReq {
/**
* 查询客户的id
*/
@NotBlank(message = "客户唯一编码不能为空")
private String userId;
/**
* 时间戳
*/
@NotNull(message = "时间戳不能为空")
private long timestamp;
}
package com.hikcreate.edl.pub.web.mobile.infra.model;
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.Data;
......@@ -12,7 +12,7 @@ import java.io.Serializable;
* @time:2020/6/18 16:07
**/
@Data
public class BindInfoQuery implements Serializable {
public class H5BindInfoQuery implements Serializable {
/**
* 绑定信息的唯一标识.
......
package com.hikcreate.edl.pub.web.mobile.infra.model.param.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author lixian
* @description
* @date 2020/6/21 16:34
**/
@Data
public class UnBindReq {
/**
* 绑定信息唯一标识
*/
@NotBlank(message = "绑定信息唯一标识不能为空")
private String unqId;
/**
* 客户id
*/
@NotBlank(message = "客户唯一编码不能为空")
private String userId;
/**
* 时间戳
*/
@NotNull(message = "时间戳不能为空")
private long timestamp;
}
......@@ -8,7 +8,7 @@
</insert>
<select id="selectByQuery" parameterType="com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery"
<select id="selectByQuery" parameterType="java.lang.String"
resultType="com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo">
select b.unq_id, b.user_id, b.phone,
case plate_color
......@@ -27,13 +27,12 @@
when '0' then '未绑定'
when '1' then '已绑定'
end status,
b.plate_num,b.plate_type,b.gmt_bind_time from edl_public.bind_info as b where b.status='1'
b.plate_num,b.plate_type,b.gmt_bind_time
from edl_public.bind_info as b
where b.status='1'
<if test="userId!=null and nuserId!=''">
and b.user_id=#{userId}
</if>
<if test="phone!=null and phone!=''">
and b.phone=#{phone}
</if>
</select>
<update id="unbind">
......
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