serv init

This commit is contained in:
2025-09-28 14:20:09 +08:00
parent f37a9f4163
commit 6fda9d89f6
57 changed files with 3756 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xyzh</groupId>
<artifactId>common</artifactId>
<version>${school-news.version}</version>
</parent>
<groupId>org.xyzh</groupId>
<artifactId>common-core</artifactId>
<version>${school-news.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.xyzh</groupId>
<artifactId>common-dto</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,19 @@
package org.xyzh.common.core.constant;
/**
* @description Constants.java文件描述
* @filename Constants.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class Constants {
/**
* @description JSON_WHITELIST_STR JSON白名单
* @author yslg
* @since 2025-09-07
*/
public static final String JSON_WHITELIST_STR = "org.xyzh";
}

View File

@@ -0,0 +1,5 @@
package org.xyzh.common.core.domain;
public class LoginDomain {
}

View File

@@ -0,0 +1,42 @@
package org.xyzh.common.core.domain;
/**
* @description LoginParam.java文件描述 登录参数
* @filename LoginParam.java
* @author yslg
* @copyright xyzh
* @since 2025-09-28
*/
public class LoginParam {
/**
* @description 邮箱
* @author yslg
* @since 2025-09-28
*/
private String email;
/**
* @description 密码
* @author yslg
* @since 2025-09-28
*/
private String password;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -0,0 +1,404 @@
package org.xyzh.common.core.domain;
import java.io.Serializable;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.core.page.PageParam;
/**
* @description ResultDomain.java文件描述 统一返回结果实体类
* @filename ResultDomain.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class ResultDomain<T> implements Serializable{
private static final long serialVersionUID = 1L;
/**
* @description 状态码
* @author yslg
* @since 2025-09-07
*/
private int code;
/**
* @description 返回消息
* @author yslg
* @since 2025-09-07
*/
private String message;
/**
* @description 操作是否成功
* @author yslg
* @since 2025-09-07
*/
private boolean success;
/**
* @description 是否登录
* @author yslg
* @since 2025-09-07
*/
private boolean login;
/**
* @description 是否有权限
* @author yslg
* @since 2025-09-07
*/
private boolean auth;
/**
* @description 返回数据
* @author yslg
* @since 2025-09-07
*/
private T data;
/**
* @description 返回数据列表
* @author yslg
* @since 2025-09-07
*/
private List<T> dataList;
/**
* @description 分页参数
* @author yslg
* @since 2025-09-07
*/
private PageParam pageParam;
/**
* @description 分页信息
* @author yslg
* @since 2025-09-07
*/
private PageDomain<T> pageDomain;
public ResultDomain() {
}
public ResultDomain(int code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public ResultDomain(int code, String message, List<T> dataList) {
this.code = code;
this.message = message;
this.dataList = dataList;
}
public ResultDomain(int code, String message, PageDomain<T> pageDomain) {
this.code = code;
this.message = message;
this.pageDomain = pageDomain;
this.pageParam = pageDomain.getPageParam();
this.dataList = pageDomain.getDataList();
}
/**
* @description 获取状态码
* @return int 状态码
* @author yslg
* @since 2025-09-07
*/
public int getCode() {
return code;
}
/**
* @description 设置状态码
* @param code 状态码
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setCode(int code) {
this.code = code;
}
/**
* @description 获取返回消息
* @return String 返回消息
* @author yslg
* @since 2025-09-07
*/
public String getMessage() {
return message;
}
/**
* @description 设置返回消息
* @param message 返回消息
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @description 获取数据
* @return T 数据
* @author yslg
* @since 2025-09-07
*/
public T getData() {
return data;
}
/**
* @description 设置数据
* @param data 数据
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setData(T data) {
this.data = data;
}
/**
* @description 获取数据列表
* @return List<T> 数据列表
* @author yslg
* @since 2025-09-07
*/
public List<T> getDataList() {
return dataList;
}
/**
* @description 设置数据列表
* @param dataList 数据列表
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setDataList(List<T> dataList) {
this.dataList = dataList;
}
/**
* @description 获取分页参数
* @return PageParam 分页参数
* @author yslg
* @since 2025-09-07
*/
public PageParam getPageParam() {
return pageParam;
}
/**
* @description 设置分页参数
* @param pageParam 分页参数
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setPageParam(PageParam pageParam) {
this.pageParam = pageParam;
}
/**
* @description 获取分页信息
* @return PageDomain<T> 分页信息
* @author yslg
* @since 2025-09-07
*/
public PageDomain<T> getPageDomain() {
return pageDomain;
}
/**
* @description 设置分页信息
* @param pageDomain 分页信息
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setPageDomain(PageDomain<T> pageDomain) {
this.pageDomain = pageDomain;
}
/**
* @description 获取成功标志
* @return boolean 成功标志
* @author yslg
* @since 2025-09-07
*/
public boolean isSuccess() {
return success;
}
/**
* @description 设置成功标志
* @param success 成功标志
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setSuccess(boolean success) {
this.success = success;
}
/**
* @description 获取登录标志
* @return boolean 登录标志
* @author yslg
* @since 2025-09-07
*/
public boolean isLogin() {
return login;
}
/**
* @description 设置登录标志
* @param login 登录标志
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setLogin(boolean login) {
this.login = login;
}
/**
* @description 获取权限标志
* @return boolean 权限标志
* @author yslg
* @since 2025-09-07
*/
public boolean isAuth() {
return auth;
}
/**
* @description 设置权限标志
* @param auth 权限标志
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setAuth(boolean auth) {
this.auth = auth;
}
/**
* @description 操作成功
* @param message 返回消息
* @param data 返回数据
* @author yslg
* @since 2025-09-07
*/
public void success(String message, T data) {
this.code = HttpStatus.OK.value();
this.message = message;
this.success = true;
this.auth = true;
this.login = true;
this.data = data;
}
/**
* @description 操作成功
* @param message 返回消息
* @param dataList 返回数据列表
* @author yslg
* @since 2025-09-07
*/
public void success(String message, List<T> dataList) {
this.code = HttpStatus.OK.value();
this.message = message;
this.success = true;
this.auth = true;
this.login = true;
this.dataList = dataList;
}
/**
* @description 操作成功
* @param message 返回消息
* @param pageDomain 返回分页信息
* @author yslg
* @since 2025-09-07
*/
public void success(String message, PageDomain<T> pageDomain) {
this.code = HttpStatus.OK.value();
this.message = message;
this.success = true;
this.auth = true;
this.login = true;
this.pageDomain = pageDomain;
this.pageParam = pageDomain.getPageParam();
this.dataList = pageDomain.getDataList();
}
/**
* @description 操作失败
* @param message 返回消息
* @author yslg
* @since 2025-09-07
*/
public void fail(String message) {
this.code = HttpStatus.BAD_REQUEST.value();
this.message = message;
this.success = false;
this.auth = true;
this.login = true;
this.data = null;
}
/**
* @description 操作失败
* @param code 状态码
* @param message 返回消息
* @author yslg
* @since 2025-09-07
*/
public void fail(int code, String message) {
this.code = code;
this.message = message;
this.success = false;
this.auth = true;
this.login = true;
this.data = null;
}
/**
* @description 未登录
* @param message 返回消息
* @author yslg
* @since 2025-09-07
*/
public void noLogin(String message) {
this.code = HttpStatus.UNAUTHORIZED.value();
this.message = message;
this.success = false;
this.auth = false;
this.login = false;
this.data = null;
}
/**
* @description 无权限
* @param message 返回消息
* @author yslg
* @since 2025-09-07
*/
public void noAuth(String message) {
this.code = HttpStatus.FORBIDDEN.value();
this.message = message;
this.success = false;
this.auth = false;
this.login = true;
this.data = null;
}
}

View File

@@ -0,0 +1,66 @@
package org.xyzh.common.core.entity;
import java.sql.Date;
import java.io.Serializable;
/**
* @description BaseEntity.java文件描述 基础实体类
* @filename BaseEntity.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* @description id 主键
* @author yslg
* @since 2025-09-07
*/
private String id;
/**
* @description 创建时间
* @author yslg
* @since 2025-09-07
*/
private Date createTime;
/**
* @description 更新时间
* @author yslg
* @since 2025-09-07
*/
private Date updateTime;
/**
* @description 删除时间
* @author yslg
* @since 2025-09-07
*/
private Date deleteTime;
/**
* @description 是否删除 0未删除 1已删除
* @author yslg
* @since 2025-09-07
*/
private Integer isDeleted;
/**
* @description 版本号
* @author yslg
* @since 2025-09-07
*/
private Integer version;
/**
* @description 备注
* @author yslg
* @since 2025-09-07
*/
private String remark;
}

View File

@@ -0,0 +1,100 @@
package org.xyzh.common.core.entity;
import java.util.List;
import org.xyzh.common.core.enums.DataStatus;
/**
* @description DataEntity.java文件描述 数据实体类
* @filename DataEntity.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class DataEntity<T> extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* @description 创建人ID
* @author yslg
* @since 2025-09-07
*/
private String creatorID;
/**
* @description 创建人名称
* @author yslg
* @since 2025-09-07
*/
private String creatorName;
/**
* @description 更新人ID
* @author yslg
* @since 2025-09-07
*/
private String updatorID;
/**
* @description 更新人名称
* @author yslg
* @since 2025-09-07
*/
private String updatorName;
/**
* @description 删除人ID
* @author yslg
* @since 2025-09-07
*/
private String deleterID;
/**
* @description 删除人名称
* @author yslg
* @since 2025-09-07
*/
private String deleterName;
/**
* @description 所有者ID
* @author yslg
* @since 2025-09-07
*/
private String ownerID;
/**
* @description 所有者名称
* @author yslg
* @since 2025-09-07
*/
private String ownerName;
/**
* @description 数据状态
* @author yslg
* @since 2025-09-07
*/
private DataStatus dataStatus;
/**
* @description 是否可见
* @author yslg
* @since 2025-09-07
*/
private Boolean visible;
/**
* @description 实体数据
* @author yslg
* @since 2025-09-07
*/
private T data;
/**
* @description 实体数据列表
* @author yslg
* @since 2025-09-07
*/
private List<T> dataList;
}

View File

@@ -0,0 +1,59 @@
package org.xyzh.common.core.enums;
/**
* @description DataStatus枚举类 数据状态枚举类
* @filename DataStatus.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public enum DataStatus {
WAITING("0", "待处理", "数据待处理"),
PROCESSING("1", "处理中", "数据处理中"),
COMPLETED("2", "已完成", "数据已完成"),
FAILED("3", "处理失败", "数据处理失败"),
CANCELLED("4", "已取消", "数据已取消"),
DELETED("5", "已删除", "数据已删除");
private final String code;
private final String name;
private final String description;
DataStatus(String code, String name, String description) {
this.code = code;
this.name = name;
this.description = description;
}
/**
* @description 获取枚举值
* @param
* @return String 枚举值
* @author yslg
* @since 2025-09-07
*/
public String getCode() {
return code;
}
/**
* @description 获取枚举名称
* @return String 枚举名称
* @author yslg
* @since 2025-09-07
*/
public String getName() {
return name;
}
/**
* @description 获取枚举描述
* @return String 枚举描述
* @author yslg
* @since 2025-09-07
*/
public String getDescription() {
return description;
}
}

View File

@@ -0,0 +1,5 @@
package org.xyzh.common.core.enums;
public enum UserStatus {
}

View File

@@ -0,0 +1,84 @@
package org.xyzh.common.core.page;
import java.io.Serializable;
import java.util.List;
/**
* @description PageDomain.java文件描述 分页数据实体类
* @filename PageDomain.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class PageDomain<T> implements Serializable{
private static final long serialVersionUID = 1L;
/**
* @description 分页参数
* @author yslg
* @since 2025-09-07
*/
private PageParam pageParam;
/**
* @description 数据列表
* @author yslg
* @since 2025-09-07
*/
private List<T> dataList;
public PageDomain() {
}
public PageDomain(PageParam pageParam, List<T> dataList) {
this.pageParam = pageParam;
this.dataList = dataList;
}
public PageDomain(int pageNumber, int pageSize, int totalPages, long totalElements, List<T> dataList) {
this.pageParam = new PageParam(pageNumber, pageSize, totalPages, totalElements);
this.dataList = dataList;
}
/**
* @description 设置分页参数
* @param pageParam 分页参数
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setPageParam(PageParam pageParam) {
this.pageParam = pageParam;
}
/**
* @description 获取分页参数
* @return PageParam 分页参数
* @author yslg
* @since 2025-09-07
*/
public PageParam getPageParam() {
return pageParam;
}
/**
* @description 设置数据列表
* @param dataList 数据列表
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setDataList(List<T> dataList) {
this.dataList = dataList;
}
/**
* @description 获取数据列表
* @return List<T> 数据列表
* @author yslg
* @since 2025-09-07
*/
public List<T> getDataList() {
return dataList;
}
}

View File

@@ -0,0 +1,151 @@
package org.xyzh.common.core.page;
import java.io.Serializable;
/**
* @description PageParam.java文件描述 分页参数
* @filename PageParam.java
* @author yslg
* @copyright yslg
* @since 2025-09-07
*/
public class PageParam implements Serializable {
private static final long serialVersionUID = 1L;
/**
* @description 当前页码
* @author yslg
* @since 2025-09-07
*/
private int pageNumber;
/**
* @description 每页显示数量
* @author yslg
* @since 2025-09-07
*/
private int pageSize;
/**
* @description 总页数
* @author yslg
* @since 2025-09-07
*/
private int totalPages;
/**
* @description 总记录数
* @author yslg
* @since 2025-09-07
*/
private long totalElements;
public PageParam() {
this.pageNumber = 1;
this.pageSize = 10;
this.totalPages = 0;
this.totalElements = 0;
}
public PageParam(int pageNumber, int pageSize) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
}
public PageParam(int pageNumber, int pageSize, int totalPages, long totalElements) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.totalPages = totalPages;
this.totalElements = totalElements;
}
/**
* @description 设置当前页码
* @param pageNumber 当前页码
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
/**
* @description 获取当前页码
* @return 当前页码
* @author yslg
* @since 2025-09-07
*/
public int getPageNumber() {
return pageNumber;
}
/**
* @description 设置每页显示数量
* @param pageSize 每页显示数量
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* @description 获取每页显示数量
* @return 每页显示数量
* @author yslg
* @since 2025-09-07
*/
public int getPageSize() {
return pageSize;
}
/**
* @description 设置总页数
* @param totalPages 总页数
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
/**
* @description 获取总页数
* @return 总页数
* @author yslg
* @since 2025-09-07
*/
public int getTotalPages() {
return totalPages;
}
/**
* @description 设置总记录数
* @param totalElements 总记录数
* @return void
* @author yslg
* @since 2025-09-07
*/
public void setTotalElements(long totalElements) {
this.totalElements = totalElements;
if (this.pageSize > 0) {
this.totalPages = (int) ((totalElements + pageSize - 1) / pageSize);
} else {
this.totalPages = 0;
}
}
/**
* @description 获取总记录数
* @return 总记录数
* @author yslg
* @since 2025-09-07
*/
public long getTotalElements() {
return totalElements;
}
}