Commit ed08c194 authored by hezhen's avatar hezhen

Merge branch 'dev-chw' of http://113.105.137.151:22280/youjj/cloud-platform into dev-chw

parents 99b3c6a9 01f42db2
...@@ -34,88 +34,88 @@ import java.util.List; ...@@ -34,88 +34,88 @@ import java.util.List;
@Slf4j @Slf4j
public class OrderViolationController extends BaseController<OrderViolationBiz, OrderViolation> implements UserRestInterface { public class OrderViolationController extends BaseController<OrderViolationBiz, OrderViolation> implements UserRestInterface {
@Autowired @Autowired
private UserFeign userFeign; private UserFeign userFeign;
@Autowired @Autowired
OrderDepositRefundRecordBiz orderDepositRefundRecordBiz; OrderDepositRefundRecordBiz orderDepositRefundRecordBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
private Long MAX_DRIVING_LICENSE_SIZE = 1024 * 1024 * 50L; @Override
public UserFeign getUserFeign() {
return userFeign;
}
private final String FILE_TYPE="JPG"; private Long MAX_DRIVING_LICENSE_SIZE = 1024 * 1024 * 50L;
/** private final String FILE_TYPE = "JPG";
* 保存违章记录
*
* @param orderViolation
* @param request
* @return
*/
@PostMapping("/saveOrderViolation")
public ObjectRestResponse saveOrderViolation(@RequestBody OrderViolation orderViolation, HttpServletRequest request) {
log.info("保存违章记录:orderViolation = {}", orderViolation.toString());
UserDTO userDTOD = getAdminUserInfo();
if (orderViolation.getId()==null) {
orderViolation.setIsDel(0);
orderViolation.setCrtHost(request.getRemoteHost());
orderViolation.setCrtName(userDTOD.getName());
orderViolation.setCrtUserId(userDTOD.getId());
orderViolation.setCrtTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
getBaseBiz().insertOrderViolation(orderViolation);
}else {
orderViolation.setUpdHost(request.getRemoteHost());
orderViolation.setUpdName(userDTOD.getName());
orderViolation.setUpdUserId(userDTOD.getId());
orderViolation.setUpdTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
getBaseBiz().updateOrderViolation(orderViolation);
}
orderDepositRefundRecordBiz.saveViolationDeposit(orderViolation);
return ObjectRestResponse.succ();
}
/** /**
* 通过订单id查询违章记录 * 保存违章记录
* *
* @param detailId * @param orderViolation
* @return * @param request
*/ * @return
@GetMapping("/getOne/{detailId}") */
public ObjectRestResponse<OrderViolation> getOne(@PathVariable Integer detailId) { @PostMapping("/saveOrderViolation")
Example exa = Example.builder(OrderViolation.class) public ObjectRestResponse saveOrderViolation(@RequestBody OrderViolation orderViolation, HttpServletRequest request) {
.where(WeekendSqls.<OrderViolation>custom().andEqualTo(OrderViolation::getDetailId, detailId) log.info("保存违章记录:orderViolation = {}", orderViolation.toString());
.andEqualTo(OrderViolation::getIsDel, 0)).build(); UserDTO userDTOD = getBusinessUserByAppUser();
List<OrderViolation> orderViolations = getBaseBiz().selectByExample(exa); if (orderViolation.getId() == null) {
if (orderViolations.size() > 1) { orderViolation.setIsDel(0);
throw new BaseException("The database has multiple records"); orderViolation.setCrtHost(request.getRemoteHost());
} orderViolation.setCrtName(userDTOD.getName());
OrderViolation orderViolation= new OrderViolation(); orderViolation.setCrtUserId(userDTOD.getId());
orderViolation=(orderViolations.size()==0)? null:orderViolations.get(0); orderViolation.setCrtTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
return ObjectRestResponse.succ(orderViolation); getBaseBiz().insertOrderViolation(orderViolation);
} } else {
orderViolation.setUpdHost(request.getRemoteHost());
orderViolation.setUpdName(userDTOD.getName());
orderViolation.setUpdUserId(userDTOD.getId());
orderViolation.setUpdTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
getBaseBiz().updateOrderViolation(orderViolation);
}
orderDepositRefundRecordBiz.saveViolationDeposit(orderViolation);
return ObjectRestResponse.succ();
}
/**
* 通过订单id查询违章记录
*
* @param detailId
* @return
*/
@GetMapping("/getOne/{detailId}")
public ObjectRestResponse<OrderViolation> getOne(@PathVariable Integer detailId) {
Example exa = Example.builder(OrderViolation.class)
.where(WeekendSqls.<OrderViolation>custom().andEqualTo(OrderViolation::getDetailId, detailId)
.andEqualTo(OrderViolation::getIsDel, 0)).build();
List<OrderViolation> orderViolations = getBaseBiz().selectByExample(exa);
if (orderViolations.size() > 1) {
throw new BaseException("The database has multiple records");
}
OrderViolation orderViolation = new OrderViolation();
orderViolation = (orderViolations.size() == 0) ? null : orderViolations.get(0);
return ObjectRestResponse.succ(orderViolation);
}
@PostMapping(value = "/upload/violation") @PostMapping(value = "/upload/violation")
public ObjectRestResponse uploadViolation(@RequestParam("file") MultipartFile file) public ObjectRestResponse uploadViolation(@RequestParam("file") MultipartFile file)
throws Exception { throws Exception {
Assert.notNull(file); Assert.notNull(file);
//文件类型 //文件类型
String contentType = file.getContentType(); String contentType = file.getContentType();
if (!FILE_TYPE.equalsIgnoreCase(contentType)||"png".equalsIgnoreCase(contentType)) { if (!FILE_TYPE.equalsIgnoreCase(contentType) || "png".equalsIgnoreCase(contentType)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"Picture format error"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "Picture format error");
} }
if (file.getSize() > MAX_DRIVING_LICENSE_SIZE) { if (file.getSize() > MAX_DRIVING_LICENSE_SIZE) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"Picture is too large"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "Picture is too large");
} }
return baseBiz.uploadViolation(file); return baseBiz.uploadViolation(file);
} }
@GetMapping(value = "/download/Violation/{realFileRelPath}") //匹配的是href中的download请求 @GetMapping(value = "/download/Violation/{realFileRelPath}") //匹配的是href中的download请求
public ResponseEntity<byte[]> downloadViolation(@RequestParam("realFileRelPath") String realFileRelPath) throws Exception { public ResponseEntity<byte[]> downloadViolation(@RequestParam("realFileRelPath") String realFileRelPath) throws Exception {
return baseBiz.downloadViolation(realFileRelPath); return baseBiz.downloadViolation(realFileRelPath);
} }
} }
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