mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
常用实体
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -29,6 +29,8 @@
|
||||
</repository>
|
||||
|
||||
|
||||
|
||||
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
@@ -44,6 +46,12 @@
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>1.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
||||
10
src/main/java/cn/lihongjie/coal/common/JwtUtils.java
Normal file
10
src/main/java/cn/lihongjie/coal/common/JwtUtils.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class JwtUtils {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package cn.lihongjie.coal.controller;
|
||||
import cn.lihongjie.coal.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.dto.IdRequest;
|
||||
import cn.lihongjie.coal.entity.BaseEntity;
|
||||
import cn.lihongjie.coal.entity.base.BaseEntity;
|
||||
import cn.lihongjie.coal.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.lihongjie.coal.controller;
|
||||
|
||||
import cn.lihongjie.coal.dao.OrganizationRepository;
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.service.OrganizationService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/coalWashingDailyAnalysis")
|
||||
public class OrganizationController extends BaseController<OrganizationRepository, OrganizationService, OrganizationEntity> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
|
||||
@Repository
|
||||
public interface OrganizationRepository extends BaseRepository<OrganizationEntity> {
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgCommonEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
@@ -8,7 +9,7 @@ import java.time.LocalDate;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class CoalWashingDailyAnalysisEntity extends BaseEntity {
|
||||
public class CoalWashingDailyAnalysisEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
39
src/main/java/cn/lihongjie/coal/entity/OperationLog.java
Normal file
39
src/main/java/cn/lihongjie/coal/entity/OperationLog.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgBaseEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Comment("操作日志")
|
||||
public class OperationLog extends OrgBaseEntity {
|
||||
|
||||
@Comment("ip")
|
||||
private String ip;
|
||||
@Comment("ip定位")
|
||||
private String ipLocation;
|
||||
|
||||
@Comment("userAgent")
|
||||
private String userAgent;
|
||||
|
||||
|
||||
@Comment("耗时")
|
||||
private Integer timeCost;
|
||||
|
||||
@Comment("URL")
|
||||
private String url;
|
||||
|
||||
|
||||
@Comment("操作状态")
|
||||
@OneToOne
|
||||
private DictionaryItemEntity status;
|
||||
|
||||
@Comment("错误堆栈")
|
||||
private String stacktrace;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
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
|
||||
@Comment("机构")
|
||||
@Getter
|
||||
@Setter
|
||||
public class OrganizationEntity extends CommonEntity {
|
||||
|
||||
|
||||
@OneToMany
|
||||
@JsonManagedReference
|
||||
private List<OrganizationEntity> children;
|
||||
|
||||
@ManyToOne
|
||||
@JsonBackReference
|
||||
@JoinColumn(name = "parent_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
|
||||
private OrganizationEntity parent;
|
||||
|
||||
|
||||
}
|
||||
23
src/main/java/cn/lihongjie/coal/entity/PermissionEntity.java
Normal file
23
src/main/java/cn/lihongjie/coal/entity/PermissionEntity.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Comment("权限")
|
||||
public class PermissionEntity extends CommonEntity {
|
||||
|
||||
|
||||
@ManyToMany(mappedBy = "permissions")
|
||||
@JsonManagedReference
|
||||
private List<ResourceEntity> resources;
|
||||
|
||||
|
||||
}
|
||||
49
src/main/java/cn/lihongjie/coal/entity/ResourceEntity.java
Normal file
49
src/main/java/cn/lihongjie/coal/entity/ResourceEntity.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Comment("资源")
|
||||
public class ResourceEntity extends CommonEntity {
|
||||
|
||||
@ManyToMany
|
||||
@JsonBackReference
|
||||
private List<PermissionEntity> permissions;
|
||||
|
||||
|
||||
@OneToMany
|
||||
@JsonManagedReference
|
||||
private List<ResourceEntity> children;
|
||||
|
||||
@ManyToOne
|
||||
@JsonBackReference
|
||||
@JoinColumn(name = "parent_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
|
||||
private ResourceEntity parent;
|
||||
|
||||
|
||||
@Comment("资源类型")
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
@Comment("资源地址")
|
||||
private String url;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
23
src/main/java/cn/lihongjie/coal/entity/RoleEntity.java
Normal file
23
src/main/java/cn/lihongjie/coal/entity/RoleEntity.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgBaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class RoleEntity extends OrgBaseEntity {
|
||||
|
||||
|
||||
@ManyToMany(mappedBy = "roles")
|
||||
@JsonBackReference
|
||||
private List<UserEntity> users;
|
||||
|
||||
@ManyToMany
|
||||
private List<PermissionEntity> permissions;
|
||||
|
||||
}
|
||||
48
src/main/java/cn/lihongjie/coal/entity/UserEntity.java
Normal file
48
src/main/java/cn/lihongjie/coal/entity/UserEntity.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgCommonEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class UserEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@Comment("用户名")
|
||||
private String username;
|
||||
|
||||
@Comment("密码")
|
||||
private String password;
|
||||
|
||||
|
||||
@Comment("邮箱")
|
||||
private String email;
|
||||
|
||||
|
||||
|
||||
@Comment("手机号")
|
||||
private String phone;
|
||||
|
||||
@ManyToMany
|
||||
@JsonManagedReference
|
||||
private List<RoleEntity> roles;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
package cn.lihongjie.coal.entity.base;
|
||||
|
||||
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
package cn.lihongjie.coal.entity.base;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.BaseEntity;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -17,6 +18,11 @@ public class CommonEntity extends BaseEntity {
|
||||
private String code;
|
||||
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lihongjie.coal.entity.base;
|
||||
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.entity.base.BaseEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
public class OrgBaseEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "organization_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private OrganizationEntity organization;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.lihongjie.coal.entity.base;
|
||||
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.entity.base.CommonEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
public class OrgCommonEntity extends CommonEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "organization_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
@JsonIgnore
|
||||
private OrganizationEntity organization;
|
||||
|
||||
}
|
||||
@@ -3,13 +3,11 @@ package cn.lihongjie.coal.service;
|
||||
import cn.lihongjie.coal.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.dto.IdRequest;
|
||||
import cn.lihongjie.coal.dto.PagedData;
|
||||
import cn.lihongjie.coal.entity.BaseEntity;
|
||||
import cn.lihongjie.coal.entity.base.BaseEntity;
|
||||
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.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
public abstract class BaseService<Entity extends BaseEntity, Repository extends BaseRepository<Entity>> {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.service;
|
||||
|
||||
import cn.lihongjie.coal.dao.OrganizationRepository;
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OrganizationService extends BaseService<OrganizationEntity, OrganizationRepository> {
|
||||
}
|
||||
Reference in New Issue
Block a user