Commit 3d6a4c38 authored by huangcb's avatar huangcb

承运商接口:查询承运商详情

parent 2cf02814
...@@ -125,4 +125,7 @@ public class ErrorMessageComponent { ...@@ -125,4 +125,7 @@ public class ErrorMessageComponent {
private String carrierAccountEdit1003; private String carrierAccountEdit1003;
@Value("${error-message.carrier.account.edit.1004}") @Value("${error-message.carrier.account.edit.1004}")
private String carrierAccountEdit1004; private String carrierAccountEdit1004;
@Value("${error-message.carrier.account.detail.1001}")
private String carrierAccountDetail1001;
} }
...@@ -4,12 +4,17 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,12 +4,17 @@ import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.common.exception.EException; import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse; import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.util.ReqUtils; import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate; import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.carrier.CarrierConstants; import com.esv.freight.customer.module.carrier.CarrierConstants;
import com.esv.freight.customer.module.carrier.dto.CarrierInfoDto;
import com.esv.freight.customer.module.carrier.form.CarrierInfoForm; import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import com.esv.freight.customer.module.carrier.form.CarrierQueryForm;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService; import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.carrier.vo.CarrierInfoDetailVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -81,4 +86,24 @@ public class CarrierAccountController { ...@@ -81,4 +86,24 @@ public class CarrierAccountController {
return EResponse.ok(carrierAccountService.updateCarrier(form)); return EResponse.ok(carrierAccountService.updateCarrier(form));
} }
/**
* description 查询承运商详情
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/24 17:21
**/
@PostMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) CarrierQueryForm form) throws EException {
// 查询
CarrierInfoDto dto = carrierAccountService.getCarrierDetail(form);
// 数据转换
CarrierInfoDetailVO vo = new CarrierInfoDetailVO();
BeanUtils.copyProperties(dto, vo);
vo.setCreateTime(dto.getCreateTime().getTime());
return EResponse.ok(vo);
}
} }
...@@ -26,5 +26,14 @@ public interface CarrierAccountDao extends BaseMapper<CarrierAccountEntity> { ...@@ -26,5 +26,14 @@ public interface CarrierAccountDao extends BaseMapper<CarrierAccountEntity> {
* createTime 2020/04/23 19:36 * createTime 2020/04/23 19:36
**/ **/
List<CarrierInfoDto> selectCarrierList(CarrierQueryForm queryObj); List<CarrierInfoDto> selectCarrierList(CarrierQueryForm queryObj);
/**
* description 查询承运商详情
* param [queryObj]
* return com.esv.freight.customer.module.carrier.dto.CarrierInfoDto
* author Administrator
* createTime 2020/04/24 17:06
**/
CarrierInfoDto selectCarrierDetail(CarrierQueryForm queryObj);
} }
package com.esv.freight.customer.module.carrier.form; package com.esv.freight.customer.module.carrier.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate; import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import lombok.Data; import lombok.Data;
......
package com.esv.freight.customer.module.carrier.form; package com.esv.freight.customer.module.carrier.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
/** /**
* @description: * @description:
* @project: freight-customer-service * @project: freight-customer-service
...@@ -19,6 +23,7 @@ public class CarrierQueryForm { ...@@ -19,6 +23,7 @@ public class CarrierQueryForm {
/** /**
* *
*/ */
@NotNull(message = "参数id不能为空", groups = {ValidatorDetail.class})
private Long id; private Long id;
/** /**
* 登录帐号,承运商联系人电话 * 登录帐号,承运商联系人电话
......
package com.esv.freight.customer.module.carrier.service; package com.esv.freight.customer.module.carrier.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.carrier.dto.CarrierInfoDto;
import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity; import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity;
import com.esv.freight.customer.module.carrier.form.CarrierInfoForm; import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import com.esv.freight.customer.module.carrier.form.CarrierQueryForm; import com.esv.freight.customer.module.carrier.form.CarrierQueryForm;
...@@ -41,5 +42,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> { ...@@ -41,5 +42,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> {
**/ **/
Integer updateCarrier(CarrierInfoForm form); Integer updateCarrier(CarrierInfoForm form);
/**
* description 查询承运商详情
* param [form]
* return com.esv.freight.customer.module.carrier.dto.CarrierInfoDto
* author Administrator
* createTime 2020/04/24 17:06
**/
CarrierInfoDto getCarrierDetail(CarrierQueryForm form);
} }
...@@ -176,4 +176,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca ...@@ -176,4 +176,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
return count; return count;
} }
@Override
public CarrierInfoDto getCarrierDetail(CarrierQueryForm form) {
CarrierAccountEntity entity = this.baseMapper.selectById(form.getId());
if (null == entity) {
throw new EException(1001, errorMessageComponent.getCarrierAccountDetail1001());
}
return this.baseMapper.selectCarrierDetail(form);
}
} }
\ No newline at end of file
package com.esv.freight.customer.module.carrier.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 承运商详情VO
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.carrier.vo.CarrierInfoDetailVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/24 16:58
* @version:1.0
*/
@Data
public class CarrierInfoDetailVO {
/**
*
*/
private Long id;
/**
* 登录帐号,承运商联系人电话
*/
private String account;
/**
* 帐号状态:1-正常、2-停用
*/
private String accountStatus;
/**
* 创建者
*/
private String createUser;
/**
* 创建时间
*/
private Long createTime;
/**
* 客户编码
*/
private String carrierNumber;
/**
* 统一社会信用代码
*/
private String uniCreditCode;
/**
* 承运商名称
*/
private String carrierFullName;
/**
* 承运商简称
*/
private String carrierBriefName;
/**
* 承运商类别:1-企业承运人、2-个体承运人
*/
private Integer carrierType;
/**
* 承运商车辆类型(字典表):1-自营车、2-外协车、3-其他
*/
private Integer carrierVehicleType;
/**
* 企业注册地址-省份代码
*/
private String provinceCode;
/**
* 企业注册地址-市代码
*/
private String cityCode;
/**
* 企业注册地址-区县代码
*/
private String districtCode;
/**
* 企业注册地址-详细地址
*/
private String detailAddress;
/**
* 企业法人姓名
*/
private String legalPerson;
/**
* 营业执照URL
*/
private String businessLicenseUrl;
/**
* 道路运输经营许可证号
*/
private String roadLicenseNumber;
/**
* 经营范围
*/
private String businessScope;
/**
* 道路运输经营许可证有效期
*/
private String roadLicenseExpireDate;
/**
* 道路运输经营许可证URL
*/
private String roadLicenseUrl;
/**
* 联系人
*/
private String contactor;
/**
* 电子邮件
*/
private String email;
/**
* 信用评分:1-100
*/
private Integer creditScore;
/**
* 备注
*/
private String remark;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
...@@ -117,4 +117,6 @@ error-message: ...@@ -117,4 +117,6 @@ error-message:
1001: 无效的帐号ID 1001: 无效的帐号ID
1002: 道路运输经营许可证号已存在 1002: 道路运输经营许可证号已存在
1003: 统一社会信用代码已存在 1003: 统一社会信用代码已存在
1004: 承运商名称已存在 1004: 承运商名称已存在
\ No newline at end of file detail:
1001: 无效的帐号ID
\ No newline at end of file
...@@ -56,5 +56,22 @@ ...@@ -56,5 +56,22 @@
ORDER BY a.update_time DESC, a.account ASC ORDER BY a.update_time DESC, a.account ASC
</select> </select>
<!-- 查询帐号详情 -->
<select id="selectCarrierDetail" parameterType="com.esv.freight.customer.module.carrier.form.CarrierQueryForm"
resultType="com.esv.freight.customer.module.carrier.dto.CarrierInfoDto">
select a.id, a.account, a.account_status, a.create_user, a.create_time,
b.carrier_number, b.uni_credit_code, b.carrier_full_name, b.carrier_brief_name, b.carrier_type, b.carrier_vehicle_type,
b.province_code, b.city_code, b.district_code, b.detail_address, b.legal_person, b.business_license_url, b.road_license_number,
b.business_scope, b.road_license_expire_date, b.road_license_url, b.contactor, b.email, b.credit_score, b.remark
from carrier_account a, carrier_info b
where a.id = b.account_id
<if test="id != null">
and a.id = #{id}
</if>
<if test="account != null">
and a.account = #{account}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.esv.freight.customer.BaseTestController; ...@@ -5,6 +5,7 @@ import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode; import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.carrier.CarrierConstants; import com.esv.freight.customer.module.carrier.CarrierConstants;
import com.esv.freight.customer.module.carrier.form.CarrierInfoForm; import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import com.esv.freight.customer.module.carrier.form.CarrierQueryForm;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Assert; import org.junit.Assert;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
...@@ -576,4 +577,63 @@ public class CarrierAccountControllerTest extends BaseTestController { ...@@ -576,4 +577,63 @@ public class CarrierAccountControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr); JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1004, result.getIntValue("code")); Assert.assertEquals(1004, result.getIntValue("code"));
} }
/**
* 查询承运商详情
**/
@Test
@Rollback
public void c1_detail_success_test() throws Exception {
String url = "/carrier/account/detail";
// 构造数据
CarrierQueryForm form = new CarrierQueryForm();
form.setId(2L);
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(result.getJSONObject("data").containsKey("id"));
}
/**
* 查询承运商详情:无效的帐号ID
**/
@Test
@Rollback
public void c2_detail_wrong_id_failure_test() throws Exception {
String url = "/carrier/account/detail";
// 构造数据
CarrierQueryForm form = new CarrierQueryForm();
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