Commit a0981ee2 by xieshixiang

为绑定请求参数中的车牌颜色,增加正则校验

parent be72e56d
...@@ -95,16 +95,16 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -95,16 +95,16 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
PlateNumQueryReq req = new PlateNumQueryReq(); PlateNumQueryReq req = new PlateNumQueryReq();
req.setPlateNum(info.getPlateNum()); req.setPlateNum(info.getPlateNum());
List<VehicleRes> byPlateNum = vechicleCache.getByPlateNum(req); List<VehicleRes> byPlateNum = vechicleCache.getByPlateNum(req);
if (byPlateNum==null || byPlateNum.size()==0){ if (byPlateNum == null || byPlateNum.size() == 0) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR,"车辆信息不存在"); return ResponseGenerator.fail(StatusCode.DATA_ERROR, "车辆信息不存在");
} }
for (VehicleRes res : byPlateNum) { for (VehicleRes res : byPlateNum) {
if (info.getPhone().equals(res.getSjhm())) { if (info.getPhone().equals(res.getSjhm())) {
info.setPlateType(res.getHpzl()); info.setPlateType(res.getHpzl());
} }
} }
if (info.getPlateType() == null || info.getPlateType().equals("")) { if (info.getPlateType() == null || "".equals(info.getPlateType())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR,"当前手机号,与车辆备案手机号不一致"); return ResponseGenerator.fail(StatusCode.DATA_ERROR, "当前手机号,与车辆备案手机号不一致");
} }
//规则3:判断当前车牌号是否已绑定 //规则3:判断当前车牌号是否已绑定
...@@ -115,7 +115,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -115,7 +115,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
queryWrapper.eq("status", "1"); queryWrapper.eq("status", "1");
ParkBindInfo bindExist = mapper.selectOne(queryWrapper); ParkBindInfo bindExist = mapper.selectOne(queryWrapper);
if (bindExist != null) { if (bindExist != null) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR,"此车牌号已绑定"); return ResponseGenerator.fail(StatusCode.DATA_ERROR, "此车牌号已绑定");
} else { } else {
info.setUnqId(UUID.randomUUID().toString()); info.setUnqId(UUID.randomUUID().toString());
mapper.insert(info); mapper.insert(info);
......
...@@ -4,6 +4,7 @@ import lombok.Data; ...@@ -4,6 +4,7 @@ import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/** /**
* @author lixian * @author lixian
...@@ -27,6 +28,7 @@ public class BindInfoReq { ...@@ -27,6 +28,7 @@ public class BindInfoReq {
* F:紫,G:绿,H:蓝,I:棕,J:黑', * F:紫,G:绿,H:蓝,I:棕,J:黑',
*/ */
@NotBlank(message = "车牌颜色不能为空") @NotBlank(message = "车牌颜色不能为空")
@Pattern(regexp = "[ABCDEFGHIJ]")
private String plateColor; private String plateColor;
/** /**
* 车牌号 * 车牌号
......
-- auto-generated definition -- auto-generated definition
...@@ -10,7 +10,9 @@ create table bind_info ...@@ -10,7 +10,9 @@ create table bind_info
plate_type varchar(20) not null comment '车牌类型', plate_type varchar(20) not null comment '车牌类型',
status varchar(10) default '1' null comment '绑定状态:0,未绑定,1,已绑定', status varchar(10) default '1' null comment '绑定状态:0,未绑定,1,已绑定',
gmt_bind_time datetime null comment '绑定时间', gmt_bind_time datetime null comment '绑定时间',
unbind_time datetime null comment '解绑时间' unbind_time datetime null comment '解绑时间',
constraint bind_info_pk
unique (user_id, unbind_time)
) )
comment '用户车辆绑定信息'; comment '用户车辆绑定信息';
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