Commit 113ab99b by xieshixiang

1.代码注释

2.定时清除失效绑定信息.
parent d98fe56e
......@@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* description: 基本的controller
* 基本的controller
*
* @author: xieshixiang
* @time:2020/6/18 16:00
......
......@@ -18,9 +18,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* description:绑定信息的controller
* 绑定信息的controller
*
* @author: xieshixiang
* @time:2020/6/18 15:59
......@@ -36,6 +35,14 @@ public class BindInfoControlller extends BaseController {
BindInfoMapper mapper;
/**
* 绑定用户信息的接口
*
* @param info
* @return Result
* @author: xsx
* @date: 2020/6/19 10:27
*/
@PostMapping("bind")
public Result bindInfo(@RequestBody BindInfo info) {
if (info == null) {
......@@ -45,15 +52,33 @@ public class BindInfoControlller extends BaseController {
}
/**
* 解绑用户信息的接口
*
* @param info
* @return Result
* @author: xsx
* @date: 2020/6/19 10:27
*/
@PostMapping("unbind")
public Result unbindInfo(@RequestBody BindInfo info) {
if (info == null) {
return Result.errorResult(ResultCode.PARAMETER_ERROR, "参数不能为空");
}
info.setEditorTime(new DateTime());
info.setStatus("0");
info.setEditorTime(DateTime.now());
return mapper.updateById(info) > 0 ? Result.successResult() : Result.errorResult();
}
/**
* 绑定信息查询接口
*
* @param query
* @return Result
* @author: xsx
* @date: 2020/6/19 10:31
*/
@PostMapping("query")
public Result bindInfoQery(@RequestBody BindInfoQuery query) {
if (query == null) {
......@@ -62,7 +87,14 @@ public class BindInfoControlller extends BaseController {
return Result.successResult(mapper.selectByQuery(query));
}
/**
* 鉴权接口
*
* @param query
* @return Result
* @author: xsx
* @date: 2020/6/19 10:32
*/
@GetMapping("authentication")
public Result authority(@RequestBody BindInfoQuery query) {
if (query == null) {
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- <springProperty scope="context" name="logPath" source="logging.path" defaultValue="../../log"/>-->
<springProperty scope="context" name="logPath" source="logging.path" defaultValue="../../log"/>
<property name="logPath" value="../../../log/park"/>
<property name="appName" value="park"/>
......
......@@ -5,13 +5,21 @@ import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
/**
* description: 客户绑定服务接口
* 客户绑定服务接口
*
* @author: xieshixiang
* @time:2020/6/18 16:11
**/
public interface IBindService extends IService<BindInfo> {
/**
* 信息绑定接口
*
* @param info
* @return Result
* @author: xsx
* @date: 2020/6/19 10:32
*/
Result bind(BindInfo info);
}
package com.hikcreate.edl.pub.web.mobile.domain.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.enums.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.UserDataFegin;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.UUID;
......@@ -20,15 +26,20 @@ import java.util.UUID;
* @time:2020/6/18 16:12
**/
@Service
@EnableScheduling
@Slf4j
public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> implements IBindService {
@Resource
BindInfoMapper mapper;
@Resource
UserDataFegin fegin;
@Override
public Result bind(BindInfo info) {
info.setUnqId(UUID.randomUUID().toString());
info.setEditorTime(new DateTime());
info.setEditorTime(DateTime.now());
//判断规则1:用户已绑定的车辆不超过3辆
QueryWrapper boundQuery = new QueryWrapper();
......@@ -41,4 +52,22 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
return null;
}
@PostConstruct
public void init() {
clearPast();
}
@Scheduled(cron = "0 0/30 * * * ? ")
public void clearPast() {
DateTime now = DateTime.now();
log.info("开始清除,已过期且无效的绑定信息.当前时间:" + now);
DateTime lastMonth = DateUtil.offsetDay(now, -30);
Integer count = mapper.clearPast(lastMonth);
log.info("清除完毕,共清除过期且无效的绑定信息:" + count);
}
}
package com.hikcreate.edl.pub.web.mobile.infra.core.page;
/**
* description:
* 查询对象公共封装类
*
* @author: xieshixiang
* @time:2020/6/18 16:17
**/
public class PageQuery {
/**
* 当前页码
*/
private int pageNum = 1;
/**
* 此次查询的数据条数
*/
private int pageSize = 10;
public PageQuery() {
......
package com.hikcreate.edl.pub.web.mobile.infra.data.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* description:
......
package com.hikcreate.edl.pub.web.mobile.infra.data.mapper;
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;
......@@ -15,4 +16,7 @@ public interface BindInfoMapper extends BaseMapper<BindInfo> {
PageResult<BindInfo> selectByQuery(BindInfoQuery query);
Integer clearPast(DateTime dateTime);
}
package com.hikcreate.edl.pub.web.mobile.infra.model;
import cn.hutool.core.date.DateTime;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 绑定信息实体类
*
* @author: xsx
* @date: 2020/6/19 9:50
*/
@Data
public class BindInfo implements Serializable {
/**
* 绑定信息唯一标识,使用UUID
*/
private String unqId;
/**
* 客户id
*/
private String userId;
/**
* 客户电话号码
*/
private String phone;
/**
* 车牌颜色:A:白,B:灰,C:黄,D:粉,E:红,
* F:紫,G:绿,H:蓝,I:棕,J:黑',
*/
private String plateColor;
/**
* 车牌号
*/
private String plateNum;
/**
* 绑定信息状态:0,未绑定,1已绑定
*/
private String status;
private Date editorTime;
/**
* 信息的编辑时间
*/
private DateTime editorTime;
......
package com.hikcreate.edl.pub.web.mobile.infra.model;
import cn.hutool.core.date.DateTime;
import com.hikcreate.edl.pub.web.mobile.infra.core.page.PageQuery;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* description: 客户绑定信息请求实体类
* 绑定信息请求实体类
*
* @author: xieshixiang
* @time:2020/6/18 16:07
......@@ -15,10 +15,28 @@ import java.util.Date;
@Data
public class BindInfoQuery extends PageQuery implements Serializable {
/**
* 查询客户的id
*/
private String userId;
/**
*查询客户的电话号码
*/
private String phone;
/**
* 查询车辆的颜色
*/
private String plateColor;
/**
* 查询车辆的车牌号
*/
private String plateNum;
/**
* 查询车量的状态
*/
private String status;
private Date editorTime;
/**
* 信息的编辑时间
*/
private DateTime editorTime;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper">
<select id="selectByQuery" parameterType="com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery"
resultType="com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo">
select b.unq_id, b.user_id, b.phone,
......@@ -44,4 +43,9 @@
</where>
</select>
<delete id="clearPast">
delete from edl_public.bind_info as b where b.editor_time <![CDATA[ <= ]]> #{dateTime} and b.status='0'
</delete>
</mapper>
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