|
@@ -1,12 +1,18 @@
|
|
|
package com.aoyang.tms.controller;
|
|
package com.aoyang.tms.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.aoyang.tms.common.ErrCodeEnum;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import com.aoyang.tms.service.ShipperService;
|
|
import com.aoyang.tms.service.ShipperService;
|
|
@@ -35,25 +41,61 @@ public class ShipperController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private ShipperService shipperService;
|
|
private ShipperService shipperService;
|
|
|
|
|
|
|
|
- @ApiOperation(value = "获取shipper列表",notes="")
|
|
|
|
|
- @PostMapping("/list")
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取托运方分页列表",notes="必传参数:orgId")
|
|
|
|
|
+ @PostMapping("/page_list")
|
|
|
public Result list(@RequestBody PageParam<Shipper> pageParam) {
|
|
public Result list(@RequestBody PageParam<Shipper> pageParam) {
|
|
|
- Page<Shipper> page = new Page<>(pageParam.getPage(), pageParam.getSize());
|
|
|
|
|
- IPage<Shipper> records = shipperService.page(page, Wrappers.query(pageParam.getParam()));
|
|
|
|
|
- return new Result<>(records);
|
|
|
|
|
|
|
+ log.info("获取托运方分页列表,调用/tms/shipper/page_list,参数:{}", JSON.toJSONString(pageParam));
|
|
|
|
|
+ if (pageParam == null || pageParam.getParam() == null || pageParam.getParam().getOrgId() == null) {
|
|
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return new Result<>(shipperService.findPage(pageParam));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value = "修改shipper",notes="根据id修改shipper")
|
|
|
|
|
|
|
+ @ApiOperation(value = "修改托运方",notes="必传参数:shipperId")
|
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
|
- public Result update(@RequestBody Shipper shipper) {
|
|
|
|
|
- Boolean flag = shipperService.updateById(shipper);
|
|
|
|
|
- return new Result<>(flag);
|
|
|
|
|
|
|
+ public Result update(@RequestHeader(value = "userId") Long userId,
|
|
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
|
|
+ @RequestBody Shipper param) {
|
|
|
|
|
+
|
|
|
|
|
+ log.info("修改托运方,调用/tms/shipper/update,参数:{}", JSON.toJSONString(param));
|
|
|
|
|
+ if (param == null || param.getShipperId() == null) {
|
|
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ String utf8Name = userName;
|
|
|
|
|
+ try {
|
|
|
|
|
+ utf8Name = URLDecoder.decode(userName, "UTF-8");
|
|
|
|
|
+ } catch (UnsupportedEncodingException ignored) {
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setUpdater(userId);
|
|
|
|
|
+ param.setUpdaterName(utf8Name);
|
|
|
|
|
+ param.setUpdateDate(LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ return new Result<>(shipperService.updateById(param));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value = "添加shipper",notes="新增一条shipper")
|
|
|
|
|
|
|
+ @ApiOperation(value = "添加托运方",notes="必传参数:orgId,orgName,orgShortName,shipperName")
|
|
|
@PostMapping("/add")
|
|
@PostMapping("/add")
|
|
|
- public Result add(@RequestBody Shipper shipper) {
|
|
|
|
|
- Boolean flag = shipperService.save(shipper);
|
|
|
|
|
- return new Result<>(flag);
|
|
|
|
|
|
|
+ public Result add(@RequestHeader(value = "userId") Long userId,
|
|
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
|
|
+ @RequestBody Shipper param) {
|
|
|
|
|
+
|
|
|
|
|
+ log.info("添加托运方,调用/tms/shipper/add,参数:{}", JSON.toJSONString(param));
|
|
|
|
|
+ if (param == null || param.getOrgId() == null || param.getOrgName() == null
|
|
|
|
|
+ || param.getOrgShortName() == null || param.getShipperName() == null) {
|
|
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ String utf8Name = userName;
|
|
|
|
|
+ try {
|
|
|
|
|
+ utf8Name = URLDecoder.decode(userName, "UTF-8");
|
|
|
|
|
+ } catch (UnsupportedEncodingException ignored) {
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setCreater(userId);
|
|
|
|
|
+ param.setCreaterName(utf8Name);
|
|
|
|
|
+ param.setCreateDate(LocalDateTime.now());
|
|
|
|
|
+ param.setUpdater(userId);
|
|
|
|
|
+ param.setUpdaterName(utf8Name);
|
|
|
|
|
+ param.setUpdateDate(LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ return new Result<>(shipperService.save(param));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|