diff --git a/src/main/java/cn/lihongjie/coal/controller/DictionaryController.java b/src/main/java/cn/lihongjie/coal/controller/DictionaryController.java new file mode 100644 index 00000000..d4aafa23 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/controller/DictionaryController.java @@ -0,0 +1,12 @@ +package cn.lihongjie.coal.controller; + +import cn.lihongjie.coal.dao.DictionaryRepository; +import cn.lihongjie.coal.entity.DictionaryEntity; +import cn.lihongjie.coal.service.DictionaryService; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/coalWashingDailyAnalysis") +public class DictionaryController extends BaseController { +} diff --git a/src/main/java/cn/lihongjie/coal/dao/DictionaryRepository.java b/src/main/java/cn/lihongjie/coal/dao/DictionaryRepository.java new file mode 100644 index 00000000..5fb31925 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/dao/DictionaryRepository.java @@ -0,0 +1,8 @@ +package cn.lihongjie.coal.dao; + +import org.springframework.stereotype.Repository; +import cn.lihongjie.coal.entity.DictionaryEntity; + +@Repository +public interface DictionaryRepository extends BaseRepository { +} \ No newline at end of file diff --git a/src/main/java/cn/lihongjie/coal/entity/BaseEntity.java b/src/main/java/cn/lihongjie/coal/entity/BaseEntity.java index dc55cacc..6227ba6d 100644 --- a/src/main/java/cn/lihongjie/coal/entity/BaseEntity.java +++ b/src/main/java/cn/lihongjie/coal/entity/BaseEntity.java @@ -7,10 +7,7 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; -import org.hibernate.annotations.Formula; -import org.hibernate.annotations.SourceType; -import org.hibernate.annotations.UpdateTimestamp; +import org.hibernate.annotations.*; import org.springframework.data.annotation.CreatedDate; import java.time.LocalDateTime; @@ -26,24 +23,27 @@ public class BaseEntity { + + + @Comment("创建用户ID") private String createUserId; @Formula("(select '')") private String createUserName; - + @Comment("创建时间") @CreationTimestamp(source = SourceType.VM) private LocalDateTime createTime; - + @Comment("更新用户ID") private String updateUserId; @Formula("(select '')") private String updateUserName; - + @Comment("更新时间") @UpdateTimestamp(source = SourceType.VM) private LocalDateTime updateTime; diff --git a/src/main/java/cn/lihongjie/coal/entity/CoalWashingDailyAnalysisEntity.java b/src/main/java/cn/lihongjie/coal/entity/CoalWashingDailyAnalysisEntity.java index f7f20967..9f8d15bc 100644 --- a/src/main/java/cn/lihongjie/coal/entity/CoalWashingDailyAnalysisEntity.java +++ b/src/main/java/cn/lihongjie/coal/entity/CoalWashingDailyAnalysisEntity.java @@ -10,8 +10,7 @@ import java.time.LocalDate; @Data public class CoalWashingDailyAnalysisEntity extends BaseEntity { - @Comment("显示名称") - private String name; + @Comment("日期") diff --git a/src/main/java/cn/lihongjie/coal/entity/CommonEntity.java b/src/main/java/cn/lihongjie/coal/entity/CommonEntity.java new file mode 100644 index 00000000..ff6237e8 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/entity/CommonEntity.java @@ -0,0 +1,27 @@ +package cn.lihongjie.coal.entity; + +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.Comment; + +@MappedSuperclass +@Getter +@Setter +public class CommonEntity extends BaseEntity { + + @Comment("名称") + private String name; + + @Comment("编码") + private String code; + + + @Comment("排序键") + private Integer sortKey; + + + @Comment("常用状态 0 禁用 1 启用") + private Integer status; + +} diff --git a/src/main/java/cn/lihongjie/coal/entity/DictionaryEntity.java b/src/main/java/cn/lihongjie/coal/entity/DictionaryEntity.java new file mode 100644 index 00000000..08eec1c9 --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/entity/DictionaryEntity.java @@ -0,0 +1,24 @@ +package cn.lihongjie.coal.entity; + +import com.fasterxml.jackson.annotation.JsonManagedReference; +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.JoinFormula; + +import java.util.List; + +@Entity +@Comment("数据字典主表") +@Getter +@Setter +public class DictionaryEntity extends CommonEntity { + + + + @OneToMany(mappedBy = "dictionary") + @JsonManagedReference + private List item; +} diff --git a/src/main/java/cn/lihongjie/coal/entity/DictionaryItemEntity.java b/src/main/java/cn/lihongjie/coal/entity/DictionaryItemEntity.java new file mode 100644 index 00000000..ee0fc24e --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/entity/DictionaryItemEntity.java @@ -0,0 +1,37 @@ +package cn.lihongjie.coal.entity; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.Comment; + +import java.util.List; + +@Entity +@Getter +@Setter +@Comment("数据字典数据项") +public class DictionaryItemEntity extends CommonEntity { + + + @ManyToOne + @JsonBackReference + private DictionaryEntity dictionary; + + @OneToMany(mappedBy = "parent") + @JsonManagedReference + private List children; + + + + @ManyToOne + @JsonBackReference + @JoinColumn(name = "parent_id",foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) + private DictionaryItemEntity parent; + + + + +} diff --git a/src/main/java/cn/lihongjie/coal/service/DictionaryService.java b/src/main/java/cn/lihongjie/coal/service/DictionaryService.java new file mode 100644 index 00000000..a8ffb1ae --- /dev/null +++ b/src/main/java/cn/lihongjie/coal/service/DictionaryService.java @@ -0,0 +1,11 @@ +package cn.lihongjie.coal.service; + +import cn.lihongjie.coal.dao.DictionaryRepository; +import cn.lihongjie.coal.entity.DictionaryEntity; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class DictionaryService extends BaseService { +}