mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-25 07:07:37 +08:00
feat(JsPurchaser): add purchaser field to receipt DTOs and entity for buyer information
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.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.jsPurchaser.dto.CreateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.JsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.UpdateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.service.JsPurchaserService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/jsPurchaser")
|
||||
@SysLog(module = "")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class JsPurchaserController {
|
||||
@Autowired private JsPurchaserService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public JsPurchaserDto create(@RequestBody CreateJsPurchaserDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public JsPurchaserDto update(@RequestBody UpdateJsPurchaserDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public JsPurchaserDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<JsPurchaserDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CreateJsPurchaserDto extends OrgCommonDto {
|
||||
@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;
|
||||
|
||||
@Comment("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class JsPurchaserDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
|
||||
|
||||
@Comment("社会统一信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
@Comment("银行")
|
||||
private String bank;
|
||||
|
||||
@Comment("开户行")
|
||||
private String bankBranch;
|
||||
|
||||
@Comment("开户行地址")
|
||||
private String bankBranchAddress;
|
||||
|
||||
@Comment("卡号")
|
||||
private String bankCardNumber;
|
||||
|
||||
@Comment("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateJsPurchaserDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@Comment("社会统一信用代码")
|
||||
private String socialCreditCode;
|
||||
|
||||
@Comment("银行")
|
||||
private String bank;
|
||||
|
||||
@Comment("开户行")
|
||||
private String bankBranch;
|
||||
|
||||
@Comment("开户行地址")
|
||||
private String bankBranchAddress;
|
||||
|
||||
@Comment("卡号")
|
||||
private String bankCardNumber;
|
||||
|
||||
@Comment("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_jsPurchaser_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class JsPurchaserEntity 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;
|
||||
|
||||
@Comment("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
private String address;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.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.jsPurchaser.dto.CreateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.JsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.UpdateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.entity.JsPurchaserEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface JsPurchaserMapper
|
||||
extends BaseMapper<
|
||||
JsPurchaserEntity, JsPurchaserDto, CreateJsPurchaserDto, UpdateJsPurchaserDto> {}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.jsPurchaser.entity.JsPurchaserEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JsPurchaserRepository extends BaseRepository<JsPurchaserEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.lihongjie.coal.jsPurchaser.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.jsPurchaser.dto.CreateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.JsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.UpdateJsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsPurchaser.entity.JsPurchaserEntity;
|
||||
import cn.lihongjie.coal.jsPurchaser.mapper.JsPurchaserMapper;
|
||||
import cn.lihongjie.coal.jsPurchaser.repository.JsPurchaserRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class JsPurchaserService extends BaseService<JsPurchaserEntity, JsPurchaserRepository> {
|
||||
@Autowired private JsPurchaserRepository repository;
|
||||
|
||||
@Autowired private JsPurchaserMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public JsPurchaserDto create(CreateJsPurchaserDto request) {
|
||||
JsPurchaserEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public JsPurchaserDto update(UpdateJsPurchaserDto request) {
|
||||
JsPurchaserEntity entity = this.repository.get(request.getId());
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
if (this.repository.containArchived(request)) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public JsPurchaserDto getById(String id) {
|
||||
JsPurchaserEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<JsPurchaserDto> list(CommonQuery query) {
|
||||
Page<JsPurchaserEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ public class CreateJsReceiptDto extends OrgCommonDto {
|
||||
@Comment("供应商ID")
|
||||
private String supplier;
|
||||
|
||||
private String purchaser;
|
||||
|
||||
@Comment("总金额")
|
||||
private Double totalAmount;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.lihongjie.coal.jsReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.JsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsReceiptDetail.dto.JsReceiptDetailSimpleDto;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
@@ -28,6 +29,8 @@ public class JsReceiptDto extends OrgCommonDto {
|
||||
@Comment("供应商")
|
||||
private cn.lihongjie.coal.jsSupplier.dto.JsSupplierDto supplier;
|
||||
|
||||
private JsPurchaserDto purchaser;
|
||||
|
||||
@Comment("商品数量(明细行数)")
|
||||
private Integer itemCount;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.lihongjie.coal.jsReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.jsPurchaser.dto.JsPurchaserDto;
|
||||
import cn.lihongjie.coal.jsSupplier.dto.JsSupplierDto;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
@@ -22,6 +23,7 @@ public class JsReceiptSimpleDto extends OrgCommonDto {
|
||||
|
||||
@Comment("供应商")
|
||||
private JsSupplierDto supplier;
|
||||
private JsPurchaserDto purchaser;
|
||||
|
||||
@Comment("商品数量(明细行数)")
|
||||
private Integer itemCount;
|
||||
|
||||
@@ -22,6 +22,10 @@ public class UpdateJsReceiptDto extends OrgCommonDto {
|
||||
@Comment("供应商ID")
|
||||
private String supplier;
|
||||
|
||||
|
||||
private String purchaser;
|
||||
|
||||
|
||||
@Comment("总金额")
|
||||
private Double totalAmount;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lihongjie.coal.jsReceipt.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.jsPurchaser.entity.JsPurchaserEntity;
|
||||
import cn.lihongjie.coal.jsReceiptDetail.entity.JsReceiptDetailEntity;
|
||||
import cn.lihongjie.coal.jsSupplier.entity.JsSupplierEntity;
|
||||
|
||||
@@ -44,6 +45,10 @@ public class JsReceiptEntity extends OrgCommonEntity {
|
||||
@ManyToOne
|
||||
private JsSupplierEntity supplier;
|
||||
|
||||
@Comment("购买方")
|
||||
@ManyToOne
|
||||
private JsPurchaserEntity purchaser;
|
||||
|
||||
@Comment("商品数量(明细行数)")
|
||||
private Integer itemCount;
|
||||
|
||||
|
||||
19
src/main/resources/scripts/dict/enum/jsPurchaserDict.groovy
Normal file
19
src/main/resources/scripts/dict/enum/jsPurchaserDict.groovy
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.jsPurchaser.controller.JsPurchaserController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(JsPurchaserController.class)
|
||||
def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user