refactor(backend): 重命名后端项目为 gym-manage-api,修改包名为 cn.novalon.gym.manage
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
package cn.novalon.gym.manage.db.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "cn.novalon.gym.manage.db.repository")
|
||||
public class RepositoryScanConfig {
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.audit.domain.AuditLog;
|
||||
import cn.novalon.gym.manage.db.entity.AuditLogEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 审计日志实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-04-08
|
||||
*/
|
||||
@Component
|
||||
public class AuditLogConverter {
|
||||
|
||||
public AuditLog toDomain(AuditLogEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
AuditLog domain = new AuditLog();
|
||||
domain.setId(entity.getId());
|
||||
domain.setEntityType(entity.getEntityType());
|
||||
domain.setEntityId(entity.getEntityId());
|
||||
domain.setOperationType(entity.getOperationType());
|
||||
domain.setOperator(entity.getOperator());
|
||||
domain.setOperationTime(entity.getOperationTime());
|
||||
domain.setBeforeData(entity.getBeforeData());
|
||||
domain.setAfterData(entity.getAfterData());
|
||||
domain.setChangedFields(entity.getChangedFields());
|
||||
domain.setIpAddress(entity.getIpAddress());
|
||||
domain.setUserAgent(entity.getUserAgent());
|
||||
domain.setDescription(entity.getDescription());
|
||||
domain.setCreateBy(entity.getCreateBy());
|
||||
domain.setUpdateBy(entity.getUpdateBy());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public AuditLogEntity toEntity(AuditLog domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
AuditLogEntity entity = new AuditLogEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setEntityType(domain.getEntityType());
|
||||
entity.setEntityId(domain.getEntityId());
|
||||
entity.setOperationType(domain.getOperationType());
|
||||
entity.setOperator(domain.getOperator());
|
||||
entity.setOperationTime(domain.getOperationTime());
|
||||
entity.setBeforeData(domain.getBeforeData());
|
||||
entity.setAfterData(domain.getAfterData());
|
||||
entity.setChangedFields(domain.getChangedFields());
|
||||
entity.setIpAddress(domain.getIpAddress());
|
||||
entity.setUserAgent(domain.getUserAgent());
|
||||
entity.setDescription(domain.getDescription());
|
||||
entity.setCreateBy(domain.getCreateBy());
|
||||
entity.setUpdateBy(domain.getUpdateBy());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<AuditLog> toDomainList(List<AuditLogEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<AuditLogEntity> toEntityList(List<AuditLog> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.Dictionary;
|
||||
import cn.novalon.gym.manage.db.entity.DictionaryEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class DictionaryConverter {
|
||||
|
||||
public DictionaryEntity toEntity(Dictionary domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
DictionaryEntity entity = new DictionaryEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setType(domain.getType());
|
||||
entity.setCode(domain.getCode());
|
||||
entity.setName(domain.getName());
|
||||
entity.setValue(domain.getValue());
|
||||
entity.setRemark(domain.getRemark());
|
||||
entity.setSort(domain.getSort());
|
||||
entity.setCreateBy(domain.getCreateBy());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Dictionary toDomain(DictionaryEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
Dictionary domain = new Dictionary();
|
||||
domain.setId(entity.getId());
|
||||
domain.setType(entity.getType());
|
||||
domain.setCode(entity.getCode());
|
||||
domain.setName(entity.getName());
|
||||
domain.setValue(entity.getValue());
|
||||
domain.setRemark(entity.getRemark());
|
||||
domain.setSort(entity.getSort());
|
||||
domain.setCreateBy(entity.getCreateBy());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public List<DictionaryEntity> toEntityList(List<Dictionary> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Dictionary> toDomainList(List<DictionaryEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.OperationLog;
|
||||
import cn.novalon.gym.manage.db.entity.OperationLogEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 操作日志实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class OperationLogConverter {
|
||||
|
||||
public OperationLog toDomain(OperationLogEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
OperationLog domain = new OperationLog();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUsername(entity.getUsername());
|
||||
domain.setOperation(entity.getOperation());
|
||||
domain.setMethod(entity.getMethod());
|
||||
domain.setParams(entity.getParams());
|
||||
domain.setResult(entity.getResult());
|
||||
domain.setIp(entity.getIp());
|
||||
domain.setDuration(entity.getDuration());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setErrorMsg(entity.getErrorMsg());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public OperationLogEntity toEntity(OperationLog domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
OperationLogEntity entity = new OperationLogEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUsername(domain.getUsername());
|
||||
entity.setOperation(domain.getOperation());
|
||||
entity.setMethod(domain.getMethod());
|
||||
entity.setParams(domain.getParams());
|
||||
entity.setResult(domain.getResult());
|
||||
entity.setIp(domain.getIp());
|
||||
entity.setDuration(domain.getDuration());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setErrorMsg(domain.getErrorMsg());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<OperationLog> toDomainList(List<OperationLogEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<OperationLogEntity> toEntityList(List<OperationLog> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysConfig;
|
||||
import cn.novalon.gym.manage.db.entity.SysConfigEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统配置实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysConfigConverter {
|
||||
|
||||
public SysConfig toDomain(SysConfigEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysConfig domain = new SysConfig();
|
||||
domain.setId(entity.getId());
|
||||
domain.setConfigName(entity.getConfigName());
|
||||
domain.setConfigKey(entity.getConfigKey());
|
||||
domain.setConfigValue(entity.getConfigValue());
|
||||
domain.setConfigType(entity.getConfigType());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysConfigEntity toEntity(SysConfig domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysConfigEntity entity = new SysConfigEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setConfigName(domain.getConfigName());
|
||||
entity.setConfigKey(domain.getConfigKey());
|
||||
entity.setConfigValue(domain.getConfigValue());
|
||||
entity.setConfigType(domain.getConfigType());
|
||||
entity.setCreateBy(domain.getCreateBy());
|
||||
entity.setUpdateBy(domain.getUpdateBy());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysConfig> toDomainList(List<SysConfigEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysConfigEntity> toEntityList(List<SysConfig> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictData;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictDataEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典数据实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysDictDataConverter {
|
||||
|
||||
public SysDictData toDomain(SysDictDataEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysDictData domain = new SysDictData();
|
||||
domain.setId(entity.getId());
|
||||
domain.setDictSort(entity.getDictSort());
|
||||
domain.setDictLabel(entity.getDictLabel());
|
||||
domain.setDictValue(entity.getDictValue());
|
||||
domain.setDictType(entity.getDictType());
|
||||
domain.setCssClass(entity.getCssClass());
|
||||
domain.setListClass(entity.getListClass());
|
||||
domain.setIsDefault(entity.getIsDefault());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysDictDataEntity toEntity(SysDictData domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysDictDataEntity entity = new SysDictDataEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setDictSort(domain.getDictSort());
|
||||
entity.setDictLabel(domain.getDictLabel());
|
||||
entity.setDictValue(domain.getDictValue());
|
||||
entity.setDictType(domain.getDictType());
|
||||
entity.setCssClass(domain.getCssClass());
|
||||
entity.setListClass(domain.getListClass());
|
||||
entity.setIsDefault(domain.getIsDefault());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysDictData> toDomainList(List<SysDictDataEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysDictDataEntity> toEntityList(List<SysDictData> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictType;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictTypeEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典类型实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysDictTypeConverter {
|
||||
|
||||
public SysDictType toDomain(SysDictTypeEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysDictType domain = new SysDictType();
|
||||
domain.setId(entity.getId());
|
||||
domain.setDictName(entity.getDictName());
|
||||
domain.setDictType(entity.getDictType());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setRemark(entity.getRemark());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysDictTypeEntity toEntity(SysDictType domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysDictTypeEntity entity = new SysDictTypeEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setDictName(domain.getDictName());
|
||||
entity.setDictType(domain.getDictType());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setRemark(domain.getRemark());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysDictType> toDomainList(List<SysDictTypeEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysDictTypeEntity> toEntityList(List<SysDictType> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysExceptionLog;
|
||||
import cn.novalon.gym.manage.db.entity.SysExceptionLogEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 异常日志实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysExceptionLogConverter {
|
||||
|
||||
public SysExceptionLog toDomain(SysExceptionLogEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysExceptionLog domain = new SysExceptionLog();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUsername(entity.getUsername());
|
||||
domain.setTitle(entity.getTitle());
|
||||
domain.setExceptionName(entity.getExceptionName());
|
||||
domain.setMethodName(entity.getMethodName());
|
||||
domain.setMethodParams(entity.getMethodParams());
|
||||
domain.setExceptionMsg(entity.getExceptionMsg());
|
||||
domain.setExceptionStack(entity.getExceptionStack());
|
||||
domain.setIp(entity.getIp());
|
||||
domain.setCreateTime(entity.getCreateTime());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysExceptionLogEntity toEntity(SysExceptionLog domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysExceptionLogEntity entity = new SysExceptionLogEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUsername(domain.getUsername());
|
||||
entity.setTitle(domain.getTitle());
|
||||
entity.setExceptionName(domain.getExceptionName());
|
||||
entity.setMethodName(domain.getMethodName());
|
||||
entity.setMethodParams(domain.getMethodParams());
|
||||
entity.setExceptionMsg(domain.getExceptionMsg());
|
||||
entity.setExceptionStack(domain.getExceptionStack());
|
||||
entity.setIp(domain.getIp());
|
||||
entity.setCreateTime(domain.getCreateTime());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysExceptionLog> toDomainList(List<SysExceptionLogEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysExceptionLogEntity> toEntityList(List<SysExceptionLog> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.file.core.domain.SysFile;
|
||||
import cn.novalon.gym.manage.db.entity.SysFileEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文件实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysFileConverter {
|
||||
|
||||
public SysFile toDomain(SysFileEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysFile domain = new SysFile();
|
||||
domain.setId(entity.getId());
|
||||
domain.setFileName(entity.getFileName());
|
||||
domain.setFilePath(entity.getFilePath());
|
||||
domain.setFileSize(entity.getFileSize());
|
||||
domain.setFileType(entity.getFileType());
|
||||
domain.setStorageType(entity.getStorageType());
|
||||
domain.setCreateBy(entity.getCreateBy());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysFileEntity toEntity(SysFile domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysFileEntity entity = new SysFileEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setFileName(domain.getFileName());
|
||||
entity.setFilePath(domain.getFilePath());
|
||||
entity.setFileSize(domain.getFileSize());
|
||||
entity.setFileType(domain.getFileType());
|
||||
entity.setStorageType(domain.getStorageType());
|
||||
entity.setCreateBy(domain.getCreateBy());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysFile> toDomainList(List<SysFileEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysFileEntity> toEntityList(List<SysFile> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysLoginLog;
|
||||
import cn.novalon.gym.manage.db.entity.SysLoginLogEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 登录日志实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysLoginLogConverter {
|
||||
|
||||
public SysLoginLog toDomain(SysLoginLogEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysLoginLog domain = new SysLoginLog();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUsername(entity.getUsername());
|
||||
domain.setIp(entity.getIp());
|
||||
domain.setLocation(entity.getLocation());
|
||||
domain.setBrowser(entity.getBrowser());
|
||||
domain.setOs(entity.getOs());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setMessage(entity.getMessage());
|
||||
domain.setLoginTime(entity.getLoginTime());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysLoginLogEntity toEntity(SysLoginLog domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysLoginLogEntity entity = new SysLoginLogEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUsername(domain.getUsername());
|
||||
entity.setIp(domain.getIp());
|
||||
entity.setLocation(domain.getLocation());
|
||||
entity.setBrowser(domain.getBrowser());
|
||||
entity.setOs(domain.getOs());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setMessage(domain.getMessage());
|
||||
entity.setLoginTime(domain.getLoginTime());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysLoginLog> toDomainList(List<SysLoginLogEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysLoginLogEntity> toEntityList(List<SysLoginLog> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysMenu;
|
||||
import cn.novalon.gym.manage.db.entity.SysMenuEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysMenuConverter {
|
||||
|
||||
public SysMenu toDomain(SysMenuEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysMenu domain = new SysMenu();
|
||||
domain.setId(entity.getId());
|
||||
domain.setMenuName(entity.getMenuName());
|
||||
domain.setParentId(entity.getParentId());
|
||||
domain.setOrderNum(entity.getOrderNum());
|
||||
domain.setMenuType(entity.getMenuType());
|
||||
domain.setPerms(entity.getPerms());
|
||||
domain.setComponent(entity.getComponent());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreateBy(entity.getCreateBy());
|
||||
domain.setUpdateBy(entity.getUpdateBy());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysMenuEntity toEntity(SysMenu domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysMenuEntity entity = new SysMenuEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setMenuName(domain.getMenuName());
|
||||
entity.setParentId(domain.getParentId());
|
||||
entity.setOrderNum(domain.getOrderNum());
|
||||
entity.setMenuType(domain.getMenuType());
|
||||
entity.setPerms(domain.getPerms());
|
||||
entity.setComponent(domain.getComponent());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreateBy(domain.getCreateBy());
|
||||
entity.setUpdateBy(domain.getUpdateBy());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysMenu> toDomainList(List<SysMenuEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysMenuEntity> toEntityList(List<SysMenu> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.notify.core.domain.SysNotice;
|
||||
import cn.novalon.gym.manage.db.entity.SysNoticeEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 通知公告实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysNoticeConverter {
|
||||
|
||||
public SysNotice toDomain(SysNoticeEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysNotice domain = new SysNotice();
|
||||
domain.setId(entity.getId());
|
||||
domain.setNoticeTitle(entity.getNoticeTitle());
|
||||
domain.setNoticeType(entity.getNoticeType());
|
||||
domain.setNoticeContent(entity.getNoticeContent());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysNoticeEntity toEntity(SysNotice domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysNoticeEntity entity = new SysNoticeEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setNoticeTitle(domain.getNoticeTitle());
|
||||
entity.setNoticeType(domain.getNoticeType());
|
||||
entity.setNoticeContent(domain.getNoticeContent());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysNotice> toDomainList(List<SysNoticeEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysNoticeEntity> toEntityList(List<SysNotice> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysPermission;
|
||||
import cn.novalon.gym.manage.db.entity.SysPermissionEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Component
|
||||
public class SysPermissionConverter {
|
||||
|
||||
public SysPermission toDomain(SysPermissionEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysPermission domain = new SysPermission();
|
||||
domain.setId(entity.getId());
|
||||
domain.setPermissionName(entity.getPermissionName());
|
||||
domain.setPermissionCode(entity.getPermissionCode());
|
||||
domain.setResource(entity.getResource());
|
||||
domain.setAction(entity.getAction());
|
||||
domain.setDescription(entity.getDescription());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysPermissionEntity toEntity(SysPermission domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysPermissionEntity entity = new SysPermissionEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setPermissionName(domain.getPermissionName());
|
||||
entity.setPermissionCode(domain.getPermissionCode());
|
||||
entity.setResource(domain.getResource());
|
||||
entity.setAction(domain.getAction());
|
||||
entity.setDescription(domain.getDescription());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysPermission> toDomainList(List<SysPermissionEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysPermissionEntity> toEntityList(List<SysPermission> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysRole;
|
||||
import cn.novalon.gym.manage.db.entity.SysRoleEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysRoleConverter {
|
||||
|
||||
public SysRole toDomain(SysRoleEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysRole domain = new SysRole();
|
||||
domain.setId(entity.getId());
|
||||
domain.setRoleName(entity.getRoleName());
|
||||
domain.setRoleKey(entity.getRoleKey());
|
||||
domain.setRoleSort(entity.getRoleSort());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysRoleEntity toEntity(SysRole domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysRoleEntity entity = new SysRoleEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setRoleName(domain.getRoleName());
|
||||
entity.setRoleKey(domain.getRoleKey());
|
||||
entity.setRoleSort(domain.getRoleSort());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysRole> toDomainList(List<SysRoleEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysRoleEntity> toEntityList(List<SysRole> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysRolePermission;
|
||||
import cn.novalon.gym.manage.db.entity.SysRolePermissionEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色权限关联实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Component
|
||||
public class SysRolePermissionConverter {
|
||||
|
||||
public SysRolePermission toDomain(SysRolePermissionEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysRolePermission domain = new SysRolePermission();
|
||||
domain.setId(entity.getId());
|
||||
domain.setRoleId(entity.getRoleId());
|
||||
domain.setPermissionId(entity.getPermissionId());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysRolePermissionEntity toEntity(SysRolePermission domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysRolePermissionEntity entity = new SysRolePermissionEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setRoleId(domain.getRoleId());
|
||||
entity.setPermissionId(domain.getPermissionId());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysRolePermission> toDomainList(List<SysRolePermissionEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysRolePermissionEntity> toEntityList(List<SysRolePermission> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysUser;
|
||||
import cn.novalon.gym.manage.db.entity.SysUserEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysUserConverter {
|
||||
|
||||
public SysUser toDomain(SysUserEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysUser domain = new SysUser();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUsername(entity.getUsername());
|
||||
domain.setPassword(entity.getPassword());
|
||||
domain.setEmail(entity.getEmail());
|
||||
domain.setPhone(entity.getPhone());
|
||||
domain.setNickname(entity.getNickname());
|
||||
domain.setRoleId(entity.getRoleId());
|
||||
domain.setStatus(entity.getStatus());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setUpdatedAt(entity.getUpdatedAt());
|
||||
domain.setDeletedAt(entity.getDeletedAt());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysUserEntity toEntity(SysUser domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysUserEntity entity = new SysUserEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUsername(domain.getUsername());
|
||||
entity.setPassword(domain.getPassword());
|
||||
entity.setEmail(domain.getEmail());
|
||||
entity.setPhone(domain.getPhone());
|
||||
entity.setNickname(domain.getNickname());
|
||||
entity.setRoleId(domain.getRoleId());
|
||||
entity.setStatus(domain.getStatus());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setUpdatedAt(domain.getUpdatedAt());
|
||||
entity.setDeletedAt(domain.getDeletedAt());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysUser> toDomainList(List<SysUserEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysUserEntity> toEntityList(List<SysUser> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.notify.core.domain.SysUserMessage;
|
||||
import cn.novalon.gym.manage.db.entity.SysUserMessageEntity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户消息实体转换器
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Component
|
||||
public class SysUserMessageConverter {
|
||||
|
||||
public SysUserMessage toDomain(SysUserMessageEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
SysUserMessage domain = new SysUserMessage();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUserId(entity.getUserId());
|
||||
domain.setTitle(entity.getTitle());
|
||||
domain.setContent(entity.getContent());
|
||||
domain.setMessageType(entity.getMessageType());
|
||||
domain.setIsRead(entity.getIsRead());
|
||||
domain.setCreateTime(entity.getCreateTime());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public SysUserMessageEntity toEntity(SysUserMessage domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
SysUserMessageEntity entity = new SysUserMessageEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUserId(domain.getUserId());
|
||||
entity.setTitle(domain.getTitle());
|
||||
entity.setContent(domain.getContent());
|
||||
entity.setMessageType(domain.getMessageType());
|
||||
entity.setIsRead(domain.getIsRead());
|
||||
entity.setCreateTime(domain.getCreateTime());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<SysUserMessage> toDomainList(List<SysUserMessageEntity> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
}
|
||||
return entities.stream()
|
||||
.map(this::toDomain)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysUserMessageEntity> toEntityList(List<SysUserMessage> domains) {
|
||||
if (domains == null) {
|
||||
return null;
|
||||
}
|
||||
return domains.stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.UserRoleEntity;
|
||||
import cn.novalon.gym.manage.sys.core.domain.UserRole;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UserRoleConverter {
|
||||
|
||||
public UserRole toDomain(UserRoleEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserRole domain = new UserRole();
|
||||
domain.setId(entity.getId());
|
||||
domain.setUserId(entity.getUserId());
|
||||
domain.setRoleId(entity.getRoleId());
|
||||
domain.setCreatedAt(entity.getCreatedAt());
|
||||
domain.setCreatedBy(entity.getCreatedBy());
|
||||
return domain;
|
||||
}
|
||||
|
||||
public UserRoleEntity toEntity(UserRole domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserRoleEntity entity = new UserRoleEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setUserId(domain.getUserId());
|
||||
entity.setRoleId(domain.getRoleId());
|
||||
entity.setCreatedAt(domain.getCreatedAt());
|
||||
entity.setCreatedBy(domain.getCreatedBy());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.AuditLogEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 审计日志数据访问接口
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-04-08
|
||||
*/
|
||||
@Repository
|
||||
public interface AuditLogDao extends R2dbcRepository<AuditLogEntity, Long> {
|
||||
|
||||
Flux<AuditLogEntity> findByEntityTypeAndDeletedAtIsNull(String entityType);
|
||||
|
||||
Flux<AuditLogEntity> findByEntityIdAndDeletedAtIsNull(Long entityId);
|
||||
|
||||
Flux<AuditLogEntity> findByEntityTypeAndEntityIdAndDeletedAtIsNull(String entityType, Long entityId);
|
||||
|
||||
Flux<AuditLogEntity> findByOperatorAndDeletedAtIsNull(String operator);
|
||||
|
||||
Flux<AuditLogEntity> findByOperationTypeAndDeletedAtIsNull(String operationType);
|
||||
|
||||
Flux<AuditLogEntity> findByOperationTimeBetweenAndDeletedAtIsNull(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
Flux<AuditLogEntity> findByEntityTypeAndOperationTimeBetweenAndDeletedAtIsNull(
|
||||
String entityType,
|
||||
LocalDateTime startTime,
|
||||
LocalDateTime endTime
|
||||
);
|
||||
|
||||
Flux<AuditLogEntity> findByOperatorAndOperationTimeBetweenAndDeletedAtIsNull(
|
||||
String operator,
|
||||
LocalDateTime startTime,
|
||||
LocalDateTime endTime
|
||||
);
|
||||
|
||||
Mono<Long> countByEntityTypeAndDeletedAtIsNull(String entityType);
|
||||
|
||||
Mono<Long> countByOperationTypeAndDeletedAtIsNull(String operationType);
|
||||
|
||||
Mono<Long> countByOperatorAndDeletedAtIsNull(String operator);
|
||||
|
||||
Mono<Long> countByOperationTimeBetweenAndDeletedAtIsNull(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
Flux<AuditLogEntity> findByDeletedAtIsNull();
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.DictionaryEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 字典数据访问接口
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public interface DictionaryDao extends R2dbcRepository<DictionaryEntity, Long> {
|
||||
|
||||
Flux<DictionaryEntity> findByType(String type);
|
||||
|
||||
Mono<DictionaryEntity> findByTypeAndCode(String type, String code);
|
||||
|
||||
Mono<DictionaryEntity> findByTypeAndCodeAndDeletedAtIsNull(String type, String code);
|
||||
|
||||
Flux<DictionaryEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<DictionaryEntity> findByDeletedAtIsNullOrderBySortAsc();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.OperationLogEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface OperationLogDao extends R2dbcRepository<OperationLogEntity, Long> {
|
||||
|
||||
Flux<OperationLogEntity> findByUsernameAndDeletedAtIsNull(String username);
|
||||
|
||||
Flux<OperationLogEntity> findByDeletedAtIsNull();
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Long> countByCreatedAtAfterAndDeletedAtIsNull(LocalDateTime dateTime);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 查询字段注解
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface QueryField {
|
||||
|
||||
String propName() default "";
|
||||
|
||||
String blurry() default "";
|
||||
|
||||
Type type() default Type.EQUAL;
|
||||
|
||||
Type orPropVal() default Type.EQUAL;
|
||||
|
||||
String[] orPropNames() default {};
|
||||
|
||||
enum Type {
|
||||
EQUAL,
|
||||
GREATER_THAN,
|
||||
LESS_THAN,
|
||||
LESS_THAN_NQ,
|
||||
INNER_LIKE,
|
||||
LEFT_LIKE,
|
||||
NOT_LEFT_LIKE,
|
||||
RIGHT_LIKE,
|
||||
IN,
|
||||
OR,
|
||||
IS_NULL,
|
||||
IS_NOT_NULL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询工具类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class QueryUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QueryUtil.class);
|
||||
|
||||
public static <Q> Query getQuery(Q query) {
|
||||
return getQuery(query, true);
|
||||
}
|
||||
|
||||
public static <Q> Query getQueryAll(Q query) {
|
||||
return getQuery(query, false);
|
||||
}
|
||||
|
||||
public static <Q> Query getQuery(Q query, Boolean enabled) {
|
||||
Criteria criteria = Criteria.empty();
|
||||
if (enabled) {
|
||||
criteria = criteria.and("deletedAt").isNull();
|
||||
}
|
||||
if (query == null) {
|
||||
log.info("Query object is null, returning empty criteria");
|
||||
return Query.query(criteria);
|
||||
}
|
||||
System.out.println("=== QueryUtil.getQuery START ===");
|
||||
System.out.println("Query object class: " + query.getClass().getName());
|
||||
log.info("=== QueryUtil.getQuery START ===");
|
||||
log.info("Query object class: {}", query.getClass().getName());
|
||||
try {
|
||||
List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
|
||||
log.info("Found {} fields to process", fields.size());
|
||||
System.out.println("Found " + fields.size() + " fields to process");
|
||||
for (Field field : fields) {
|
||||
boolean accessible = Modifier.isStatic(field.getModifiers()) ? field.canAccess(null)
|
||||
: field.canAccess(query);
|
||||
field.setAccessible(true);
|
||||
QueryField q = field.getAnnotation(QueryField.class);
|
||||
if (q != null) {
|
||||
String propName = q.propName();
|
||||
String blurry = q.blurry();
|
||||
String attributeName = isBlank(propName) ? field.getName() : propName;
|
||||
Object val = field.get(query);
|
||||
log.info("Processing field: {}, value: {}, blurry: {}", attributeName, val, blurry);
|
||||
System.out.println("Processing field: " + attributeName + ", value: " + val + ", blurry: " + blurry);
|
||||
if (val == null || "".equals(val)) {
|
||||
log.info("Field {} has null or empty value, skipping", attributeName);
|
||||
System.out.println("Field " + attributeName + " has null or empty value, skipping");
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotBlank(blurry)) {
|
||||
log.info("Field {} has blurry search configuration: {}", attributeName, blurry);
|
||||
System.out.println("Field " + attributeName + " has blurry search configuration: " + blurry);
|
||||
String[] blurrys = blurry.split(",");
|
||||
Criteria orCriteria = null;
|
||||
for (int i = 0; i < blurrys.length; i++) {
|
||||
String s = blurrys[i];
|
||||
if (i == 0) {
|
||||
orCriteria = Criteria.where(s).like("%" + val + "%");
|
||||
} else {
|
||||
orCriteria = orCriteria.or(s).like("%" + val + "%");
|
||||
}
|
||||
}
|
||||
if (orCriteria != null) {
|
||||
criteria = criteria.and(orCriteria);
|
||||
log.info("Added OR criteria for blurry search: {} with value: {}", blurry, val);
|
||||
System.out.println("Added OR criteria for blurry search: " + blurry + " with value: " + val);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
switch (q.type()) {
|
||||
case EQUAL:
|
||||
criteria = criteria.and(attributeName).is(val);
|
||||
break;
|
||||
case GREATER_THAN:
|
||||
criteria = criteria.and(attributeName).greaterThanOrEquals(val);
|
||||
break;
|
||||
case LESS_THAN:
|
||||
criteria = criteria.and(attributeName).lessThanOrEquals(val);
|
||||
break;
|
||||
case LESS_THAN_NQ:
|
||||
criteria = criteria.and(attributeName).lessThan(val);
|
||||
break;
|
||||
case INNER_LIKE:
|
||||
criteria = criteria.and(attributeName).like("%" + val + "%");
|
||||
break;
|
||||
case LEFT_LIKE:
|
||||
criteria = criteria.and(attributeName).like("%" + val);
|
||||
break;
|
||||
case NOT_LEFT_LIKE:
|
||||
criteria = criteria.and(attributeName).notLike("%" + val);
|
||||
break;
|
||||
case RIGHT_LIKE:
|
||||
criteria = criteria.and(attributeName).like(val + "%");
|
||||
break;
|
||||
case IN:
|
||||
if (val instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) val)) {
|
||||
criteria = criteria.and(attributeName).in((Collection<?>) val);
|
||||
}
|
||||
break;
|
||||
case OR:
|
||||
QueryField.Type orValue = q.orPropVal();
|
||||
String[] orPropNames = q.orPropNames();
|
||||
Criteria orPredicate = Criteria.empty();
|
||||
if (QueryField.Type.IS_NULL.equals(orValue)) {
|
||||
for (String prop : orPropNames) {
|
||||
orPredicate = orPredicate.or(prop).isNull();
|
||||
}
|
||||
}
|
||||
if (QueryField.Type.IS_NOT_NULL.equals(orValue)) {
|
||||
for (String prop : orPropNames) {
|
||||
orPredicate = orPredicate.or(prop).isNotNull();
|
||||
}
|
||||
}
|
||||
criteria = criteria.and(orPredicate);
|
||||
break;
|
||||
case IS_NULL:
|
||||
criteria = criteria.and(attributeName).isNull();
|
||||
break;
|
||||
case IS_NOT_NULL:
|
||||
criteria = criteria.and(attributeName).isNotNull();
|
||||
break;
|
||||
}
|
||||
}
|
||||
field.setAccessible(accessible);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return Query.query(criteria);
|
||||
}
|
||||
|
||||
public static boolean isBlank(final CharSequence cs) {
|
||||
int strLen;
|
||||
if (cs == null || (strLen = cs.length()) == 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
if (!Character.isWhitespace(cs.charAt(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static List<Field> getAllFields(Class<?> clazz, List<Field> fields) {
|
||||
if (clazz != null) {
|
||||
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||
getAllFields(clazz.getSuperclass(), fields);
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysConfigEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysConfigDao extends R2dbcRepository<SysConfigEntity, Long> {
|
||||
|
||||
Mono<SysConfigEntity> findByConfigKeyAndDeletedAtIsNull(String configKey);
|
||||
|
||||
Flux<SysConfigEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysConfigEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysDictDataEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysDictDataDao extends R2dbcRepository<SysDictDataEntity, Long> {
|
||||
|
||||
Flux<SysDictDataEntity> findByDictTypeAndStatusAndDeletedAtIsNull(String dictType, String status);
|
||||
|
||||
Flux<SysDictDataEntity> findByDictTypeAndDeletedAtIsNull(String dictType);
|
||||
|
||||
Flux<SysDictDataEntity> findByDictTypeAndDeletedAtIsNull(String dictType, Sort sort);
|
||||
|
||||
Flux<SysDictDataEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysDictDataEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysDictTypeEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysDictTypeDao extends R2dbcRepository<SysDictTypeEntity, Long> {
|
||||
|
||||
Mono<SysDictTypeEntity> findByDictTypeAndDeletedAtIsNull(String dictType);
|
||||
|
||||
Flux<SysDictTypeEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysDictTypeEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysExceptionLogEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface SysExceptionLogDao extends R2dbcRepository<SysExceptionLogEntity, Long> {
|
||||
|
||||
Flux<SysExceptionLogEntity> findByUsername(String username);
|
||||
|
||||
Flux<SysExceptionLogEntity> findByUsernameOrderByCreateTimeDesc(String username);
|
||||
|
||||
Flux<SysExceptionLogEntity> findByCreateTimeBetweenOrderByCreateTimeDesc(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
Flux<SysExceptionLogEntity> findAllByOrderByCreateTimeDesc();
|
||||
|
||||
Mono<Long> count();
|
||||
|
||||
Mono<Long> countByUsername(String username);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysFileEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysFileDao extends R2dbcRepository<SysFileEntity, Long> {
|
||||
|
||||
Flux<SysFileEntity> findByCreateBy(String createBy);
|
||||
|
||||
Flux<SysFileEntity> findByCreateBy(String createBy, Sort sort);
|
||||
|
||||
Flux<SysFileEntity> findByCreateByOrderByCreatedAtDesc(String createBy);
|
||||
|
||||
Flux<SysFileEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysFileEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Flux<SysFileEntity> findByDeletedAtIsNullOrderByCreatedAtDesc();
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<SysFileEntity> findByFilePathContaining(String fileName);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysLoginLogEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface SysLoginLogDao extends R2dbcRepository<SysLoginLogEntity, Long> {
|
||||
|
||||
Flux<SysLoginLogEntity> findByUsername(String username);
|
||||
|
||||
Flux<SysLoginLogEntity> findByUsernameOrderByLoginTimeDesc(String username);
|
||||
|
||||
Flux<SysLoginLogEntity> findByLoginTimeBetweenOrderByLoginTimeDesc(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
Flux<SysLoginLogEntity> findAllByOrderByLoginTimeDesc();
|
||||
|
||||
Mono<Long> count();
|
||||
|
||||
Mono<Long> countByUsername(String username);
|
||||
|
||||
Mono<Long> countByLoginTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysMenuEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysMenuDao extends R2dbcRepository<SysMenuEntity, Long> {
|
||||
|
||||
Mono<SysMenuEntity> findByIdAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<SysMenuEntity> findByParentIdAndDeletedAtIsNull(Long parentId);
|
||||
|
||||
Flux<SysMenuEntity> findByDeletedAtIsNull();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysNoticeEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysNoticeDao extends R2dbcRepository<SysNoticeEntity, Long> {
|
||||
|
||||
Flux<SysNoticeEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||
|
||||
Flux<SysNoticeEntity> findByStatusAndDeletedAtIsNull(String status, Sort sort);
|
||||
|
||||
Flux<SysNoticeEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysNoticeEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Void> deleteByIdAndDeletedAtIsNull(Long id);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysPermissionEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysPermissionDao extends R2dbcRepository<SysPermissionEntity, Long> {
|
||||
|
||||
Mono<SysPermissionEntity> findByIdAndDeletedAtIsNull(Long id);
|
||||
|
||||
Mono<SysPermissionEntity> findByPermissionCodeAndDeletedAtIsNull(String permissionCode);
|
||||
|
||||
Flux<SysPermissionEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysPermissionEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Boolean> existsByPermissionCodeAndDeletedAtIsNull(String permissionCode);
|
||||
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
SELECT p.* FROM sys_permission p
|
||||
INNER JOIN sys_role_permission rp ON p.id = rp.permission_id
|
||||
WHERE rp.role_id = :roleId AND p.deleted_at IS NULL
|
||||
""")
|
||||
Flux<SysPermissionEntity> findByRoleId(Long roleId);
|
||||
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
SELECT DISTINCT p.* FROM sys_permission p
|
||||
INNER JOIN sys_role_permission rp ON p.id = rp.permission_id
|
||||
WHERE rp.role_id IN (:roleIds) AND p.deleted_at IS NULL
|
||||
""")
|
||||
Flux<SysPermissionEntity> findByRoleIds(java.util.List<Long> roleIds);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysRoleEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysRoleDao extends R2dbcRepository<SysRoleEntity, Long> {
|
||||
|
||||
Mono<SysRoleEntity> findByIdAndDeletedAtIsNull(Long id);
|
||||
|
||||
Mono<SysRoleEntity> findByRoleKeyAndDeletedAtIsNull(String roleKey);
|
||||
|
||||
Flux<SysRoleEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysRoleEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Flux<SysRoleEntity> findByRoleNameLikeAndRoleKeyLikeAndDeletedAtIsNull(String roleName, String roleKey, Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Mono<Long> countByRoleNameLikeAndRoleKeyLikeAndDeletedAtIsNull(String roleName, String roleKey);
|
||||
|
||||
Mono<SysRoleEntity> findByRoleNameAndDeletedAtIsNull(String roleName);
|
||||
|
||||
Mono<Boolean> existsByRoleNameAndDeletedAtIsNull(String roleName);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysRolePermissionEntity;
|
||||
import org.springframework.data.r2dbc.repository.Modifying;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysRolePermissionDao extends R2dbcRepository<SysRolePermissionEntity, Long> {
|
||||
|
||||
Flux<SysRolePermissionEntity> findByRoleId(Long roleId);
|
||||
|
||||
Flux<SysRolePermissionEntity> findByPermissionId(Long permissionId);
|
||||
|
||||
Flux<Long> findPermissionIdsByRoleId(Long roleId);
|
||||
|
||||
Flux<Long> findRoleIdsByPermissionId(Long permissionId);
|
||||
|
||||
@Modifying
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
DELETE FROM sys_role_permission
|
||||
WHERE role_id = :roleId AND permission_id IN (:permissionIds)
|
||||
""")
|
||||
Mono<Void> deleteByRoleIdAndPermissionIds(Long roleId, java.util.List<Long> permissionIds);
|
||||
|
||||
@Modifying
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
DELETE FROM sys_role_permission
|
||||
WHERE permission_id = :permissionId AND role_id IN (:roleIds)
|
||||
""")
|
||||
Mono<Void> deleteByPermissionIdAndRoleIds(Long permissionId, java.util.List<Long> roleIds);
|
||||
|
||||
@Modifying
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
DELETE FROM sys_role_permission WHERE role_id = :roleId
|
||||
""")
|
||||
Mono<Void> deleteByRoleId(Long roleId);
|
||||
|
||||
@Modifying
|
||||
@org.springframework.data.r2dbc.repository.Query("""
|
||||
DELETE FROM sys_role_permission WHERE permission_id = :permissionId
|
||||
""")
|
||||
Mono<Void> deleteByPermissionId(Long permissionId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysUserEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 用户数据访问接口
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public interface SysUserDao extends R2dbcRepository<SysUserEntity, Long> {
|
||||
|
||||
Mono<SysUserEntity> findByUsernameAndDeletedAtIsNull(String username);
|
||||
|
||||
Mono<SysUserEntity> findByEmailAndDeletedAtIsNull(String email);
|
||||
|
||||
Mono<SysUserEntity> findByIdAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<SysUserEntity> findAll();
|
||||
|
||||
Flux<SysUserEntity> findAll(Sort sort);
|
||||
|
||||
Flux<SysUserEntity> findByDeletedAtIsNull();
|
||||
|
||||
Flux<SysUserEntity> findByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Mono<Long> countByDeletedAtIsNull();
|
||||
|
||||
Flux<SysUserEntity> findByRoleId(Long roleId);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.SysUserMessageEntity;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public interface SysUserMessageDao extends R2dbcRepository<SysUserMessageEntity, Long> {
|
||||
|
||||
Flux<SysUserMessageEntity> findByUserIdAndIsReadOrderByCreateTimeDesc(Long userId, String isRead);
|
||||
|
||||
Flux<SysUserMessageEntity> findByUserIdOrderByCreateTimeDesc(Long userId);
|
||||
|
||||
Mono<Long> countByUserIdAndIsRead(Long userId, String isRead);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.novalon.gym.manage.db.dao;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.UserRoleEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.Modifying;
|
||||
import org.springframework.data.r2dbc.repository.Query;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface UserRoleDao extends R2dbcRepository<UserRoleEntity, Long> {
|
||||
|
||||
Flux<UserRoleEntity> findByUserId(Long userId);
|
||||
|
||||
Flux<UserRoleEntity> findByUserId(Long userId, Sort sort);
|
||||
|
||||
Flux<UserRoleEntity> findByRoleId(Long roleId);
|
||||
|
||||
Flux<UserRoleEntity> findByRoleId(Long roleId, Sort sort);
|
||||
|
||||
Mono<Long> countByUserId(Long userId);
|
||||
|
||||
Mono<Long> countByRoleId(Long roleId);
|
||||
|
||||
@Modifying
|
||||
@Query("DELETE FROM user_role WHERE user_id = :userId")
|
||||
Mono<Integer> deleteByUserId(Long userId);
|
||||
|
||||
@Modifying
|
||||
@Query("DELETE FROM user_role WHERE role_id = :roleId")
|
||||
Mono<Integer> deleteByRoleId(Long roleId);
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 审计日志数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-04-08
|
||||
*/
|
||||
@Table("audit_log")
|
||||
public class AuditLogEntity extends BaseEntity {
|
||||
|
||||
@Column("entity_type")
|
||||
private String entityType;
|
||||
|
||||
@Column("entity_id")
|
||||
private Long entityId;
|
||||
|
||||
@Column("operation_type")
|
||||
private String operationType;
|
||||
|
||||
@Column("operator")
|
||||
private String operator;
|
||||
|
||||
@Column("operation_time")
|
||||
private java.time.LocalDateTime operationTime;
|
||||
|
||||
@Column("before_data")
|
||||
private String beforeData;
|
||||
|
||||
@Column("after_data")
|
||||
private String afterData;
|
||||
|
||||
@Column("changed_fields")
|
||||
private String[] changedFields;
|
||||
|
||||
@Column("ip_address")
|
||||
private String ipAddress;
|
||||
|
||||
@Column("user_agent")
|
||||
private String userAgent;
|
||||
|
||||
@Column("description")
|
||||
private String description;
|
||||
|
||||
public String getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(String entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public Long getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(Long entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public String getOperationType() {
|
||||
return operationType;
|
||||
}
|
||||
|
||||
public void setOperationType(String operationType) {
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public java.time.LocalDateTime getOperationTime() {
|
||||
return operationTime;
|
||||
}
|
||||
|
||||
public void setOperationTime(java.time.LocalDateTime operationTime) {
|
||||
this.operationTime = operationTime;
|
||||
}
|
||||
|
||||
public String getBeforeData() {
|
||||
return beforeData;
|
||||
}
|
||||
|
||||
public void setBeforeData(String beforeData) {
|
||||
this.beforeData = beforeData;
|
||||
}
|
||||
|
||||
public String getAfterData() {
|
||||
return afterData;
|
||||
}
|
||||
|
||||
public void setAfterData(String afterData) {
|
||||
this.afterData = afterData;
|
||||
}
|
||||
|
||||
public String[] getChangedFields() {
|
||||
return changedFields;
|
||||
}
|
||||
|
||||
public void setChangedFields(String[] changedFields) {
|
||||
this.changedFields = changedFields;
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.domain.Persistable;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据库实体基类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public abstract class BaseEntity implements Persistable<Long> {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@CreatedBy
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@LastModifiedBy
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断实体是否为新的
|
||||
* 如果createdAt为null,则认为是新实体
|
||||
*/
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return createdAt == null;
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_dictionary")
|
||||
public class DictionaryEntity {
|
||||
@Id
|
||||
private Long id;
|
||||
private String type;
|
||||
private String code;
|
||||
private String name;
|
||||
private String value;
|
||||
private String remark;
|
||||
private Integer sort;
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public DictionaryEntity() {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 操作日志数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("operation_log")
|
||||
public class OperationLogEntity extends BaseEntity {
|
||||
|
||||
@Column("username")
|
||||
private String username;
|
||||
|
||||
@Column("operation")
|
||||
private String operation;
|
||||
|
||||
@Column("method")
|
||||
private String method;
|
||||
|
||||
@Column("params")
|
||||
private String params;
|
||||
|
||||
@Column("result")
|
||||
private String result;
|
||||
|
||||
@Column("ip")
|
||||
private String ip;
|
||||
|
||||
@Column("duration")
|
||||
private Long duration;
|
||||
|
||||
@Column("status")
|
||||
private String status;
|
||||
|
||||
@Column("error_msg")
|
||||
private String errorMsg;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 系统配置数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_config")
|
||||
public class SysConfigEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("config_name")
|
||||
private String configName;
|
||||
|
||||
@Column("config_key")
|
||||
private String configKey;
|
||||
|
||||
@Column("config_value")
|
||||
private String configValue;
|
||||
|
||||
@Column("config_type")
|
||||
private String configType;
|
||||
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getConfigName() {
|
||||
return configName;
|
||||
}
|
||||
|
||||
public void setConfigName(String configName) {
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
public String getConfigKey() {
|
||||
return configKey;
|
||||
}
|
||||
|
||||
public void setConfigKey(String configKey) {
|
||||
this.configKey = configKey;
|
||||
}
|
||||
|
||||
public String getConfigValue() {
|
||||
return configValue;
|
||||
}
|
||||
|
||||
public void setConfigValue(String configValue) {
|
||||
this.configValue = configValue;
|
||||
}
|
||||
|
||||
public String getConfigType() {
|
||||
return configType;
|
||||
}
|
||||
|
||||
public void setConfigType(String configType) {
|
||||
this.configType = configType;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典数据数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_dict_data")
|
||||
public class SysDictDataEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("dict_sort")
|
||||
private Integer dictSort;
|
||||
|
||||
@Column("dict_label")
|
||||
private String dictLabel;
|
||||
|
||||
@Column("dict_value")
|
||||
private String dictValue;
|
||||
|
||||
@Column("dict_type")
|
||||
private String dictType;
|
||||
|
||||
@Column("css_class")
|
||||
private String cssClass;
|
||||
|
||||
@Column("list_class")
|
||||
private String listClass;
|
||||
|
||||
@Column("is_default")
|
||||
private String isDefault;
|
||||
|
||||
@Column("status")
|
||||
private String status;
|
||||
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getDictSort() {
|
||||
return dictSort;
|
||||
}
|
||||
|
||||
public void setDictSort(Integer dictSort) {
|
||||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
public String getDictLabel() {
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel) {
|
||||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
public String getDictValue() {
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
public void setDictValue(String dictValue) {
|
||||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass) {
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass() {
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass) {
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public String getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典类型数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_dict_type")
|
||||
public class SysDictTypeEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("dict_name")
|
||||
private String dictName;
|
||||
|
||||
@Column("dict_type")
|
||||
private String dictType;
|
||||
|
||||
@Column("status")
|
||||
private String status;
|
||||
|
||||
@Column("remark")
|
||||
private String remark;
|
||||
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDictName() {
|
||||
return dictName;
|
||||
}
|
||||
|
||||
public void setDictName(String dictName) {
|
||||
this.dictName = dictName;
|
||||
}
|
||||
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 异常日志数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_exception_log")
|
||||
public class SysExceptionLogEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("username")
|
||||
private String username;
|
||||
|
||||
@Column("title")
|
||||
private String title;
|
||||
|
||||
@Column("exception_name")
|
||||
private String exceptionName;
|
||||
|
||||
@Column("method_name")
|
||||
private String methodName;
|
||||
|
||||
@Column("method_params")
|
||||
private String methodParams;
|
||||
|
||||
@Column("exception_msg")
|
||||
private String exceptionMsg;
|
||||
|
||||
@Column("exception_stack")
|
||||
private String exceptionStack;
|
||||
|
||||
@Column("ip")
|
||||
private String ip;
|
||||
|
||||
@Column("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getExceptionName() {
|
||||
return exceptionName;
|
||||
}
|
||||
|
||||
public void setExceptionName(String exceptionName) {
|
||||
this.exceptionName = exceptionName;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public String getMethodParams() {
|
||||
return methodParams;
|
||||
}
|
||||
|
||||
public void setMethodParams(String methodParams) {
|
||||
this.methodParams = methodParams;
|
||||
}
|
||||
|
||||
public String getExceptionMsg() {
|
||||
return exceptionMsg;
|
||||
}
|
||||
|
||||
public void setExceptionMsg(String exceptionMsg) {
|
||||
this.exceptionMsg = exceptionMsg;
|
||||
}
|
||||
|
||||
public String getExceptionStack() {
|
||||
return exceptionStack;
|
||||
}
|
||||
|
||||
public void setExceptionStack(String exceptionStack) {
|
||||
this.exceptionStack = exceptionStack;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 文件管理数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_file")
|
||||
public class SysFileEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("file_name")
|
||||
private String fileName;
|
||||
|
||||
@Column("file_path")
|
||||
private String filePath;
|
||||
|
||||
@Column("file_size")
|
||||
private Long fileSize;
|
||||
|
||||
@Column("file_type")
|
||||
private String fileType;
|
||||
|
||||
@Column("storage_type")
|
||||
private String storageType;
|
||||
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public Long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(Long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
public String getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
public void setFileType(String fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(String storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 登录日志数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_login_log")
|
||||
public class SysLoginLogEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("username")
|
||||
private String username;
|
||||
|
||||
@Column("ip")
|
||||
private String ip;
|
||||
|
||||
@Column("location")
|
||||
private String location;
|
||||
|
||||
@Column("browser")
|
||||
private String browser;
|
||||
|
||||
@Column("os")
|
||||
private String os;
|
||||
|
||||
@Column("status")
|
||||
private String status;
|
||||
|
||||
@Column("message")
|
||||
private String message;
|
||||
|
||||
@Column("login_time")
|
||||
private LocalDateTime loginTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getBrowser() {
|
||||
return browser;
|
||||
}
|
||||
|
||||
public void setBrowser(String browser) {
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(String os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public LocalDateTime getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(LocalDateTime loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 菜单数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_menu")
|
||||
public class SysMenuEntity extends BaseEntity {
|
||||
|
||||
@Column("menu_name")
|
||||
private String menuName;
|
||||
|
||||
@Column("parent_id")
|
||||
private Long parentId;
|
||||
|
||||
@Column("order_num")
|
||||
private Integer orderNum;
|
||||
|
||||
@Column("menu_type")
|
||||
private String menuType;
|
||||
|
||||
@Column("perms")
|
||||
private String perms;
|
||||
|
||||
@Column("component")
|
||||
private String component;
|
||||
|
||||
@Column("status")
|
||||
private Integer status;
|
||||
|
||||
public String getMenuName() {
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName) {
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(String menuType) {
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
public String getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通知公告数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_notice")
|
||||
public class SysNoticeEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("notice_title")
|
||||
private String noticeTitle;
|
||||
|
||||
@Column("notice_type")
|
||||
private String noticeType;
|
||||
|
||||
@Column("notice_content")
|
||||
private String noticeContent;
|
||||
|
||||
@Column("status")
|
||||
private String status;
|
||||
|
||||
@Column("create_by")
|
||||
private String createBy;
|
||||
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@Column("deleted_at")
|
||||
private LocalDateTime deletedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNoticeTitle() {
|
||||
return noticeTitle;
|
||||
}
|
||||
|
||||
public void setNoticeTitle(String noticeTitle) {
|
||||
this.noticeTitle = noticeTitle;
|
||||
}
|
||||
|
||||
public String getNoticeType() {
|
||||
return noticeType;
|
||||
}
|
||||
|
||||
public void setNoticeType(String noticeType) {
|
||||
this.noticeType = noticeType;
|
||||
}
|
||||
|
||||
public String getNoticeContent() {
|
||||
return noticeContent;
|
||||
}
|
||||
|
||||
public void setNoticeContent(String noticeContent) {
|
||||
this.noticeContent = noticeContent;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 权限数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Table("sys_permission")
|
||||
public class SysPermissionEntity extends BaseEntity {
|
||||
|
||||
@Column("permission_name")
|
||||
private String permissionName;
|
||||
|
||||
@Column("permission_code")
|
||||
private String permissionCode;
|
||||
|
||||
@Column("resource")
|
||||
private String resource;
|
||||
|
||||
@Column("action")
|
||||
private String action;
|
||||
|
||||
@Column("description")
|
||||
private String description;
|
||||
|
||||
@Column("status")
|
||||
private Integer status;
|
||||
|
||||
public String getPermissionName() {
|
||||
return permissionName;
|
||||
}
|
||||
|
||||
public void setPermissionName(String permissionName) {
|
||||
this.permissionName = permissionName;
|
||||
}
|
||||
|
||||
public String getPermissionCode() {
|
||||
return permissionCode;
|
||||
}
|
||||
|
||||
public void setPermissionCode(String permissionCode) {
|
||||
this.permissionCode = permissionCode;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 角色数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_role")
|
||||
public class SysRoleEntity extends BaseEntity {
|
||||
|
||||
@Column("role_name")
|
||||
private String roleName;
|
||||
|
||||
@Column("role_key")
|
||||
private String roleKey;
|
||||
|
||||
@Column("role_sort")
|
||||
private Integer roleSort;
|
||||
|
||||
@Column("status")
|
||||
private Integer status;
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleKey() {
|
||||
return roleKey;
|
||||
}
|
||||
|
||||
public void setRoleKey(String roleKey) {
|
||||
this.roleKey = roleKey;
|
||||
}
|
||||
|
||||
public Integer getRoleSort() {
|
||||
return roleSort;
|
||||
}
|
||||
|
||||
public void setRoleSort(Integer roleSort) {
|
||||
this.roleSort = roleSort;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 角色权限关联数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Table("sys_role_permission")
|
||||
public class SysRolePermissionEntity extends BaseEntity {
|
||||
|
||||
@Column("role_id")
|
||||
private Long roleId;
|
||||
|
||||
@Column("permission_id")
|
||||
private Long permissionId;
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getPermissionId() {
|
||||
return permissionId;
|
||||
}
|
||||
|
||||
public void setPermissionId(Long permissionId) {
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* 用户数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_user")
|
||||
public class SysUserEntity extends BaseEntity {
|
||||
|
||||
@Column("username")
|
||||
private String username;
|
||||
|
||||
@Column("password")
|
||||
private String password;
|
||||
|
||||
@Column("email")
|
||||
private String email;
|
||||
|
||||
@Column("phone")
|
||||
private String phone;
|
||||
|
||||
@Column("nickname")
|
||||
private String nickname;
|
||||
|
||||
@Column("role_id")
|
||||
private Long roleId;
|
||||
|
||||
@Column("status")
|
||||
private Integer status;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户消息数据库实体类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Table("sys_user_message")
|
||||
public class SysUserMessageEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("user_id")
|
||||
private Long userId;
|
||||
|
||||
@Column("title")
|
||||
private String title;
|
||||
|
||||
@Column("content")
|
||||
private String content;
|
||||
|
||||
@Column("message_type")
|
||||
private String messageType;
|
||||
|
||||
@Column("is_read")
|
||||
private String isRead;
|
||||
|
||||
@Column("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMessageType() {
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public void setMessageType(String messageType) {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public String getIsRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
||||
public void setIsRead(String isRead) {
|
||||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package cn.novalon.gym.manage.db.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Table("user_role")
|
||||
public class UserRoleEntity {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Column("user_id")
|
||||
private Long userId;
|
||||
|
||||
@Column("role_id")
|
||||
private Long roleId;
|
||||
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column("created_by")
|
||||
private String createdBy;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.OperationLogQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 操作日志查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class OperationLogQueryCriteria {
|
||||
|
||||
@QueryField(propName = "username", type = QueryField.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@QueryField(propName = "operation", type = QueryField.Type.INNER_LIKE)
|
||||
private String operation;
|
||||
|
||||
@QueryField(propName = "status", type = QueryField.Type.EQUAL)
|
||||
private String status;
|
||||
|
||||
@QueryField(blurry = "username,operation,ip", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
@QueryField(propName = "createdAt", type = QueryField.Type.GREATER_THAN)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@QueryField(propName = "createdAt", type = QueryField.Type.LESS_THAN)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@QueryField(propName = "ip", type = QueryField.Type.INNER_LIKE)
|
||||
private String ip;
|
||||
|
||||
@QueryField(propName = "method", type = QueryField.Type.INNER_LIKE)
|
||||
private String method;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(OperationLogQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.username = query.getUsername();
|
||||
this.operation = query.getOperation();
|
||||
this.status = query.getStatus();
|
||||
this.keyword = query.getKeyword();
|
||||
this.startTime = query.getStartTime();
|
||||
this.endTime = query.getEndTime();
|
||||
this.ip = query.getIp();
|
||||
this.method = query.getMethod();
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.SysExceptionLogQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 异常日志查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysExceptionLogQueryCriteria {
|
||||
|
||||
@QueryField(propName = "username", type = QueryField.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@QueryField(propName = "title", type = QueryField.Type.INNER_LIKE)
|
||||
private String title;
|
||||
|
||||
@QueryField(propName = "exceptionName", type = QueryField.Type.INNER_LIKE)
|
||||
private String exceptionName;
|
||||
|
||||
@QueryField(blurry = "username,title,exceptionName,ip", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getExceptionName() {
|
||||
return exceptionName;
|
||||
}
|
||||
|
||||
public void setExceptionName(String exceptionName) {
|
||||
this.exceptionName = exceptionName;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysExceptionLogQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.username = query.getUsername();
|
||||
this.title = query.getTitle();
|
||||
this.exceptionName = query.getExceptionName();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.SysLoginLogQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 登录日志查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysLoginLogQueryCriteria {
|
||||
|
||||
@QueryField(propName = "username", type = QueryField.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@QueryField(propName = "ip", type = QueryField.Type.INNER_LIKE)
|
||||
private String ip;
|
||||
|
||||
@QueryField(propName = "status", type = QueryField.Type.EQUAL)
|
||||
private String status;
|
||||
|
||||
@QueryField(blurry = "username,ip,location", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysLoginLogQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.username = query.getUsername();
|
||||
this.ip = query.getIp();
|
||||
this.status = query.getStatus();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.SysMenuQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 菜单查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysMenuQueryCriteria {
|
||||
|
||||
@QueryField(type = QueryField.Type.INNER_LIKE)
|
||||
private String menuName;
|
||||
|
||||
@QueryField(type = QueryField.Type.EQUAL)
|
||||
private String menuType;
|
||||
|
||||
@QueryField(type = QueryField.Type.EQUAL)
|
||||
private Integer status;
|
||||
|
||||
@QueryField(type = QueryField.Type.EQUAL)
|
||||
private Long parentId;
|
||||
|
||||
@QueryField(blurry = "menuName,perms,component", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public String getMenuName() {
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName) {
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public String getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(String menuType) {
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysMenuQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.menuName = query.getMenuName();
|
||||
this.menuType = query.getMenuType();
|
||||
this.status = query.getStatus();
|
||||
this.parentId = query.getParentId();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.SysRoleQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 角色查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysRoleQueryCriteria {
|
||||
|
||||
@QueryField(propName = "roleName", type = QueryField.Type.INNER_LIKE)
|
||||
private String roleName;
|
||||
|
||||
@QueryField(propName = "roleKey", type = QueryField.Type.INNER_LIKE)
|
||||
private String roleKey;
|
||||
|
||||
@QueryField(propName = "status", type = QueryField.Type.EQUAL)
|
||||
private Integer status;
|
||||
|
||||
@QueryField(blurry = "roleName,roleKey", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleKey() {
|
||||
return roleKey;
|
||||
}
|
||||
|
||||
public void setRoleKey(String roleKey) {
|
||||
this.roleKey = roleKey;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysRoleQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.roleName = query.getRoleName();
|
||||
this.roleKey = query.getRoleKey();
|
||||
this.status = query.getStatus();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.notify.core.query.SysUserMessageQuery;
|
||||
import cn.novalon.gym.manage.db.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 用户消息查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysUserMessageQueryCriteria {
|
||||
|
||||
@QueryField(propName = "userId", type = QueryField.Type.EQUAL)
|
||||
private Long userId;
|
||||
|
||||
@QueryField(propName = "isRead", type = QueryField.Type.EQUAL)
|
||||
private String isRead;
|
||||
|
||||
@QueryField(blurry = "title,content", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getIsRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
||||
public void setIsRead(String isRead) {
|
||||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysUserMessageQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.userId = query.getUserId();
|
||||
this.isRead = query.getIsRead();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
package cn.novalon.gym.manage.db.entity.query;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.query.SysUserQuery;
|
||||
import cn.novalon.gym.manage.common.dao.QueryField;
|
||||
|
||||
/**
|
||||
* 用户查询条件对象
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
public class SysUserQueryCriteria {
|
||||
|
||||
@QueryField(propName = "username", type = QueryField.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@QueryField(propName = "email", type = QueryField.Type.INNER_LIKE)
|
||||
private String email;
|
||||
|
||||
@QueryField(propName = "roleId", type = QueryField.Type.EQUAL)
|
||||
private Long roleId;
|
||||
|
||||
@QueryField(propName = "status", type = QueryField.Type.EQUAL)
|
||||
private Integer status;
|
||||
|
||||
@QueryField(blurry = "username,email", type = QueryField.Type.INNER_LIKE)
|
||||
private String keyword;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convert(SysUserQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.username = query.getUsername();
|
||||
this.email = query.getEmail();
|
||||
this.roleId = query.getRoleId();
|
||||
this.status = query.getStatus();
|
||||
this.keyword = query.getKeyword();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从领域查询对象转换(不包含keyword)
|
||||
*
|
||||
* @param query 领域查询对象
|
||||
*/
|
||||
public void convertWithoutKeyword(SysUserQuery query) {
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
this.username = query.getUsername();
|
||||
this.email = query.getEmail();
|
||||
this.roleId = query.getRoleId();
|
||||
this.status = query.getStatus();
|
||||
this.keyword = null;
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.audit.domain.AuditLog;
|
||||
import cn.novalon.gym.manage.sys.audit.repository.IAuditLogRepository;
|
||||
import cn.novalon.gym.manage.db.converter.AuditLogConverter;
|
||||
import cn.novalon.gym.manage.db.dao.AuditLogDao;
|
||||
import cn.novalon.gym.manage.db.entity.AuditLogEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 审计日志仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-04-08
|
||||
*/
|
||||
@Repository
|
||||
public class AuditLogRepository implements IAuditLogRepository {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuditLogRepository.class);
|
||||
|
||||
private final AuditLogDao auditLogDao;
|
||||
private final AuditLogConverter auditLogConverter;
|
||||
|
||||
public AuditLogRepository(AuditLogDao auditLogDao, AuditLogConverter auditLogConverter) {
|
||||
this.auditLogDao = auditLogDao;
|
||||
this.auditLogConverter = auditLogConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<AuditLog> findById(Long id) {
|
||||
return auditLogDao.findById(id)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<AuditLog> save(AuditLog auditLog) {
|
||||
AuditLogEntity entity = auditLogConverter.toEntity(auditLog);
|
||||
return auditLogDao.save(entity)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return auditLogDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findAll() {
|
||||
return auditLogDao.findByDeletedAtIsNull()
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByEntityType(String entityType) {
|
||||
return auditLogDao.findByEntityTypeAndDeletedAtIsNull(entityType)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByEntityId(Long entityId) {
|
||||
return auditLogDao.findByEntityIdAndDeletedAtIsNull(entityId)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByEntityTypeAndEntityId(String entityType, Long entityId) {
|
||||
return auditLogDao.findByEntityTypeAndEntityIdAndDeletedAtIsNull(entityType, entityId)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByOperator(String operator) {
|
||||
return auditLogDao.findByOperatorAndDeletedAtIsNull(operator)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByOperationType(String operationType) {
|
||||
return auditLogDao.findByOperationTypeAndDeletedAtIsNull(operationType)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByOperationTimeBetween(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return auditLogDao.findByOperationTimeBetweenAndDeletedAtIsNull(startTime, endTime)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByEntityTypeAndOperationTimeBetween(
|
||||
String entityType,
|
||||
LocalDateTime startTime,
|
||||
LocalDateTime endTime
|
||||
) {
|
||||
return auditLogDao.findByEntityTypeAndOperationTimeBetweenAndDeletedAtIsNull(entityType, startTime, endTime)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<AuditLog> findByOperatorAndOperationTimeBetween(
|
||||
String operator,
|
||||
LocalDateTime startTime,
|
||||
LocalDateTime endTime
|
||||
) {
|
||||
return auditLogDao.findByOperatorAndOperationTimeBetweenAndDeletedAtIsNull(operator, startTime, endTime)
|
||||
.map(auditLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByEntityType(String entityType) {
|
||||
return auditLogDao.countByEntityTypeAndDeletedAtIsNull(entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByOperationType(String operationType) {
|
||||
return auditLogDao.countByOperationTypeAndDeletedAtIsNull(operationType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByOperator(String operator) {
|
||||
return auditLogDao.countByOperatorAndDeletedAtIsNull(operator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByOperationTimeBetween(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return auditLogDao.countByOperationTimeBetweenAndDeletedAtIsNull(startTime, endTime);
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.Dictionary;
|
||||
import cn.novalon.gym.manage.sys.core.repository.IDictionaryRepository;
|
||||
import cn.novalon.gym.manage.db.converter.DictionaryConverter;
|
||||
import cn.novalon.gym.manage.db.dao.DictionaryDao;
|
||||
import cn.novalon.gym.manage.db.entity.DictionaryEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 字典仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class DictionaryRepository implements IDictionaryRepository {
|
||||
|
||||
private final DictionaryDao dictionaryDao;
|
||||
private final DictionaryConverter dictionaryConverter;
|
||||
|
||||
public DictionaryRepository(DictionaryDao dictionaryDao, DictionaryConverter dictionaryConverter) {
|
||||
this.dictionaryDao = dictionaryDao;
|
||||
this.dictionaryConverter = dictionaryConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Dictionary> findAll() {
|
||||
return dictionaryDao.findByDeletedAtIsNullOrderBySortAsc()
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Dictionary> findByDeletedAtIsNullOrderBySortAsc() {
|
||||
return dictionaryDao.findByDeletedAtIsNullOrderBySortAsc()
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Dictionary> findById(Long id) {
|
||||
return dictionaryDao.findById(id)
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Dictionary> findByType(String type) {
|
||||
return dictionaryDao.findByType(type)
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Dictionary> findByTypeAndCode(String type, String code) {
|
||||
return dictionaryDao.findByTypeAndCodeAndDeletedAtIsNull(type, code)
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByTypeAndCode(String type, String code) {
|
||||
return dictionaryDao.findByTypeAndCodeAndDeletedAtIsNull(type, code)
|
||||
.map(entity -> true)
|
||||
.defaultIfEmpty(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Dictionary> save(Dictionary dictionary) {
|
||||
DictionaryEntity entity = dictionaryConverter.toEntity(dictionary);
|
||||
return dictionaryDao.save(entity)
|
||||
.map(dictionaryConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return dictionaryDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return dictionaryDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.sys.core.domain.OperationLog;
|
||||
import cn.novalon.gym.manage.sys.core.query.OperationLogQuery;
|
||||
import cn.novalon.gym.manage.sys.core.repository.IOperationLogRepository;
|
||||
import cn.novalon.gym.manage.db.converter.OperationLogConverter;
|
||||
import cn.novalon.gym.manage.db.dao.OperationLogDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.OperationLogEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.OperationLogQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class OperationLogRepository implements IOperationLogRepository {
|
||||
|
||||
private final OperationLogDao operationLogDao;
|
||||
private final OperationLogConverter operationLogConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public OperationLogRepository(OperationLogDao operationLogDao, OperationLogConverter operationLogConverter,
|
||||
R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.operationLogDao = operationLogDao;
|
||||
this.operationLogConverter = operationLogConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<OperationLog> findById(Long id) {
|
||||
return operationLogDao.findById(id)
|
||||
.map(operationLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<OperationLog> save(OperationLog operationLog) {
|
||||
OperationLogEntity entity = operationLogConverter.toEntity(operationLog);
|
||||
return operationLogDao.save(entity)
|
||||
.map(operationLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return operationLogDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<OperationLog> findAll() {
|
||||
return operationLogDao.findByDeletedAtIsNull()
|
||||
.map(operationLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<OperationLog> findByUsername(String username) {
|
||||
return operationLogDao.findByUsernameAndDeletedAtIsNull(username)
|
||||
.map(operationLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<OperationLog>> findByQueryWithPagination(OperationLogQuery query,
|
||||
PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
OperationLogQueryCriteria criteria = new OperationLogQueryCriteria();
|
||||
criteria.convert(query);
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
return r2dbcEntityTemplate.select(OperationLogEntity.class)
|
||||
.matching(dbQuery.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(dbQuery, OperationLogEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<OperationLog> logList = tuple.getT1().stream()
|
||||
.map(operationLogConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(logList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return operationLogDao.countByDeletedAtIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByCreatedAtAfter(LocalDateTime dateTime) {
|
||||
return operationLogDao.countByCreatedAtAfterAndDeletedAtIsNull(dateTime);
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.db.converter.SysConfigConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysConfigDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysConfigEntity;
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysConfig;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysConfigRepository;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 系统配置仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysConfigRepository implements ISysConfigRepository {
|
||||
|
||||
private final SysConfigDao sysConfigDao;
|
||||
private final SysConfigConverter sysConfigConverter;
|
||||
|
||||
public SysConfigRepository(SysConfigDao sysConfigDao, SysConfigConverter sysConfigConverter) {
|
||||
this.sysConfigDao = sysConfigDao;
|
||||
this.sysConfigConverter = sysConfigConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysConfig> findById(Long id) {
|
||||
return sysConfigDao.findById(id)
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysConfig> findByConfigKeyAndDeletedAtIsNull(String configKey) {
|
||||
return sysConfigDao.findByConfigKeyAndDeletedAtIsNull(configKey)
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysConfig> findByDeletedAtIsNull() {
|
||||
return sysConfigDao.findByDeletedAtIsNull()
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysConfig> findAll() {
|
||||
return sysConfigDao.findByDeletedAtIsNull()
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysConfig> findAll(Sort sort) {
|
||||
return sysConfigDao.findByDeletedAtIsNull(sort)
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysConfig> save(SysConfig config) {
|
||||
SysConfigEntity entity = sysConfigConverter.toEntity(config);
|
||||
return sysConfigDao.save(entity)
|
||||
.map(sysConfigConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return sysConfigDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysConfigDao.countByDeletedAtIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByConfigKey(String configKey) {
|
||||
return sysConfigDao.findByConfigKeyAndDeletedAtIsNull(configKey)
|
||||
.map(config -> true)
|
||||
.defaultIfEmpty(false);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictData;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysDictDataRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysDictDataConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysDictDataDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictDataEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 字典数据仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysDictDataRepository implements ISysDictDataRepository {
|
||||
|
||||
private final SysDictDataDao sysDictDataDao;
|
||||
private final SysDictDataConverter sysDictDataConverter;
|
||||
|
||||
public SysDictDataRepository(SysDictDataDao sysDictDataDao, SysDictDataConverter sysDictDataConverter) {
|
||||
this.sysDictDataDao = sysDictDataDao;
|
||||
this.sysDictDataConverter = sysDictDataConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysDictData> findByDeletedAtIsNull() {
|
||||
return sysDictDataDao.findByDeletedAtIsNull()
|
||||
.map(sysDictDataConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysDictData> findByDictTypeAndDeletedAtIsNull(String dictType) {
|
||||
return sysDictDataDao.findByDictTypeAndDeletedAtIsNull(dictType)
|
||||
.map(sysDictDataConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysDictData> findByDictTypeAndStatusAndDeletedAtIsNull(String dictType, String status) {
|
||||
return sysDictDataDao.findByDictTypeAndStatusAndDeletedAtIsNull(dictType, status)
|
||||
.map(sysDictDataConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysDictData> findById(Long id) {
|
||||
return sysDictDataDao.findById(id)
|
||||
.map(sysDictDataConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysDictData> save(SysDictData dictData) {
|
||||
SysDictDataEntity entity = sysDictDataConverter.toEntity(dictData);
|
||||
return sysDictDataDao.save(entity)
|
||||
.map(sysDictDataConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return sysDictDataDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictType;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysDictTypeRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysDictTypeConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysDictTypeDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictTypeEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 字典类型仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysDictTypeRepository implements ISysDictTypeRepository {
|
||||
|
||||
private final SysDictTypeDao sysDictTypeDao;
|
||||
private final SysDictTypeConverter sysDictTypeConverter;
|
||||
|
||||
public SysDictTypeRepository(SysDictTypeDao sysDictTypeDao, SysDictTypeConverter sysDictTypeConverter) {
|
||||
this.sysDictTypeDao = sysDictTypeDao;
|
||||
this.sysDictTypeConverter = sysDictTypeConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysDictType> findByDeletedAtIsNull() {
|
||||
return sysDictTypeDao.findByDeletedAtIsNull()
|
||||
.map(sysDictTypeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysDictType> findById(Long id) {
|
||||
return sysDictTypeDao.findById(id)
|
||||
.map(sysDictTypeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysDictType> findByDictTypeAndDeletedAtIsNull(String dictType) {
|
||||
return sysDictTypeDao.findByDictTypeAndDeletedAtIsNull(dictType)
|
||||
.map(sysDictTypeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysDictType> save(SysDictType dictType) {
|
||||
SysDictTypeEntity entity = sysDictTypeConverter.toEntity(dictType);
|
||||
return sysDictTypeDao.save(entity)
|
||||
.map(sysDictTypeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return sysDictTypeDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysExceptionLog;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysExceptionLogRepository;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.db.converter.SysExceptionLogConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysExceptionLogDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.SysExceptionLogEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysExceptionLogQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 异常日志仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysExceptionLogRepository implements ISysExceptionLogRepository {
|
||||
|
||||
private final SysExceptionLogDao sysExceptionLogDao;
|
||||
private final SysExceptionLogConverter sysExceptionLogConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysExceptionLogRepository(SysExceptionLogDao sysExceptionLogDao,
|
||||
SysExceptionLogConverter sysExceptionLogConverter, R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysExceptionLogDao = sysExceptionLogDao;
|
||||
this.sysExceptionLogConverter = sysExceptionLogConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysExceptionLog> findAllByOrderByCreateTimeDesc() {
|
||||
return sysExceptionLogDao.findAllByOrderByCreateTimeDesc()
|
||||
.map(sysExceptionLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysExceptionLog> findByUsernameOrderByCreateTimeDesc(String username) {
|
||||
SysExceptionLogQueryCriteria criteria = new SysExceptionLogQueryCriteria();
|
||||
criteria.setUsername(username);
|
||||
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysExceptionLogEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysExceptionLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysExceptionLog> findByCreateTimeBetweenOrderByCreateTimeDesc(LocalDateTime startTime,
|
||||
LocalDateTime endTime) {
|
||||
Criteria criteria = Criteria.where("createTime").between(startTime, endTime);
|
||||
Query dbQuery = Query.query(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysExceptionLogEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysExceptionLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysExceptionLog> save(SysExceptionLog exceptionLog) {
|
||||
SysExceptionLogEntity entity = sysExceptionLogConverter.toEntity(exceptionLog);
|
||||
return sysExceptionLogDao.save(entity)
|
||||
.map(sysExceptionLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysExceptionLog> findById(Long id) {
|
||||
return sysExceptionLogDao.findById(id)
|
||||
.map(sysExceptionLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysExceptionLogDao.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<SysExceptionLog>> findExceptionLogsByPage(PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
String keyword = pageRequest.getKeyword();
|
||||
|
||||
SysExceptionLogQueryCriteria criteria = new SysExceptionLogQueryCriteria();
|
||||
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
criteria.setKeyword(keyword);
|
||||
}
|
||||
|
||||
Query queryObj = QueryUtil.getQuery(criteria);
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
} else {
|
||||
sortObj = Sort.by(Sort.Direction.DESC, "createTime");
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysExceptionLogEntity.class)
|
||||
.matching(queryObj.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(queryObj, SysExceptionLogEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<SysExceptionLog> logList = tuple.getT1().stream()
|
||||
.map(sysExceptionLogConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(logList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.file.core.domain.SysFile;
|
||||
import cn.novalon.gym.manage.file.core.repository.ISysFileRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysFileConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysFileDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysFileEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 文件管理仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysFileRepository implements ISysFileRepository {
|
||||
|
||||
private final SysFileDao sysFileDao;
|
||||
private final SysFileConverter sysFileConverter;
|
||||
|
||||
public SysFileRepository(SysFileDao sysFileDao, SysFileConverter sysFileConverter) {
|
||||
this.sysFileDao = sysFileDao;
|
||||
this.sysFileConverter = sysFileConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysFile> findByDeletedAtIsNullOrderByCreatedAtDesc() {
|
||||
return sysFileDao.findByDeletedAtIsNullOrderByCreatedAtDesc()
|
||||
.map(sysFileConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysFile> findByCreateByOrderByCreatedAtDesc(String createBy) {
|
||||
return sysFileDao.findByCreateByOrderByCreatedAtDesc(createBy)
|
||||
.map(sysFileConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysFile> findById(Long id) {
|
||||
return sysFileDao.findById(id)
|
||||
.map(sysFileConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysFile> findByFilePathContaining(String fileName) {
|
||||
return sysFileDao.findByFilePathContaining(fileName)
|
||||
.map(sysFileConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysFile> save(SysFile sysFile) {
|
||||
SysFileEntity entity = sysFileConverter.toEntity(sysFile);
|
||||
return sysFileDao.save(entity)
|
||||
.map(sysFileConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return sysFileDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysLoginLog;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysLoginLogRepository;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.db.converter.SysLoginLogConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysLoginLogDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.SysLoginLogEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysLoginLogQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 登录日志仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysLoginLogRepository implements ISysLoginLogRepository {
|
||||
|
||||
private final SysLoginLogDao sysLoginLogDao;
|
||||
private final SysLoginLogConverter sysLoginLogConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysLoginLogRepository(SysLoginLogDao sysLoginLogDao, SysLoginLogConverter sysLoginLogConverter, R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysLoginLogDao = sysLoginLogDao;
|
||||
this.sysLoginLogConverter = sysLoginLogConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysLoginLog> findAllByOrderByLoginTimeDesc() {
|
||||
return sysLoginLogDao.findAllByOrderByLoginTimeDesc()
|
||||
.map(sysLoginLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysLoginLog> findByUsernameOrderByLoginTimeDesc(String username) {
|
||||
SysLoginLogQueryCriteria criteria = new SysLoginLogQueryCriteria();
|
||||
criteria.setUsername(username);
|
||||
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "loginTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysLoginLogEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysLoginLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysLoginLog> findByLoginTimeBetweenOrderByLoginTimeDesc(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
Criteria criteria = Criteria.where("loginTime").between(startTime, endTime);
|
||||
Query dbQuery = Query.query(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "loginTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysLoginLogEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysLoginLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysLoginLog> save(SysLoginLog loginLog) {
|
||||
SysLoginLogEntity entity = sysLoginLogConverter.toEntity(loginLog);
|
||||
return sysLoginLogDao.save(entity)
|
||||
.map(sysLoginLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysLoginLog> findById(Long id) {
|
||||
return sysLoginLogDao.findById(id)
|
||||
.map(sysLoginLogConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysLoginLogDao.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countToday() {
|
||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
||||
LocalDateTime todayEnd = todayStart.plusDays(1);
|
||||
return findByLoginTimeBetweenOrderByLoginTimeDesc(todayStart, todayEnd).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<SysLoginLog>> findLoginLogsByPage(PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
String keyword = pageRequest.getKeyword();
|
||||
|
||||
SysLoginLogQueryCriteria criteria = new SysLoginLogQueryCriteria();
|
||||
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
criteria.setKeyword(keyword);
|
||||
}
|
||||
|
||||
Query queryObj = QueryUtil.getQuery(criteria);
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
} else {
|
||||
sortObj = Sort.by(Sort.Direction.DESC, "loginTime");
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysLoginLogEntity.class)
|
||||
.matching(queryObj.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(queryObj, SysLoginLogEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<SysLoginLog> logList = tuple.getT1().stream()
|
||||
.map(sysLoginLogConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(logList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysMenu;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysMenuRepository;
|
||||
import cn.novalon.gym.manage.sys.core.query.SysMenuQuery;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.db.converter.SysMenuConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysMenuDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.SysMenuEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysMenuQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysMenuRepository implements ISysMenuRepository {
|
||||
|
||||
private final SysMenuDao sysMenuDao;
|
||||
private final SysMenuConverter sysMenuConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysMenuRepository(SysMenuDao sysMenuDao, SysMenuConverter sysMenuConverter,
|
||||
R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysMenuDao = sysMenuDao;
|
||||
this.sysMenuConverter = sysMenuConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysMenu> findByParentId(Long parentId) {
|
||||
return sysMenuDao.findByParentIdAndDeletedAtIsNull(parentId)
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysMenu> findByParentIdOrderBySort(Long parentId, Sort sort) {
|
||||
return sysMenuDao.findByParentIdAndDeletedAtIsNull(parentId)
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysMenu> findById(Long id) {
|
||||
return sysMenuDao.findByIdAndDeletedAtIsNull(id)
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysMenu> save(SysMenu sysMenu) {
|
||||
SysMenuEntity entity = sysMenuConverter.toEntity(sysMenu);
|
||||
return sysMenuDao.save(entity)
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysMenuDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysMenu> findAll() {
|
||||
return sysMenuDao.findByDeletedAtIsNull()
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysMenu> findAll(Sort sort) {
|
||||
return sysMenuDao.findByDeletedAtIsNull()
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysMenuDao.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<SysMenu>> findByQueryWithPagination(SysMenuQuery query, PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
SysMenuQueryCriteria criteria = new SysMenuQueryCriteria();
|
||||
criteria.convert(query);
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysMenuEntity.class)
|
||||
.matching(dbQuery.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(dbQuery, SysMenuEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<SysMenu> menuList = tuple.getT1().stream()
|
||||
.map(sysMenuConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(menuList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysMenu> findByStatus(String status) {
|
||||
return sysMenuDao.findByDeletedAtIsNull()
|
||||
.map(sysMenuConverter::toDomain);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.notify.core.domain.SysNotice;
|
||||
import cn.novalon.gym.manage.notify.core.repository.ISysNoticeRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysNoticeConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysNoticeDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysNoticeEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 通知公告仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysNoticeRepository implements ISysNoticeRepository {
|
||||
|
||||
private final SysNoticeDao sysNoticeDao;
|
||||
private final SysNoticeConverter sysNoticeConverter;
|
||||
|
||||
public SysNoticeRepository(SysNoticeDao sysNoticeDao, SysNoticeConverter sysNoticeConverter) {
|
||||
this.sysNoticeDao = sysNoticeDao;
|
||||
this.sysNoticeConverter = sysNoticeConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysNotice> findByDeletedAtIsNull() {
|
||||
return sysNoticeDao.findByDeletedAtIsNull()
|
||||
.map(sysNoticeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysNotice> findByStatusAndDeletedAtIsNull(String status) {
|
||||
return sysNoticeDao.findByStatusAndDeletedAtIsNull(status)
|
||||
.map(sysNoticeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysNotice> findById(Long id) {
|
||||
return sysNoticeDao.findById(id)
|
||||
.map(sysNoticeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysNotice> save(SysNotice notice) {
|
||||
SysNoticeEntity entity = sysNoticeConverter.toEntity(notice);
|
||||
return sysNoticeDao.save(entity)
|
||||
.map(sysNoticeConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByIdAndDeletedAtIsNull(Long id) {
|
||||
return sysNoticeDao.deleteByIdAndDeletedAtIsNull(id);
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysPermission;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysPermissionRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysPermissionConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysPermissionDao;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 权限仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Repository
|
||||
public class SysPermissionRepository implements ISysPermissionRepository {
|
||||
|
||||
private final SysPermissionDao sysPermissionDao;
|
||||
private final SysPermissionConverter sysPermissionConverter;
|
||||
|
||||
public SysPermissionRepository(SysPermissionDao sysPermissionDao, SysPermissionConverter sysPermissionConverter) {
|
||||
this.sysPermissionDao = sysPermissionDao;
|
||||
this.sysPermissionConverter = sysPermissionConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysPermission> findById(Long id) {
|
||||
return sysPermissionDao.findByIdAndDeletedAtIsNull(id)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysPermission> findByIdIncludingDeleted(Long id) {
|
||||
return sysPermissionDao.findById(id)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysPermission> save(SysPermission sysPermission) {
|
||||
return sysPermissionDao.save(sysPermissionConverter.toEntity(sysPermission))
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysPermissionDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysPermission> findAll() {
|
||||
return sysPermissionDao.findByDeletedAtIsNull()
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysPermission> findAll(Sort sort) {
|
||||
return sysPermissionDao.findByDeletedAtIsNull(sort)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysPermission> findByPermissionCode(String permissionCode) {
|
||||
return sysPermissionDao.findByPermissionCodeAndDeletedAtIsNull(permissionCode)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysPermissionDao.countByDeletedAtIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByPermissionCode(String permissionCode) {
|
||||
return sysPermissionDao.existsByPermissionCodeAndDeletedAtIsNull(permissionCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysPermission> updatePermission(SysPermission permission) {
|
||||
return sysPermissionDao.save(sysPermissionConverter.toEntity(permission))
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysPermission> findByRoleId(Long roleId) {
|
||||
return sysPermissionDao.findByRoleId(roleId)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysPermission> findByRoleIds(java.util.List<Long> roleIds) {
|
||||
return sysPermissionDao.findByRoleIds(roleIds)
|
||||
.map(sysPermissionConverter::toDomain);
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysRolePermission;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysRolePermissionRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysRolePermissionConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysRolePermissionDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 角色权限关联仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-25
|
||||
*/
|
||||
@Repository
|
||||
public class SysRolePermissionRepository implements ISysRolePermissionRepository {
|
||||
|
||||
private final SysRolePermissionDao sysRolePermissionDao;
|
||||
private final SysRolePermissionConverter sysRolePermissionConverter;
|
||||
|
||||
public SysRolePermissionRepository(SysRolePermissionDao sysRolePermissionDao, SysRolePermissionConverter sysRolePermissionConverter) {
|
||||
this.sysRolePermissionDao = sysRolePermissionDao;
|
||||
this.sysRolePermissionConverter = sysRolePermissionConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRolePermission> save(SysRolePermission rolePermission) {
|
||||
return sysRolePermissionDao.save(sysRolePermissionConverter.toEntity(rolePermission))
|
||||
.map(sysRolePermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysRolePermissionDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByRoleId(Long roleId) {
|
||||
return sysRolePermissionDao.deleteByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByPermissionId(Long permissionId) {
|
||||
return sysRolePermissionDao.deleteByPermissionId(permissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysRolePermission> findByRoleId(Long roleId) {
|
||||
return sysRolePermissionDao.findByRoleId(roleId)
|
||||
.map(sysRolePermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysRolePermission> findByPermissionId(Long permissionId) {
|
||||
return sysRolePermissionDao.findByPermissionId(permissionId)
|
||||
.map(sysRolePermissionConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Long> findPermissionIdsByRoleId(Long roleId) {
|
||||
return sysRolePermissionDao.findPermissionIdsByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Long> findRoleIdsByPermissionId(Long permissionId) {
|
||||
return sysRolePermissionDao.findRoleIdsByPermissionId(permissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByRoleIdAndPermissionIds(Long roleId, java.util.List<Long> permissionIds) {
|
||||
return sysRolePermissionDao.deleteByRoleIdAndPermissionIds(roleId, permissionIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByPermissionIdAndRoleIds(Long permissionId, java.util.List<Long> roleIds) {
|
||||
return sysRolePermissionDao.deleteByPermissionIdAndRoleIds(permissionId, roleIds);
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysRole;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysRoleRepository;
|
||||
import cn.novalon.gym.manage.sys.core.query.SysRoleQuery;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.db.converter.SysRoleConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysRoleDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.SysRoleEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysRoleQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysRoleRepository implements ISysRoleRepository {
|
||||
|
||||
private final SysRoleDao sysRoleDao;
|
||||
private final SysRoleConverter sysRoleConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysRoleRepository(SysRoleDao sysRoleDao, SysRoleConverter sysRoleConverter, R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysRoleDao = sysRoleDao;
|
||||
this.sysRoleConverter = sysRoleConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRole> findById(Long id) {
|
||||
return sysRoleDao.findByIdAndDeletedAtIsNull(id)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRole> findByIdIncludingDeleted(Long id) {
|
||||
return sysRoleDao.findById(id)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRole> save(SysRole sysRole) {
|
||||
SysRoleEntity entity = sysRoleConverter.toEntity(sysRole);
|
||||
return sysRoleDao.save(entity)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysRoleDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysRole> findAll() {
|
||||
return sysRoleDao.findByDeletedAtIsNull()
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysRole> findAll(Sort sort) {
|
||||
return sysRoleDao.findByDeletedAtIsNull(sort)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysRole> findByRoleNameLikeOrRoleKeyLike(String roleName, String roleKey, Sort sort) {
|
||||
SysRoleQueryCriteria criteria = new SysRoleQueryCriteria();
|
||||
criteria.setRoleName(roleName);
|
||||
criteria.setRoleKey(roleKey);
|
||||
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
if (sort != null && sort.isSorted()) {
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
}
|
||||
|
||||
return r2dbcEntityTemplate.select(SysRoleEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysRoleDao.countByDeletedAtIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByRoleNameLikeOrRoleKeyLike(String roleName, String roleKey) {
|
||||
SysRoleQueryCriteria criteria = new SysRoleQueryCriteria();
|
||||
criteria.setRoleName(roleName);
|
||||
criteria.setRoleKey(roleKey);
|
||||
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
return r2dbcEntityTemplate.count(dbQuery, SysRoleEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<SysRole>> findByQueryWithPagination(SysRoleQuery query, PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
SysRoleQueryCriteria criteria = new SysRoleQueryCriteria();
|
||||
criteria.convert(query);
|
||||
Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysRoleEntity.class)
|
||||
.matching(dbQuery.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(dbQuery, SysRoleEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<SysRole> roleList = tuple.getT1().stream()
|
||||
.map(sysRoleConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(roleList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRole> findByRoleName(String roleName) {
|
||||
return sysRoleDao.findByRoleNameAndDeletedAtIsNull(roleName)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByRoleName(String roleName) {
|
||||
return sysRoleDao.existsByRoleNameAndDeletedAtIsNull(roleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysRole> updateRole(SysRole role) {
|
||||
SysRoleEntity entity = sysRoleConverter.toEntity(role);
|
||||
return sysRoleDao.save(entity)
|
||||
.map(sysRoleConverter::toDomain);
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.notify.core.domain.SysUserMessage;
|
||||
import cn.novalon.gym.manage.notify.core.repository.ISysUserMessageRepository;
|
||||
import cn.novalon.gym.manage.db.converter.SysUserMessageConverter;
|
||||
import cn.novalon.gym.manage.db.entity.SysUserMessageEntity;
|
||||
import cn.novalon.gym.manage.db.dao.SysUserMessageDao;
|
||||
import cn.novalon.gym.manage.db.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysUserMessageQueryCriteria;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 用户消息仓储实现类
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysUserMessageRepository implements ISysUserMessageRepository {
|
||||
|
||||
private final SysUserMessageDao sysUserMessageDao;
|
||||
private final SysUserMessageConverter sysUserMessageConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysUserMessageRepository(SysUserMessageDao sysUserMessageDao,
|
||||
SysUserMessageConverter sysUserMessageConverter, R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysUserMessageDao = sysUserMessageDao;
|
||||
this.sysUserMessageConverter = sysUserMessageConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUserMessage> findByUserIdOrderByCreateTimeDesc(Long userId) {
|
||||
SysUserMessageQueryCriteria criteria = new SysUserMessageQueryCriteria();
|
||||
criteria.setUserId(userId);
|
||||
|
||||
org.springframework.data.relational.core.query.Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysUserMessageEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysUserMessageConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUserMessage> findByUserIdAndIsReadOrderByCreateTimeDesc(Long userId, String isRead) {
|
||||
SysUserMessageQueryCriteria criteria = new SysUserMessageQueryCriteria();
|
||||
criteria.setUserId(userId);
|
||||
criteria.setIsRead(isRead);
|
||||
|
||||
org.springframework.data.relational.core.query.Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
|
||||
dbQuery = dbQuery.sort(sort);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysUserMessageEntity.class)
|
||||
.matching(dbQuery)
|
||||
.all()
|
||||
.map(sysUserMessageConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByUserIdAndIsRead(Long userId, String isRead) {
|
||||
SysUserMessageQueryCriteria criteria = new SysUserMessageQueryCriteria();
|
||||
criteria.setUserId(userId);
|
||||
criteria.setIsRead(isRead);
|
||||
|
||||
org.springframework.data.relational.core.query.Query dbQuery = QueryUtil.getQuery(criteria);
|
||||
|
||||
return r2dbcEntityTemplate.count(dbQuery, SysUserMessageEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUserMessage> save(SysUserMessage message) {
|
||||
SysUserMessageEntity entity = sysUserMessageConverter.toEntity(message);
|
||||
return sysUserMessageDao.save(entity)
|
||||
.map(sysUserMessageConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUserMessage> findById(Long id) {
|
||||
return sysUserMessageDao.findById(id)
|
||||
.map(sysUserMessageConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysUserMessageDao.deleteById(id);
|
||||
}
|
||||
}
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.db.converter.SysUserConverter;
|
||||
import cn.novalon.gym.manage.db.dao.SysUserDao;
|
||||
import cn.novalon.gym.manage.db.entity.SysUserEntity;
|
||||
import cn.novalon.gym.manage.db.entity.query.SysUserQueryCriteria;
|
||||
import cn.novalon.gym.manage.common.dao.QueryUtil;
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysUser;
|
||||
import cn.novalon.gym.manage.sys.core.query.SysUserQuery;
|
||||
import cn.novalon.gym.manage.sys.core.repository.ISysUserRepository;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户仓储实现类
|
||||
*
|
||||
* 文件定义:用户数据访问层的仓储实现,负责用户数据的持久化操作
|
||||
* 涉及业务:用户增删改查、分页查询、条件查询、逻辑删除等数据访问业务
|
||||
* 算法:使用R2DBC进行响应式数据库操作,支持分页算法、条件查询算法
|
||||
*
|
||||
* @author 张翔
|
||||
* @date 2026-03-13
|
||||
*/
|
||||
@Repository
|
||||
public class SysUserRepository implements ISysUserRepository {
|
||||
|
||||
private final SysUserDao sysUserDao;
|
||||
private final SysUserConverter sysUserConverter;
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public SysUserRepository(SysUserDao sysUserDao, SysUserConverter sysUserConverter,
|
||||
R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.sysUserDao = sysUserDao;
|
||||
this.sysUserConverter = sysUserConverter;
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUser> findByUsername(String username) {
|
||||
return sysUserDao.findByUsernameAndDeletedAtIsNull(username)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUser> findByEmail(String email) {
|
||||
return sysUserDao.findByEmailAndDeletedAtIsNull(email)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUser> findById(Long id) {
|
||||
return sysUserDao.findByIdAndDeletedAtIsNull(id)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUser> findByIdIncludingDeleted(Long id) {
|
||||
return sysUserDao.findById(id)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SysUser> save(SysUser sysUser) {
|
||||
SysUserEntity entity = sysUserConverter.toEntity(sysUser);
|
||||
return sysUserDao.save(entity)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return sysUserDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUser> findAll() {
|
||||
return sysUserDao.findAll()
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUser> findAll(Sort sort) {
|
||||
return sysUserDao.findAll(sort)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUser> findByDeletedAtIsNull() {
|
||||
return sysUserDao.findByDeletedAtIsNull()
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<SysUser> findByDeletedAtIsNull(Sort sort) {
|
||||
return sysUserDao.findByDeletedAtIsNull(sort)
|
||||
.map(sysUserConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> count() {
|
||||
return sysUserDao.countByDeletedAtIsNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<PageResponse<SysUser>> findByQueryWithPagination(SysUserQuery query, PageRequest pageRequest) {
|
||||
int page = pageRequest.getPage();
|
||||
int size = pageRequest.getSize();
|
||||
String sort = pageRequest.getSort();
|
||||
String order = pageRequest.getOrder();
|
||||
String keyword = pageRequest.getKeyword();
|
||||
|
||||
System.out.println("=== SysUserRepository.findByQueryWithPagination ===");
|
||||
System.out.println("Keyword from pageRequest: " + keyword);
|
||||
|
||||
SysUserQuery sysUserQuery = new SysUserQuery();
|
||||
sysUserQuery.setKeyword(keyword);
|
||||
|
||||
SysUserQueryCriteria criteria = new SysUserQueryCriteria();
|
||||
criteria.convertWithoutKeyword(sysUserQuery);
|
||||
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
criteria.setKeyword(keyword);
|
||||
System.out.println("Set keyword to criteria: " + keyword);
|
||||
}
|
||||
|
||||
System.out.println("Criteria keyword: " + criteria.getKeyword());
|
||||
|
||||
Query queryObj = QueryUtil.getQuery(criteria);
|
||||
System.out.println("Generated query: " + queryObj);
|
||||
|
||||
Sort sortObj = Sort.unsorted();
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
sortObj = Sort.by(Sort.Direction.fromString(order), sort);
|
||||
}
|
||||
|
||||
org.springframework.data.domain.PageRequest pageable = org.springframework.data.domain.PageRequest.of(page,
|
||||
size, sortObj);
|
||||
|
||||
return r2dbcEntityTemplate.select(SysUserEntity.class)
|
||||
.matching(queryObj.with(pageable))
|
||||
.all()
|
||||
.collectList()
|
||||
.zipWith(r2dbcEntityTemplate.count(queryObj, SysUserEntity.class))
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT2();
|
||||
int totalPages = (int) Math.ceil((double) total / size);
|
||||
List<SysUser> userList = tuple.getT1().stream()
|
||||
.map(sysUserConverter::toDomain)
|
||||
.toList();
|
||||
return new PageResponse<>(userList, totalPages, total, page, size);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByUsername(String username) {
|
||||
return sysUserDao.findByUsernameAndDeletedAtIsNull(username)
|
||||
.map(user -> true)
|
||||
.defaultIfEmpty(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> existsByEmail(String email) {
|
||||
return sysUserDao.findByEmailAndDeletedAtIsNull(email)
|
||||
.map(user -> true)
|
||||
.defaultIfEmpty(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> logicalDeleteById(Long id) {
|
||||
return sysUserDao.findById(id)
|
||||
.flatMap(entity -> {
|
||||
entity.setDeletedAt(java.time.LocalDateTime.now());
|
||||
return sysUserDao.save(entity).then();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> logicalDeleteByIds(List<Long> ids) {
|
||||
return Flux.fromIterable(ids)
|
||||
.flatMap(id -> logicalDeleteById(id))
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> restoreById(Long id) {
|
||||
return sysUserDao.findById(id)
|
||||
.flatMap(entity -> {
|
||||
entity.setDeletedAt(null);
|
||||
return sysUserDao.save(entity).then();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> restoreByIds(List<Long> ids) {
|
||||
return Flux.fromIterable(ids)
|
||||
.flatMap(id -> restoreById(id))
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> updateRoleIdToNullByRoleId(Long roleId) {
|
||||
return sysUserDao.findByRoleId(roleId)
|
||||
.flatMap(entity -> {
|
||||
entity.setRoleId(null);
|
||||
return sysUserDao.save(entity);
|
||||
})
|
||||
.then();
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.novalon.gym.manage.db.repository;
|
||||
|
||||
import cn.novalon.gym.manage.db.converter.UserRoleConverter;
|
||||
import cn.novalon.gym.manage.db.dao.UserRoleDao;
|
||||
import cn.novalon.gym.manage.db.entity.UserRoleEntity;
|
||||
import cn.novalon.gym.manage.sys.core.domain.UserRole;
|
||||
import cn.novalon.gym.manage.sys.core.repository.IUserRoleRepository;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Repository
|
||||
public class UserRoleRepository implements IUserRoleRepository {
|
||||
|
||||
private final UserRoleDao userRoleDao;
|
||||
private final UserRoleConverter userRoleConverter;
|
||||
|
||||
public UserRoleRepository(UserRoleDao userRoleDao, UserRoleConverter userRoleConverter) {
|
||||
this.userRoleDao = userRoleDao;
|
||||
this.userRoleConverter = userRoleConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UserRole> save(UserRole userRole) {
|
||||
UserRoleEntity entity = userRoleConverter.toEntity(userRole);
|
||||
return userRoleDao.save(entity)
|
||||
.map(userRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return userRoleDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByUserId(Long userId) {
|
||||
return userRoleDao.deleteByUserId(userId).then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteByRoleId(Long roleId) {
|
||||
return userRoleDao.deleteByRoleId(roleId).then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<UserRole> findByUserId(Long userId) {
|
||||
return userRoleDao.findByUserId(userId, Sort.by(Sort.Direction.DESC, "created_at"))
|
||||
.map(userRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<UserRole> findByRoleId(Long roleId) {
|
||||
return userRoleDao.findByRoleId(roleId, Sort.by(Sort.Direction.DESC, "created_at"))
|
||||
.map(userRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByUserId(Long userId) {
|
||||
return userRoleDao.countByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Long> countByRoleId(Long roleId) {
|
||||
return userRoleDao.countByRoleId(roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<UserRole> findAll() {
|
||||
return userRoleDao.findAll()
|
||||
.map(userRoleConverter::toDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UserRole> findById(Long id) {
|
||||
return userRoleDao.findById(id)
|
||||
.map(userRoleConverter::toDomain);
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
cn.novalon.manage.db.config.RepositoryScanConfig
|
||||
@@ -0,0 +1,9 @@
|
||||
spring:
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: classpath:db/migration
|
||||
baseline-on-migrate: true
|
||||
baseline-version: 0
|
||||
table: flyway_schema_history
|
||||
validate-on-migrate: true
|
||||
out-of-order: false
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
-- Novalon管理系统普通用户角色和数据
|
||||
-- 版本: V10
|
||||
-- 描述: 创建普通用户角色并分配权限
|
||||
|
||||
-- 插入普通用户角色
|
||||
INSERT INTO sys_role (role_name, role_key, role_sort, status, create_by, update_by)
|
||||
VALUES ('普通用户', 'user', 2, 1, 'system', 'system')
|
||||
ON CONFLICT (role_key) DO UPDATE SET
|
||||
role_name = EXCLUDED.role_name,
|
||||
role_sort = EXCLUDED.role_sort,
|
||||
status = EXCLUDED.status;
|
||||
|
||||
-- 为普通用户分配基本权限(查看个人信息、修改密码等)
|
||||
-- 注意:这里只分配基本权限,不包含管理功能权限
|
||||
INSERT INTO sys_permission (permission_name, permission_key, permission_type, parent_id, path, component, icon, sort, status, create_by, update_by)
|
||||
VALUES
|
||||
('个人中心', 'profile', 'MENU', 0, '/profile', 'views/profile/index', 'user', 1, 1, 'system', 'system'),
|
||||
('个人信息', 'profile:info', 'BUTTON', (SELECT id FROM sys_permission WHERE permission_key = 'profile'), '', '', '', 1, 1, 'system', 'system'),
|
||||
('修改密码', 'profile:password', 'BUTTON', (SELECT id FROM sys_permission WHERE permission_key = 'profile'), '', '', '', 2, 1, 'system', 'system')
|
||||
ON CONFLICT (permission_key) DO NOTHING;
|
||||
|
||||
-- 为普通用户角色分配权限
|
||||
INSERT INTO sys_role_permission (role_id, permission_id, create_by, update_by)
|
||||
SELECT
|
||||
r.id as role_id,
|
||||
p.id as permission_id,
|
||||
'system' as create_by,
|
||||
'system' as update_by
|
||||
FROM sys_role r
|
||||
CROSS JOIN sys_permission p
|
||||
WHERE r.role_key = 'user'
|
||||
AND p.permission_key IN ('profile', 'profile:info', 'profile:password')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 将测试用户分配给普通用户角色
|
||||
INSERT INTO user_role (user_id, role_id, create_by, update_by)
|
||||
SELECT
|
||||
u.id as user_id,
|
||||
r.id as role_id,
|
||||
'system' as create_by,
|
||||
'system' as update_by
|
||||
FROM sys_user u
|
||||
CROSS JOIN sys_role r
|
||||
WHERE u.username = 'user' AND r.role_key = 'user'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 重置序列值
|
||||
SELECT setval('sys_role_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_role));
|
||||
SELECT setval('sys_permission_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_permission));
|
||||
SELECT setval('sys_role_permission_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_role_permission));
|
||||
SELECT setval('user_role_id_seq', (SELECT COALESCE(MAX(id), 1) FROM user_role));
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
-- Novalon管理系统测试数据脚本
|
||||
-- 版本: V11
|
||||
-- 描述: 更新测试用户密码为Test@123,插入E2E测试所需数据
|
||||
|
||||
-- 更新admin用户密码为Test@123
|
||||
-- BCrypt哈希值对应明文密码: Test@123
|
||||
UPDATE sys_user
|
||||
SET password = '$2a$12$nZ1EMUpZQljbnEdIKzH72eHlDJKUmHmHppnTTVth/SlHs5VpSAr8C'
|
||||
WHERE username = 'admin';
|
||||
|
||||
-- 更新user用户密码为Test@123
|
||||
UPDATE sys_user
|
||||
SET password = '$2a$12$nZ1EMUpZQljbnEdIKzH72eHlDJKUmHmHppnTTVth/SlHs5VpSAr8C'
|
||||
WHERE username = 'user';
|
||||
|
||||
-- 插入测试角色(如果不存在)
|
||||
INSERT INTO sys_role (role_name, role_key, role_sort, status, create_by, update_by)
|
||||
VALUES
|
||||
('测试管理员', 'test_admin', 2, 1, 'system', 'system'),
|
||||
('普通用户', 'normal_user', 3, 1, 'system', 'system'),
|
||||
('访客', 'guest', 4, 1, 'system', 'system')
|
||||
ON CONFLICT (role_key) DO NOTHING;
|
||||
|
||||
-- 为admin用户分配超级管理员角色
|
||||
INSERT INTO user_role (user_id, role_id, created_by)
|
||||
SELECT 1, id, 'system' FROM sys_role WHERE role_key = 'admin'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 为user用户分配普通用户角色
|
||||
INSERT INTO user_role (user_id, role_id, created_by)
|
||||
SELECT 2, id, 'system' FROM sys_role WHERE role_key = 'normal_user'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 插入E2E测试专用用户
|
||||
-- BCrypt哈希值对应明文密码: Test@123
|
||||
INSERT INTO sys_user (id, username, password, email, phone, nickname, status, create_by, update_by)
|
||||
VALUES
|
||||
(10, 'e2e_test_user', '$2a$12$nZ1EMUpZQljbnEdIKzH72eHlDJKUmHmHppnTTVth/SlHs5VpSAr8C', 'e2e@test.com', '13900139000', 'E2E测试用户', 1, 'system', 'system')
|
||||
ON CONFLICT (username) DO UPDATE SET
|
||||
password = EXCLUDED.password,
|
||||
status = EXCLUDED.status;
|
||||
|
||||
-- 为E2E测试用户分配超级管理员角色
|
||||
INSERT INTO user_role (user_id, role_id, created_by)
|
||||
SELECT 10, id, 'system' FROM sys_role WHERE role_key = 'admin'
|
||||
ON CONFLICT DO NOTHING;
|
||||
@@ -0,0 +1,28 @@
|
||||
-- V14__Fix_menu_data.sql
|
||||
-- 清理测试菜单数据
|
||||
DELETE FROM sys_menu WHERE menu_name LIKE '%测试%' OR menu_name LIKE '%回归%';
|
||||
|
||||
-- 插入一级菜单
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, status, created_at, updated_at) VALUES
|
||||
('系统管理', 0, 1, 'M', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('系统监控', 0, 2, 'M', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('审计日志', 0, 3, 'M', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
|
||||
-- 插入二级菜单(系统管理下)
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, component, perms, status, created_at, updated_at) VALUES
|
||||
('用户管理', (SELECT id FROM sys_menu WHERE menu_name = '系统管理' AND parent_id = 0), 1, 'C', 'system/user/index', 'system:user:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('角色管理', (SELECT id FROM sys_menu WHERE menu_name = '系统管理' AND parent_id = 0), 2, 'C', 'system/role/index', 'system:role:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('菜单管理', (SELECT id FROM sys_menu WHERE menu_name = '系统管理' AND parent_id = 0), 3, 'C', 'system/menu/index', 'system:menu:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('参数配置', (SELECT id FROM sys_menu WHERE menu_name = '系统管理' AND parent_id = 0), 4, 'C', 'system/config/index', 'system:config:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('字典管理', (SELECT id FROM sys_menu WHERE menu_name = '系统管理' AND parent_id = 0), 5, 'C', 'system/dict/index', 'system:dict:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
|
||||
-- 插入二级菜单(系统监控下)
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, component, perms, status, created_at, updated_at) VALUES
|
||||
('文件管理', (SELECT id FROM sys_menu WHERE menu_name = '系统监控' AND parent_id = 0), 1, 'C', 'system/file/index', 'system:file:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('通知公告', (SELECT id FROM sys_menu WHERE menu_name = '系统监控' AND parent_id = 0), 2, 'C', 'system/notice/index', 'system:notice:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
|
||||
-- 插入二级菜单(审计日志下)
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, component, perms, status, created_at, updated_at) VALUES
|
||||
('登录日志', (SELECT id FROM sys_menu WHERE menu_name = '审计日志' AND parent_id = 0), 1, 'C', 'audit/login/index', 'audit:login:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('操作日志', (SELECT id FROM sys_menu WHERE menu_name = '审计日志' AND parent_id = 0), 2, 'C', 'audit/operation/index', 'audit:operation:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||
('异常日志', (SELECT id FROM sys_menu WHERE menu_name = '审计日志' AND parent_id = 0), 3, 'C', 'audit/exception/index', 'audit:exception:list', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||
@@ -0,0 +1,224 @@
|
||||
-- Novalon管理系统数据库初始化脚本
|
||||
-- 版本: V1
|
||||
-- 描述: 创建所有核心表结构
|
||||
-- 用户表
|
||||
CREATE TABLE IF NOT EXISTS sys_user (
|
||||
id BIGINT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(100),
|
||||
phone VARCHAR(20),
|
||||
nickname VARCHAR(100),
|
||||
role_id BIGINT,
|
||||
status INTEGER DEFAULT 1,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 角色表
|
||||
CREATE TABLE IF NOT EXISTS sys_role (
|
||||
id BIGINT PRIMARY KEY,
|
||||
role_name VARCHAR(100) NOT NULL,
|
||||
role_key VARCHAR(100) NOT NULL UNIQUE,
|
||||
role_sort INTEGER DEFAULT 0,
|
||||
status INTEGER DEFAULT 1,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 菜单表(统一使用sys_menu表名)
|
||||
CREATE TABLE IF NOT EXISTS sys_menu (
|
||||
id BIGINT PRIMARY KEY,
|
||||
menu_name VARCHAR(50) NOT NULL,
|
||||
parent_id BIGINT DEFAULT 0,
|
||||
order_num INTEGER DEFAULT 0,
|
||||
menu_type VARCHAR(1) DEFAULT 'C',
|
||||
perms VARCHAR(100),
|
||||
component VARCHAR(200),
|
||||
status INTEGER DEFAULT 1,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 字典类型表
|
||||
CREATE TABLE IF NOT EXISTS sys_dict_type (
|
||||
id BIGINT PRIMARY KEY,
|
||||
dict_name VARCHAR(100) NOT NULL,
|
||||
dict_type VARCHAR(100) NOT NULL UNIQUE,
|
||||
status VARCHAR(1) DEFAULT '0',
|
||||
remark VARCHAR(500),
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 字典数据表
|
||||
CREATE TABLE IF NOT EXISTS sys_dict_data (
|
||||
id BIGINT PRIMARY KEY,
|
||||
dict_sort INTEGER DEFAULT 0,
|
||||
dict_label VARCHAR(100) NOT NULL,
|
||||
dict_value VARCHAR(100) NOT NULL,
|
||||
dict_type VARCHAR(100) NOT NULL,
|
||||
css_class VARCHAR(100),
|
||||
list_class VARCHAR(100),
|
||||
is_default VARCHAR(1) DEFAULT 'N',
|
||||
status VARCHAR(1) DEFAULT '0',
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 字典表(通用字典)
|
||||
CREATE TABLE IF NOT EXISTS sys_dictionary (
|
||||
id BIGINT PRIMARY KEY,
|
||||
type VARCHAR(100) NOT NULL,
|
||||
code VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
value VARCHAR(500),
|
||||
remark VARCHAR(500),
|
||||
sort INTEGER DEFAULT 0,
|
||||
create_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 系统配置表
|
||||
CREATE TABLE IF NOT EXISTS sys_config (
|
||||
id BIGINT PRIMARY KEY,
|
||||
config_name VARCHAR(100) NOT NULL,
|
||||
config_key VARCHAR(100) NOT NULL UNIQUE,
|
||||
config_value VARCHAR(500) NOT NULL,
|
||||
config_type VARCHAR(1) DEFAULT 'N',
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 登录日志表
|
||||
CREATE TABLE IF NOT EXISTS sys_login_log (
|
||||
id BIGINT PRIMARY KEY,
|
||||
username VARCHAR(50),
|
||||
ip VARCHAR(50),
|
||||
location VARCHAR(255),
|
||||
browser VARCHAR(50),
|
||||
os VARCHAR(50),
|
||||
status VARCHAR(1),
|
||||
message VARCHAR(255),
|
||||
login_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
-- 异常日志表
|
||||
CREATE TABLE IF NOT EXISTS sys_exception_log (
|
||||
id BIGINT PRIMARY KEY,
|
||||
username VARCHAR(50),
|
||||
title VARCHAR(100),
|
||||
exception_name VARCHAR(100),
|
||||
method_name VARCHAR(255),
|
||||
method_params TEXT,
|
||||
exception_msg TEXT,
|
||||
exception_stack TEXT,
|
||||
ip VARCHAR(50),
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
-- 操作日志表
|
||||
CREATE TABLE IF NOT EXISTS operation_log (
|
||||
id BIGINT PRIMARY KEY,
|
||||
username VARCHAR(50),
|
||||
operation VARCHAR(100),
|
||||
method VARCHAR(200),
|
||||
params TEXT,
|
||||
result TEXT,
|
||||
ip VARCHAR(50),
|
||||
duration BIGINT,
|
||||
status VARCHAR(1) DEFAULT '0',
|
||||
error_msg TEXT,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 系统公告表
|
||||
CREATE TABLE IF NOT EXISTS sys_notice (
|
||||
id BIGINT PRIMARY KEY,
|
||||
notice_title VARCHAR(50) NOT NULL,
|
||||
notice_type VARCHAR(1) NOT NULL,
|
||||
notice_content TEXT,
|
||||
status VARCHAR(1) DEFAULT '0',
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 用户消息表
|
||||
CREATE TABLE IF NOT EXISTS sys_user_message (
|
||||
id BIGINT PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
notice_id BIGINT,
|
||||
message_title VARCHAR(255),
|
||||
message_content TEXT,
|
||||
is_read VARCHAR(1) DEFAULT '0',
|
||||
read_time TIMESTAMP,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 文件管理表
|
||||
CREATE TABLE IF NOT EXISTS sys_file (
|
||||
id BIGINT PRIMARY KEY,
|
||||
file_name VARCHAR(255) NOT NULL,
|
||||
file_path VARCHAR(500) NOT NULL,
|
||||
file_size BIGINT,
|
||||
file_type VARCHAR(100),
|
||||
file_extension VARCHAR(10),
|
||||
storage_type VARCHAR(50),
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- OAuth2客户端表
|
||||
CREATE TABLE IF NOT EXISTS oauth2_client (
|
||||
id BIGINT PRIMARY KEY,
|
||||
client_id VARCHAR(100) NOT NULL UNIQUE,
|
||||
client_secret VARCHAR(255) NOT NULL,
|
||||
client_name VARCHAR(100),
|
||||
web_server_redirect_uri VARCHAR(500),
|
||||
scope VARCHAR(500),
|
||||
authorized_grant_types VARCHAR(500),
|
||||
access_token_validity_seconds INTEGER,
|
||||
refresh_token_validity_seconds INTEGER,
|
||||
auto_approve VARCHAR(1) DEFAULT 'false',
|
||||
enabled VARCHAR(1) DEFAULT 'true',
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
-- 表注释
|
||||
COMMENT ON TABLE sys_exception_log IS '异常日志表';
|
||||
COMMENT ON COLUMN sys_exception_log.id IS '主键ID';
|
||||
COMMENT ON COLUMN sys_exception_log.username IS '操作用户';
|
||||
COMMENT ON COLUMN sys_exception_log.title IS '异常标题';
|
||||
COMMENT ON COLUMN sys_exception_log.exception_name IS '异常名称';
|
||||
COMMENT ON COLUMN sys_exception_log.method_name IS '方法名称';
|
||||
COMMENT ON COLUMN sys_exception_log.method_params IS '方法参数';
|
||||
COMMENT ON COLUMN sys_exception_log.exception_msg IS '异常消息';
|
||||
COMMENT ON COLUMN sys_exception_log.exception_stack IS '异常堆栈';
|
||||
COMMENT ON COLUMN sys_exception_log.ip IS 'IP地址';
|
||||
COMMENT ON COLUMN sys_exception_log.create_time IS '创建时间';
|
||||
COMMENT ON TABLE sys_menu IS '系统菜单表';
|
||||
COMMENT ON TABLE sys_login_log IS '登录日志表';
|
||||
@@ -0,0 +1,67 @@
|
||||
-- Novalon管理系统初始数据脚本
|
||||
-- 版本: V2
|
||||
-- 描述: 插入必要的初始数据
|
||||
|
||||
-- 插入初始角色
|
||||
INSERT INTO sys_role (role_name, role_key, role_sort, status, create_by, update_by)
|
||||
VALUES ('超级管理员', 'admin', 1, 1, 'system', 'system')
|
||||
ON CONFLICT (role_key) DO NOTHING;
|
||||
|
||||
-- 插入初始管理员用户
|
||||
-- BCrypt哈希值对应明文密码: admin123
|
||||
INSERT INTO sys_user (id, username, password, email, phone, status, create_by, update_by)
|
||||
VALUES (1, 'admin', '$2b$12$SFefXlGRFMA0fvxIufpWPuIAl0OPLgRDoCZPThCvjpiJGPYS8yNYy', 'admin@novalon.com', '13800138000', 1, 'system', 'system')
|
||||
ON CONFLICT (username) DO UPDATE SET
|
||||
password = EXCLUDED.password,
|
||||
status = EXCLUDED.status;
|
||||
|
||||
-- 插入测试用户(用于E2E测试)
|
||||
-- BCrypt哈希值对应明文密码: admin123
|
||||
INSERT INTO sys_user (id, username, password, email, phone, status, create_by, update_by)
|
||||
VALUES (2, 'user', '$2b$12$SFefXlGRFMA0fvxIufpWPuIAl0OPLgRDoCZPThCvjpiJGPYS8yNYy', 'user@novalon.com', '13800138001', 1, 'system', 'system')
|
||||
ON CONFLICT (username) DO UPDATE SET
|
||||
password = EXCLUDED.password,
|
||||
status = EXCLUDED.status;
|
||||
|
||||
-- 插入初始字典类型
|
||||
INSERT INTO sys_dict_type (dict_name, dict_type, status, remark, create_by, update_by)
|
||||
VALUES
|
||||
('用户状态', 'user_status', '0', '用户状态列表', 'system', 'system'),
|
||||
('菜单状态', 'menu_status', '0', '菜单状态列表', 'system', 'system'),
|
||||
('角色状态', 'role_status', '0', '角色状态列表', 'system', 'system'),
|
||||
('系统开关', 'sys_normal_disable', '0', '系统开关列表', 'system', 'system')
|
||||
ON CONFLICT (dict_type) DO NOTHING;
|
||||
|
||||
-- 插入初始字典数据
|
||||
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, update_by)
|
||||
VALUES
|
||||
-- 用户状态
|
||||
(1, '正常', '1', 'user_status', '', 'primary', 'Y', '0', 'system', 'system'),
|
||||
(2, '停用', '0', 'user_status', '', 'danger', 'N', '0', 'system', 'system'),
|
||||
-- 菜单状态
|
||||
(1, '正常', '0', 'menu_status', '', 'primary', 'Y', '0', 'system', 'system'),
|
||||
(2, '停用', '1', 'menu_status', '', 'danger', 'N', '0', 'system', 'system'),
|
||||
-- 角色状态
|
||||
(1, '正常', '0', 'role_status', '', 'primary', 'Y', '0', 'system', 'system'),
|
||||
(2, '停用', '1', 'role_status', '', 'danger', 'N', '0', 'system', 'system'),
|
||||
-- 系统开关
|
||||
(1, '正常', '0', 'sys_normal_disable', '', 'primary', 'Y', '0', 'system', 'system'),
|
||||
(2, '停用', '1', 'sys_normal_disable', '', 'danger', 'N', '0', 'system', 'system')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 插入初始系统配置
|
||||
INSERT INTO sys_config (config_name, config_key, config_value, config_type, create_by, update_by)
|
||||
VALUES
|
||||
('用户管理-用户初始密码', 'sys.user.initPassword', '123456', 'Y', 'system', 'system'),
|
||||
('主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'system', 'system'),
|
||||
('用户自助-验证码开关', 'sys.account.captchaEnabled', 'true', 'Y', 'system', 'system'),
|
||||
('用户自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'system', 'system'),
|
||||
('账号自助-密码验证码', 'sys.account.pwdCaptchaEnabled', 'true', 'Y', 'system', 'system')
|
||||
ON CONFLICT (config_key) DO NOTHING;
|
||||
|
||||
-- 重置序列值
|
||||
SELECT setval('sys_user_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_user));
|
||||
SELECT setval('sys_role_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_role));
|
||||
SELECT setval('sys_dict_type_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_dict_type));
|
||||
SELECT setval('sys_dict_data_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_dict_data));
|
||||
SELECT setval('sys_config_id_seq', (SELECT COALESCE(MAX(id), 1) FROM sys_config));
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
-- 创建用户角色关联表(支持多对多关系)
|
||||
CREATE TABLE IF NOT EXISTS user_role (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL,
|
||||
role_id BIGINT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
created_by VARCHAR(50),
|
||||
CONSTRAINT fk_user_role_user FOREIGN KEY (user_id) REFERENCES sys_user(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_user_role_role FOREIGN KEY (role_id) REFERENCES sys_role(id) ON DELETE CASCADE,
|
||||
CONSTRAINT uk_user_role UNIQUE (user_id, role_id)
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IF NOT EXISTS idx_user_role_user_id ON user_role(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_role_role_id ON user_role(role_id);
|
||||
|
||||
-- 表注释
|
||||
COMMENT ON TABLE user_role IS '用户角色关联表';
|
||||
COMMENT ON COLUMN user_role.id IS '主键ID';
|
||||
COMMENT ON COLUMN user_role.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_role.role_id IS '角色ID';
|
||||
COMMENT ON COLUMN user_role.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN user_role.created_by IS '创建人';
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
-- Novalon管理系统权限功能数据库迁移脚本
|
||||
-- 版本: V4
|
||||
-- 描述: 创建权限管理相关表结构
|
||||
|
||||
-- 权限表
|
||||
CREATE TABLE IF NOT EXISTS sys_permission (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
permission_name VARCHAR(100) NOT NULL,
|
||||
permission_code VARCHAR(100) NOT NULL UNIQUE,
|
||||
resource VARCHAR(200) NOT NULL,
|
||||
action VARCHAR(50) NOT NULL,
|
||||
description VARCHAR(500),
|
||||
status INTEGER DEFAULT 1,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
|
||||
-- 角色权限关联表
|
||||
CREATE TABLE IF NOT EXISTS sys_role_permission (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
role_id BIGINT NOT NULL,
|
||||
permission_id BIGINT NOT NULL,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (role_id) REFERENCES sys_role(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (permission_id) REFERENCES sys_permission(id) ON DELETE CASCADE,
|
||||
UNIQUE (role_id, permission_id)
|
||||
);
|
||||
|
||||
-- 表注释
|
||||
COMMENT ON TABLE sys_permission IS '系统权限表';
|
||||
COMMENT ON COLUMN sys_permission.id IS '主键ID';
|
||||
COMMENT ON COLUMN sys_permission.permission_name IS '权限名称';
|
||||
COMMENT ON COLUMN sys_permission.permission_code IS '权限编码';
|
||||
COMMENT ON COLUMN sys_permission.resource IS '资源路径';
|
||||
COMMENT ON COLUMN sys_permission.action IS '操作类型';
|
||||
COMMENT ON COLUMN sys_permission.description IS '权限描述';
|
||||
COMMENT ON COLUMN sys_permission.status IS '状态:0-禁用,1-正常';
|
||||
COMMENT ON COLUMN sys_permission.create_by IS '创建者';
|
||||
COMMENT ON COLUMN sys_permission.update_by IS '更新者';
|
||||
COMMENT ON COLUMN sys_permission.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN sys_permission.updated_at IS '更新时间';
|
||||
COMMENT ON COLUMN sys_permission.deleted_at IS '删除时间';
|
||||
|
||||
COMMENT ON TABLE sys_role_permission IS '角色权限关联表';
|
||||
COMMENT ON COLUMN sys_role_permission.id IS '主键ID';
|
||||
COMMENT ON COLUMN sys_role_permission.role_id IS '角色ID';
|
||||
COMMENT ON COLUMN sys_role_permission.permission_id IS '权限ID';
|
||||
COMMENT ON COLUMN sys_role_permission.create_by IS '创建者';
|
||||
COMMENT ON COLUMN sys_role_permission.update_by IS '更新者';
|
||||
COMMENT ON COLUMN sys_role_permission.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN sys_role_permission.updated_at IS '更新时间';
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IF NOT EXISTS idx_permission_code ON sys_permission(permission_code);
|
||||
CREATE INDEX IF NOT EXISTS idx_permission_resource ON sys_permission(resource);
|
||||
CREATE INDEX IF NOT EXISTS idx_permission_status ON sys_permission(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_role_permission_role_id ON sys_role_permission(role_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_role_permission_permission_id ON sys_role_permission(permission_id);
|
||||
|
||||
-- 插入初始权限数据
|
||||
INSERT INTO sys_permission (permission_name, permission_code, resource, action, description, status) VALUES
|
||||
('用户查看', 'system:user:view', '/api/users', 'GET', '查看用户列表', 1),
|
||||
('用户创建', 'system:user:create', '/api/users', 'POST', '创建用户', 1),
|
||||
('用户编辑', 'system:user:edit', '/api/users', 'PUT', '编辑用户', 1),
|
||||
('用户删除', 'system:user:delete', '/api/users', 'DELETE', '删除用户', 1),
|
||||
('角色查看', 'system:role:view', '/api/roles', 'GET', '查看角色列表', 1),
|
||||
('角色创建', 'system:role:create', '/api/roles', 'POST', '创建角色', 1),
|
||||
('角色编辑', 'system:role:edit', '/api/roles', 'PUT', '编辑角色', 1),
|
||||
('角色删除', 'system:role:delete', '/api/roles', 'DELETE', '删除角色', 1),
|
||||
('角色分配权限', 'system:role:assign', '/api/roles/*/permissions', 'POST', '为角色分配权限', 1),
|
||||
('权限查看', 'system:permission:view', '/api/permissions', 'GET', '查看权限列表', 1),
|
||||
('权限创建', 'system:permission:create', '/api/permissions', 'POST', '创建权限', 1),
|
||||
('权限编辑', 'system:permission:edit', '/api/permissions', 'PUT', '编辑权限', 1),
|
||||
('权限删除', 'system:permission:delete', '/api/permissions', 'DELETE', '删除权限', 1),
|
||||
('菜单查看', 'system:menu:view', '/api/menus', 'GET', '查看菜单列表', 1),
|
||||
('菜单创建', 'system:menu:create', '/api/menus', 'POST', '创建菜单', 1),
|
||||
('菜单编辑', 'system:menu:edit', '/api/menus', 'PUT', '编辑菜单', 1),
|
||||
('菜单删除', 'system:menu:delete', '/api/menus', 'DELETE', '删除菜单', 1),
|
||||
('字典查看', 'system:dict:view', '/api/dict', 'GET', '查看字典列表', 1),
|
||||
('字典创建', 'system:dict:create', '/api/dict', 'POST', '创建字典', 1),
|
||||
('字典编辑', 'system:dict:edit', '/api/dict', 'PUT', '编辑字典', 1),
|
||||
('字典删除', 'system:dict:delete', '/api/dict', 'DELETE', '删除字典', 1),
|
||||
('配置查看', 'system:config:view', '/api/config', 'GET', '查看系统配置', 1),
|
||||
('配置创建', 'system:config:create', '/api/config', 'POST', '创建系统配置', 1),
|
||||
('配置编辑', 'system:config:edit', '/api/config', 'PUT', '编辑系统配置', 1),
|
||||
('配置删除', 'system:config:delete', '/api/config', 'DELETE', '删除系统配置', 1),
|
||||
('日志查看', 'system:log:view', '/api/logs', 'GET', '查看日志', 1),
|
||||
('文件上传', 'system:file:upload', '/api/files/upload', 'POST', '上传文件', 1),
|
||||
('文件下载', 'system:file:download', '/api/files/download', 'GET', '下载文件', 1),
|
||||
('文件删除', 'system:file:delete', '/api/files', 'DELETE', '删除文件', 1),
|
||||
('公告查看', 'system:notice:view', '/api/notices', 'GET', '查看公告', 1),
|
||||
('公告创建', 'system:notice:create', '/api/notices', 'POST', '创建公告', 1),
|
||||
('公告编辑', 'system:notice:edit', '/api/notices', 'PUT', '编辑公告', 1),
|
||||
('公告删除', 'system:notice:delete', '/api/notices', 'DELETE', '删除公告', 1);
|
||||
|
||||
-- 为管理员角色分配所有权限
|
||||
INSERT INTO sys_role_permission (role_id, permission_id)
|
||||
SELECT 1, id FROM sys_permission WHERE status = 1;
|
||||
@@ -0,0 +1,78 @@
|
||||
-- Novalon管理系统索引优化脚本
|
||||
-- 版本: V5
|
||||
-- 描述: 为表创建必要的索引以提升查询性能
|
||||
|
||||
-- 用户表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_users_username ON sys_user(username);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_email ON sys_user(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_status ON sys_user(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_deleted_at ON sys_user(deleted_at);
|
||||
|
||||
-- 角色表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_roles_role_key ON sys_role(role_key);
|
||||
CREATE INDEX IF NOT EXISTS idx_roles_status ON sys_role(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_roles_deleted_at ON sys_role(deleted_at);
|
||||
|
||||
-- 菜单表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_menu_parent_id ON sys_menu(parent_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_menu_status ON sys_menu(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_menu_deleted_at ON sys_menu(deleted_at);
|
||||
|
||||
-- 字典类型表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_type_dict_type ON sys_dict_type(dict_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_type_status ON sys_dict_type(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_type_deleted_at ON sys_dict_type(deleted_at);
|
||||
|
||||
-- 字典数据表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_data_dict_type ON sys_dict_data(dict_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_data_dict_value ON sys_dict_data(dict_value);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_data_status ON sys_dict_data(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dict_data_deleted_at ON sys_dict_data(deleted_at);
|
||||
|
||||
-- 字典表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dictionary_type ON sys_dictionary(type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dictionary_type_code ON sys_dictionary(type, code);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_dictionary_deleted_at ON sys_dictionary(deleted_at);
|
||||
|
||||
-- 系统配置表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_config_config_key ON sys_config(config_key);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_config_config_type ON sys_config(config_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_config_deleted_at ON sys_config(deleted_at);
|
||||
|
||||
-- 登录日志表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_login_log_username ON sys_login_log(username);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_login_log_ip ON sys_login_log(ip);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_login_log_status ON sys_login_log(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_login_log_login_time ON sys_login_log(login_time);
|
||||
|
||||
-- 异常日志表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_exception_log_username ON sys_exception_log(username);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_exception_log_exception_name ON sys_exception_log(exception_name);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_exception_log_create_time ON sys_exception_log(create_time);
|
||||
|
||||
-- 操作日志表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_operation_log_username ON operation_log(username);
|
||||
CREATE INDEX IF NOT EXISTS idx_operation_log_operation ON operation_log(operation);
|
||||
CREATE INDEX IF NOT EXISTS idx_operation_log_created_at ON operation_log(created_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_operation_log_status ON operation_log(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_operation_log_deleted_at ON operation_log(deleted_at);
|
||||
|
||||
-- 系统公告表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_notice_notice_type ON sys_notice(notice_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_notice_status ON sys_notice(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_notice_deleted_at ON sys_notice(deleted_at);
|
||||
|
||||
-- 用户消息表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_user_message_user_id ON sys_user_message(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_user_message_notice_id ON sys_user_message(notice_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_user_message_is_read ON sys_user_message(is_read);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_user_message_deleted_at ON sys_user_message(deleted_at);
|
||||
|
||||
-- 文件管理表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_file_file_type ON sys_file(file_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_sys_file_deleted_at ON sys_file(deleted_at);
|
||||
|
||||
-- OAuth2客户端表索引
|
||||
CREATE INDEX IF NOT EXISTS idx_oauth2_client_client_id ON oauth2_client(client_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_oauth2_client_enabled ON oauth2_client(enabled);
|
||||
CREATE INDEX IF NOT EXISTS idx_oauth2_client_deleted_at ON oauth2_client(deleted_at);
|
||||
@@ -0,0 +1,90 @@
|
||||
-- 系统菜单初始化数据
|
||||
-- 版本: V6
|
||||
-- 描述: 初始化系统菜单数据
|
||||
|
||||
-- 一级菜单
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(1, 0, '系统管理', 1, 'M', NULL, NULL, 1, NOW(), NOW()),
|
||||
(2, 0, '审计日志', 2, 'M', NULL, NULL, 1, NOW(), NOW()),
|
||||
(3, 0, '系统监控', 3, 'M', NULL, NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 系统管理子菜单
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(11, 1, '用户管理', 1, 'C', 'system:user:list', 'system/user/index', 1, NOW(), NOW()),
|
||||
(12, 1, '角色管理', 2, 'C', 'system:role:list', 'system/role/index', 1, NOW(), NOW()),
|
||||
(13, 1, '菜单管理', 3, 'C', 'system:menu:list', 'system/menu/index', 1, NOW(), NOW()),
|
||||
(14, 1, '部门管理', 4, 'C', 'system:dept:list', 'system/dept/index', 1, NOW(), NOW()),
|
||||
(15, 1, '字典管理', 5, 'C', 'system:dict:list', 'system/dict/index', 1, NOW(), NOW()),
|
||||
(16, 1, '参数管理', 6, 'C', 'system:config:list', 'system/config/index', 1, NOW(), NOW()),
|
||||
(17, 1, '通知公告', 7, 'C', 'system:notice:list', 'system/notice/index', 1, NOW(), NOW()),
|
||||
(18, 1, '文件管理', 8, 'C', 'system:file:list', 'system/file/index', 1, NOW(), NOW());
|
||||
|
||||
-- 用户管理按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(111, 11, '用户查询', 1, 'F', 'system:user:query', NULL, 1, NOW(), NOW()),
|
||||
(112, 11, '用户新增', 2, 'F', 'system:user:add', NULL, 1, NOW(), NOW()),
|
||||
(113, 11, '用户修改', 3, 'F', 'system:user:edit', NULL, 1, NOW(), NOW()),
|
||||
(114, 11, '用户删除', 4, 'F', 'system:user:remove', NULL, 1, NOW(), NOW()),
|
||||
(115, 11, '用户导出', 5, 'F', 'system:user:export', NULL, 1, NOW(), NOW()),
|
||||
(116, 11, '用户导入', 6, 'F', 'system:user:import', NULL, 1, NOW(), NOW()),
|
||||
(117, 11, '重置密码', 7, 'F', 'system:user:resetPwd', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 角色管理按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(121, 12, '角色查询', 1, 'F', 'system:role:query', NULL, 1, NOW(), NOW()),
|
||||
(122, 12, '角色新增', 2, 'F', 'system:role:add', NULL, 1, NOW(), NOW()),
|
||||
(123, 12, '角色修改', 3, 'F', 'system:role:edit', NULL, 1, NOW(), NOW()),
|
||||
(124, 12, '角色删除', 4, 'F', 'system:role:remove', NULL, 1, NOW(), NOW()),
|
||||
(125, 12, '角色导出', 5, 'F', 'system:role:export', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 菜单管理按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(131, 13, '菜单查询', 1, 'F', 'system:menu:query', NULL, 1, NOW(), NOW()),
|
||||
(132, 13, '菜单新增', 2, 'F', 'system:menu:add', NULL, 1, NOW(), NOW()),
|
||||
(133, 13, '菜单修改', 3, 'F', 'system:menu:edit', NULL, 1, NOW(), NOW()),
|
||||
(134, 13, '菜单删除', 4, 'F', 'system:menu:remove', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 审计日志子菜单
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(21, 2, '操作日志', 1, 'C', 'audit:operation:list', 'audit/operation/index', 1, NOW(), NOW()),
|
||||
(22, 2, '登录日志', 2, 'C', 'audit:login:list', 'audit/login/index', 1, NOW(), NOW()),
|
||||
(23, 2, '异常日志', 3, 'C', 'audit:exception:list', 'audit/exception/index', 1, NOW(), NOW());
|
||||
|
||||
-- 操作日志按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(211, 21, '操作查询', 1, 'F', 'audit:operation:query', NULL, 1, NOW(), NOW()),
|
||||
(212, 21, '操作删除', 2, 'F', 'audit:operation:remove', NULL, 1, NOW(), NOW()),
|
||||
(213, 21, '操作导出', 3, 'F', 'audit:operation:export', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 登录日志按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(221, 22, '登录查询', 1, 'F', 'audit:login:query', NULL, 1, NOW(), NOW()),
|
||||
(222, 22, '登录删除', 2, 'F', 'audit:login:remove', NULL, 1, NOW(), NOW()),
|
||||
(223, 22, '登录导出', 3, 'F', 'audit:login:export', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 异常日志按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(231, 23, '异常查询', 1, 'F', 'audit:exception:query', NULL, 1, NOW(), NOW()),
|
||||
(232, 23, '异常删除', 2, 'F', 'audit:exception:remove', NULL, 1, NOW(), NOW()),
|
||||
(233, 23, '异常导出', 3, 'F', 'audit:exception:export', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 系统监控子菜单
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(31, 3, '在线用户', 1, 'C', 'monitor:online:list', 'monitor/online/index', 1, NOW(), NOW()),
|
||||
(32, 3, '定时任务', 2, 'C', 'monitor:job:list', 'monitor/job/index', 1, NOW(), NOW()),
|
||||
(33, 3, '数据监控', 3, 'C', 'monitor:data:list', 'monitor/data/index', 1, NOW(), NOW()),
|
||||
(34, 3, '服务监控', 4, 'C', 'monitor:server:list', 'monitor/server/index', 1, NOW(), NOW()),
|
||||
(35, 3, '缓存监控', 5, 'C', 'monitor:cache:list', 'monitor/cache/index', 1, NOW(), NOW());
|
||||
|
||||
-- 在线用户按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(311, 31, '在线查询', 1, 'F', 'monitor:online:query', NULL, 1, NOW(), NOW()),
|
||||
(312, 31, '在线强退', 2, 'F', 'monitor:online:forceLogout', NULL, 1, NOW(), NOW());
|
||||
|
||||
-- 定时任务按钮权限
|
||||
INSERT INTO sys_menu (id, parent_id, menu_name, order_num, menu_type, perms, component, status, created_at, updated_at) VALUES
|
||||
(321, 32, '任务查询', 1, 'F', 'monitor:job:query', NULL, 1, NOW(), NOW()),
|
||||
(322, 32, '任务新增', 2, 'F', 'monitor:job:add', NULL, 1, NOW(), NOW()),
|
||||
(323, 32, '任务修改', 3, 'F', 'monitor:job:edit', NULL, 1, NOW(), NOW()),
|
||||
(324, 32, '任务删除', 4, 'F', 'monitor:job:remove', NULL, 1, NOW(), NOW()),
|
||||
(325, 32, '任务执行', 5, 'F', 'monitor:job:execute', NULL, 1, NOW(), NOW());
|
||||
@@ -0,0 +1,40 @@
|
||||
-- Novalon管理系统审计日志表
|
||||
-- 版本: V7
|
||||
-- 描述: 创建审计日志表,记录数据变更前后的完整对比
|
||||
CREATE TABLE IF NOT EXISTS audit_log (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
entity_type VARCHAR(100) NOT NULL,
|
||||
entity_id BIGINT,
|
||||
operation_type VARCHAR(20) NOT NULL,
|
||||
operator VARCHAR(100),
|
||||
operation_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
before_data JSONB,
|
||||
after_data JSONB,
|
||||
changed_fields TEXT [],
|
||||
ip_address VARCHAR(50),
|
||||
user_agent TEXT,
|
||||
description TEXT,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_audit_log_entity_type ON audit_log(entity_type);
|
||||
CREATE INDEX idx_audit_log_entity_id ON audit_log(entity_id);
|
||||
CREATE INDEX idx_audit_log_operation_type ON audit_log(operation_type);
|
||||
CREATE INDEX idx_audit_log_operator ON audit_log(operator);
|
||||
CREATE INDEX idx_audit_log_operation_time ON audit_log(operation_time);
|
||||
CREATE INDEX idx_audit_log_entity ON audit_log(entity_type, entity_id);
|
||||
COMMENT ON TABLE audit_log IS '审计日志表';
|
||||
COMMENT ON COLUMN audit_log.id IS '主键ID';
|
||||
COMMENT ON COLUMN audit_log.entity_type IS '实体类型(如User, Role等)';
|
||||
COMMENT ON COLUMN audit_log.entity_id IS '实体ID';
|
||||
COMMENT ON COLUMN audit_log.operation_type IS '操作类型(CREATE, UPDATE, DELETE)';
|
||||
COMMENT ON COLUMN audit_log.operator IS '操作人';
|
||||
COMMENT ON COLUMN audit_log.operation_time IS '操作时间';
|
||||
COMMENT ON COLUMN audit_log.before_data IS '变更前数据(JSON格式)';
|
||||
COMMENT ON COLUMN audit_log.after_data IS '变更后数据(JSON格式)';
|
||||
COMMENT ON COLUMN audit_log.changed_fields IS '变更字段列表';
|
||||
COMMENT ON COLUMN audit_log.ip_address IS 'IP地址';COMMENT ON COLUMN audit_log.description IS '操作描述';
|
||||
COMMENT ON COLUMN audit_log.created_at IS '记录创建时间';
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
-- Novalon管理系统审计日志归档表
|
||||
-- 版本: V8
|
||||
-- 描述: 创建审计日志归档表,用于存储历史审计日志
|
||||
|
||||
CREATE TABLE IF NOT EXISTS audit_log_archive (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
entity_type VARCHAR(100) NOT NULL,
|
||||
entity_id BIGINT,
|
||||
operation_type VARCHAR(20) NOT NULL,
|
||||
operator VARCHAR(100),
|
||||
operation_time TIMESTAMP,
|
||||
before_data JSONB,
|
||||
after_data JSONB,
|
||||
changed_fields TEXT[],
|
||||
ip_address VARCHAR(50),
|
||||
user_agent TEXT,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP,
|
||||
archived_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX idx_audit_log_archive_entity_type ON audit_log_archive(entity_type);
|
||||
CREATE INDEX idx_audit_log_archive_entity_id ON audit_log_archive(entity_id);
|
||||
CREATE INDEX idx_audit_log_archive_operation_type ON audit_log_archive(operation_type);
|
||||
CREATE INDEX idx_audit_log_archive_operator ON audit_log_archive(operator);
|
||||
CREATE INDEX idx_audit_log_archive_operation_time ON audit_log_archive(operation_time);
|
||||
CREATE INDEX idx_audit_log_archive_archived_at ON audit_log_archive(archived_at);
|
||||
|
||||
COMMENT ON TABLE audit_log_archive IS '审计日志归档表';
|
||||
COMMENT ON COLUMN audit_log_archive.id IS '主键ID';
|
||||
COMMENT ON COLUMN audit_log_archive.entity_type IS '实体类型(如User, Role等)';
|
||||
COMMENT ON COLUMN audit_log_archive.entity_id IS '实体ID';
|
||||
COMMENT ON COLUMN audit_log_archive.operation_type IS '操作类型(CREATE, UPDATE, DELETE)';
|
||||
COMMENT ON COLUMN audit_log_archive.operator IS '操作人';
|
||||
COMMENT ON COLUMN audit_log_archive.operation_time IS '操作时间';
|
||||
COMMENT ON COLUMN audit_log_archive.before_data IS '变更前数据(JSON格式)';
|
||||
COMMENT ON COLUMN audit_log_archive.after_data IS '变更后数据(JSON格式)';
|
||||
COMMENT ON COLUMN audit_log_archive.changed_fields IS '变更字段列表';
|
||||
COMMENT ON COLUMN audit_log_archive.ip_address IS 'IP地址';
|
||||
COMMENT ON COLUMN audit_log_archive.user_agent IS '用户代理';
|
||||
COMMENT ON COLUMN audit_log_archive.description IS '操作描述';
|
||||
COMMENT ON COLUMN audit_log_archive.created_at IS '记录创建时间';
|
||||
COMMENT ON COLUMN audit_log_archive.archived_at IS '归档时间';
|
||||
@@ -0,0 +1,13 @@
|
||||
-- Novalon管理系统权限授予脚本
|
||||
-- 版本: V9
|
||||
-- 描述: 为novalon用户授予所有表的访问权限
|
||||
|
||||
-- 授予所有表的SELECT, INSERT, UPDATE, DELETE权限
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO novalon;
|
||||
|
||||
-- 授予所有序列的使用权限
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO novalon;
|
||||
|
||||
-- 设置默认权限,使未来创建的表自动授予novalon用户权限
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO novalon;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO novalon;
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package cn.novalon.gym.manage.db.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FlywayMigrationScriptTest {
|
||||
|
||||
@Test
|
||||
void testMigrationScriptsExist() throws IOException {
|
||||
Path migrationDir = Paths.get("src/main/resources/db/migration");
|
||||
|
||||
assertTrue(Files.exists(migrationDir), "Migration directory should exist");
|
||||
|
||||
List<Path> sqlFiles = Files.list(migrationDir)
|
||||
.filter(p -> p.toString().endsWith(".sql"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertFalse(sqlFiles.isEmpty(), "Should have migration scripts");
|
||||
|
||||
System.out.println("Found migration scripts:");
|
||||
sqlFiles.forEach(p -> System.out.println(" - " + p.getFileName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMigrationScriptNaming() throws IOException {
|
||||
Path migrationDir = Paths.get("src/main/resources/db/migration");
|
||||
|
||||
List<Path> sqlFiles = Files.list(migrationDir)
|
||||
.filter(p -> p.toString().endsWith(".sql"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Path file : sqlFiles) {
|
||||
String filename = file.getFileName().toString();
|
||||
assertTrue(filename.matches("V\\d+__.*\\.sql"),
|
||||
"Migration script should follow Flyway naming convention: " + filename);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMigrationScriptContent() throws IOException {
|
||||
Path migrationDir = Paths.get("src/main/resources/db/migration");
|
||||
|
||||
List<Path> sqlFiles = Files.list(migrationDir)
|
||||
.filter(p -> p.toString().endsWith(".sql"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (Path file : sqlFiles) {
|
||||
String content = Files.readString(file);
|
||||
assertNotNull(content, "Migration script should have content: " + file.getFileName());
|
||||
assertFalse(content.trim().isEmpty(), "Migration script should not be empty: " + file.getFileName());
|
||||
|
||||
if (content.contains("CREATE TABLE")) {
|
||||
assertTrue(content.contains("IF NOT EXISTS"),
|
||||
"CREATE TABLE statements should use IF NOT EXISTS: " + file.getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMigrationScriptVersionOrder() throws IOException {
|
||||
Path migrationDir = Paths.get("src/main/resources/db/migration");
|
||||
|
||||
List<Path> sqlFiles = Files.list(migrationDir)
|
||||
.filter(p -> p.toString().endsWith(".sql"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Integer> versions = sqlFiles.stream()
|
||||
.map(p -> {
|
||||
String filename = p.getFileName().toString();
|
||||
String versionStr = filename.substring(1, filename.indexOf("__"));
|
||||
return Integer.parseInt(versionStr);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (int i = 1; i < versions.size(); i++) {
|
||||
assertTrue(versions.get(i) > versions.get(i - 1),
|
||||
"Migration versions should be in ascending order");
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.Dictionary;
|
||||
import cn.novalon.gym.manage.db.entity.DictionaryEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DictionaryConverterTest {
|
||||
|
||||
private DictionaryConverter converter;
|
||||
private DictionaryEntity testEntity;
|
||||
private Dictionary testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new DictionaryConverter();
|
||||
|
||||
testEntity = new DictionaryEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setType("user_status");
|
||||
testEntity.setCode("active");
|
||||
testEntity.setName("正常");
|
||||
testEntity.setValue("0");
|
||||
testEntity.setRemark("用户正常状态");
|
||||
testEntity.setSort(1);
|
||||
testEntity.setCreateBy("admin");
|
||||
testEntity.setCreatedAt(LocalDateTime.now());
|
||||
testEntity.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
testDomain = new Dictionary();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setType("user_status");
|
||||
testDomain.setCode("active");
|
||||
testDomain.setName("正常");
|
||||
testDomain.setValue("0");
|
||||
testDomain.setRemark("用户正常状态");
|
||||
testDomain.setSort(1);
|
||||
testDomain.setCreateBy("admin");
|
||||
testDomain.setCreatedAt(LocalDateTime.now());
|
||||
testDomain.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
Dictionary result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getType()).isEqualTo(testEntity.getType());
|
||||
assertThat(result.getCode()).isEqualTo(testEntity.getCode());
|
||||
assertThat(result.getName()).isEqualTo(testEntity.getName());
|
||||
assertThat(result.getValue()).isEqualTo(testEntity.getValue());
|
||||
assertThat(result.getRemark()).isEqualTo(testEntity.getRemark());
|
||||
assertThat(result.getSort()).isEqualTo(testEntity.getSort());
|
||||
assertThat(result.getCreateBy()).isEqualTo(testEntity.getCreateBy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
DictionaryEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getType()).isEqualTo(testDomain.getType());
|
||||
assertThat(result.getCode()).isEqualTo(testDomain.getCode());
|
||||
assertThat(result.getName()).isEqualTo(testDomain.getName());
|
||||
assertThat(result.getValue()).isEqualTo(testDomain.getValue());
|
||||
assertThat(result.getRemark()).isEqualTo(testDomain.getRemark());
|
||||
assertThat(result.getSort()).isEqualTo(testDomain.getSort());
|
||||
assertThat(result.getCreateBy()).isEqualTo(testDomain.getCreateBy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
Dictionary result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
DictionaryEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.OperationLog;
|
||||
import cn.novalon.gym.manage.db.entity.OperationLogEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class OperationLogConverterTest {
|
||||
|
||||
private OperationLogConverter converter;
|
||||
private OperationLogEntity testEntity;
|
||||
private OperationLog testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new OperationLogConverter();
|
||||
|
||||
testEntity = new OperationLogEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setUsername("admin");
|
||||
testEntity.setOperation("用户登录");
|
||||
testEntity.setMethod("login");
|
||||
testEntity.setParams("{\"username\":\"admin\"}");
|
||||
testEntity.setResult("success");
|
||||
testEntity.setIp("127.0.0.1");
|
||||
testEntity.setDuration(100L);
|
||||
testEntity.setStatus("0");
|
||||
testEntity.setErrorMsg(null);
|
||||
testEntity.setCreatedAt(LocalDateTime.now());
|
||||
testEntity.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
testDomain = new OperationLog();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setUsername("admin");
|
||||
testDomain.setOperation("用户登录");
|
||||
testDomain.setMethod("login");
|
||||
testDomain.setParams("{\"username\":\"admin\"}");
|
||||
testDomain.setResult("success");
|
||||
testDomain.setIp("127.0.0.1");
|
||||
testDomain.setDuration(100L);
|
||||
testDomain.setStatus("0");
|
||||
testDomain.setErrorMsg(null);
|
||||
testDomain.setCreatedAt(LocalDateTime.now());
|
||||
testDomain.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
OperationLog result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getUsername()).isEqualTo(testEntity.getUsername());
|
||||
assertThat(result.getOperation()).isEqualTo(testEntity.getOperation());
|
||||
assertThat(result.getMethod()).isEqualTo(testEntity.getMethod());
|
||||
assertThat(result.getParams()).isEqualTo(testEntity.getParams());
|
||||
assertThat(result.getResult()).isEqualTo(testEntity.getResult());
|
||||
assertThat(result.getIp()).isEqualTo(testEntity.getIp());
|
||||
assertThat(result.getDuration()).isEqualTo(testEntity.getDuration());
|
||||
assertThat(result.getStatus()).isEqualTo(testEntity.getStatus());
|
||||
assertThat(result.getErrorMsg()).isEqualTo(testEntity.getErrorMsg());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
OperationLogEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getUsername()).isEqualTo(testDomain.getUsername());
|
||||
assertThat(result.getOperation()).isEqualTo(testDomain.getOperation());
|
||||
assertThat(result.getMethod()).isEqualTo(testDomain.getMethod());
|
||||
assertThat(result.getParams()).isEqualTo(testDomain.getParams());
|
||||
assertThat(result.getResult()).isEqualTo(testDomain.getResult());
|
||||
assertThat(result.getIp()).isEqualTo(testDomain.getIp());
|
||||
assertThat(result.getDuration()).isEqualTo(testDomain.getDuration());
|
||||
assertThat(result.getStatus()).isEqualTo(testDomain.getStatus());
|
||||
assertThat(result.getErrorMsg()).isEqualTo(testDomain.getErrorMsg());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
OperationLog result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
OperationLogEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysConfig;
|
||||
import cn.novalon.gym.manage.db.entity.SysConfigEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SysConfigConverterTest {
|
||||
|
||||
private SysConfigConverter converter;
|
||||
private SysConfigEntity testEntity;
|
||||
private SysConfig testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new SysConfigConverter();
|
||||
|
||||
testEntity = new SysConfigEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setConfigName("系统名称");
|
||||
testEntity.setConfigKey("system.name");
|
||||
testEntity.setConfigValue("Novalon管理系统");
|
||||
testEntity.setConfigType("string");
|
||||
testEntity.setCreatedAt(LocalDateTime.now());
|
||||
testEntity.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
testDomain = new SysConfig();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setConfigName("系统名称");
|
||||
testDomain.setConfigKey("system.name");
|
||||
testDomain.setConfigValue("Novalon管理系统");
|
||||
testDomain.setConfigType("string");
|
||||
testDomain.setCreatedAt(LocalDateTime.now());
|
||||
testDomain.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
SysConfig result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getConfigName()).isEqualTo(testEntity.getConfigName());
|
||||
assertThat(result.getConfigKey()).isEqualTo(testEntity.getConfigKey());
|
||||
assertThat(result.getConfigValue()).isEqualTo(testEntity.getConfigValue());
|
||||
assertThat(result.getConfigType()).isEqualTo(testEntity.getConfigType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
SysConfigEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getConfigName()).isEqualTo(testDomain.getConfigName());
|
||||
assertThat(result.getConfigKey()).isEqualTo(testDomain.getConfigKey());
|
||||
assertThat(result.getConfigValue()).isEqualTo(testDomain.getConfigValue());
|
||||
assertThat(result.getConfigType()).isEqualTo(testDomain.getConfigType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
SysConfig result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
SysConfigEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictData;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictDataEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SysDictDataConverterTest {
|
||||
|
||||
private SysDictDataConverter converter;
|
||||
private SysDictDataEntity testEntity;
|
||||
private SysDictData testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new SysDictDataConverter();
|
||||
|
||||
testEntity = new SysDictDataEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setDictSort(1);
|
||||
testEntity.setDictLabel("正常");
|
||||
testEntity.setDictValue("0");
|
||||
testEntity.setDictType("user_status");
|
||||
testEntity.setCssClass("default");
|
||||
testEntity.setListClass("default");
|
||||
testEntity.setIsDefault("Y");
|
||||
testEntity.setStatus("0");
|
||||
testEntity.setCreatedAt(LocalDateTime.now());
|
||||
testEntity.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
testDomain = new SysDictData();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setDictSort(1);
|
||||
testDomain.setDictLabel("正常");
|
||||
testDomain.setDictValue("0");
|
||||
testDomain.setDictType("user_status");
|
||||
testDomain.setCssClass("default");
|
||||
testDomain.setListClass("default");
|
||||
testDomain.setIsDefault("Y");
|
||||
testDomain.setStatus("0");
|
||||
testDomain.setCreatedAt(LocalDateTime.now());
|
||||
testDomain.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
SysDictData result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getDictSort()).isEqualTo(testEntity.getDictSort());
|
||||
assertThat(result.getDictLabel()).isEqualTo(testEntity.getDictLabel());
|
||||
assertThat(result.getDictValue()).isEqualTo(testEntity.getDictValue());
|
||||
assertThat(result.getDictType()).isEqualTo(testEntity.getDictType());
|
||||
assertThat(result.getCssClass()).isEqualTo(testEntity.getCssClass());
|
||||
assertThat(result.getListClass()).isEqualTo(testEntity.getListClass());
|
||||
assertThat(result.getIsDefault()).isEqualTo(testEntity.getIsDefault());
|
||||
assertThat(result.getStatus()).isEqualTo(testEntity.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
SysDictDataEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getDictSort()).isEqualTo(testDomain.getDictSort());
|
||||
assertThat(result.getDictLabel()).isEqualTo(testDomain.getDictLabel());
|
||||
assertThat(result.getDictValue()).isEqualTo(testDomain.getDictValue());
|
||||
assertThat(result.getDictType()).isEqualTo(testDomain.getDictType());
|
||||
assertThat(result.getCssClass()).isEqualTo(testDomain.getCssClass());
|
||||
assertThat(result.getListClass()).isEqualTo(testDomain.getListClass());
|
||||
assertThat(result.getIsDefault()).isEqualTo(testDomain.getIsDefault());
|
||||
assertThat(result.getStatus()).isEqualTo(testDomain.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
SysDictData result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
SysDictDataEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysDictType;
|
||||
import cn.novalon.gym.manage.db.entity.SysDictTypeEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SysDictTypeConverterTest {
|
||||
|
||||
private SysDictTypeConverter converter;
|
||||
private SysDictTypeEntity testEntity;
|
||||
private SysDictType testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new SysDictTypeConverter();
|
||||
|
||||
testEntity = new SysDictTypeEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setDictName("用户状态");
|
||||
testEntity.setDictType("user_status");
|
||||
testEntity.setStatus("1");
|
||||
testEntity.setRemark("用户状态字典");
|
||||
testEntity.setCreatedAt(LocalDateTime.now());
|
||||
testEntity.setUpdatedAt(LocalDateTime.now());
|
||||
|
||||
testDomain = new SysDictType();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setDictName("用户状态");
|
||||
testDomain.setDictType("user_status");
|
||||
testDomain.setStatus("1");
|
||||
testDomain.setRemark("用户状态字典");
|
||||
testDomain.setCreatedAt(LocalDateTime.now());
|
||||
testDomain.setUpdatedAt(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
SysDictType result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getDictName()).isEqualTo(testEntity.getDictName());
|
||||
assertThat(result.getDictType()).isEqualTo(testEntity.getDictType());
|
||||
assertThat(result.getStatus()).isEqualTo(testEntity.getStatus());
|
||||
assertThat(result.getRemark()).isEqualTo(testEntity.getRemark());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
SysDictTypeEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getDictName()).isEqualTo(testDomain.getDictName());
|
||||
assertThat(result.getDictType()).isEqualTo(testDomain.getDictType());
|
||||
assertThat(result.getStatus()).isEqualTo(testDomain.getStatus());
|
||||
assertThat(result.getRemark()).isEqualTo(testDomain.getRemark());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
SysDictType result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
SysDictTypeEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.novalon.gym.manage.db.converter;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.SysExceptionLog;
|
||||
import cn.novalon.gym.manage.db.entity.SysExceptionLogEntity;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SysExceptionLogConverterTest {
|
||||
|
||||
private SysExceptionLogConverter converter;
|
||||
private SysExceptionLogEntity testEntity;
|
||||
private SysExceptionLog testDomain;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new SysExceptionLogConverter();
|
||||
|
||||
testEntity = new SysExceptionLogEntity();
|
||||
testEntity.setId(1L);
|
||||
testEntity.setUsername("admin");
|
||||
testEntity.setTitle("系统异常");
|
||||
testEntity.setExceptionName("NullPointerException");
|
||||
testEntity.setMethodName("getUserById");
|
||||
testEntity.setMethodParams("{\"id\":1}");
|
||||
testEntity.setExceptionMsg("空指针异常");
|
||||
testEntity.setExceptionStack("java.lang.NullPointerException\n\tat...");
|
||||
testEntity.setIp("127.0.0.1");
|
||||
testEntity.setCreateTime(LocalDateTime.now());
|
||||
|
||||
testDomain = new SysExceptionLog();
|
||||
testDomain.setId(1L);
|
||||
testDomain.setUsername("admin");
|
||||
testDomain.setTitle("系统异常");
|
||||
testDomain.setExceptionName("NullPointerException");
|
||||
testDomain.setMethodName("getUserById");
|
||||
testDomain.setMethodParams("{\"id\":1}");
|
||||
testDomain.setExceptionMsg("空指针异常");
|
||||
testDomain.setExceptionStack("java.lang.NullPointerException\n\tat...");
|
||||
testDomain.setIp("127.0.0.1");
|
||||
testDomain.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomain() {
|
||||
SysExceptionLog result = converter.toDomain(testEntity);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testEntity.getId());
|
||||
assertThat(result.getUsername()).isEqualTo(testEntity.getUsername());
|
||||
assertThat(result.getTitle()).isEqualTo(testEntity.getTitle());
|
||||
assertThat(result.getExceptionName()).isEqualTo(testEntity.getExceptionName());
|
||||
assertThat(result.getMethodName()).isEqualTo(testEntity.getMethodName());
|
||||
assertThat(result.getMethodParams()).isEqualTo(testEntity.getMethodParams());
|
||||
assertThat(result.getExceptionMsg()).isEqualTo(testEntity.getExceptionMsg());
|
||||
assertThat(result.getExceptionStack()).isEqualTo(testEntity.getExceptionStack());
|
||||
assertThat(result.getIp()).isEqualTo(testEntity.getIp());
|
||||
assertThat(result.getCreateTime()).isEqualTo(testEntity.getCreateTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntity() {
|
||||
SysExceptionLogEntity result = converter.toEntity(testDomain);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getId()).isEqualTo(testDomain.getId());
|
||||
assertThat(result.getUsername()).isEqualTo(testDomain.getUsername());
|
||||
assertThat(result.getTitle()).isEqualTo(testDomain.getTitle());
|
||||
assertThat(result.getExceptionName()).isEqualTo(testDomain.getExceptionName());
|
||||
assertThat(result.getMethodName()).isEqualTo(testDomain.getMethodName());
|
||||
assertThat(result.getMethodParams()).isEqualTo(testDomain.getMethodParams());
|
||||
assertThat(result.getExceptionMsg()).isEqualTo(testDomain.getExceptionMsg());
|
||||
assertThat(result.getExceptionStack()).isEqualTo(testDomain.getExceptionStack());
|
||||
assertThat(result.getIp()).isEqualTo(testDomain.getIp());
|
||||
assertThat(result.getCreateTime()).isEqualTo(testDomain.getCreateTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToDomainWithNull() {
|
||||
SysExceptionLog result = converter.toDomain(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToEntityWithNull() {
|
||||
SysExceptionLogEntity result = converter.toEntity(null);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user