Commit 1c48a7a3 authored by huangcb's avatar huangcb

承运商接口:查询所有承运商列表

parent 3d6a4c38
......@@ -12,6 +12,7 @@ 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.CarrierQueryForm;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.carrier.vo.CarrierInfoBriefVO;
import com.esv.freight.customer.module.carrier.vo.CarrierInfoDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......@@ -21,6 +22,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: 承运商帐号Controller
* @project: freight-customer-service
......@@ -106,4 +110,32 @@ public class CarrierAccountController {
return EResponse.ok(vo);
}
/**
* description 查询所有承运商列表
* param []
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/24 17:44
**/
@PostMapping("/all")
public EResponse all() throws EException {
// 查询
List<CarrierInfoDto> dtoList = carrierAccountService.getAllCarrierBrief();
// 数据转换
List<CarrierInfoBriefVO> voList = new ArrayList<>();
dtoList.forEach(dto -> {
CarrierInfoBriefVO vo = new CarrierInfoBriefVO();
BeanUtils.copyProperties(dto, vo);
if (CarrierConstants.CARRIER_TYPE_COMPANY.equals(dto.getCarrierType())) {
vo.setCarrierName(dto.getCarrierFullName());
} else {
vo.setCarrierName(dto.getContactor());
}
voList.add(vo);
});
return EResponse.ok(voList);
}
}
......@@ -36,4 +36,13 @@ public interface CarrierAccountDao extends BaseMapper<CarrierAccountEntity> {
**/
CarrierInfoDto selectCarrierDetail(CarrierQueryForm queryObj);
/**
* description 查询所有帐号简要信息
* param []
* return java.util.List<com.esv.freight.customer.module.carrier.dto.CarrierInfoDto>
* author Administrator
* createTime 2020/04/24 17:36
**/
List<CarrierInfoDto> selectAllCarrierBrief();
}
......@@ -6,6 +6,8 @@ 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.CarrierQueryForm;
import java.util.List;
/**
* 承运商帐号表
*
......@@ -51,5 +53,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> {
**/
CarrierInfoDto getCarrierDetail(CarrierQueryForm form);
/**
* description 查询所有帐号简要信息
* param []
* return java.util.List<com.esv.freight.customer.module.carrier.dto.CarrierInfoDto>
* author Administrator
* createTime 2020/04/24 17:37
**/
List<CarrierInfoDto> getAllCarrierBrief();
}
......@@ -186,4 +186,9 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
return this.baseMapper.selectCarrierDetail(form);
}
@Override
public List<CarrierInfoDto> getAllCarrierBrief() {
return this.baseMapper.selectAllCarrierBrief();
}
}
\ 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.CarrierInfoBriefVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/24 16:58
* @version:1.0
*/
@Data
public class CarrierInfoBriefVO {
/**
*
*/
private Long id;
/**
* 登录帐号,承运商联系人电话
*/
private String account;
/**
* 帐号状态:1-正常、2-停用
*/
private String accountStatus;
/**
* 客户编码
*/
private String carrierNumber;
/**
* 承运商名称
*/
private String carrierName;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -73,5 +73,14 @@
</if>
</select>
<!-- 查询所有帐号简要信息 -->
<select id="selectAllCarrierBrief" resultType="com.esv.freight.customer.module.carrier.dto.CarrierInfoDto">
select a.id, a.account, a.account_status,
b.carrier_number, b.carrier_full_name, b.carrier_type, b.contactor
from carrier_account a, carrier_info b
where a.id = b.account_id
ORDER BY b.carrier_type ASC, b.carrier_full_name ASC, b.contactor ASC
</select>
</mapper>
\ No newline at end of file
......@@ -636,4 +636,28 @@ public class CarrierAccountControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
/**
* 查询所有承运商列表
**/
@Test
@Rollback
public void d1_detail_success_test() throws Exception {
String url = "/carrier/account/all";
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(new JSONObject().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.assertFalse(result.getJSONArray("data").isEmpty());
}
}
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