|
|
@ -1,103 +0,0 @@
|
|
|
|
package com.backend.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.backend.pojo.Express;
|
|
|
|
|
|
|
|
import com.backend.pojo.Result;
|
|
|
|
|
|
|
|
import com.backend.service.ExpressService;
|
|
|
|
|
|
|
|
import jakarta.validation.constraints.Pattern;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
|
|
@RequestMapping("/express")
|
|
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
|
|
public class ExpressController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ExpressService expressService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/addexpress")
|
|
|
|
|
|
|
|
public Result<Express> addexpress(
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[A-Za-z0-9]{10,20}$") final String expressid, // 快递ID,长度10-20字符,字母或数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{2,30}$") final String sename, // 发件人姓名,长度2-30字符,不能有空白
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-9]{11}$") final String sephone, // 发件人电话,11位数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{5,100}$") final String seaddress, // 发件人地址,长度5-100字符
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{2,30}$") final String rename, // 收件人姓名,长度2-30字符,不能有空白
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-9]{11}$") final String rephone, // 收件人电话,11位数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{5,100}$") final String readdress, // 收件人地址,长度5-100字符
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-1]$") final Integer issign, // 是否签收,0或1
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$") final Date signtime // 签收时间,格式yyyy-MM-dd HH:mm:ss
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
final Express existexpress = expressService.findExpressById(expressid);
|
|
|
|
|
|
|
|
if (existexpress== null) {
|
|
|
|
|
|
|
|
expressService.insert(expressid, sename, sephone, seaddress, rename, rephone, readdress, issign, signtime);
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Result.error("该快递单号已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/updateexpress")
|
|
|
|
|
|
|
|
public Result<Express> updateExpress(
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[A-Za-z0-9]{10,20}$") final String expressid, // 快递ID,长度10-20字符,字母或数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{2,30}$") final String sename, // 发件人姓名,长度2-30字符,不能有空白
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-9]{11}$") final String sephone, // 发件人电话,11位数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{5,100}$") final String seaddress, // 发件人地址,长度5-100字符
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{2,30}$") final String rename, // 收件人姓名,长度2-30字符,不能有空白
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-9]{11}$") final String rephone, // 收件人电话,10位数字
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\S{5,100}$") final String readdress, // 收件人地址,长度5-100字符
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[0-1]$") final Integer issign, // 是否签收,0或1
|
|
|
|
|
|
|
|
@Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$") final Date signtime // 签收时间,格式yyyy-MM-dd HH:mm:ss
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
Express express = new Express();
|
|
|
|
|
|
|
|
express.setExpressid(expressid);
|
|
|
|
|
|
|
|
express.setSename(sename);
|
|
|
|
|
|
|
|
express.setSephone(sephone);
|
|
|
|
|
|
|
|
express.setSeaddress(seaddress);
|
|
|
|
|
|
|
|
express.setRename(rename);
|
|
|
|
|
|
|
|
express.setRephone(rephone);
|
|
|
|
|
|
|
|
express.setReaddress(readdress);
|
|
|
|
|
|
|
|
express.setIssigned(issign);
|
|
|
|
|
|
|
|
express.setSigntime(signtime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expressService.update(express);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(express);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/deleteexpress")
|
|
|
|
|
|
|
|
public Result<Express> deleteExpress(
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[A-Za-z0-9]{10,20}$") final String expressid
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
final Express express = expressService.findExpressById(expressid);
|
|
|
|
|
|
|
|
if(express!= null){
|
|
|
|
|
|
|
|
expressService.delete(express);
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Result.error("快递单号为空或者不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/getexpress")
|
|
|
|
|
|
|
|
public Result<Express> getExpress(
|
|
|
|
|
|
|
|
@Pattern(regexp = "^[A-Za-z0-9]{10,20}$") final String expressid
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
final Express express = expressService.findExpressById(expressid);
|
|
|
|
|
|
|
|
if(express != null){
|
|
|
|
|
|
|
|
return Result.success(express);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Result.error("快递单号为空或者不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|