Commit c27be7fb authored by huangcb's avatar huangcb

承运商接口:查看审核历史

parent dbcbaa07
......@@ -154,4 +154,7 @@ public class ErrorMessageComponent {
private String carrierVehicleAudit1001;
@Value("${error-message.carrier.vehicle.audit.1002}")
private String carrierVehicleAudit1002;
@Value("${error-message.carrier.vehicle.audit-list.1001}")
private String carrierVehicleAuditList1001;
}
......@@ -11,10 +11,14 @@ import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.carrier.service.CarrierInfoService;
import com.esv.freight.customer.module.vehicle.VehicleConstants;
import com.esv.freight.customer.module.vehicle.dto.VehicleDetailDto;
import com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity;
import com.esv.freight.customer.module.vehicle.form.VehicleAuditForm;
import com.esv.freight.customer.module.vehicle.form.VehicleInfoForm;
import com.esv.freight.customer.module.vehicle.form.VehicleQueryForm;
import com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService;
import com.esv.freight.customer.module.vehicle.service.VehicleService;
import com.esv.freight.customer.module.vehicle.validator.groups.ValidatorAuditHistory;
import com.esv.freight.customer.module.vehicle.vo.VehicleAuditVO;
import com.esv.freight.customer.module.vehicle.vo.VehicleDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -27,6 +31,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 承运商车辆Controller
......@@ -47,12 +53,16 @@ public class VehicleController {
private VehicleService vehicleService;
private VehicleAuditHistoryService vehicleAuditHistoryService;
private CarrierInfoService carrierInfoService;
@Autowired
public VehicleController(ErrorMessageComponent errorMessageComponent, VehicleService vehicleService, CarrierInfoService carrierInfoService) {
public VehicleController(ErrorMessageComponent errorMessageComponent, VehicleService vehicleService,
VehicleAuditHistoryService vehicleAuditHistoryService , CarrierInfoService carrierInfoService) {
this.errorMessageComponent = errorMessageComponent;
this.vehicleService = vehicleService;
this.vehicleAuditHistoryService = vehicleAuditHistoryService;
this.carrierInfoService = carrierInfoService;
}
......@@ -64,7 +74,7 @@ public class VehicleController {
* createTime 2020/04/26 15:17
**/
@PostMapping("/add")
public EResponse insertVehicleByPlatform(@RequestBody @Validated(ValidatorInsert.class) VehicleInfoForm form) throws EException {
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) VehicleInfoForm form) throws EException {
/****************************** 参数校验 ******************************/
// 总质量/整备质量不能同时为空
if (null == form.getTotalMass() && null == form.getUnladenMass()) {
......@@ -133,4 +143,33 @@ public class VehicleController {
return EResponse.ok();
}
/**
* description 查看审核历史
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/27 16:36
**/
@PostMapping("/auditList")
public EResponse auditList(@RequestBody @Validated(ValidatorAuditHistory.class) VehicleQueryForm form) throws EException {
// 判断车辆是否存在
if (!vehicleService.vehicleExits(form.getId())) {
throw new EException(1001, errorMessageComponent.getCarrierVehicleAuditList1001());
}
// 查询审核历史
List<VehicleAuditHistoryEntity> entityList = vehicleAuditHistoryService.getVehicleAuditList(form.getId());
// 数据转换
List<VehicleAuditVO> voList = new ArrayList<>();
entityList.forEach(entity -> {
VehicleAuditVO vo = new VehicleAuditVO();
BeanUtils.copyProperties(entity, vo);
vo.setOperateTime(entity.getOperateTime().getTime());
voList.add(vo);
});
return EResponse.ok(voList);
}
}
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.vehicle.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.vehicle.validator.groups.ValidatorAuditHistory;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -23,7 +24,7 @@ public class VehicleQueryForm {
/**
*
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class, ValidatorAuditHistory.class})
private Long id;
/**
* 承运商帐号ID
......
......@@ -2,6 +2,9 @@ package com.esv.freight.customer.module.vehicle.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity;
import com.esv.freight.customer.module.vehicle.vo.VehicleAuditVO;
import java.util.List;
/**
* 车辆审核历史表
......@@ -12,5 +15,14 @@ import com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity;
*/
public interface VehicleAuditHistoryService extends IService<VehicleAuditHistoryEntity> {
/**
* description 获取车辆审核记录列表
* param [vehicleId]
* return java.util.List<com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity>
* author Administrator
* createTime 2020/04/27 16:23
**/
List<VehicleAuditHistoryEntity> getVehicleAuditList(Long vehicleId);
}
......@@ -51,5 +51,14 @@ public interface VehicleService extends IService<VehicleEntity> {
**/
void auditVehicle(VehicleAuditForm form);
/**
* description 车辆是否存在
* param [id]
* return java.lang.Boolean
* author Administrator
* createTime 2020/04/27 16:29
**/
Boolean vehicleExits(Long id);
}
package com.esv.freight.customer.module.vehicle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.module.vehicle.dao.VehicleAuditHistoryDao;
import com.esv.freight.customer.module.vehicle.entity.VehicleAuditHistoryEntity;
import com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService;
import com.esv.freight.customer.module.vehicle.vo.VehicleAuditVO;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("vehicleAuditHistoryService")
public class VehicleAuditHistoryServiceImpl extends ServiceImpl<VehicleAuditHistoryDao, VehicleAuditHistoryEntity> implements VehicleAuditHistoryService {
@Override
public List<VehicleAuditHistoryEntity> getVehicleAuditList(Long vehicleId) {
return this.baseMapper.selectList(new QueryWrapper<VehicleAuditHistoryEntity>().lambda()
.eq(VehicleAuditHistoryEntity::getVehicleId, vehicleId)
.orderByAsc(VehicleAuditHistoryEntity::getOperateTime));
}
}
\ No newline at end of file
......@@ -122,6 +122,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateVehicle(VehicleInfoForm form) {
// 1:校验
// 1.1校验车辆ID是否有效
......@@ -212,4 +213,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
vehicleAuditHistoryEntity.setRemark(form.getRemark());
this.vehicleAuditHistoryService.getBaseMapper().insert(vehicleAuditHistoryEntity);
}
@Override
public Boolean vehicleExits(Long id) {
int count = this.baseMapper.selectCount(new QueryWrapper<VehicleEntity>().lambda().eq(VehicleEntity::getId, id));
if (0 == count) {
return false;
} else {
return true;
}
}
}
\ No newline at end of file
package com.esv.freight.customer.module.vehicle.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组:审核历史
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.vehicle.validator.groups.ValidatorAuditHistory
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public interface ValidatorAuditHistory extends Default {
}
package com.esv.freight.customer.module.vehicle.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.vehicle.vo.VehicleAuditVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/27 16:20
* @version:1.0
*/
@Data
public class VehicleAuditVO {
/**
* 审核状态(字典表):1-审核成功,2-审核失败
**/
private Integer auditStatus;
/**
* 备注
**/
private String remark;
/**
* 审核人
**/
private String operateUser;
/**
* 审核时间
**/
private Long operateTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -135,4 +135,6 @@ error-message:
1001: 无效的车辆ID
audit:
1001: 无效的车辆ID
1002: 车辆已审核通过
\ No newline at end of file
1002: 车辆已审核通过
audit-list:
1001: 无效的车辆ID
\ No newline at end of file
......@@ -218,4 +218,33 @@ public class VehicleControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.PARAM_ERROR.code(), result.getIntValue("code"));
}
/**
* 查看审核历史
**/
@Test
public void c1_auditList_success_test() throws Exception {
String url = "/carrier/vehicle/auditList";
// 构造数据
VehicleQueryForm form = new VehicleQueryForm();
form.setId(1L);
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(null != result.getJSONArray("data"));
}
}
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