This commit is contained in:
2023-07-25 21:00:10 +08:00
parent 40f04fdcc3
commit 1941174dd1
7 changed files with 405 additions and 0 deletions

19
pom.xml
View File

@@ -48,6 +48,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -65,6 +70,13 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
@@ -110,6 +122,13 @@
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency>
<groupId>org.apache.commons</groupId>

View File

@@ -0,0 +1,8 @@
package cn.lihongjie.coal.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
public interface BaseDao<T> extends JpaRepository<T, String> {
}

View File

@@ -0,0 +1,6 @@
package cn.lihongjie.coal.dao;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysis;
public interface CoalWashingDailyAnalysisDao extends BaseDao<CoalWashingDailyAnalysis>{
}

View File

@@ -0,0 +1,55 @@
package cn.lihongjie.coal.dto;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import lombok.Data;
import org.springframework.data.jpa.domain.Specification;
import java.util.List;
@Data
public class CommonQuery {
private List<QueryItem> items;
private Integer pageNo;
private Integer pageSize;
@Data
public static class QueryItem {
private String key;
private String opt;
private String value;
private String group = "default";
}
public Specification specification(){
return new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) {
return criteriaBuilder.or();
}
};
}
}

View File

@@ -0,0 +1,52 @@
package cn.lihongjie.coal.entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
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.springframework.data.annotation.CreatedDate;
import java.time.LocalDateTime;
@MappedSuperclass
@Getter
@Setter
public class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private String id;
private String createUserId;
@Formula("(select '')")
private String createUserName;
@CreationTimestamp(source = SourceType.VM)
private LocalDateTime createTime;
private String updateUserId;
@Formula("(select '')")
private String updateUserName;
@UpdateTimestamp(source = SourceType.VM)
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,212 @@
package cn.lihongjie.coal.entity;
import jakarta.persistence.Entity;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.time.LocalDate;
@Entity
@Data
public class CoalWashingDailyAnalysis extends BaseEntity {
@Comment("显示名称")
private String name;
@Comment("日期")
private LocalDate date;
@Comment("成分0 比例")
private Double c0p0;
@Comment("成分0 灰")
private Double c0p1;
@Comment("成分0 硫")
private Double c0p2;
@Comment("成分1 比例")
private Double c1p0;
@Comment("成分1 灰")
private Double c1p1;
@Comment("成分1 硫")
private Double c1p2;
@Comment("成分2 比例")
private Double c2p0;
@Comment("成分2 灰")
private Double c2p1;
@Comment("成分2 硫")
private Double c2p2;
@Comment("成分3 比例")
private Double c3p0;
@Comment("成分3 灰")
private Double c3p1;
@Comment("成分3 硫")
private Double c3p2;
@Comment("成分4 比例")
private Double c4p0;
@Comment("成分4 灰")
private Double c4p1;
@Comment("成分4 硫")
private Double c4p2;
@Comment("成分5 比例")
private Double c5p0;
@Comment("成分5 灰")
private Double c5p1;
@Comment("成分5 硫")
private Double c5p2;
@Comment("成分6 比例")
private Double c6p0;
@Comment("成分6 灰")
private Double c6p1;
@Comment("成分6 硫")
private Double c6p2;
@Comment("成分7 比例")
private Double c7p0;
@Comment("成分7 灰")
private Double c7p1;
@Comment("成分7 硫")
private Double c7p2;
@Comment("成分8 比例")
private Double c8p0;
@Comment("成分8 灰")
private Double c8p1;
@Comment("成分8 硫")
private Double c8p2;
@Comment("成分9 比例")
private Double c9p0;
@Comment("成分9 灰")
private Double c9p1;
@Comment("成分9 硫")
private Double c9p2;
@Comment("大堆 灰")
private Double ddp1;
@Comment("大堆 硫")
private Double ddp2;
@Comment("大堆 挥发")
private Double ddp3;
@Comment("大堆 粘结")
private Double ddp4;
@Comment("大堆 备用")
private Double ddp5;
}

View File

@@ -0,0 +1,53 @@
package cn.lihongjie.coal.service;
import cn.lihongjie.coal.dao.BaseDao;
import cn.lihongjie.coal.entity.BaseEntity;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class BaseService<Dao, Entity extends BaseEntity> {
@Autowired
BaseDao<Entity> dao;
public String create(Entity entity){
dao.save(entity);
return entity.getId();
}
public void update(Entity entity){
dao.save(entity);
}
public void deleteById(String id){
dao.deleteById(id);
}
public void deleteAllById(Iterable<String> id){
dao.deleteAllById(id);
}
public Object list(){
return null;
}
}