供应商信息表提交
parent
c2fc20dce5
commit
814b99043d
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
||||
import cn.iocoder.yudao.module.bs.convert.suppliercompany.SupplierCompanyConvert;
|
||||
import cn.iocoder.yudao.module.bs.service.suppliercompany.SupplierCompanyService;
|
||||
|
||||
@Tag(name = "管理后台 - 供应商信息")
|
||||
@RestController
|
||||
@RequestMapping("/bs/supplier-company")
|
||||
@Validated
|
||||
public class SupplierCompanyController {
|
||||
|
||||
@Resource
|
||||
private SupplierCompanyService supplierCompanyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建供应商信息")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:create')")
|
||||
public CommonResult<Long> createSupplierCompany(@Valid @RequestBody SupplierCompanyCreateReqVO createReqVO) {
|
||||
return success(supplierCompanyService.createSupplierCompany(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新供应商信息")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:update')")
|
||||
public CommonResult<Boolean> updateSupplierCompany(@Valid @RequestBody SupplierCompanyUpdateReqVO updateReqVO) {
|
||||
supplierCompanyService.updateSupplierCompany(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除供应商信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:delete')")
|
||||
public CommonResult<Boolean> deleteSupplierCompany(@RequestParam("id") Long id) {
|
||||
supplierCompanyService.deleteSupplierCompany(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得供应商信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:query')")
|
||||
public CommonResult<SupplierCompanyRespVO> getSupplierCompany(@RequestParam("id") Long id) {
|
||||
SupplierCompanyDO supplierCompany = supplierCompanyService.getSupplierCompany(id);
|
||||
return success(SupplierCompanyConvert.INSTANCE.convert(supplierCompany));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得供应商信息列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:query')")
|
||||
public CommonResult<List<SupplierCompanyRespVO>> getSupplierCompanyList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<SupplierCompanyDO> list = supplierCompanyService.getSupplierCompanyList(ids);
|
||||
return success(SupplierCompanyConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得供应商信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:query')")
|
||||
public CommonResult<PageResult<SupplierCompanyRespVO>> getSupplierCompanyPage(@Valid SupplierCompanyPageReqVO pageVO) {
|
||||
PageResult<SupplierCompanyDO> pageResult = supplierCompanyService.getSupplierCompanyPage(pageVO);
|
||||
return success(SupplierCompanyConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出供应商信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('bs:supplier-company:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportSupplierCompanyExcel(@Valid SupplierCompanyExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<SupplierCompanyDO> list = supplierCompanyService.getSupplierCompanyList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<SupplierCompanyExcelVO> datas = SupplierCompanyConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "供应商信息.xls", "数据", SupplierCompanyExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 供应商信息创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierCompanyCreateReqVO extends SupplierCompanyBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 供应商信息 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SupplierCompanyExcelVO {
|
||||
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("供应商企业名称")
|
||||
private String companyAme;
|
||||
|
||||
@ExcelProperty("供应商编码")
|
||||
private String companyNumber;
|
||||
|
||||
@ExcelProperty("企业性质")
|
||||
private Integer companyType;
|
||||
|
||||
@ExcelProperty("法人代表")
|
||||
private String legalPerson;
|
||||
|
||||
@ExcelProperty("联系方式")
|
||||
private String phone;
|
||||
|
||||
@ExcelProperty("统一社会信用代码")
|
||||
private String creditCode;
|
||||
|
||||
@ExcelProperty("企业地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty("营业期限(起)")
|
||||
private LocalDateTime businessStratDate;
|
||||
|
||||
@ExcelProperty("营业期限(止)")
|
||||
private LocalDateTime businessEndDate;
|
||||
|
||||
@ExcelProperty("注册资本(w)")
|
||||
private Integer capital;
|
||||
|
||||
@ExcelProperty("银行户名")
|
||||
private String bankName;
|
||||
|
||||
@ExcelProperty("银行账号")
|
||||
private String bankNumber;
|
||||
|
||||
@ExcelProperty("开户行名称")
|
||||
private String bankOfDeposit;
|
||||
|
||||
@ExcelProperty("是否注册")
|
||||
private Byte isRegister;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("附件")
|
||||
private String files;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 供应商信息分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierCompanyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "供应商企业名称")
|
||||
private String companyAme;
|
||||
|
||||
@Schema(description = "供应商编码")
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "企业性质", example = "2")
|
||||
private Integer companyType;
|
||||
|
||||
@Schema(description = "法人代表")
|
||||
private String legalPerson;
|
||||
|
||||
@Schema(description = "联系方式")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "统一社会信用代码")
|
||||
private String creditCode;
|
||||
|
||||
@Schema(description = "企业地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "营业期限(起)")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] businessStratDate;
|
||||
|
||||
@Schema(description = "营业期限(止)")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] businessEndDate;
|
||||
|
||||
@Schema(description = "注册资本(w)")
|
||||
private Integer capital;
|
||||
|
||||
@Schema(description = "银行户名", example = "李四")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "银行账号")
|
||||
private String bankNumber;
|
||||
|
||||
@Schema(description = "开户行名称")
|
||||
private String bankOfDeposit;
|
||||
|
||||
@Schema(description = "是否注册")
|
||||
private Byte isRegister;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "附件")
|
||||
private String files;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 供应商信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierCompanyRespVO extends SupplierCompanyBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14420")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 供应商信息更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SupplierCompanyUpdateReqVO extends SupplierCompanyBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14420")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.bs.convert.suppliercompany;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
||||
|
||||
/**
|
||||
* 供应商信息 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SupplierCompanyConvert {
|
||||
|
||||
SupplierCompanyConvert INSTANCE = Mappers.getMapper(SupplierCompanyConvert.class);
|
||||
|
||||
SupplierCompanyDO convert(SupplierCompanyCreateReqVO bean);
|
||||
|
||||
SupplierCompanyDO convert(SupplierCompanyUpdateReqVO bean);
|
||||
|
||||
SupplierCompanyRespVO convert(SupplierCompanyDO bean);
|
||||
|
||||
List<SupplierCompanyRespVO> convertList(List<SupplierCompanyDO> list);
|
||||
|
||||
PageResult<SupplierCompanyRespVO> convertPage(PageResult<SupplierCompanyDO> page);
|
||||
|
||||
List<SupplierCompanyExcelVO> convertList02(List<SupplierCompanyDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 供应商信息 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("bs_supplier_company")
|
||||
@KeySequence("bs_supplier_company_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SupplierCompanyDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 供应商企业名称
|
||||
*/
|
||||
private String companyAme;
|
||||
/**
|
||||
* 供应商编码
|
||||
*/
|
||||
private String companyNumber;
|
||||
/**
|
||||
* 企业性质
|
||||
*/
|
||||
private Integer companyType;
|
||||
/**
|
||||
* 法人代表
|
||||
*/
|
||||
private String legalPerson;
|
||||
/**
|
||||
* 联系方式
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
*/
|
||||
private String creditCode;
|
||||
/**
|
||||
* 企业地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 营业期限(起)
|
||||
*/
|
||||
private LocalDateTime businessStratDate;
|
||||
/**
|
||||
* 营业期限(止)
|
||||
*/
|
||||
private LocalDateTime businessEndDate;
|
||||
/**
|
||||
* 注册资本(w)
|
||||
*/
|
||||
private Integer capital;
|
||||
/**
|
||||
* 银行户名
|
||||
*/
|
||||
private String bankName;
|
||||
/**
|
||||
* 银行账号
|
||||
*/
|
||||
private String bankNumber;
|
||||
/**
|
||||
* 开户行名称
|
||||
*/
|
||||
private String bankOfDeposit;
|
||||
/**
|
||||
* 是否注册
|
||||
*/
|
||||
private Byte isRegister;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private String files;
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.bs.dal.mysql.suppliercompany;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
||||
|
||||
/**
|
||||
* 供应商信息 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SupplierCompanyMapper extends BaseMapperX<SupplierCompanyDO> {
|
||||
|
||||
default PageResult<SupplierCompanyDO> selectPage(SupplierCompanyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SupplierCompanyDO>()
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyAme, reqVO.getCompanyAme())
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyNumber, reqVO.getCompanyNumber())
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyType, reqVO.getCompanyType())
|
||||
.eqIfPresent(SupplierCompanyDO::getLegalPerson, reqVO.getLegalPerson())
|
||||
.eqIfPresent(SupplierCompanyDO::getPhone, reqVO.getPhone())
|
||||
.eqIfPresent(SupplierCompanyDO::getCreditCode, reqVO.getCreditCode())
|
||||
.eqIfPresent(SupplierCompanyDO::getAddress, reqVO.getAddress())
|
||||
.betweenIfPresent(SupplierCompanyDO::getBusinessStratDate, reqVO.getBusinessStratDate())
|
||||
.betweenIfPresent(SupplierCompanyDO::getBusinessEndDate, reqVO.getBusinessEndDate())
|
||||
.eqIfPresent(SupplierCompanyDO::getCapital, reqVO.getCapital())
|
||||
.likeIfPresent(SupplierCompanyDO::getBankName, reqVO.getBankName())
|
||||
.eqIfPresent(SupplierCompanyDO::getBankNumber, reqVO.getBankNumber())
|
||||
.eqIfPresent(SupplierCompanyDO::getBankOfDeposit, reqVO.getBankOfDeposit())
|
||||
.eqIfPresent(SupplierCompanyDO::getIsRegister, reqVO.getIsRegister())
|
||||
.eqIfPresent(SupplierCompanyDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(SupplierCompanyDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(SupplierCompanyDO::getFiles, reqVO.getFiles())
|
||||
.betweenIfPresent(SupplierCompanyDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(SupplierCompanyDO::getId));
|
||||
}
|
||||
|
||||
default List<SupplierCompanyDO> selectList(SupplierCompanyExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<SupplierCompanyDO>()
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyAme, reqVO.getCompanyAme())
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyNumber, reqVO.getCompanyNumber())
|
||||
.eqIfPresent(SupplierCompanyDO::getCompanyType, reqVO.getCompanyType())
|
||||
.eqIfPresent(SupplierCompanyDO::getLegalPerson, reqVO.getLegalPerson())
|
||||
.eqIfPresent(SupplierCompanyDO::getPhone, reqVO.getPhone())
|
||||
.eqIfPresent(SupplierCompanyDO::getCreditCode, reqVO.getCreditCode())
|
||||
.eqIfPresent(SupplierCompanyDO::getAddress, reqVO.getAddress())
|
||||
.betweenIfPresent(SupplierCompanyDO::getBusinessStratDate, reqVO.getBusinessStratDate())
|
||||
.betweenIfPresent(SupplierCompanyDO::getBusinessEndDate, reqVO.getBusinessEndDate())
|
||||
.eqIfPresent(SupplierCompanyDO::getCapital, reqVO.getCapital())
|
||||
.likeIfPresent(SupplierCompanyDO::getBankName, reqVO.getBankName())
|
||||
.eqIfPresent(SupplierCompanyDO::getBankNumber, reqVO.getBankNumber())
|
||||
.eqIfPresent(SupplierCompanyDO::getBankOfDeposit, reqVO.getBankOfDeposit())
|
||||
.eqIfPresent(SupplierCompanyDO::getIsRegister, reqVO.getIsRegister())
|
||||
.eqIfPresent(SupplierCompanyDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(SupplierCompanyDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(SupplierCompanyDO::getFiles, reqVO.getFiles())
|
||||
.betweenIfPresent(SupplierCompanyDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(SupplierCompanyDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.bs.service.suppliercompany;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 供应商信息 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SupplierCompanyService {
|
||||
|
||||
/**
|
||||
* 创建供应商信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createSupplierCompany(@Valid SupplierCompanyCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新供应商信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateSupplierCompany(@Valid SupplierCompanyUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除供应商信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteSupplierCompany(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 供应商信息
|
||||
*/
|
||||
SupplierCompanyDO getSupplierCompany(Long id);
|
||||
|
||||
/**
|
||||
* 获得供应商信息列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 供应商信息列表
|
||||
*/
|
||||
List<SupplierCompanyDO> getSupplierCompanyList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得供应商信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 供应商信息分页
|
||||
*/
|
||||
PageResult<SupplierCompanyDO> getSupplierCompanyPage(SupplierCompanyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得供应商信息列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 供应商信息列表
|
||||
*/
|
||||
List<SupplierCompanyDO> getSupplierCompanyList(SupplierCompanyExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package cn.iocoder.yudao.module.bs.service.suppliercompany;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.suppliercompany.vo.*;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.suppliercompany.SupplierCompanyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.bs.convert.suppliercompany.SupplierCompanyConvert;
|
||||
import cn.iocoder.yudao.module.bs.dal.mysql.suppliercompany.SupplierCompanyMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 供应商信息 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SupplierCompanyServiceImpl implements SupplierCompanyService {
|
||||
|
||||
@Resource
|
||||
private SupplierCompanyMapper supplierCompanyMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Long createSupplierCompany(SupplierCompanyCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
SupplierCompanyDO supplierCompany = SupplierCompanyConvert.INSTANCE.convert(createReqVO);
|
||||
String companyNumber = numberCreate();
|
||||
supplierCompany.setCompanyNumber(companyNumber);
|
||||
supplierCompanyMapper.insert(supplierCompany);
|
||||
// 返回
|
||||
return supplierCompany.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSupplierCompany(SupplierCompanyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateSupplierCompanyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
SupplierCompanyDO updateObj = SupplierCompanyConvert.INSTANCE.convert(updateReqVO);
|
||||
supplierCompanyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSupplierCompany(Long id) {
|
||||
// 校验存在
|
||||
validateSupplierCompanyExists(id);
|
||||
// 删除
|
||||
supplierCompanyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateSupplierCompanyExists(Long id) {
|
||||
if (supplierCompanyMapper.selectById(id) == null) {
|
||||
throw exception(SUPPLIER_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SupplierCompanyDO getSupplierCompany(Long id) {
|
||||
return supplierCompanyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SupplierCompanyDO> getSupplierCompanyList(Collection<Long> ids) {
|
||||
return supplierCompanyMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SupplierCompanyDO> getSupplierCompanyPage(SupplierCompanyPageReqVO pageReqVO) {
|
||||
return supplierCompanyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SupplierCompanyDO> getSupplierCompanyList(SupplierCompanyExportReqVO exportReqVO) {
|
||||
return supplierCompanyMapper.selectList(exportReqVO);
|
||||
}
|
||||
/**
|
||||
* 编号生成方法
|
||||
* @return
|
||||
*/
|
||||
private String numberCreate(){
|
||||
long currentTime = System.currentTimeMillis();
|
||||
Date date = new Date(currentTime);
|
||||
String companyNumber="gys"+ DateUtils.dateToStr(DateUtils.FORMAT_HOUR_MINUT,date);
|
||||
Long companyNumberSize = supplierCompanyMapper.selectCount(new QueryWrapper<SupplierCompanyDO>().likeLeft("company_number", companyNumber));
|
||||
Long l = companyNumberSize + 1L;
|
||||
int length = String.valueOf(companyNumberSize + 1L).length();
|
||||
if ((4-length) !=0){
|
||||
String gys = fillStr("", (4-length), true, "0");
|
||||
companyNumber=companyNumber+gys+l.intValue();
|
||||
}else {
|
||||
companyNumber=companyNumber+l;
|
||||
}
|
||||
return companyNumber;
|
||||
}
|
||||
|
||||
private String fillStr(String value, int count, boolean frontORback, String fillChar) {
|
||||
String rtvalue = value;
|
||||
if (rtvalue == null) {
|
||||
rtvalue = "";
|
||||
for (int i = 0; i < count; i++)
|
||||
if (frontORback)
|
||||
rtvalue = String.valueOf(rtvalue)
|
||||
+ String.valueOf(fillChar);
|
||||
else
|
||||
rtvalue = String.valueOf(fillChar)
|
||||
+ String.valueOf(rtvalue);
|
||||
} else {
|
||||
int len = rtvalue.length();
|
||||
if (len > count) {
|
||||
rtvalue = rtvalue.substring(0, count);
|
||||
} else {
|
||||
int a = count - len;
|
||||
for (int i = 0; i < a; i++)
|
||||
if (frontORback)
|
||||
rtvalue = String.valueOf(rtvalue)
|
||||
+ String.valueOf(fillChar);
|
||||
else
|
||||
rtvalue = String.valueOf(fillChar)
|
||||
+ String.valueOf(rtvalue);
|
||||
}
|
||||
}
|
||||
return rtvalue;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue