mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-25 07:07:37 +08:00
feat(JsSupplier): implement CRUD operations and DTOs for supplier management
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateJsSuppilerDto extends OrgCommonDto {}
|
||||
@@ -1,15 +0,0 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class JsSuppilerDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateJsSuppilerDto extends OrgCommonDto {}
|
||||
@@ -1,13 +1,13 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.controller;
|
||||
package cn.lihongjie.coal.jsSupplier.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.CreateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.JsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.UpdateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.service.JsSuppilerService;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.CreateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.JsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.UpdateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.service.JsSupplierService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -19,20 +19,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/jsSuppiler")
|
||||
@RequestMapping("/jsSupplier")
|
||||
@SysLog(module = "")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class JsSuppilerController {
|
||||
@Autowired private JsSuppilerService service;
|
||||
public class JsSupplierController {
|
||||
@Autowired private JsSupplierService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public JsSuppilerDto create(@RequestBody CreateJsSuppilerDto request) {
|
||||
public JsSupplierDto create(@RequestBody CreateJsSupplierDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public JsSuppilerDto update(@RequestBody UpdateJsSuppilerDto request) {
|
||||
public JsSupplierDto update(@RequestBody UpdateJsSupplierDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ public class JsSuppilerController {
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public JsSuppilerDto getById(@RequestBody IdRequest request) {
|
||||
public JsSupplierDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<JsSuppilerDto> list(@RequestBody CommonQuery request) {
|
||||
public Page<JsSupplierDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lihongjie.coal.jsSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateJsSupplierDto extends OrgCommonDto {
|
||||
private String socialCreditCode;
|
||||
|
||||
private String bank;
|
||||
|
||||
private String bankBranch;
|
||||
|
||||
private String bankBranchAddress;
|
||||
|
||||
private String bankCardNumber;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.lihongjie.coal.jsSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class JsSupplierDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
private String socialCreditCode;
|
||||
|
||||
private String bank;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.BANK)
|
||||
private String bankName;
|
||||
|
||||
private String bankBranch;
|
||||
|
||||
private String bankBranchAddress;
|
||||
|
||||
private String bankCardNumber;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lihongjie.coal.jsSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateJsSupplierDto extends OrgCommonDto {
|
||||
private String socialCreditCode;
|
||||
|
||||
private String bank;
|
||||
|
||||
private String bankBranch;
|
||||
|
||||
private String bankBranchAddress;
|
||||
|
||||
private String bankCardNumber;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.entity;
|
||||
package cn.lihongjie.coal.jsSupplier.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
@@ -15,10 +15,25 @@ import org.hibernate.annotations.Comment;
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_jsSuppiler_org_id",
|
||||
name = "idx_jsSupplier_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class JsSuppilerEntity extends OrgCommonEntity {
|
||||
public class JsSupplierEntity extends OrgCommonEntity {
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
@Comment("社会统一信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
@Comment("银行")
|
||||
private String bank;
|
||||
|
||||
@Comment("开户行")
|
||||
private String bankBranch;
|
||||
|
||||
@Comment("开户行地址")
|
||||
private String bankBranchAddress;
|
||||
|
||||
@Comment("卡号")
|
||||
private String bankCardNumber;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.mapper;
|
||||
package cn.lihongjie.coal.jsSupplier.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.CreateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.JsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.UpdateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.entity.JsSuppilerEntity;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.CreateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.JsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.UpdateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.entity.JsSupplierEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
@@ -15,6 +15,6 @@ import org.mapstruct.control.DeepClone;
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface JsSuppilerMapper
|
||||
public interface JsSupplierMapper
|
||||
extends BaseMapper<
|
||||
JsSuppilerEntity, JsSuppilerDto, CreateJsSuppilerDto, UpdateJsSuppilerDto> {}
|
||||
JsSupplierEntity, JsSupplierDto, CreateJsSupplierDto, UpdateJsSupplierDto> {}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.repository;
|
||||
package cn.lihongjie.coal.jsSupplier.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.jsSuppiler.entity.JsSuppilerEntity;
|
||||
import cn.lihongjie.coal.jsSupplier.entity.JsSupplierEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JsSuppilerRepository extends BaseRepository<JsSuppilerEntity> {
|
||||
public interface JsSupplierRepository extends BaseRepository<JsSupplierEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package cn.lihongjie.coal.jsSuppiler.service;
|
||||
package cn.lihongjie.coal.jsSupplier.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.CreateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.JsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.dto.UpdateJsSuppilerDto;
|
||||
import cn.lihongjie.coal.jsSuppiler.entity.JsSuppilerEntity;
|
||||
import cn.lihongjie.coal.jsSuppiler.mapper.JsSuppilerMapper;
|
||||
import cn.lihongjie.coal.jsSuppiler.repository.JsSuppilerRepository;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.CreateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.JsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.UpdateJsSupplierDto;
|
||||
import cn.lihongjie.coal.jsSupplier.entity.JsSupplierEntity;
|
||||
import cn.lihongjie.coal.jsSupplier.mapper.JsSupplierMapper;
|
||||
import cn.lihongjie.coal.jsSupplier.repository.JsSupplierRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -25,24 +25,24 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class JsSuppilerService extends BaseService<JsSuppilerEntity, JsSuppilerRepository> {
|
||||
@Autowired private JsSuppilerRepository repository;
|
||||
public class JsSupplierService extends BaseService<JsSupplierEntity, JsSupplierRepository> {
|
||||
@Autowired private JsSupplierRepository repository;
|
||||
|
||||
@Autowired private JsSuppilerMapper mapper;
|
||||
@Autowired private JsSupplierMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public JsSuppilerDto create(CreateJsSuppilerDto request) {
|
||||
JsSuppilerEntity entity = mapper.toEntity(request);
|
||||
public JsSupplierDto create(CreateJsSupplierDto request) {
|
||||
JsSupplierEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public JsSuppilerDto update(UpdateJsSuppilerDto request) {
|
||||
JsSuppilerEntity entity = this.repository.get(request.getId());
|
||||
public JsSupplierDto update(UpdateJsSupplierDto request) {
|
||||
JsSupplierEntity entity = this.repository.get(request.getId());
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
@@ -65,14 +65,14 @@ public class JsSuppilerService extends BaseService<JsSuppilerEntity, JsSuppilerR
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public JsSuppilerDto getById(String id) {
|
||||
JsSuppilerEntity entity = repository.get(id);
|
||||
public JsSupplierDto getById(String id) {
|
||||
JsSupplierEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<JsSuppilerDto> list(CommonQuery query) {
|
||||
Page<JsSuppilerEntity> page =
|
||||
public Page<JsSupplierDto> list(CommonQuery query) {
|
||||
Page<JsSupplierEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
@@ -2,13 +2,13 @@
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.jsSuppiler.controller.JsSuppilerController
|
||||
import cn.lihongjie.coal.jsSupplier.controller.JsSupplierController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(JsSuppilerController.class)
|
||||
def controller = ioc.getBean(JsSupplierController.class)
|
||||
def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper
|
||||
|
||||
|
||||
Reference in New Issue
Block a user