Commit 81be4042 authored by huangcb's avatar huangcb

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

parent 0a48f425
......@@ -210,4 +210,7 @@ public class ErrorMessageComponent {
private String carrierDriverRegister1001;
@Value("${error-message.carrier.driver.register.1002}")
private String carrierDriverRegister1002;
@Value("${error-message.carrier.driver.audit-history.1001}")
private String carrierDriverAuditHistory1001;
}
......@@ -12,11 +12,13 @@ import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.driver.DriverConstants;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.entity.DriverAuditHistoryEntity;
import com.esv.freight.customer.module.driver.form.DriverAuditForm;
import com.esv.freight.customer.module.driver.form.DriverInfoForm;
import com.esv.freight.customer.module.driver.form.DriverQueryForm;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister;
import com.esv.freight.customer.module.driver.vo.DriverAuditHistoryVO;
import com.esv.freight.customer.module.driver.vo.DriverDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -28,6 +30,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @project: freight-customer-service
......@@ -188,4 +193,27 @@ public class DriverController {
return EResponse.ok(data);
}
/**
* description 查看帐号的审核历史
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/29 11:30
**/
@PostMapping("/auditHistory")
public EResponse auditHistory(@RequestBody @Validated(ValidatorDetail.class) DriverQueryForm form) throws EException {
List<DriverAuditHistoryEntity> entityList = driverAccountService.getAuditHistory(form.getId());
// 数据转换
List<DriverAuditHistoryVO> voList = new ArrayList<>();
entityList.forEach(entity -> {
DriverAuditHistoryVO vo = new DriverAuditHistoryVO();
BeanUtils.copyProperties(entity, vo);
vo.setOperateTime(entity.getOperateTime().getTime());
voList.add(vo);
});
return EResponse.ok(voList);
}
}
......@@ -3,9 +3,12 @@ package com.esv.freight.customer.module.driver.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.entity.DriverAuditHistoryEntity;
import com.esv.freight.customer.module.driver.form.DriverAuditForm;
import com.esv.freight.customer.module.driver.form.DriverInfoForm;
import java.util.List;
/**
* 司机帐号表
*
......@@ -77,6 +80,15 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
* createTime 2020/04/29 10:43
**/
Long registerDriver(DriverInfoForm form);
/**
* description 查看帐号的审核历史
* param [id]
* return java.util.List<com.esv.freight.customer.module.driver.entity.DriverAuditHistoryEntity>
* author Administrator
* createTime 2020/04/29 11:21
**/
List<DriverAuditHistoryEntity> getAuditHistory(Long id);
}
......@@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service("driverAccountService")
public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, DriverAccountEntity> implements DriverAccountService {
......@@ -286,4 +288,15 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
return driverId;
}
@Override
public List<DriverAuditHistoryEntity> getAuditHistory(Long id) {
DriverAccountEntity driverAccountEntity = this.baseMapper.selectById(id);
if (null == driverAccountEntity) {
throw new EException(1001, errorMessageComponent.getCarrierDriverAuditHistory1001());
}
return this.driverAuditHistoryService.getBaseMapper().selectList(new QueryWrapper<DriverAuditHistoryEntity>().lambda()
.eq(DriverAuditHistoryEntity::getDriverId, id).orderByAsc(DriverAuditHistoryEntity::getOperateTime));
}
}
\ No newline at end of file
package com.esv.freight.customer.module.driver.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.driver.vo.DriverAuditHistoryVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/29 11:27
* @version:1.0
*/
@Data
public class DriverAuditHistoryVO {
/**
* 审核状态(字典表):0-待审核、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);
}
}
......@@ -169,4 +169,6 @@ error-message:
1002: 帐号已启用
register:
1001: 帐号已存在
1002: 无效的承运商ID​
\ No newline at end of file
1002: 无效的承运商ID​
audit-history:
1001: 无效的账号ID
\ No newline at end of file
......@@ -481,4 +481,61 @@ public class DriverAccountTest extends BaseTestController {
Assert.assertEquals(1002, result.getIntValue("code"));
}
/**
* 查看帐号的审核历史
**/
@Test
public void e1_auditHistory_success_test() throws Exception {
String url = "/carrier/driver/auditHistory";
// 构造数据
DriverQueryForm form = new DriverQueryForm();
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"));
}
/**
* 查看帐号的审核历史:无效的帐号ID
**/
@Test
public void e2_auditHistory_wrong_id_failure_test() throws Exception {
String url = "/carrier/driver/auditHistory";
// 构造数据
DriverQueryForm form = new DriverQueryForm();
form.setId(99999L);
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(1001, result.getIntValue("code"));
}
}
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