mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
数据字典实体
This commit is contained in:
@@ -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<DictionaryRepository, DictionaryService, DictionaryEntity> {
|
||||
}
|
||||
@@ -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<DictionaryEntity> {
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import java.time.LocalDate;
|
||||
@Data
|
||||
public class CoalWashingDailyAnalysisEntity extends BaseEntity {
|
||||
|
||||
@Comment("显示名称")
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
@Comment("日期")
|
||||
|
||||
27
src/main/java/cn/lihongjie/coal/entity/CommonEntity.java
Normal file
27
src/main/java/cn/lihongjie/coal/entity/CommonEntity.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
24
src/main/java/cn/lihongjie/coal/entity/DictionaryEntity.java
Normal file
24
src/main/java/cn/lihongjie/coal/entity/DictionaryEntity.java
Normal file
@@ -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<DictionaryItemEntity> item;
|
||||
}
|
||||
@@ -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<DictionaryEntity> children;
|
||||
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JsonBackReference
|
||||
@JoinColumn(name = "parent_id",foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
|
||||
private DictionaryItemEntity parent;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<DictionaryEntity, DictionaryRepository> {
|
||||
}
|
||||
Reference in New Issue
Block a user