mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
添加事由说明
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.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.warehouseReceiptReason.dto.CreateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.UpdateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.WarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.service.WarehouseReceiptReasonService;
|
||||||
|
|
||||||
|
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("/warehouseReceiptReason")
|
||||||
|
@SysLog(module = "仓库单据事由模板")
|
||||||
|
@Slf4j
|
||||||
|
@OrgScope
|
||||||
|
public class WarehouseReceiptReasonController {
|
||||||
|
@Autowired private WarehouseReceiptReasonService service;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public WarehouseReceiptReasonDto create(@RequestBody CreateWarehouseReceiptReasonDto request) {
|
||||||
|
return this.service.create(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public WarehouseReceiptReasonDto update(@RequestBody UpdateWarehouseReceiptReasonDto request) {
|
||||||
|
return this.service.update(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public Object delete(@RequestBody IdRequest request) {
|
||||||
|
this.service.delete(request);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getById")
|
||||||
|
public WarehouseReceiptReasonDto getById(@RequestBody IdRequest request) {
|
||||||
|
return this.service.getById(request.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
public Page<WarehouseReceiptReasonDto> list(@RequestBody CommonQuery request) {
|
||||||
|
return this.service.list(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.dto;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||||
|
|
||||||
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CreateWarehouseReceiptReasonDto extends OrgCommonDto {
|
||||||
|
|
||||||
|
@Comment("单据类型")
|
||||||
|
private String receiptType;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'warehouse.receiptType'\n"
|
||||||
|
+ " and i.code = receipt_type)")
|
||||||
|
private String receiptTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("事由")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("用于存储多个事由说明, 用于下拉框展示和快速填写")
|
||||||
|
@Column(columnDefinition = "text[]")
|
||||||
|
@Type(ListArrayType.class)
|
||||||
|
private List<String> reasonDesc;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.dto;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||||
|
|
||||||
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateWarehouseReceiptReasonDto extends OrgCommonDto {
|
||||||
|
|
||||||
|
@Comment("单据类型")
|
||||||
|
private String receiptType;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'warehouse.receiptType'\n"
|
||||||
|
+ " and i.code = receipt_type)")
|
||||||
|
private String receiptTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("事由")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("用于存储多个事由说明, 用于下拉框展示和快速填写")
|
||||||
|
@Column(columnDefinition = "text[]")
|
||||||
|
@Type(ListArrayType.class)
|
||||||
|
private List<String> reasonDesc;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.dto;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||||
|
|
||||||
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WarehouseReceiptReasonDto extends OrgCommonDto {
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("单据类型")
|
||||||
|
private String receiptType;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'warehouse.receiptType'\n"
|
||||||
|
+ " and i.code = receipt_type)")
|
||||||
|
private String receiptTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("事由")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("用于存储多个事由说明, 用于下拉框展示和快速填写")
|
||||||
|
@Column(columnDefinition = "text[]")
|
||||||
|
@Type(ListArrayType.class)
|
||||||
|
private List<String> reasonDesc;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.entity;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||||
|
|
||||||
|
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Comment;
|
||||||
|
import org.hibernate.annotations.Formula;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class WarehouseReceiptReasonEntity extends OrgCommonEntity {
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("单据类型")
|
||||||
|
private String receiptType;
|
||||||
|
|
||||||
|
@Formula(
|
||||||
|
"(select i.name\n"
|
||||||
|
+ "from t_dictionary d,\n"
|
||||||
|
+ " t_dictionary_item i\n"
|
||||||
|
+ "where d.id = i.dictionary_id\n"
|
||||||
|
+ " and d.code = 'warehouse.receiptType'\n"
|
||||||
|
+ " and i.code = receipt_type)")
|
||||||
|
private String receiptTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("事由")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Comment("用于存储多个事由说明, 用于下拉框展示和快速填写")
|
||||||
|
@Column(columnDefinition = "text[]")
|
||||||
|
@Type(ListArrayType.class)
|
||||||
|
private List<String> reasonDesc;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.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.warehouseReceiptReason.dto.CreateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.UpdateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.WarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.entity.WarehouseReceiptReasonEntity;
|
||||||
|
|
||||||
|
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 WarehouseReceiptReasonMapper
|
||||||
|
extends BaseMapper<
|
||||||
|
WarehouseReceiptReasonEntity,
|
||||||
|
WarehouseReceiptReasonDto,
|
||||||
|
CreateWarehouseReceiptReasonDto,
|
||||||
|
UpdateWarehouseReceiptReasonDto> {}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.repository;
|
||||||
|
|
||||||
|
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.entity.WarehouseReceiptReasonEntity;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface WarehouseReceiptReasonRepository
|
||||||
|
extends BaseRepository<WarehouseReceiptReasonEntity> {}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package cn.lihongjie.coal.warehouseReceiptReason.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.warehouseReceiptReason.dto.CreateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.UpdateWarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.dto.WarehouseReceiptReasonDto;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.entity.WarehouseReceiptReasonEntity;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.mapper.WarehouseReceiptReasonMapper;
|
||||||
|
import cn.lihongjie.coal.warehouseReceiptReason.repository.WarehouseReceiptReasonRepository;
|
||||||
|
|
||||||
|
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 WarehouseReceiptReasonService
|
||||||
|
extends BaseService<WarehouseReceiptReasonEntity, WarehouseReceiptReasonRepository> {
|
||||||
|
@Autowired private WarehouseReceiptReasonRepository repository;
|
||||||
|
|
||||||
|
@Autowired private WarehouseReceiptReasonMapper mapper;
|
||||||
|
|
||||||
|
@Autowired private ConversionService conversionService;
|
||||||
|
|
||||||
|
public WarehouseReceiptReasonDto create(CreateWarehouseReceiptReasonDto request) {
|
||||||
|
WarehouseReceiptReasonEntity entity = mapper.toEntity(request);
|
||||||
|
|
||||||
|
this.repository.save(entity);
|
||||||
|
return getById(entity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarehouseReceiptReasonDto update(UpdateWarehouseReceiptReasonDto request) {
|
||||||
|
WarehouseReceiptReasonEntity entity = this.repository.get(request.getId());
|
||||||
|
this.mapper.updateEntity(entity, request);
|
||||||
|
|
||||||
|
this.repository.save(entity);
|
||||||
|
|
||||||
|
return getById(entity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(IdRequest request) {
|
||||||
|
this.repository.deleteAllById(request.getIds());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarehouseReceiptReasonDto getById(String id) {
|
||||||
|
WarehouseReceiptReasonEntity entity = repository.get(id);
|
||||||
|
|
||||||
|
return mapper.toDto(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<WarehouseReceiptReasonDto> list(CommonQuery query) {
|
||||||
|
Page<WarehouseReceiptReasonEntity> page =
|
||||||
|
repository.findAll(
|
||||||
|
query.specification(conversionService),
|
||||||
|
PageRequest.of(
|
||||||
|
query.getPageNo(),
|
||||||
|
query.getPageSize(),
|
||||||
|
Sort.by(query.getOrders())));
|
||||||
|
|
||||||
|
return page.map(this.mapper::toDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user