mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 23:57:12 +08:00
仓库管理相关
This commit is contained in:
@@ -13,6 +13,8 @@ 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.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.ArchiveUtils;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.googlejavaformat.java.Formatter;
|
||||
@@ -82,6 +84,11 @@ public class Codegen {
|
||||
Objects.equals(
|
||||
StringUtils.defaultIfBlank(new Scanner(System.in).nextLine(), "Y"), "Y");
|
||||
|
||||
System.out.print("支持归档[Y]:");
|
||||
boolean archive =
|
||||
Objects.equals(
|
||||
StringUtils.defaultIfBlank(new Scanner(System.in).nextLine(), "Y"), "Y");
|
||||
|
||||
String lModuleName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, moduleName);
|
||||
String prefix = Codegen.class.getPackage().getName() + "." + lModuleName;
|
||||
String entityPackage = prefix + ".entity";
|
||||
@@ -101,6 +108,48 @@ public class Codegen {
|
||||
.addAnnotation(Entity.class)
|
||||
.build();
|
||||
|
||||
if (archive) {
|
||||
entity =
|
||||
entity.toBuilder()
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
String.class, "archiveStatus", Modifier.PRIVATE)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(
|
||||
org.hibernate.annotations
|
||||
.Comment.class)
|
||||
.addMember("value", "$S", "归档状态")
|
||||
.build())
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(
|
||||
org.hibernate.annotations
|
||||
.ColumnDefault.class)
|
||||
.addMember("value", "$S", "'0'")
|
||||
.build())
|
||||
.build())
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
String.class,
|
||||
"archiveStatusName",
|
||||
Modifier.PRIVATE)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(
|
||||
org.hibernate.annotations
|
||||
.Formula.class)
|
||||
.addMember(
|
||||
"value",
|
||||
"$S",
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'archiveStatus'\n"
|
||||
+ " and i.code = archive_status)")
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
saveFile(entityPackage, entity);
|
||||
|
||||
// 生成dto
|
||||
@@ -111,6 +160,26 @@ public class Codegen {
|
||||
.addAnnotation(Data.class)
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
if (archive) {
|
||||
dto =
|
||||
dto.toBuilder()
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
String.class, "archiveStatus", Modifier.PRIVATE)
|
||||
|
||||
.build())
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
String.class,
|
||||
"archiveStatusName",
|
||||
Modifier.PRIVATE)
|
||||
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
saveFile(dtoPackage, dto);
|
||||
|
||||
// 生成createDto
|
||||
@@ -156,7 +225,11 @@ public class Codegen {
|
||||
"componentModel",
|
||||
"org.mapstruct.MappingConstants.ComponentModel.SPRING",
|
||||
"")
|
||||
.addMember("uses", "{$T.class, $T.class}", CommonMapper.class, CommonEntityMapper.class)
|
||||
.addMember(
|
||||
"uses",
|
||||
"{$T.class, $T.class}",
|
||||
CommonMapper.class,
|
||||
CommonEntityMapper.class)
|
||||
.addMember("mappingControl", "$T.class", DeepClone.class)
|
||||
.build())
|
||||
.addSuperinterface(
|
||||
@@ -171,6 +244,83 @@ public class Codegen {
|
||||
saveFile(mapperPackage, mapper);
|
||||
|
||||
// 生成service
|
||||
MethodSpec serviceUpdate = MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(
|
||||
ClassName.get(dtoPackage, updateDto.name),
|
||||
"request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId())
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build();
|
||||
|
||||
|
||||
if (archive){
|
||||
serviceUpdate =
|
||||
MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(dtoPackage, updateDto.name), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = this.repository.get(request.getId());
|
||||
$T.checkArchiveStatus(
|
||||
entity,
|
||||
$T::getArchiveStatus,
|
||||
x -> "0",
|
||||
(e, actual, expected) -> {
|
||||
throw new $T("数据 " + "已归档,无法编辑");
|
||||
});
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId())
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name), ClassName.get(ArchiveUtils.class), ClassName.get(entityPackage, entity.name), ClassName.get(BizException.class))
|
||||
.build();
|
||||
}
|
||||
|
||||
MethodSpec serviceDelete = MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
""")
|
||||
.build();
|
||||
|
||||
if (archive){
|
||||
serviceDelete =
|
||||
MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T.checkArchiveStatus(
|
||||
this.repository::findAllById,
|
||||
request.getIds(),
|
||||
$T::getArchiveStatus,
|
||||
x -> "0",
|
||||
(e, actual, expected) -> {
|
||||
throw new $T("数据 " + "已归档,无法删除");
|
||||
});
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
""",
|
||||
ClassName.get(ArchiveUtils.class), ClassName.get(entityPackage, entity.name), ClassName.get(BizException.class)).build();
|
||||
|
||||
}
|
||||
|
||||
TypeSpec service =
|
||||
TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Service")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
@@ -221,33 +371,9 @@ public class Codegen {
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(
|
||||
ClassName.get(dtoPackage, updateDto.name),
|
||||
"request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId())
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build())
|
||||
serviceUpdate)
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
""")
|
||||
.build())
|
||||
serviceDelete)
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("getById")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
@@ -284,6 +410,48 @@ public class Codegen {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
if (archive) {
|
||||
service =
|
||||
service.toBuilder()
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("archive")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "dto")
|
||||
.addStatement(
|
||||
"""
|
||||
this.repository.findAllById(dto.getIds()).stream()
|
||||
.peek(x -> $T.checkArchiveStatus(x, $T::getArchiveStatus, y -> "0", (e, actual, expected) -> {
|
||||
throw new $T("数据 " + "已归档,无法再次归档");
|
||||
}))
|
||||
.peek(x -> x.setArchiveStatus("1"))
|
||||
.forEach(this.repository::save);
|
||||
""", ClassName.get(ArchiveUtils.class), ClassName.get(entityPackage, entity.name), ClassName.get(BizException.class))
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("unarchive")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "dto")
|
||||
.addStatement(
|
||||
"""
|
||||
this.repository.findAllById(dto.getIds()).stream()
|
||||
.peek(x->$T.checkArchiveStatus(x, $T::getArchiveStatus, y -> "1", (e, actual, expected) -> {
|
||||
throw new $T("数据" + "未归档,无法取消归档");
|
||||
}))
|
||||
.peek(x -> x.setArchiveStatus("0"))
|
||||
.forEach(this.repository::save);
|
||||
""", ClassName.get(ArchiveUtils.class), ClassName.get(entityPackage, entity.name), ClassName.get(BizException.class))
|
||||
.build())
|
||||
|
||||
|
||||
.build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
saveFile(servicePackage, service);
|
||||
|
||||
// 生成controller
|
||||
@@ -416,6 +584,49 @@ public class Codegen {
|
||||
ClassName.get(Sort.class))
|
||||
.build());
|
||||
|
||||
|
||||
if (archive){
|
||||
controllerBuilder
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("archive")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(Object.class)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/archive")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(
|
||||
ClassName.get(IdRequest.class), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
this.service.archive(request);
|
||||
return true
|
||||
""")
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("unarchive")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(Object.class)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/unarchive")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(
|
||||
ClassName.get(IdRequest.class), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
this.service.unarchive(request);
|
||||
return true
|
||||
""")
|
||||
.build());
|
||||
}
|
||||
|
||||
saveFile(controllerPackage, controllerBuilder.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
package cn.lihongjie.coal;
|
||||
|
||||
import static org.reflections.scanners.Scanners.SubTypes;
|
||||
import static org.reflections.scanners.Scanners.TypesAnnotated;
|
||||
|
||||
import com.google.googlejavaformat.java.Formatter;
|
||||
import com.google.googlejavaformat.java.JavaFormatterOptions;
|
||||
import com.squareup.javapoet.*;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
|
||||
/**
|
||||
* google-java-format uses internal javac APIs for parsing Java source. The following JVM flags are
|
||||
* required when running on JDK 16 and newer, due to JEP 396: Strongly Encapsulate JDK Internals by
|
||||
* Default:
|
||||
*
|
||||
* <p>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
|
||||
* --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
|
||||
* --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
|
||||
* --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
|
||||
* --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
|
||||
* --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
*/
|
||||
public class EntityMapperGen {
|
||||
|
||||
public static final Path DIRECTORY = Path.of("src/main/java/");
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reflections reflections = new Reflections("cn.lihongjie.coal");
|
||||
|
||||
Set<String> entityClasses =
|
||||
reflections.get(SubTypes.of(TypesAnnotated.with(Entity.class)));
|
||||
|
||||
// 生成entity
|
||||
|
||||
TypeSpec.Builder entityMapperBuilder =
|
||||
TypeSpec.interfaceBuilder("CommonEntityMapper")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(Mapper.class)
|
||||
.addMember("componentModel", "\"spring\"")
|
||||
.build());
|
||||
|
||||
|
||||
|
||||
for (String e : entityClasses) {
|
||||
Class<?> entityClass = Class.forName(e);
|
||||
System.out.println("entityClass = " + entityClass);
|
||||
|
||||
MethodSpec.Builder methodBuilder =
|
||||
MethodSpec.methodBuilder("create" + entityClass.getSimpleName());
|
||||
methodBuilder.addModifiers(Modifier.PUBLIC);
|
||||
methodBuilder.addModifiers(Modifier.DEFAULT);
|
||||
methodBuilder.returns(ClassName.get(entityClass));
|
||||
methodBuilder.addParameter(ClassName.get(String.class), "id");
|
||||
methodBuilder.addStatement(
|
||||
"""
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new $T();
|
||||
e.setId(id);
|
||||
return e
|
||||
|
||||
""",
|
||||
ClassName.get(entityClass));
|
||||
entityMapperBuilder.addMethod(methodBuilder.build());
|
||||
}
|
||||
|
||||
saveFile("cn.lihongjie.coal.base.mapper", entityMapperBuilder.build());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void saveFile(String pkg, TypeSpec entity) throws IOException {
|
||||
|
||||
JavaFile javaFile = JavaFile.builder(pkg, entity).build();
|
||||
|
||||
Path outputDirectory = DIRECTORY;
|
||||
if (!javaFile.packageName.isEmpty()) {
|
||||
for (String packageComponent : javaFile.packageName.split("\\.")) {
|
||||
outputDirectory = outputDirectory.resolve(packageComponent);
|
||||
}
|
||||
Files.createDirectories(outputDirectory);
|
||||
}
|
||||
|
||||
Path outputPath = outputDirectory.resolve(javaFile.typeSpec.name + ".java");
|
||||
try (Writer writer =
|
||||
new OutputStreamWriter(Files.newOutputStream(outputPath), StandardCharsets.UTF_8)) {
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
javaFile.writeTo(out);
|
||||
|
||||
String formattedSource =
|
||||
new Formatter(
|
||||
JavaFormatterOptions.builder()
|
||||
.style(JavaFormatterOptions.Style.AOSP)
|
||||
.formatJavadoc(true)
|
||||
.reorderModifiers(true)
|
||||
.build())
|
||||
.formatSource(out.toString());
|
||||
|
||||
writer.write(formattedSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,635 +1,27 @@
|
||||
package cn.lihongjie.coal.base.mapper;
|
||||
|
||||
import cn.lihongjie.coal.cacheCtl.entity.CacheCtlEntity;
|
||||
import cn.lihongjie.coal.coalAnalysis.entity.CoalAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalAnalysisHis.entity.CoalAnalysisHisEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalBlendResultInfoEntity;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import cn.lihongjie.coal.coalParameterDef.entity.CoalParameterDefEntity;
|
||||
import cn.lihongjie.coal.coalPrice.entity.CoalPriceEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysisParam.entity.CoalWashingDailyAnalysisParamEntity;
|
||||
import cn.lihongjie.coal.coalWashingMonthReport.entity.CoalWashingMonthReportEntity;
|
||||
import cn.lihongjie.coal.cronJob.entity.CronJobEntity;
|
||||
import cn.lihongjie.coal.cronJobLog.entity.CronJobLogEntity;
|
||||
import cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity;
|
||||
import cn.lihongjie.coal.department.entity.DepartmentEntity;
|
||||
import cn.lihongjie.coal.dictionary.entity.DictionaryEntity;
|
||||
import cn.lihongjie.coal.dictionary.entity.DictionaryItemEntity;
|
||||
import cn.lihongjie.coal.downloadCenter.entity.DownloadCenterEntity;
|
||||
import cn.lihongjie.coal.employee.entity.EmployeeEntity;
|
||||
import cn.lihongjie.coal.enterprise.entity.EnterpriseEntity;
|
||||
import cn.lihongjie.coal.file.entity.FileEntity;
|
||||
import cn.lihongjie.coal.inventoryCheck.entity.InventoryCheckEntity;
|
||||
import cn.lihongjie.coal.inventoryCheckDetail.entity.InventoryCheckDetailEntity;
|
||||
import cn.lihongjie.coal.ipList.entity.IpListEntity;
|
||||
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;
|
||||
import cn.lihongjie.coal.loginUser.entity.LoginUserEntity;
|
||||
import cn.lihongjie.coal.loginUserHis.entity.LoginUserHisEntity;
|
||||
import cn.lihongjie.coal.meter.entity.MeterEntity;
|
||||
import cn.lihongjie.coal.meterDayLog.entity.MeterDayLogEntity;
|
||||
import cn.lihongjie.coal.meterLog.entity.MeterLogEntity;
|
||||
import cn.lihongjie.coal.meterMonthLog.entity.MeterMonthLogEntity;
|
||||
import cn.lihongjie.coal.netDisk.entity.NetDiskEntity;
|
||||
import cn.lihongjie.coal.noteBook.entity.NoteBookEntity;
|
||||
import cn.lihongjie.coal.noteBookChapter.entity.NoteBookChapterEntity;
|
||||
import cn.lihongjie.coal.notice.entity.NoticeEntity;
|
||||
import cn.lihongjie.coal.noticeStatus.entity.NoticeStatusEntity;
|
||||
import cn.lihongjie.coal.organization.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.passwordDict.entity.PasswordDictEntity;
|
||||
import cn.lihongjie.coal.pdfGenerator.entity.PdfGeneratorEntity;
|
||||
import cn.lihongjie.coal.permission.entity.PermissionEntity;
|
||||
import cn.lihongjie.coal.product.entity.ProductEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import cn.lihongjie.coal.resetPwd.entity.ResetPwdEntity;
|
||||
import cn.lihongjie.coal.resource.entity.ResourceEntity;
|
||||
import cn.lihongjie.coal.role.entity.RoleEntity;
|
||||
import cn.lihongjie.coal.salaryItem.entity.SalaryItemEntity;
|
||||
import cn.lihongjie.coal.script.entity.ScriptEntity;
|
||||
import cn.lihongjie.coal.sms.entity.SmsEntity;
|
||||
import cn.lihongjie.coal.smsTemplate.entity.SmsTemplateEntity;
|
||||
import cn.lihongjie.coal.supplier.entity.SupplierEntity;
|
||||
import cn.lihongjie.coal.sysconfig.entity.SysConfigEntity;
|
||||
import cn.lihongjie.coal.syslog.entity.SysLogEntity;
|
||||
import cn.lihongjie.coal.user.entity.UserEntity;
|
||||
import cn.lihongjie.coal.warehouse.entity.WarehouseEntity;
|
||||
import cn.lihongjie.coal.warehouseShelve.entity.WarehouseShelveEntity;
|
||||
import cn.lihongjie.coal.warehouseSupplier.entity.WarehouseSupplierEntity;
|
||||
import cn.lihongjie.coal.base.entity.BaseEntity;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.TargetType;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface CommonEntityMapper {
|
||||
default CoalWashingDailyAnalysisEntity createCoalWashingDailyAnalysisEntity(String id) {
|
||||
@SneakyThrows
|
||||
default <T extends BaseEntity>T toEntity(String id, @TargetType Class<T> clazz) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalWashingDailyAnalysisEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
|
||||
|
||||
T t = clazz.newInstance();
|
||||
t.setId(id);
|
||||
return t;
|
||||
}
|
||||
|
||||
default CoalInfoEntity createCoalInfoEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalInfoEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default MeterLogEntity createMeterLogEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new MeterLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default InventoryCheckDetailEntity createInventoryCheckDetailEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new InventoryCheckDetailEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default ScriptEntity createScriptEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new ScriptEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalPriceEntity createCoalPriceEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalPriceEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default OrganizationEntity createOrganizationEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new OrganizationEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default RoleEntity createRoleEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new RoleEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default DownloadCenterEntity createDownloadCenterEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new DownloadCenterEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default DictionaryItemEntity createDictionaryItemEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new DictionaryItemEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default NoticeEntity createNoticeEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new NoticeEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default ProductEntity createProductEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new ProductEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default NoteBookEntity createNoteBookEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new NoteBookEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalAnalysisEntity createCoalAnalysisEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalAnalysisEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default EmployeeEntity createEmployeeEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new EmployeeEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default UserEntity createUserEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new UserEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SalaryItemEntity createSalaryItemEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SalaryItemEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default MeterMonthLogEntity createMeterMonthLogEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new MeterMonthLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CronJobEntity createCronJobEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CronJobEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default DepartmentEntity createDepartmentEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new DepartmentEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default MeterDayLogEntity createMeterDayLogEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new MeterDayLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalAnalysisHisEntity createCoalAnalysisHisEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalAnalysisHisEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default IpListEntity createIpListEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new IpListEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalBlendResultInfoEntity createCoalBlendResultInfoEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalBlendResultInfoEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalBlendEntity createCoalBlendEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalBlendEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default NetDiskEntity createNetDiskEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new NetDiskEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CronJobLogEntity createCronJobLogEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CronJobLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default PdfGeneratorEntity createPdfGeneratorEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new PdfGeneratorEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default JobPostEntity createJobPostEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new JobPostEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default DictionaryEntity createDictionaryEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new DictionaryEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default WarehouseEntity createWarehouseEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new WarehouseEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default ResetPwdEntity createResetPwdEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new ResetPwdEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default EnterpriseEntity createEnterpriseEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new EnterpriseEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SysConfigEntity createSysConfigEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SysConfigEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalParameterDefEntity createCoalParameterDefEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalParameterDefEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CacheCtlEntity createCacheCtlEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CacheCtlEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default PermissionEntity createPermissionEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new PermissionEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SmsTemplateEntity createSmsTemplateEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SmsTemplateEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default PurchaseOrderEntity createPurchaseOrderEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new PurchaseOrderEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SmsEntity createSmsEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SmsEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default NoticeStatusEntity createNoticeStatusEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new NoticeStatusEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default NoteBookChapterEntity createNoteBookChapterEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new NoteBookChapterEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default WarehouseShelveEntity createWarehouseShelveEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new WarehouseShelveEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default DeliveryInformationEntity createDeliveryInformationEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new DeliveryInformationEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SysLogEntity createSysLogEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SysLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default InventoryCheckEntity createInventoryCheckEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new InventoryCheckEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalWashingDailyAnalysisParamEntity createCoalWashingDailyAnalysisParamEntity(
|
||||
String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalWashingDailyAnalysisParamEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default SupplierEntity createSupplierEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new SupplierEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default ResourceEntity createResourceEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new ResourceEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default MeterEntity createMeterEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new MeterEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalBlendCoalInfoEntity createCoalBlendCoalInfoEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalBlendCoalInfoEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default LoginUserHisEntity createLoginUserHisEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new LoginUserHisEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default WarehouseSupplierEntity createWarehouseSupplierEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new WarehouseSupplierEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default LoginUserEntity createLoginUserEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new LoginUserEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default PasswordDictEntity createPasswordDictEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new PasswordDictEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default CoalWashingMonthReportEntity createCoalWashingMonthReportEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new CoalWashingMonthReportEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default FileEntity createFileEntity(String id) {
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
var e = new FileEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.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.warehouseGoods.dto.CreateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.UpdateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.service.WarehouseGoodsService;
|
||||
|
||||
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("/warehouseGoods")
|
||||
@SysLog(module = "仓库商品管理")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseGoodsController {
|
||||
@Autowired private WarehouseGoodsService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseGoodsDto create(@RequestBody CreateWarehouseGoodsDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseGoodsDto update(@RequestBody UpdateWarehouseGoodsDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseGoodsDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseGoodsDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseGoodsDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseGoodsDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseGoodsDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.entity.WarehouseGoodsBrandEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.entity.WarehouseGoodsCategoryEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.entity.WarehouseGoodsUnitEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseGoodsEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsCategoryEntity category;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsBrandEntity brand;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsUnitEntity unit;
|
||||
|
||||
|
||||
@Comment("条码")
|
||||
private String barCode;
|
||||
|
||||
|
||||
@Comment("重量 kg")
|
||||
private Double weight;
|
||||
|
||||
@Comment("体积 m3")
|
||||
private Double volume;
|
||||
|
||||
@Comment("尺寸")
|
||||
private String size;
|
||||
|
||||
@Comment("进货价")
|
||||
private Double price1;
|
||||
@Comment("市场价")
|
||||
private Double price2;
|
||||
@Comment("仓库核算价")
|
||||
private Double price3;
|
||||
|
||||
private Double price4;
|
||||
private Double price5;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.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.warehouseGoods.dto.CreateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.UpdateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
|
||||
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 WarehouseGoodsMapper
|
||||
extends BaseMapper<
|
||||
WarehouseGoodsEntity,
|
||||
WarehouseGoodsDto,
|
||||
CreateWarehouseGoodsDto,
|
||||
UpdateWarehouseGoodsDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseGoodsRepository extends BaseRepository<WarehouseGoodsEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseGoods.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.warehouseGoods.dto.CreateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.UpdateWarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
import cn.lihongjie.coal.warehouseGoods.mapper.WarehouseGoodsMapper;
|
||||
import cn.lihongjie.coal.warehouseGoods.repository.WarehouseGoodsRepository;
|
||||
|
||||
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 WarehouseGoodsService
|
||||
extends BaseService<WarehouseGoodsEntity, WarehouseGoodsRepository> {
|
||||
@Autowired private WarehouseGoodsRepository repository;
|
||||
|
||||
@Autowired private WarehouseGoodsMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseGoodsDto create(CreateWarehouseGoodsDto request) {
|
||||
WarehouseGoodsEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseGoodsDto update(UpdateWarehouseGoodsDto request) {
|
||||
WarehouseGoodsEntity 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 WarehouseGoodsDto getById(String id) {
|
||||
WarehouseGoodsEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseGoodsDto> list(CommonQuery query) {
|
||||
Page<WarehouseGoodsEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.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.warehouseGoodsBrand.dto.CreateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.UpdateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.WarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.service.WarehouseGoodsBrandService;
|
||||
|
||||
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("/warehouseGoodsBrand")
|
||||
@SysLog(module = "仓库商品品牌管理")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseGoodsBrandController {
|
||||
@Autowired private WarehouseGoodsBrandService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseGoodsBrandDto create(@RequestBody CreateWarehouseGoodsBrandDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseGoodsBrandDto update(@RequestBody UpdateWarehouseGoodsBrandDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseGoodsBrandDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseGoodsBrandDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseGoodsBrandDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseGoodsBrandDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseGoodsBrandDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseGoodsBrandEntity extends OrgCommonEntity {}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.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.warehouseGoodsBrand.dto.CreateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.UpdateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.WarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.entity.WarehouseGoodsBrandEntity;
|
||||
|
||||
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 WarehouseGoodsBrandMapper
|
||||
extends BaseMapper<
|
||||
WarehouseGoodsBrandEntity,
|
||||
WarehouseGoodsBrandDto,
|
||||
CreateWarehouseGoodsBrandDto,
|
||||
UpdateWarehouseGoodsBrandDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.entity.WarehouseGoodsBrandEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseGoodsBrandRepository extends BaseRepository<WarehouseGoodsBrandEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsBrand.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.warehouseGoodsBrand.dto.CreateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.UpdateWarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.dto.WarehouseGoodsBrandDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.entity.WarehouseGoodsBrandEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.mapper.WarehouseGoodsBrandMapper;
|
||||
import cn.lihongjie.coal.warehouseGoodsBrand.repository.WarehouseGoodsBrandRepository;
|
||||
|
||||
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 WarehouseGoodsBrandService
|
||||
extends BaseService<WarehouseGoodsBrandEntity, WarehouseGoodsBrandRepository> {
|
||||
@Autowired private WarehouseGoodsBrandRepository repository;
|
||||
|
||||
@Autowired private WarehouseGoodsBrandMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseGoodsBrandDto create(CreateWarehouseGoodsBrandDto request) {
|
||||
WarehouseGoodsBrandEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseGoodsBrandDto update(UpdateWarehouseGoodsBrandDto request) {
|
||||
WarehouseGoodsBrandEntity 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 WarehouseGoodsBrandDto getById(String id) {
|
||||
WarehouseGoodsBrandEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseGoodsBrandDto> list(CommonQuery query) {
|
||||
Page<WarehouseGoodsBrandEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.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.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.service.WarehouseGoodsCategoryService;
|
||||
|
||||
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("/warehouseGoodsCategory")
|
||||
@SysLog(module = "仓库商品类目管理")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseGoodsCategoryController {
|
||||
@Autowired private WarehouseGoodsCategoryService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseGoodsCategoryDto create(@RequestBody CreateWarehouseGoodsCategoryDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseGoodsCategoryDto update(@RequestBody UpdateWarehouseGoodsCategoryDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseGoodsCategoryDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseGoodsCategoryDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseGoodsCategoryDto extends OrgCommonDto {
|
||||
@ManyToOne
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseGoodsCategoryDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseGoodsCategoryDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseGoodsCategoryEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
private List<WarehouseGoodsCategoryEntity> children;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsCategoryEntity parent;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.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.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.entity.WarehouseGoodsCategoryEntity;
|
||||
|
||||
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 WarehouseGoodsCategoryMapper
|
||||
extends BaseMapper<
|
||||
WarehouseGoodsCategoryEntity,
|
||||
WarehouseGoodsCategoryDto,
|
||||
CreateWarehouseGoodsCategoryDto,
|
||||
UpdateWarehouseGoodsCategoryDto> {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.entity.WarehouseGoodsCategoryEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseGoodsCategoryRepository
|
||||
extends BaseRepository<WarehouseGoodsCategoryEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.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.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.entity.WarehouseGoodsCategoryEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.mapper.WarehouseGoodsCategoryMapper;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.repository.WarehouseGoodsCategoryRepository;
|
||||
|
||||
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 WarehouseGoodsCategoryService
|
||||
extends BaseService<WarehouseGoodsCategoryEntity, WarehouseGoodsCategoryRepository> {
|
||||
@Autowired private WarehouseGoodsCategoryRepository repository;
|
||||
|
||||
@Autowired private WarehouseGoodsCategoryMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseGoodsCategoryDto create(CreateWarehouseGoodsCategoryDto request) {
|
||||
WarehouseGoodsCategoryEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseGoodsCategoryDto update(UpdateWarehouseGoodsCategoryDto request) {
|
||||
WarehouseGoodsCategoryEntity 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 WarehouseGoodsCategoryDto getById(String id) {
|
||||
WarehouseGoodsCategoryEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseGoodsCategoryDto> list(CommonQuery query) {
|
||||
Page<WarehouseGoodsCategoryEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.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.warehouseGoodsUnit.dto.CreateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.UpdateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.WarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.service.WarehouseGoodsUnitService;
|
||||
|
||||
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("/warehouseGoodsUnit")
|
||||
@SysLog(module = "仓库商品单位")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseGoodsUnitController {
|
||||
@Autowired private WarehouseGoodsUnitService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseGoodsUnitDto create(@RequestBody CreateWarehouseGoodsUnitDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseGoodsUnitDto update(@RequestBody UpdateWarehouseGoodsUnitDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseGoodsUnitDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseGoodsUnitDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseGoodsUnitDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseGoodsUnitDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseGoodsUnitDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseGoodsUnitEntity extends OrgCommonEntity {}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.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.warehouseGoodsUnit.dto.CreateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.UpdateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.WarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.entity.WarehouseGoodsUnitEntity;
|
||||
|
||||
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 WarehouseGoodsUnitMapper
|
||||
extends BaseMapper<
|
||||
WarehouseGoodsUnitEntity,
|
||||
WarehouseGoodsUnitDto,
|
||||
CreateWarehouseGoodsUnitDto,
|
||||
UpdateWarehouseGoodsUnitDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.entity.WarehouseGoodsUnitEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseGoodsUnitRepository extends BaseRepository<WarehouseGoodsUnitEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsUnit.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.warehouseGoodsUnit.dto.CreateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.UpdateWarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.dto.WarehouseGoodsUnitDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.entity.WarehouseGoodsUnitEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.mapper.WarehouseGoodsUnitMapper;
|
||||
import cn.lihongjie.coal.warehouseGoodsUnit.repository.WarehouseGoodsUnitRepository;
|
||||
|
||||
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 WarehouseGoodsUnitService
|
||||
extends BaseService<WarehouseGoodsUnitEntity, WarehouseGoodsUnitRepository> {
|
||||
@Autowired private WarehouseGoodsUnitRepository repository;
|
||||
|
||||
@Autowired private WarehouseGoodsUnitMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseGoodsUnitDto create(CreateWarehouseGoodsUnitDto request) {
|
||||
WarehouseGoodsUnitEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseGoodsUnitDto update(UpdateWarehouseGoodsUnitDto request) {
|
||||
WarehouseGoodsUnitEntity 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 WarehouseGoodsUnitDto getById(String id) {
|
||||
WarehouseGoodsUnitEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseGoodsUnitDto> list(CommonQuery query) {
|
||||
Page<WarehouseGoodsUnitEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.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.warehouseReceipt.dto.CreateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.UpdateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.WarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.service.WarehouseReceiptService;
|
||||
|
||||
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("/warehouseReceipt")
|
||||
@SysLog(module = "仓库单据管理")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseReceiptController {
|
||||
@Autowired private WarehouseReceiptService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseReceiptDto create(@RequestBody CreateWarehouseReceiptDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseReceiptDto update(@RequestBody UpdateWarehouseReceiptDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseReceiptDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseReceiptDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.CreateWarehouseReceiptDetailDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseReceiptDto extends OrgCommonDto {
|
||||
|
||||
@Comment("单据类型")
|
||||
private String receiptType;
|
||||
|
||||
|
||||
|
||||
@Comment("单据编号")
|
||||
private String receiptNo;
|
||||
|
||||
@Comment("事由")
|
||||
private String reason;
|
||||
|
||||
@Comment("是由说明")
|
||||
private String reasonDesc;
|
||||
|
||||
@ManyToOne
|
||||
private String warehouse;
|
||||
|
||||
@Comment("单据日期")
|
||||
private LocalDate receiptDate;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private List<CreateWarehouseReceiptDetailDto> detail;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.CreateWarehouseReceiptDetailDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseReceiptDto extends OrgCommonDto {
|
||||
|
||||
@Comment("单据类型")
|
||||
private String receiptType;
|
||||
|
||||
|
||||
|
||||
@Comment("单据编号")
|
||||
private String receiptNo;
|
||||
|
||||
@Comment("事由")
|
||||
private String reason;
|
||||
|
||||
@Comment("是由说明")
|
||||
private String reasonDesc;
|
||||
|
||||
@ManyToOne
|
||||
private String warehouse;
|
||||
|
||||
@Comment("单据日期")
|
||||
private LocalDate receiptDate;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private List<CreateWarehouseReceiptDetailDto> detail;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.warehouse.dto.WarehouseDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.WarehouseReceiptDetailDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WarehouseReceiptDto 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 receiptNo;
|
||||
|
||||
@Comment("事由")
|
||||
private String reason;
|
||||
|
||||
@Comment("是由说明")
|
||||
private String reasonDesc;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseDto warehouse;
|
||||
|
||||
@Comment("单据日期")
|
||||
private LocalDate receiptDate;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private List<WarehouseReceiptDetailDto> detail;
|
||||
|
||||
|
||||
@Formula("(select sum(d.number * d.price) from t_warehouse_receipt_detail d where d.receipt_id = id)")
|
||||
private Double amount;
|
||||
|
||||
|
||||
@Formula("(select sum(d.number) from t_warehouse_receipt_detail d where d.receipt_id = id)")
|
||||
private Double number;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.warehouse.entity.WarehouseEntity;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.entity.WarehouseReceiptDetailEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseReceiptEntity 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 receiptNo;
|
||||
|
||||
@Comment("事由")
|
||||
private String reason;
|
||||
|
||||
@Comment("是由说明")
|
||||
private String reasonDesc;
|
||||
|
||||
@ManyToOne private WarehouseEntity warehouse;
|
||||
|
||||
@Comment("单据日期")
|
||||
private LocalDate receiptDate;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private List<WarehouseReceiptDetailEntity> detail;
|
||||
|
||||
|
||||
@Formula("(select sum(d.number * d.price) from t_warehouse_receipt_detail d where d.receipt_id = id)")
|
||||
private Double amount;
|
||||
|
||||
|
||||
@Formula("(select sum(d.number) from t_warehouse_receipt_detail d where d.receipt_id = id)")
|
||||
private Double number;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.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.warehouseReceipt.dto.CreateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.UpdateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.WarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity;
|
||||
|
||||
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 WarehouseReceiptMapper
|
||||
extends BaseMapper<
|
||||
WarehouseReceiptEntity,
|
||||
WarehouseReceiptDto,
|
||||
CreateWarehouseReceiptDto,
|
||||
UpdateWarehouseReceiptDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseReceiptRepository extends BaseRepository<WarehouseReceiptEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseReceipt.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.warehouseReceipt.dto.CreateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.UpdateWarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.WarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity;
|
||||
import cn.lihongjie.coal.warehouseReceipt.mapper.WarehouseReceiptMapper;
|
||||
import cn.lihongjie.coal.warehouseReceipt.repository.WarehouseReceiptRepository;
|
||||
|
||||
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 WarehouseReceiptService
|
||||
extends BaseService<WarehouseReceiptEntity, WarehouseReceiptRepository> {
|
||||
@Autowired private WarehouseReceiptRepository repository;
|
||||
|
||||
@Autowired private WarehouseReceiptMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseReceiptDto create(CreateWarehouseReceiptDto request) {
|
||||
WarehouseReceiptEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseReceiptDto update(UpdateWarehouseReceiptDto request) {
|
||||
WarehouseReceiptEntity 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 WarehouseReceiptDto getById(String id) {
|
||||
WarehouseReceiptEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseReceiptDto> list(CommonQuery query) {
|
||||
Page<WarehouseReceiptEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.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.warehouseReceiptDetail.dto.CreateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.UpdateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.WarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.service.WarehouseReceiptDetailService;
|
||||
|
||||
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("/warehouseReceiptDetail")
|
||||
@SysLog(module = "仓库单据明细")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WarehouseReceiptDetailController {
|
||||
@Autowired private WarehouseReceiptDetailService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WarehouseReceiptDetailDto create(@RequestBody CreateWarehouseReceiptDetailDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WarehouseReceiptDetailDto update(@RequestBody UpdateWarehouseReceiptDetailDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WarehouseReceiptDetailDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WarehouseReceiptDetailDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CreateWarehouseReceiptDetailDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private String goods;
|
||||
|
||||
@ManyToOne
|
||||
private String shelve;
|
||||
|
||||
@ManyToOne
|
||||
private String receipt;
|
||||
|
||||
@Comment("数量")
|
||||
private Double number;
|
||||
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateWarehouseReceiptDetailDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private String goods;
|
||||
|
||||
@ManyToOne
|
||||
private String shelve;
|
||||
|
||||
@ManyToOne
|
||||
private String receipt;
|
||||
|
||||
@Comment("数量")
|
||||
private Double number;
|
||||
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.dto.WarehouseGoodsDto;
|
||||
import cn.lihongjie.coal.warehouseReceipt.dto.WarehouseReceiptDto;
|
||||
import cn.lihongjie.coal.warehouseShelve.dto.WarehouseShelveDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
public class WarehouseReceiptDetailDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsDto goods;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseShelveDto shelve;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseReceiptDto receipt;
|
||||
|
||||
@Comment("数量")
|
||||
private Double number;
|
||||
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
|
||||
@Formula("(number * price)")
|
||||
private Double amount;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
import cn.lihongjie.coal.warehouseReceipt.entity.WarehouseReceiptEntity;
|
||||
import cn.lihongjie.coal.warehouseShelve.entity.WarehouseShelveEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WarehouseReceiptDetailEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseGoodsEntity goods;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseShelveEntity shelve;
|
||||
|
||||
@ManyToOne
|
||||
private WarehouseReceiptEntity receipt;
|
||||
|
||||
@Comment("数量")
|
||||
private Double number;
|
||||
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
|
||||
@Formula("(number * price)")
|
||||
private Double amount;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.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.warehouseReceiptDetail.dto.CreateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.UpdateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.WarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.entity.WarehouseReceiptDetailEntity;
|
||||
|
||||
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 WarehouseReceiptDetailMapper
|
||||
extends BaseMapper<
|
||||
WarehouseReceiptDetailEntity,
|
||||
WarehouseReceiptDetailDto,
|
||||
CreateWarehouseReceiptDetailDto,
|
||||
UpdateWarehouseReceiptDetailDto> {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.entity.WarehouseReceiptDetailEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseReceiptDetailRepository
|
||||
extends BaseRepository<WarehouseReceiptDetailEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.warehouseReceiptDetail.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.warehouseReceiptDetail.dto.CreateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.UpdateWarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.dto.WarehouseReceiptDetailDto;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.entity.WarehouseReceiptDetailEntity;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.mapper.WarehouseReceiptDetailMapper;
|
||||
import cn.lihongjie.coal.warehouseReceiptDetail.repository.WarehouseReceiptDetailRepository;
|
||||
|
||||
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 WarehouseReceiptDetailService
|
||||
extends BaseService<WarehouseReceiptDetailEntity, WarehouseReceiptDetailRepository> {
|
||||
@Autowired private WarehouseReceiptDetailRepository repository;
|
||||
|
||||
@Autowired private WarehouseReceiptDetailMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public WarehouseReceiptDetailDto create(CreateWarehouseReceiptDetailDto request) {
|
||||
WarehouseReceiptDetailEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WarehouseReceiptDetailDto update(UpdateWarehouseReceiptDetailDto request) {
|
||||
WarehouseReceiptDetailEntity 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 WarehouseReceiptDetailDto getById(String id) {
|
||||
WarehouseReceiptDetailEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WarehouseReceiptDetailDto> list(CommonQuery query) {
|
||||
Page<WarehouseReceiptDetailEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -1945,6 +1945,22 @@
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"code": "warehouse.receiptType",
|
||||
"name": "仓库单据类型",
|
||||
"item": [
|
||||
{
|
||||
"code": "0",
|
||||
"name": "入库单"
|
||||
},
|
||||
{
|
||||
"code": "1",
|
||||
"name": "出库单"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "coalBlend.coalType",
|
||||
"name": "配煤-煤类型",
|
||||
|
||||
Reference in New Issue
Block a user