refactor: 使用mybatis-plus重构运输公司基本信息
This commit is contained in:
@@ -21,7 +21,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@RequestMapping("/api/transportationbase")
|
||||
@RequestMapping("/api/transportationbase2")
|
||||
@Slf4j
|
||||
public class TransportationbaseController {
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.nl.wms.basedata.master.transport.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.basedata.master.transport.service.ITransportationBaseService;
|
||||
import org.nl.wms.basedata.master.transport.service.dao.TransportationBase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 运输公司信息管理
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/transportationbase")
|
||||
@Slf4j
|
||||
public class TransportationBaseController {
|
||||
@Autowired
|
||||
private ITransportationBaseService transportationbaseService;
|
||||
|
||||
@GetMapping
|
||||
@Log(value = "查询运输公司基本信息", isAddLogTable = false
|
||||
)
|
||||
//@SaCheckPermission("@el.check('transportationbase:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(transportationbaseService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增运输公司基本信息")
|
||||
//@SaCheckPermission("@el.check('transportationbase:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody TransportationBase dto) {
|
||||
transportationbaseService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改运输公司基本信息")
|
||||
//@SaCheckPermission("@el.check('transportationbase:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody TransportationBase dto) {
|
||||
transportationbaseService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除运输公司基本信息")
|
||||
//@SaCheckPermission("@el.check('transportationbase:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
transportationbaseService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log(value = "运输公司基本信息下拉框", isAddLogTable = false)
|
||||
@PostMapping("/getTransporta")
|
||||
public ResponseEntity<Object> getTransporta() {
|
||||
return new ResponseEntity<>(transportationbaseService.getTransporta(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 运输公司基本信息相关
|
||||
*/
|
||||
package org.nl.wms.basedata.master.transport;
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.nl.wms.basedata.master.transport.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata.master.service.dto.TransportationbaseDto;
|
||||
import org.nl.wms.basedata.master.transport.service.dao.TransportationBase;
|
||||
import org.nl.wms.pda.common.SelectVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
public interface ITransportationBaseService extends IService<TransportationBase> {
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return TransportationBase
|
||||
*/
|
||||
IPage<TransportationBase> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* <p>必须唯一,否则报错</p>
|
||||
* @param code code
|
||||
* @return Transportationbase
|
||||
*/
|
||||
TransportationBase findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void create(TransportationBase dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void update(TransportationBase dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(String[] ids);
|
||||
|
||||
/**
|
||||
* 获取下拉框
|
||||
*/
|
||||
List<SelectVo> getTransporta();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.wms.basedata.master.transport.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("md_cs_transportationbase")
|
||||
public class TransportationBase {
|
||||
@TableId
|
||||
private String cust_id;
|
||||
private String cust_code;
|
||||
private String cust_name;
|
||||
private String cust_simple_name;
|
||||
private String country;
|
||||
private String state;
|
||||
private String city;
|
||||
private String faxnumber;
|
||||
private String webSite;
|
||||
private String jurid_name;
|
||||
private String tax_no;
|
||||
private String register_no;
|
||||
private String manage_lice_no;
|
||||
private String busi_char_name;
|
||||
private String area_id;
|
||||
private String zip_code;
|
||||
private String corp_tele_no;
|
||||
private String corp_address;
|
||||
private String create_id;
|
||||
private String create_name;
|
||||
private String create_time;
|
||||
private String update_id;
|
||||
private String update_name;
|
||||
private String update_time;
|
||||
private Boolean is_used_time;
|
||||
private Boolean is_used;
|
||||
private Boolean is_delete;
|
||||
private String ext_id;
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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="org.nl.wms.basedata.master.transport.service.dao.mapper.TransportationBaseMapper">
|
||||
|
||||
<select id="getTransportSelects" resultType="org.nl.wms.pda.common.SelectVo">
|
||||
SELECT cust_code AS `value`,
|
||||
cust_name AS label
|
||||
FROM MD_CS_TransportationBase
|
||||
WHERE is_delete = '0'
|
||||
AND is_used = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.wms.basedata.master.transport.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.wms.basedata.master.transport.service.dao.TransportationBase;
|
||||
import org.nl.wms.pda.common.SelectVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
public interface TransportationBaseMapper extends BaseMapper<TransportationBase> {
|
||||
List<SelectVo> getTransportSelects();
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package org.nl.wms.basedata.master.transport.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description /
|
||||
* @date 2022-11-10
|
||||
**/
|
||||
@Data
|
||||
public class TransportationBaseDto implements Serializable {
|
||||
|
||||
/** 物流公司标识 */
|
||||
/**
|
||||
* 防止精度丢失
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cust_id;
|
||||
|
||||
/**
|
||||
* 物流公司编码
|
||||
*/
|
||||
private String cust_code;
|
||||
|
||||
/**
|
||||
* 物流公司名称
|
||||
*/
|
||||
private String cust_name;
|
||||
|
||||
/**
|
||||
* 物流公司简称
|
||||
*/
|
||||
private String cust_simple_name;
|
||||
|
||||
/**
|
||||
* 国家
|
||||
*/
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
private String faxnumber;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String webSite;
|
||||
|
||||
/**
|
||||
* 法人代表
|
||||
*/
|
||||
private String jurid_name;
|
||||
|
||||
/**
|
||||
* 税务登记号
|
||||
*/
|
||||
private String tax_no;
|
||||
|
||||
/**
|
||||
* 工商注册号
|
||||
*/
|
||||
private String register_no;
|
||||
|
||||
/**
|
||||
* 经营许可证号
|
||||
*/
|
||||
private String manage_lice_no;
|
||||
|
||||
/**
|
||||
* 营业执照
|
||||
*/
|
||||
private String busi_char_name;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
private Long area_id;
|
||||
|
||||
/**
|
||||
* 邮政编码
|
||||
*/
|
||||
private String zip_code;
|
||||
|
||||
/**
|
||||
* 公司电话
|
||||
*/
|
||||
private String corp_tele_no;
|
||||
|
||||
/**
|
||||
* 公司地址
|
||||
*/
|
||||
private String corp_address;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_optid;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String update_optname;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
/**
|
||||
* 启用时间
|
||||
*/
|
||||
private String is_used_time;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_used;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String is_delete;
|
||||
|
||||
/**
|
||||
* 外部标识
|
||||
*/
|
||||
private String ext_id;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package org.nl.wms.basedata.master.transport.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.wms.basedata.master.service.dto.TransportationbaseDto;
|
||||
import org.nl.wms.basedata.master.transport.service.ITransportationBaseService;
|
||||
import org.nl.wms.basedata.master.transport.service.dao.TransportationBase;
|
||||
import org.nl.wms.basedata.master.transport.service.dao.mapper.TransportationBaseMapper;
|
||||
import org.nl.wms.pda.common.SelectVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
@Service
|
||||
public class TransportationBaseServiceImpl extends ServiceImpl<TransportationBaseMapper, TransportationBase> implements ITransportationBaseService {
|
||||
@Autowired
|
||||
private TransportationBaseMapper transportationBaseMapper;
|
||||
@Override
|
||||
public IPage<TransportationBase> queryAll(Map whereJson, PageQuery page) {
|
||||
String custCode = MapUtil.getStr(whereJson, "cust_code");
|
||||
String custName = MapUtil.getStr(whereJson, "cust_name");
|
||||
String isUsed = MapUtil.getStr(whereJson, "is_used");
|
||||
LambdaQueryWrapper<TransportationBase> lam = new QueryWrapper<TransportationBase>().lambda();
|
||||
lam.like(ObjectUtil.isNotEmpty(custCode), TransportationBase::getCust_code, custCode)
|
||||
.like(ObjectUtil.isNotEmpty(custName), TransportationBase::getCust_name, custName)
|
||||
.eq(ObjectUtil.isNotEmpty(isUsed), TransportationBase::getIs_used, "1".equals(isUsed));
|
||||
IPage<TransportationBase> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
transportationBaseMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportationBase findByCode(String code) {
|
||||
LambdaQueryWrapper<TransportationBase> lam = new QueryWrapper<TransportationBase>().lambda();
|
||||
lam.eq(TransportationBase::getCust_code, code);
|
||||
return getOne(lam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(TransportationBase dto) {
|
||||
TransportationBase oneTran = findByCode(dto.getCust_code());
|
||||
if (ObjectUtil.isNotEmpty(oneTran)) {
|
||||
throw new BadRequestException("此编码已存在");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
dto.setCust_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
transportationBaseMapper.insert(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TransportationBase dto) {
|
||||
TransportationBase oneTran = getById(dto.getCust_id());
|
||||
if (oneTran == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
}
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
transportationBaseMapper.updateById(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(String[] ids) {
|
||||
this.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectVo> getTransporta() {
|
||||
return transportationBaseMapper.getTransportSelects();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.wms.pda.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 手持下拉框实体
|
||||
* @Author: lyd
|
||||
* @Date: 2024/10/15
|
||||
*/
|
||||
@Data
|
||||
public class SelectVo {
|
||||
private String value;
|
||||
private String label;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 手持通用类
|
||||
*/
|
||||
package org.nl.wms.pda.common;
|
||||
Reference in New Issue
Block a user