Commit c58cbc5b authored by huangcb's avatar huangcb

线下文本合同:货主合同-增加

parent 6278fb78
......@@ -271,4 +271,9 @@ public class ErrorMessageComponent {
private String carrierDriverVehicleCheckBind1002;
@Value("${error-message.carrier.driver.vehicle-check-bind.1003}")
private String carrierDriverVehicleCheckBind1003;
@Value("${error-message.contract.offline.goods-owner.add.1001}")
private String contractOfflineGoodsOwnerAdd1001;
@Value("${error-message.contract.offline.goods-owner.add.1002}")
private String contractOfflineGoodsOwnerAdd1002;
}
package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.module.contract.form.ContractOfflineGoodsOwnerForm;
import com.esv.freight.customer.module.contract.service.ContractOfflineGoodsOwnerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 线下文本合同-货主合同
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.controller.ContractOfflineGoodsOwnerController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/19 16:06
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/contract/offline/goodsowner")
@Validated
public class ContractOfflineGoodsOwnerController {
private ContractOfflineGoodsOwnerService contractOfflineGoodsOwnerService;
@Autowired
public ContractOfflineGoodsOwnerController(ContractOfflineGoodsOwnerService contractOfflineGoodsOwnerService) {
this.contractOfflineGoodsOwnerService = contractOfflineGoodsOwnerService;
}
/**
* description 新增合同
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/19 16:10
**/
@PostMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) ContractOfflineGoodsOwnerForm form) throws EException {
Long id = contractOfflineGoodsOwnerService.addOfflineContract(form);
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
}
}
package com.esv.freight.customer.module.contract.dao;
import com.esv.freight.customer.module.contract.entity.ContractOfflineCarrierEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 线下文本合同(承运商)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
@Mapper
public interface ContractOfflineCarrierDao extends BaseMapper<ContractOfflineCarrierEntity> {
}
package com.esv.freight.customer.module.contract.dao;
import com.esv.freight.customer.module.contract.entity.ContractOfflineGoodsOwnerEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 线下文本合同(货主)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
@Mapper
public interface ContractOfflineGoodsOwnerDao extends BaseMapper<ContractOfflineGoodsOwnerEntity> {
}
package com.esv.freight.customer.module.contract.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.dto.ContractOfflineGoodsOwnerDto
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/19 14:16
* @version:1.0
*/
@Data
public class ContractOfflineGoodsOwnerDto {
/**
*
*/
private Long id;
/**
* 租户ID
*/
private Long tenantId;
/**
* 部门ID
*/
private Long departmentId;
/**
* 货主帐号ID
*/
private Long goodsOwnerId;
/**
* 合同编号
*/
private String contractNumber;
/**
* 合同名称
*/
private String contractName;
/**
* 合同类型:1-主合同、2-补充合同、3-临时合同
*/
private Integer contractType;
/**
* 合同签订日期
*/
private Date signDate;
/**
* 合同起始日期
*/
private Date startDate;
/**
* 合同截止日期
*/
private Date endDate;
/**
* 合同文件URL
*/
private String fileUrl;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Long createTime;
/**
* 修改时间
*/
private Long updateTime;
/**
* 货主类型:1-个人、2-企业
*/
private Integer ownerType;
/**
* 客户名称
*/
private String ownerFullName;
/**
* (个人或企业)联系人
*/
private String contactor;
}
package com.esv.freight.customer.module.contract.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 线下文本合同(承运商)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
@Data
@TableName("contract_offline_carrier")
public class ContractOfflineCarrierEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 合同编号
*/
private String contractNumber;
/**
* 合同名称
*/
private String contractName;
/**
* 合同类型:1-主合同、2-补充合同、3-临时合同
*/
private Integer contractType;
/**
* 合同签订日期
*/
private Date signDate;
/**
* 合同起始日期
*/
private Date startDate;
/**
* 合同截止日期
*/
private Date endDate;
/**
* 合同文件URL
*/
private String fileUrl;
/**
* 删除标识:0-未删除,1-已删除
*/
@TableLogic
private Boolean deleted;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createUser;
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}
package com.esv.freight.customer.module.contract.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 线下文本合同(货主)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
@Data
@TableName("contract_offline_goods_owner")
public class ContractOfflineGoodsOwnerEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 货主帐号ID
*/
private Long goodsOwnerId;
/**
* 合同编号
*/
private String contractNumber;
/**
* 合同名称
*/
private String contractName;
/**
* 合同类型:1-主合同、2-补充合同、3-临时合同
*/
private Integer contractType;
/**
* 合同签订日期
*/
private Date signDate;
/**
* 合同起始日期
*/
private Date startDate;
/**
* 合同截止日期
*/
private Date endDate;
/**
* 合同文件URL
*/
private String fileUrl;
/**
* 删除标识:0-未删除,1-已删除
*/
@TableLogic
private Boolean deleted;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createUser;
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}
package com.esv.freight.customer.module.contract.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOfflineGoodsOwnerForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/19 14:22
* @version:1.0
*/
@Data
public class ContractOfflineGoodsOwnerForm {
/**
*
*/
private Long id;
/**
* 货主帐号ID
*/
@NotNull(message = "参数goodsOwnerId不能为空", groups = {ValidatorInsert.class})
private Long goodsOwnerId;
/**
* 合同编号
*/
@Length(max = 50, message = "参数contractNumber长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数contractNumber不能为空", groups = {ValidatorInsert.class})
private String contractNumber;
/**
* 合同名称
*/
@Length(max = 50, message = "参数contractName长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数contractName不能为空", groups = {ValidatorInsert.class})
private String contractName;
/**
* 合同类型:1-主合同、2-补充合同、3-临时合同
*/
@Range(min = 1, max = 3, message = "参数contractType不合法", groups = {ValidatorInsert.class})
@NotNull(message = "参数contractType不能为空", groups = {ValidatorInsert.class})
private Integer contractType;
/**
* 合同签订日期
*/
@Length(min = 10, max = 10, message = "参数signDate长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数signDate不能为空", groups = {ValidatorInsert.class})
private String signDate;
/**
* 合同起始日期
*/
@Length(min = 10, max = 10, message = "参数startDate长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数startDate不能为空", groups = {ValidatorInsert.class})
private String startDate;
/**
* 合同截止日期
*/
@Length(min = 10, max = 10, message = "参数endDate长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数endDate不能为空", groups = {ValidatorInsert.class})
private String endDate;
/**
* 合同文件URL
*/
@Length(max = 200, message = "参数fileUrl长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数fileUrl不能为空", groups = {ValidatorInsert.class})
private String fileUrl;
/**
* 备注
*/
@Length(max = 200, message = "参数remark长度不合法", groups = {ValidatorInsert.class})
private String remark;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.contract.entity.ContractOfflineCarrierEntity;
/**
* 线下文本合同(承运商)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
public interface ContractOfflineCarrierService extends IService<ContractOfflineCarrierEntity> {
}
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.contract.entity.ContractOfflineGoodsOwnerEntity;
import com.esv.freight.customer.module.contract.form.ContractOfflineGoodsOwnerForm;
/**
* 线下文本合同(货主)
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-19 14:05:38
*/
public interface ContractOfflineGoodsOwnerService extends IService<ContractOfflineGoodsOwnerEntity> {
/**
* description 新增线下文本合同(货主)
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/05/19 14:49
**/
Long addOfflineContract(ContractOfflineGoodsOwnerForm form);
}
package com.esv.freight.customer.module.contract.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.module.contract.dao.ContractOfflineCarrierDao;
import com.esv.freight.customer.module.contract.entity.ContractOfflineCarrierEntity;
import com.esv.freight.customer.module.contract.service.ContractOfflineCarrierService;
import org.springframework.stereotype.Service;
@Service("contractOfflineCarrierService")
public class ContractOfflineCarrierServiceImpl extends ServiceImpl<ContractOfflineCarrierDao, ContractOfflineCarrierEntity> implements ContractOfflineCarrierService {
}
\ No newline at end of file
package com.esv.freight.customer.module.contract.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.common.component.ErrorMessageComponent;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.util.DateUtils;
import com.esv.freight.customer.module.contract.dao.ContractOfflineGoodsOwnerDao;
import com.esv.freight.customer.module.contract.entity.ContractOfflineGoodsOwnerEntity;
import com.esv.freight.customer.module.contract.form.ContractOfflineGoodsOwnerForm;
import com.esv.freight.customer.module.contract.service.ContractOfflineGoodsOwnerService;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("contractOfflineGoodsOwnerService")
public class ContractOfflineGoodsOwnerServiceImpl extends ServiceImpl<ContractOfflineGoodsOwnerDao, ContractOfflineGoodsOwnerEntity> implements ContractOfflineGoodsOwnerService {
private ErrorMessageComponent errorMessageComponent;
private GoodsOwnerAccountService goodsOwnerAccountService;
@Autowired
public ContractOfflineGoodsOwnerServiceImpl(ErrorMessageComponent errorMessageComponent, GoodsOwnerAccountService goodsOwnerAccountService) {
this.errorMessageComponent = errorMessageComponent;
this.goodsOwnerAccountService = goodsOwnerAccountService;
}
@Override
public Long addOfflineContract(ContractOfflineGoodsOwnerForm form) {
// 1:校验
GoodsOwnerAccountEntity goodsOwnerAccountEntity = goodsOwnerAccountService.getAccountRecordById(form.getGoodsOwnerId());
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getContractOfflineGoodsOwnerAdd1001());
}
int count = this.baseMapper.selectCount(new LambdaQueryWrapper<ContractOfflineGoodsOwnerEntity>()
.eq(ContractOfflineGoodsOwnerEntity::getGoodsOwnerId, form.getGoodsOwnerId())
.eq(ContractOfflineGoodsOwnerEntity::getContractNumber, form.getContractNumber()));
if (0 < count) {
throw new EException(1002, errorMessageComponent.getContractOfflineGoodsOwnerAdd1002());
}
// 2:新增记录
ContractOfflineGoodsOwnerEntity contractOfflineGoodsOwnerEntity = new ContractOfflineGoodsOwnerEntity();
BeanUtils.copyProperties(form, contractOfflineGoodsOwnerEntity);
contractOfflineGoodsOwnerEntity.setSignDate(DateUtils.parse(form.getSignDate(), DateUtils.DATE_FORMAT3));
contractOfflineGoodsOwnerEntity.setStartDate(DateUtils.parse(form.getStartDate(), DateUtils.DATE_FORMAT3));
contractOfflineGoodsOwnerEntity.setEndDate(DateUtils.parse(form.getEndDate(), DateUtils.DATE_FORMAT3));
this.baseMapper.insert(contractOfflineGoodsOwnerEntity);
return contractOfflineGoodsOwnerEntity.getId();
}
}
\ No newline at end of file
package com.esv.freight.customer.module.contract.vo;
import lombok.Data;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.vo.ContractOfflineGoodsOwnerVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/19 14:24
* @version:1.0
*/
@Data
public class ContractOfflineGoodsOwnerVO {
/**
*
*/
private Long id;
/**
* 货主帐号ID
*/
private Long goodsOwnerId;
/**
* 合同编号
*/
private String contractNumber;
/**
* 合同名称
*/
private String contractName;
/**
* 合同类型:1-主合同、2-补充合同、3-临时合同
*/
private Integer contractType;
/**
* 合同签订日期
*/
private Long signDate;
/**
* 合同起始日期
*/
private Long startDate;
/**
* 合同截止日期
*/
private Long endDate;
/**
* 合同文件URL
*/
private String fileUrl;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
private String createUser;
/**
* 创建时间
*/
private Long createTime;
/**
* 客户名称
*/
private String ownerName;
}
......@@ -19,7 +19,7 @@ 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.form.AccountQueryForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import com.esv.freight.customer.module.goodsowner.validator.groups.*;
import com.esv.freight.customer.module.goodsowner.vo.AccountInfoVO;
import com.esv.freight.customer.module.goodsowner.vo.AuditHistoryVO;
......@@ -51,15 +51,15 @@ import java.util.List;
@Validated
public class GoodsOwnerController {
private AccountService accountService;
private GoodsOwnerAccountService goodsOwnerAccountService;
private ErrorMessageComponent errorMessageComponent;
private PasswordComponent passwordComponent;
@Autowired
public GoodsOwnerController(AccountService accountService, ErrorMessageComponent errorMessageComponent, PasswordComponent passwordComponent) {
this.accountService = accountService;
public GoodsOwnerController(GoodsOwnerAccountService goodsOwnerAccountService, ErrorMessageComponent errorMessageComponent, PasswordComponent passwordComponent) {
this.goodsOwnerAccountService = goodsOwnerAccountService;
this.errorMessageComponent = errorMessageComponent;
this.passwordComponent = passwordComponent;
}
......@@ -85,7 +85,7 @@ public class GoodsOwnerController {
}
/****************************** 参数校验 ******************************/
return EResponse.ok(accountService.createAccountByManager(form));
return EResponse.ok(goodsOwnerAccountService.createAccountByManager(form));
}
/**
......@@ -104,7 +104,7 @@ public class GoodsOwnerController {
}
/****************************** 参数校验 ******************************/
accountService.updateAccountInfo(form);
goodsOwnerAccountService.updateAccountInfo(form);
return EResponse.ok();
}
......@@ -117,7 +117,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/block")
public EResponse blockAccount(@RequestBody @Validated(ValidatorBlock.class) AccountForm form) throws EException {
accountService.blockAccount(form.getId());
goodsOwnerAccountService.blockAccount(form.getId());
return EResponse.ok();
}
......@@ -130,7 +130,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/unblock")
public EResponse unblockAccount(@RequestBody @Validated(ValidatorUnblock.class) AccountForm form) throws EException {
accountService.unblockAccount(form.getId());
goodsOwnerAccountService.unblockAccount(form.getId());
return EResponse.ok();
}
......@@ -150,7 +150,7 @@ public class GoodsOwnerController {
}
/****************************** 参数校验 ******************************/
accountService.auditAccount(form);
goodsOwnerAccountService.auditAccount(form);
return EResponse.ok();
}
......@@ -164,7 +164,7 @@ public class GoodsOwnerController {
@PostMapping("/audit/history")
public EResponse getAccountAuditHistory(@RequestBody @Validated(ValidatorAuditHistory.class) AccountForm form) throws EException {
// 查询审核历史
List<AuditHistoryEntity> auditHistoryEntityList = accountService.getAuditHistory(form.getId());
List<AuditHistoryEntity> auditHistoryEntityList = goodsOwnerAccountService.getAuditHistory(form.getId());
// 数据转换
List<AuditHistoryVO> auditHistoryVOList = new ArrayList<>();
......@@ -193,7 +193,7 @@ public class GoodsOwnerController {
}
/****************************** 参数校验 ******************************/
AccountInfoDto accountInfoDto = accountService.getAccountInfo(form);
AccountInfoDto accountInfoDto = goodsOwnerAccountService.getAccountInfo(form);
// 查询结果处理
if (null != form.getId()) {
if (null == accountInfoDto) {
......@@ -221,7 +221,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/password/check")
public EResponse checkAccountPwd(@RequestBody @Validated(ValidatorPasswordCheck.class) AccountForm form) throws EException {
AccountInfoDto accountInfoDto = accountService.getAccountInfo(form);
AccountInfoDto accountInfoDto = goodsOwnerAccountService.getAccountInfo(form);
// 校验帐号是否存在
if (null == accountInfoDto) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountPasswordCheck1001());
......@@ -245,7 +245,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/password/reset")
public EResponse resetAccountPwd(@RequestBody @Validated(ValidatorPasswordReset.class) AccountForm form) throws EException {
accountService.resetAccountPwd(form);
goodsOwnerAccountService.resetAccountPwd(form);
return EResponse.ok();
}
......@@ -258,7 +258,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/register")
public EResponse accountRegister(@RequestBody @Validated(ValidatorRegister.class) AccountForm form) throws EException {
Long id = accountService.registerAccount(form.getAccount());
Long id = goodsOwnerAccountService.registerAccount(form.getAccount());
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
......@@ -273,7 +273,7 @@ public class GoodsOwnerController {
**/
@PostMapping("/list")
public EResponse getAccountList(@RequestBody @Validated(ValidatorList.class) AccountQueryForm form) throws EException {
PageResultVO pageResult = accountService.selectAccountInfoList(form);
PageResultVO pageResult = goodsOwnerAccountService.selectAccountInfoList(form);
return EResponse.ok(pageResult);
}
......@@ -286,6 +286,6 @@ public class GoodsOwnerController {
**/
@PostMapping("/getAllAvailable")
public EResponse getAllAvailable() throws EException {
return EResponse.ok(accountService.selectAllAvailableAccount());
return EResponse.ok(goodsOwnerAccountService.selectAllAvailableAccount());
}
}
......@@ -3,7 +3,7 @@ package com.esv.freight.customer.module.goodsowner.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountQueryForm;
import org.apache.ibatis.annotations.Mapper;
......@@ -17,7 +17,7 @@ import java.util.List;
* @date 2020-04-17 13:54:57
*/
@Mapper
public interface AccountDao extends BaseMapper<AccountEntity> {
public interface AccountDao extends BaseMapper<GoodsOwnerAccountEntity> {
/**
* description 通过帐号id获取帐号信息
......
......@@ -18,7 +18,7 @@ import java.util.Date;
*/
@Data
@TableName("goods_owner_account")
public class AccountEntity implements Serializable {
public class GoodsOwnerAccountEntity implements Serializable {
private static final long serialVersionUID = 5500989619988830120L;
/**
......
......@@ -3,7 +3,7 @@ package com.esv.freight.customer.module.goodsowner.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.common.vo.PageResultVO;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
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;
......@@ -19,25 +19,25 @@ import java.util.List;
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
*/
public interface AccountService extends IService<AccountEntity> {
public interface GoodsOwnerAccountService extends IService<GoodsOwnerAccountEntity> {
/**
* description 通过帐号查询帐号记录
* param [account]
* return com.esv.freight.customer.module.goodsowner.entity.AccountEntity
* return com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity
* author Administrator
* createTime 2020/04/17 15:46
**/
AccountEntity getAccountRecordByAccount(String account);
GoodsOwnerAccountEntity getAccountRecordByAccount(String account);
/**
* description 通过ID查询帐号记录
* param [id]
* return com.esv.freight.customer.module.goodsowner.entity.AccountEntity
* return com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity
* author Administrator
* createTime 2020/04/17 15:46
**/
AccountEntity getAccountRecordById(Long id);
GoodsOwnerAccountEntity getAccountRecordById(Long id);
/**
* description 通过管理平台创建帐号
......
......@@ -10,7 +10,7 @@ import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountAndAddressForm;
import com.esv.freight.customer.module.goodsowner.form.AccountForm;
import com.esv.freight.customer.module.goodsowner.service.AccountAndAddressService;
import com.esv.freight.customer.module.goodsowner.service.AccountService;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService;
import com.esv.freight.customer.module.goodsowner.service.ReceiveAddressService;
import com.esv.freight.customer.module.goodsowner.vo.account4address.AccountAndAddressVO;
......@@ -35,17 +35,17 @@ public class AccountAndAddressServiceIpml implements AccountAndAddressService {
private ErrorMessageComponent errorMessageComponent;
private AccountService accountService;
private GoodsOwnerAccountService goodsOwnerAccountService;
private DeliveryAddressService deliveryAddressService;
private ReceiveAddressService receiveAddressService;
@Autowired
public AccountAndAddressServiceIpml(ErrorMessageComponent errorMessageComponent, AccountService accountService,
public AccountAndAddressServiceIpml(ErrorMessageComponent errorMessageComponent, GoodsOwnerAccountService goodsOwnerAccountService,
DeliveryAddressService deliveryAddressService, ReceiveAddressService receiveAddressService) {
this.errorMessageComponent = errorMessageComponent;
this.accountService = accountService;
this.goodsOwnerAccountService = goodsOwnerAccountService;
this.deliveryAddressService = deliveryAddressService;
this.receiveAddressService = receiveAddressService;
}
......@@ -55,7 +55,7 @@ public class AccountAndAddressServiceIpml implements AccountAndAddressService {
// 1.校验货主ID是否有效
AccountForm accountForm = new AccountForm();
accountForm.setId(form.getOwnerId());
AccountInfoDto accountInfoDto = this.accountService.getAccountInfo(accountForm);
AccountInfoDto accountInfoDto = this.goodsOwnerAccountService.getAccountInfo(accountForm);
if (null == accountInfoDto) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerExtAccountAddress1001());
}
......
......@@ -17,13 +17,13 @@ import com.esv.freight.customer.feign.FeignBaseService;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.dao.AccountDao;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.entity.InfoEntity;
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.form.AccountQueryForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import com.esv.freight.customer.module.goodsowner.service.AuditHistoryService;
import com.esv.freight.customer.module.goodsowner.service.InfoService;
import com.esv.freight.customer.module.goodsowner.vo.AccountAvailableVO;
......@@ -40,8 +40,8 @@ import java.util.ArrayList;
import java.util.List;
@Service("accountService")
public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> implements AccountService {
@Service("goodsOwnerAccountService")
public class GoodsOwnerAccountServiceImpl extends ServiceImpl<AccountDao, GoodsOwnerAccountEntity> implements GoodsOwnerAccountService {
private FeignBaseService feignBaseService;
......@@ -54,8 +54,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
private AuditHistoryService auditHistoryService;
@Autowired
public AccountServiceImpl(FeignBaseService feignBaseService, PasswordComponent passwordComponent,
ErrorMessageComponent errorMessageComponent, InfoService infoService, AuditHistoryService auditHistoryService) {
public GoodsOwnerAccountServiceImpl(FeignBaseService feignBaseService, PasswordComponent passwordComponent,
ErrorMessageComponent errorMessageComponent, InfoService infoService, AuditHistoryService auditHistoryService) {
this.feignBaseService = feignBaseService;
this.passwordComponent = passwordComponent;
this.errorMessageComponent = errorMessageComponent;
......@@ -64,18 +64,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
}
@Override
public AccountEntity getAccountRecordByAccount(String account) {
AccountEntity queryEntity = new AccountEntity();
public GoodsOwnerAccountEntity getAccountRecordByAccount(String account) {
GoodsOwnerAccountEntity queryEntity = new GoodsOwnerAccountEntity();
queryEntity.setAccount(account);
QueryWrapper<AccountEntity> queryWrapper = new QueryWrapper<>(queryEntity);
QueryWrapper<GoodsOwnerAccountEntity> queryWrapper = new QueryWrapper<>(queryEntity);
return this.baseMapper.selectOne(queryWrapper);
}
@Override
public AccountEntity getAccountRecordById(Long id) {
AccountEntity queryEntity = new AccountEntity();
public GoodsOwnerAccountEntity getAccountRecordById(Long id) {
GoodsOwnerAccountEntity queryEntity = new GoodsOwnerAccountEntity();
queryEntity.setId(id);
QueryWrapper<AccountEntity> queryWrapper = new QueryWrapper<>(queryEntity);
QueryWrapper<GoodsOwnerAccountEntity> queryWrapper = new QueryWrapper<>(queryEntity);
return this.baseMapper.selectOne(queryWrapper);
}
......@@ -83,11 +83,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Transactional(rollbackFor = Exception.class)
public Long createAccountByManager(AccountInfoForm form) {
// 1.判断帐号是否已存在
AccountEntity accountEntity = this.getAccountRecordByAccount(form.getAccount());
if (null != accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordByAccount(form.getAccount());
if (null != goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAdd1001());
} else {
accountEntity = new AccountEntity();
goodsOwnerAccountEntity = new GoodsOwnerAccountEntity();
}
// 2.获取客户编码
......@@ -105,16 +105,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
String ownerNumber = batchIdResJson.getString("batchId");
// 3.新增帐号
BeanUtils.copyProperties(form, accountEntity);
accountEntity.setId(null);
BeanUtils.copyProperties(form, goodsOwnerAccountEntity);
goodsOwnerAccountEntity.setId(null);
String salt = passwordComponent.generateAccountPwdSalt();
accountEntity.setSalt(salt);
accountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), salt));
accountEntity.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
accountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_PLATFORM);
accountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS);
this.baseMapper.insert(accountEntity);
Long accountId = accountEntity.getId();
goodsOwnerAccountEntity.setSalt(salt);
goodsOwnerAccountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), salt));
goodsOwnerAccountEntity.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
goodsOwnerAccountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_PLATFORM);
goodsOwnerAccountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS);
this.baseMapper.insert(goodsOwnerAccountEntity);
Long accountId = goodsOwnerAccountEntity.getId();
// 4.新增帐号信息
InfoEntity infoEntity = new InfoEntity();
......@@ -149,19 +149,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
public void updateAccountInfo(AccountInfoForm form) {
// 1.判断帐号是否存在
Long accountId = form.getId();
AccountEntity accountEntity = this.getAccountRecordById(accountId);
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordById(accountId);
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountEdit1001());
}
// 2.更新表:goods_owner_account,更新密码
String password = form.getPassword();
if (StringUtils.isNotBlank(password)) {
AccountEntity accountEntityUpdate = new AccountEntity();
accountEntityUpdate.setId(accountId);
password = DigestUtils.md5Hex(form.getPassword() + accountEntity.getSalt());
accountEntityUpdate.setPassword(password);
this.baseMapper.updateById(accountEntityUpdate);
GoodsOwnerAccountEntity goodsOwnerAccountEntityUpdate = new GoodsOwnerAccountEntity();
goodsOwnerAccountEntityUpdate.setId(accountId);
password = DigestUtils.md5Hex(form.getPassword() + goodsOwnerAccountEntity.getSalt());
goodsOwnerAccountEntityUpdate.setPassword(password);
this.baseMapper.updateById(goodsOwnerAccountEntityUpdate);
}
// 3.更新表:goods_owner_info
......@@ -189,59 +189,59 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
public void blockAccount(Long id) {
// 判断帐号是否存在
AccountEntity accountEntity = this.getAccountRecordById(id);
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordById(id);
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountBlock1001());
} else {
if (GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_BLOCK.equals(accountEntity.getAccountStatus())) {
if (GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_BLOCK.equals(goodsOwnerAccountEntity.getAccountStatus())) {
throw new EException(1002, errorMessageComponent.getGoodsOwnerAccountBlock1002());
}
}
// 停用帐号
AccountEntity accountEntityUpdate = new AccountEntity();
accountEntityUpdate.setId(id);
accountEntityUpdate.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_BLOCK);
this.baseMapper.updateById(accountEntityUpdate);
GoodsOwnerAccountEntity goodsOwnerAccountEntityUpdate = new GoodsOwnerAccountEntity();
goodsOwnerAccountEntityUpdate.setId(id);
goodsOwnerAccountEntityUpdate.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_BLOCK);
this.baseMapper.updateById(goodsOwnerAccountEntityUpdate);
}
@Override
public void unblockAccount(Long id) {
// 判断帐号是否存在
AccountEntity accountEntity = this.getAccountRecordById(id);
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordById(id);
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountUnblock1001());
} else {
if (GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK.equals(accountEntity.getAccountStatus())) {
if (GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK.equals(goodsOwnerAccountEntity.getAccountStatus())) {
throw new EException(1002, errorMessageComponent.getGoodsOwnerAccountUnblock1002());
}
}
// 启用帐号
AccountEntity accountEntityUpdate = new AccountEntity();
accountEntityUpdate.setId(id);
accountEntityUpdate.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
this.baseMapper.updateById(accountEntityUpdate);
GoodsOwnerAccountEntity goodsOwnerAccountEntityUpdate = new GoodsOwnerAccountEntity();
goodsOwnerAccountEntityUpdate.setId(id);
goodsOwnerAccountEntityUpdate.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
this.baseMapper.updateById(goodsOwnerAccountEntityUpdate);
}
@Override
public void auditAccount(AccountForm form) {
// 1.判断帐号是否存在
Long accountId = form.getId();
AccountEntity accountEntity = this.getAccountRecordById(accountId);
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordById(accountId);
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAudit1001());
} else {
if (GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS.equals(accountEntity.getAuditStatus())) {
if (GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS.equals(goodsOwnerAccountEntity.getAuditStatus())) {
throw new EException(1002, errorMessageComponent.getGoodsOwnerAccountAudit1002());
}
}
// 2.更新帐号审核状态
AccountEntity accountEntityUpdate = new AccountEntity();
accountEntityUpdate.setId(accountId);
accountEntityUpdate.setAuditStatus(form.getAuditStatus());
this.baseMapper.updateById(accountEntityUpdate);
GoodsOwnerAccountEntity goodsOwnerAccountEntityUpdate = new GoodsOwnerAccountEntity();
goodsOwnerAccountEntityUpdate.setId(accountId);
goodsOwnerAccountEntityUpdate.setAuditStatus(form.getAuditStatus());
this.baseMapper.updateById(goodsOwnerAccountEntityUpdate);
// 3.更新帐号审核历史
AuditHistoryEntity auditHistoryEntity = new AuditHistoryEntity();
......@@ -255,8 +255,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
public List<AuditHistoryEntity> getAuditHistory(Long id) {
// 判断帐号是否存在
AccountEntity accountEntity = this.getAccountRecordById(id);
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordById(id);
if (null == goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAuditHistory1001());
}
......@@ -284,11 +284,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
public Long registerAccount(String account) {
// 1.判断帐号是否已存在
AccountEntity accountEntity = this.getAccountRecordByAccount(account);
if (null != accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.getAccountRecordByAccount(account);
if (null != goodsOwnerAccountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountRegister1001());
} else {
accountEntity = new AccountEntity();
goodsOwnerAccountEntity = new GoodsOwnerAccountEntity();
}
// 2.获取客户编码
......@@ -306,13 +306,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
String ownerNumber = batchIdResJson.getString("batchId");
// 3.新增帐号
accountEntity.setAccount(account);
accountEntity.setSalt(passwordComponent.generateAccountPwdSalt());
accountEntity.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
accountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_REGISTER);
accountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_UNAUDITED);
this.baseMapper.insert(accountEntity);
Long accountId = accountEntity.getId();
goodsOwnerAccountEntity.setAccount(account);
goodsOwnerAccountEntity.setSalt(passwordComponent.generateAccountPwdSalt());
goodsOwnerAccountEntity.setAccountStatus(GoodsOwnerConstants.OWNER_ACCOUNT_STATUS_UNBLOCK);
goodsOwnerAccountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_REGISTER);
goodsOwnerAccountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_UNAUDITED);
this.baseMapper.insert(goodsOwnerAccountEntity);
Long accountId = goodsOwnerAccountEntity.getId();
// 4.新增帐号信息
InfoEntity infoEntity = new InfoEntity();
......@@ -374,14 +374,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
public Integer resetAccountPwd(AccountForm form) {
AccountEntity record = this.getAccountRecordById(form.getId());
GoodsOwnerAccountEntity record = this.getAccountRecordById(form.getId());
if (null == record) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountPasswordReset1001());
}
AccountEntity accountEntity = new AccountEntity();
accountEntity.setId(form.getId());
accountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), record.getSalt()));
GoodsOwnerAccountEntity goodsOwnerAccountEntity = new GoodsOwnerAccountEntity();
goodsOwnerAccountEntity.setId(form.getId());
goodsOwnerAccountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), record.getSalt()));
return this.baseMapper.updateById(accountEntity);
return this.baseMapper.updateById(goodsOwnerAccountEntity);
}
}
\ No newline at end of file
......@@ -13,14 +13,14 @@ import com.esv.freight.customer.feign.FeignBaseService;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.dao.RegularlyRouteDao;
import com.esv.freight.customer.module.goodsowner.dto.RouteDetailDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.DeliveryAddressEntity;
import com.esv.freight.customer.module.goodsowner.entity.ReceiveAddressEntity;
import com.esv.freight.customer.module.goodsowner.entity.RegularlyRouteEntity;
import com.esv.freight.customer.module.goodsowner.form.DeleteAddressForm;
import com.esv.freight.customer.module.goodsowner.form.RegularlyRouteForm;
import com.esv.freight.customer.module.goodsowner.form.RegularlyRouteListForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService;
import com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService;
import com.esv.freight.customer.module.goodsowner.service.DeliveryAddressService;
import com.esv.freight.customer.module.goodsowner.service.ReceiveAddressService;
import com.esv.freight.customer.module.goodsowner.service.RegularlyRouteService;
......@@ -43,7 +43,7 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
private FeignBaseService feignBaseService;
private AccountService accountService;
private GoodsOwnerAccountService goodsOwnerAccountService;
private DeliveryAddressService deliveryAddressService;
......@@ -51,10 +51,10 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
@Autowired
public RegularlyRouteServiceImpl(ErrorMessageComponent errorMessageComponent, FeignBaseService feignBaseService,
AccountService accountService, DeliveryAddressService deliveryAddressService, ReceiveAddressService receiveAddressService) {
GoodsOwnerAccountService goodsOwnerAccountService, DeliveryAddressService deliveryAddressService, ReceiveAddressService receiveAddressService) {
this.errorMessageComponent = errorMessageComponent;
this.feignBaseService = feignBaseService;
this.accountService = accountService;
this.goodsOwnerAccountService = goodsOwnerAccountService;
this.deliveryAddressService = deliveryAddressService;
this.receiveAddressService = receiveAddressService;
}
......@@ -68,8 +68,8 @@ public class RegularlyRouteServiceImpl extends ServiceImpl<RegularlyRouteDao, Re
}
// 2.校验获取ID是否有效
AccountEntity accountEntity = this.accountService.getById(form.getOwnerId());
if (null == accountEntity) {
GoodsOwnerAccountEntity goodsOwnerAccountEntity = this.goodsOwnerAccountService.getById(form.getOwnerId());
if (null == goodsOwnerAccountEntity) {
throw new EException(1002, errorMessageComponent.getGoodsOwnerRegularlyRouteAdd1002());
}
......
......@@ -10,7 +10,6 @@ import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorList;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.carrier.CarrierConstants;
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;
......@@ -59,15 +58,12 @@ public class VehicleController {
private VehicleAuditHistoryService vehicleAuditHistoryService;
private CarrierInfoService carrierInfoService;
@Autowired
public VehicleController(ErrorMessageComponent errorMessageComponent, VehicleService vehicleService,
VehicleAuditHistoryService vehicleAuditHistoryService , CarrierInfoService carrierInfoService) {
VehicleAuditHistoryService vehicleAuditHistoryService) {
this.errorMessageComponent = errorMessageComponent;
this.vehicleService = vehicleService;
this.vehicleAuditHistoryService = vehicleAuditHistoryService;
this.carrierInfoService = carrierInfoService;
}
/**
......
......@@ -218,3 +218,9 @@ error-message:
1001: 司机与车辆未绑定
1002: 无效的司机ID
1003: 无效的车辆ID
contract:
offline:
goods-owner:
add:
1001: 无效的货主ID
1002: 合同编号已存在
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.contract.dao.ContractOfflineCarrierDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.contract.entity.ContractOfflineCarrierEntity" id="contractOfflineCarrierMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="carrierId" column="carrier_id"/>
<result property="contractNumber" column="contract_number"/>
<result property="contractName" column="contract_name"/>
<result property="contractType" column="contract_type"/>
<result property="signDate" column="sign_date"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="fileUrl" column="file_url"/>
<result property="remark" column="remark"/>
<result property="createUser" column="create_user"/>
<result property="updateUser" column="update_user"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.contract.dao.ContractOfflineGoodsOwnerDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.contract.entity.ContractOfflineGoodsOwnerEntity" id="contractOfflineGoodsOwnerMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="goodsOwnerId" column="goods_owner_id"/>
<result property="contractNumber" column="contract_number"/>
<result property="contractName" column="contract_name"/>
<result property="contractType" column="contract_type"/>
<result property="signDate" column="sign_date"/>
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="fileUrl" column="file_url"/>
<result property="remark" column="remark"/>
<result property="createUser" column="create_user"/>
<result property="updateUser" column="update_user"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -4,7 +4,7 @@
<mapper namespace="com.esv.freight.customer.module.goodsowner.dao.AccountDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.goodsowner.entity.AccountEntity" id="accountMap">
<resultMap type="com.esv.freight.customer.module.goodsowner.entity.GoodsOwnerAccountEntity" id="accountMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
......
package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.contract.form.ContractOfflineGoodsOwnerForm;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.controller.ContractOfflineGoodsOwnerControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/19 16:11
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class ContractOfflineGoodsOwnerControllerTest extends BaseTestController {
/**
* 新增合同
**/
@Test
public void a1_add_success_test() throws Exception {
String url = "/contract/offline/goodsowner/add";
// 构造数据
ContractOfflineGoodsOwnerForm form = new ContractOfflineGoodsOwnerForm();
form.setGoodsOwnerId(4L);
form.setContractNumber("202005191001");
form.setContractName("黄朝斌测试有限公司01-运输业务框架合同");
form.setContractType(1); // 合同类型:1-主合同、2-补充合同、3-临时合同
form.setSignDate("2020-05-19");
form.setStartDate("2020-05-20");
form.setEndDate("2021-05-19");
form.setFileUrl("http://192.168.31.248:8082/file/download/direct/6FB1DC2B9961B3AFFDE452A479766F6C2E5B46D3534376A8C40ACB4987D0602B85D1E1739AF93D52A92AEB7ACABB90DC");
form.setRemark("这是一条测试数据");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.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(result.getJSONObject("data").containsKey("id"));
}
/**
* 新增合同:无效的货主ID
**/
@Test
public void a2_add_wrong_goodsOwnerId_failure_test() throws Exception {
String url = "/contract/offline/goodsowner/add";
// 构造数据
ContractOfflineGoodsOwnerForm form = new ContractOfflineGoodsOwnerForm();
form.setGoodsOwnerId(99999L);
form.setContractNumber("202005191001");
form.setContractName("黄朝斌测试有限公司01-运输业务框架合同");
form.setContractType(1); // 合同类型:1-主合同、2-补充合同、3-临时合同
form.setSignDate("2020-05-19");
form.setStartDate("2020-05-20");
form.setEndDate("2021-05-19");
form.setFileUrl("http://192.168.31.248:8082/file/download/direct/6FB1DC2B9961B3AFFDE452A479766F6C2E5B46D3534376A8C40ACB4987D0602B85D1E1739AF93D52A92AEB7ACABB90DC");
form.setRemark("这是一条测试数据");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.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"));
}
/**
* 新增合同:合同编号已存在
**/
@Test
public void a3_add_wrong_contractNumber_failure_test() throws Exception {
String url = "/contract/offline/goodsowner/add";
// 构造数据
ContractOfflineGoodsOwnerForm form = new ContractOfflineGoodsOwnerForm();
form.setGoodsOwnerId(4L);
form.setContractNumber("202005191001");
form.setContractName("黄朝斌测试有限公司01-运输业务框架合同");
form.setContractType(1); // 合同类型:1-主合同、2-补充合同、3-临时合同
form.setSignDate("2020-05-19");
form.setStartDate("2020-05-20");
form.setEndDate("2021-05-19");
form.setFileUrl("http://192.168.31.248:8082/file/download/direct/6FB1DC2B9961B3AFFDE452A479766F6C2E5B46D3534376A8C40ACB4987D0602B85D1E1739AF93D52A92AEB7ACABB90DC");
form.setRemark("这是一条测试数据");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1002, 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