Commit d7e1df8b authored by huangcb's avatar huangcb

新增接口:查看货主帐号审核历史

parent 23eee501
......@@ -40,4 +40,7 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.account.audit.1002}")
private String goodsOwnerAccountAudit1002;
@Value("${error-message.goodsowner.account.audit-history.1001}")
private String goodsOwnerAccountAuditHistory1001;
}
......@@ -9,14 +9,18 @@ import com.esv.freight.customer.common.util.VerifyUtils;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountForm;
import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock;
import com.esv.freight.customer.module.goodsowner.vo.AuditHistoryVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -24,6 +28,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
......@@ -141,4 +148,28 @@ public class GoodsOwnerController {
accountService.auditAccount(form);
return EResponse.ok();
}
/**
* description 查看帐号的审核历史
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/18 16:50
**/
@PostMapping("/audit/history")
public EResponse getAccountAuditHistory(@RequestBody @Validated(ValidatorAuditHistory.class) AccountForm form) throws EException {
// 查询审核历史
List<AuditHistoryEntity> auditHistoryEntityList = accountService.getAuditHistory(form.getId());
// 数据转换
List<AuditHistoryVO> auditHistoryVOList = new ArrayList<>();
auditHistoryEntityList.forEach(auditHistoryEntity -> {
AuditHistoryVO auditHistoryVO = new AuditHistoryVO();
BeanUtils.copyProperties(auditHistoryEntity, auditHistoryVO);
auditHistoryVO.setOperateTime(auditHistoryEntity.getOperateTime().getTime());
auditHistoryVOList.add(auditHistoryVO);
});
return EResponse.ok(auditHistoryVOList);
}
}
package com.esv.freight.customer.module.goodsowner.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock;
import lombok.Data;
......@@ -24,7 +23,7 @@ import javax.validation.constraints.NotNull;
@Data
public class AccountForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorBlock.class, ValidatorUnblock.class, ValidatorAudit.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorBlock.class, ValidatorUnblock.class, ValidatorAudit.class, ValidatorAuditHistory.class})
private Long id;
@NotNull(message = "参数auditStatus不能为空", groups = {ValidatorAudit.class})
......
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountForm;
import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm;
......@@ -79,5 +80,14 @@ public interface AccountService extends IService<AccountEntity> {
**/
void auditAccount(AccountForm form);
/**
* description 获取帐号审核历史
* param [id]
* return java.util.List<com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity>
* author Administrator
* createTime 2020/04/18 16:31
**/
List<AuditHistoryEntity> getAuditHistory(Long id);
}
......@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
......@@ -231,7 +232,23 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
AuditHistoryEntity auditHistoryEntity = new AuditHistoryEntity();
auditHistoryEntity.setAccountId(accountId);
auditHistoryEntity.setAuditStatus(form.getAuditStatus());
auditHistoryEntity.setRemark(form.getRemark());
auditHistoryEntity.setOperateUser(ReqUtils.getRequestHeader(GatewayHeaders.USER_ACCOUNT));
auditHistoryService.getBaseMapper().insert(auditHistoryEntity);
}
@Override
public List<AuditHistoryEntity> getAuditHistory(Long id) {
// 判断帐号是否存在
AccountEntity accountEntity = this.getAccountRecordById(id);
if (null == accountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAuditHistory1001());
}
// 查询审核历史
QueryWrapper<AuditHistoryEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", id);
queryWrapper.orderByAsc("operate_time");
return this.auditHistoryService.getBaseMapper().selectList(queryWrapper);
}
}
\ No newline at end of file
package com.esv.freight.customer.module.goodsowner.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组:审核历史
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.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.goodsowner.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.goodsowner.vo.AuditHistoryVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/18 16:46
* @version:1.0
*/
@Data
public class AuditHistoryVO {
/**
* 审核状态:字典表
*/
private Integer auditStatus;
/**
* 备注
*/
private String remark;
/**
* 操作者
*/
private String operateUser;
/**
* 操作时间
*/
private Long operateTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -60,4 +60,6 @@ error-message:
1002: 帐号已启用
audit:
1001: 无效的帐号ID
1002: 帐号已审核通过
\ No newline at end of file
1002: 帐号已审核通过
audit-history:
1001: 无效的帐号ID
\ No newline at end of file
......@@ -371,4 +371,31 @@ public class GoodsOwnerControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
}
/**
* 查看帐号的审核历史
**/
@Test
public void f1_getAccountAuditHistory_success_test() throws Exception {
String url = "/goodsowner/account/audit/history";
// 构造数据
AccountForm form = new AccountForm();
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"));
}
}
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