Commit 256fc793 by lixian7

Merge remote-tracking branch 'origin/master'

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