temp
This commit is contained in:
29
urbanLifelineServ/common/common-core/pom.xml
Normal file
29
urbanLifelineServ/common/common-core/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.xyzh.common</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${urban-lifeline.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.common</groupId>
|
||||
<artifactId>common-dto</artifactId>
|
||||
<version>${urban-lifeline.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.xyzh.common.core.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @description Constants.java文件描述 常量类
|
||||
* @filename Constants.java
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* @description 令牌前缀
|
||||
* @filename Constants.java
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* @description JSON_WHITELIST_STR JSON白名单
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
public static final String JSON_WHITELIST_STR = "org.xyzh";
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.xyzh.common.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.xyzh.common.dto.sys.TbSysUserDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserInfoDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysDeptDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysPermissionDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysViewDTO;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 登录域
|
||||
* @filename 登录域
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
@Data
|
||||
public class LoginDomain implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TbSysUserDTO user;
|
||||
|
||||
private TbSysUserInfoDTO userInfo;
|
||||
|
||||
private List<TbSysUserRoleDTO> userRoles;
|
||||
|
||||
private List<TbSysDeptDTO> userDepts;
|
||||
|
||||
private List<TbSysPermissionDTO> userPermissions;
|
||||
|
||||
private List<TbSysViewDTO> userViews;
|
||||
|
||||
private String token;
|
||||
|
||||
private Date tokenExpireTime;
|
||||
|
||||
private String loginTime;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
private String loginType;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.xyzh.common.core.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 登录参数
|
||||
* @filename 登录参数
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
@Data
|
||||
public class LoginParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 邮箱
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 手机号
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 微信ID
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String wechatId;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String captchaType;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String captcha;
|
||||
/**
|
||||
* 验证码ID
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String captchaId;
|
||||
/**
|
||||
* 登录类型
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private String loginType;
|
||||
/**
|
||||
* 是否记住我
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private Boolean rememberMe;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
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 lombok.Data;
|
||||
|
||||
/**
|
||||
* @description 结果域 通用返回结果
|
||||
* @filename 结果域
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
@Data
|
||||
public class ResultDomain<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer code;
|
||||
private boolean success;
|
||||
private String message;
|
||||
private T data;
|
||||
private List<T> dataList;
|
||||
private PageDomain<T> pageDomain;
|
||||
|
||||
public ResultDomain(){
|
||||
}
|
||||
|
||||
public ResultDomain(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
}
|
||||
|
||||
public ResultDomain(int code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultDomain(int code, String message, List<T> dataList) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
this.dataList = dataList;
|
||||
}
|
||||
|
||||
public ResultDomain(int code, String message, PageDomain<T> pageDomain) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
this.pageDomain = pageDomain;
|
||||
}
|
||||
|
||||
// 静态工厂方法 - 推荐使用(简洁、清晰)
|
||||
public static <R> ResultDomain<R> success(String message) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = true;
|
||||
result.message = message;
|
||||
result.code = HttpStatus.OK.value();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <R> ResultDomain<R> success(String message, R data) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = true;
|
||||
result.message = message;
|
||||
result.data = data;
|
||||
result.code = HttpStatus.OK.value();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <R> ResultDomain<R> success(String message, List<R> dataList) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = true;
|
||||
result.message = message;
|
||||
result.dataList = dataList;
|
||||
result.code = HttpStatus.OK.value();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <R> ResultDomain<R> success(String message, PageDomain<R> pageDomain) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = true;
|
||||
result.message = message;
|
||||
result.pageDomain = pageDomain;
|
||||
result.code = HttpStatus.OK.value();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <R> ResultDomain<R> failure(String message) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = false;
|
||||
result.message = message;
|
||||
result.code = HttpStatus.INTERNAL_SERVER_ERROR.value();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <R> ResultDomain<R> failure(int code, String message) {
|
||||
ResultDomain<R> result = new ResultDomain<>();
|
||||
result.success = false;
|
||||
result.message = message;
|
||||
result.code = code;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.xyzh.common.core.enums;
|
||||
|
||||
/**
|
||||
* @description 验证码类型
|
||||
* @filename CaptchaType.java
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-03
|
||||
*/
|
||||
public enum CaptchaType {
|
||||
|
||||
EMAIL(1, "EMAIL", "邮箱验证码"),
|
||||
SMS(2, "SMS", "短信验证码"),
|
||||
IMAGE(3, "IMAGE", "图形验证码");
|
||||
|
||||
/**
|
||||
* 验证码类型编码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 验证码类型名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 验证码类型描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
private CaptchaType(int code, String name, String description) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据名称获取验证码类型
|
||||
* @param name 验证码类型名称
|
||||
* @return 验证码类型
|
||||
* @author yslg
|
||||
* @since 2025-11-03
|
||||
*/
|
||||
public static CaptchaType fromName(String name) {
|
||||
for (CaptchaType type : CaptchaType.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.xyzh.common.core.page;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageDomain<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 分页参数
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private PageParam pageParam;
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private List<T> dataList;
|
||||
|
||||
public PageDomain(PageParam pageParam, List<T> dataList) {
|
||||
if (pageParam == null) {
|
||||
throw new IllegalArgumentException("分页参数不能为空");
|
||||
}
|
||||
|
||||
this.pageParam = pageParam;
|
||||
this.dataList = dataList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.xyzh.common.core.page;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description 分页参数
|
||||
* @filename 分页参数
|
||||
* @author yslg
|
||||
* @copyright yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PageParam implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private int page;
|
||||
/**
|
||||
* 每页条数
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
private int total;
|
||||
/**
|
||||
* 总页数
|
||||
* @author yslg
|
||||
* @since 2025-11-02
|
||||
*/
|
||||
private int totalPages;
|
||||
|
||||
private int offset;
|
||||
|
||||
public PageParam(int page, int pageSize) {
|
||||
if (page <= 0) {
|
||||
throw new IllegalArgumentException("页码必须大于0");
|
||||
}
|
||||
if (pageSize <= 0) {
|
||||
throw new IllegalArgumentException("每页条数必须大于0");
|
||||
}
|
||||
this.page = page;
|
||||
this.pageSize = pageSize;
|
||||
this.offset = (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
public void setPage(int page){
|
||||
if (page <= 0) {
|
||||
throw new IllegalArgumentException("页码必须大于0");
|
||||
}
|
||||
this.page = page;
|
||||
if (this.pageSize <= 0) {
|
||||
this.pageSize = 10;
|
||||
}
|
||||
this.offset = (page - 1) * this.pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize){
|
||||
if (pageSize <= 0) {
|
||||
throw new IllegalArgumentException("每页条数必须大于0");
|
||||
}
|
||||
this.pageSize = pageSize;
|
||||
if (this.page <= 0) {
|
||||
this.page = 1;
|
||||
}
|
||||
this.offset = (this.page - 1) * this.pageSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.xyzh.common.core.page;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageRequest<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PageParam pageParam;
|
||||
private T filter;
|
||||
}
|
||||
Reference in New Issue
Block a user