15 Commits

Author SHA1 Message Date
8460b9da29 修改部分 jsr305 注解的使用。 2023-04-16 00:08:04 +08:00
19fc97362c 更改 Exception Handler 版本。 2023-04-16 00:06:36 +08:00
d91f818c96 Merge remote-tracking branch 'origin/main' into main 2023-04-15 22:06:58 +08:00
0e0d6f1808 plusone-commons 做了调整。 2023-04-15 05:24:03 +08:00
06ffc8d858 避免实例化。 2023-04-04 00:32:25 +08:00
60b4f18e8c 更改 hutool 版本。 2023-04-04 00:27:53 +08:00
2b282039ad 更新 plusone-validator 和 plusone-exception-handler。 2023-04-04 00:24:31 +08:00
ea7a8ee6a0 Merge pull request '整合多次更改' (#1) from dev into main
Reviewed-on: http://zhouxy.xyz:3000/ZhouXY108/plusone-admin/pulls/1
2023-03-29 18:54:03 +08:00
67313938e1 提交代码。 2023-03-28 15:41:15 +08:00
27be582bfb 升级 Spring Boot 版本。 2023-03-28 15:40:49 +08:00
33d3d86393 Merge branch 'dev' into main 2023-02-25 00:32:34 +08:00
1b551eeb4c Merge branch 'dev' into main 2023-02-17 15:57:05 +08:00
1611bf38e8 Merge branch 'dev' into main 2023-01-28 17:37:12 +08:00
17273b0bc6 Merge pull request 'dev' (#3) from dev into master
Reviewed-on: http://zhouxy.xyz:3000/ZhouXY108/plusone-admin/pulls/3
2022-12-17 22:55:06 +08:00
2d02899372 Merge pull request 'dev' (#1) from dev into master
Reviewed-on: http://zhouxy.xyz:3000/ZhouXY108/plusone-admin/pulls/1
2022-12-10 03:46:53 +08:00
19 changed files with 79 additions and 45 deletions

View File

@@ -1,10 +1,13 @@
package xyz.zhouxy.plusone.exception.handler; package xyz.zhouxy.plusone.exception.handler;
import javax.annotation.Nonnull;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler.ExceptionInfoHolder; import xyz.zhouxy.plusone.commons.exception.handler.AllExceptionHandler;
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler.ExceptionInfoHolder;
/** /**
* AllExceptionHandlerConfig * AllExceptionHandlerConfig
@@ -14,7 +17,7 @@ import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler.ExceptionInfoHo
public class AllExceptionHandlerConfig { public class AllExceptionHandlerConfig {
@Bean @Bean
AllExceptionHandler getAllExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { AllExceptionHandler getAllExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
return new AllExceptionHandler(exceptionInfoHolder); return new AllExceptionHandler(exceptionInfoHolder);
} }
} }

View File

@@ -1,5 +1,7 @@
package xyz.zhouxy.plusone.exception.handler; package xyz.zhouxy.plusone.exception.handler;
import javax.annotation.Nonnull;
import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@@ -11,7 +13,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.util.RestfulResult; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.exception.handler.RestfulResult;
/** /**
* 默认异常的处理器 * 默认异常的处理器
@@ -40,7 +43,7 @@ import xyz.zhouxy.plusone.commons.util.RestfulResult;
@Order(Ordered.LOWEST_PRECEDENCE - 1) @Order(Ordered.LOWEST_PRECEDENCE - 1)
@Slf4j @Slf4j
public class DefaultExceptionHandler extends BaseExceptionHandler { public class DefaultExceptionHandler extends BaseExceptionHandler {
public DefaultExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { public DefaultExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
super(exceptionInfoHolder); super(exceptionInfoHolder);
set(IllegalArgumentException.class, 4010000, "格式错误", HttpStatus.FORBIDDEN); set(IllegalArgumentException.class, 4010000, "格式错误", HttpStatus.FORBIDDEN);
set(DataAccessException.class, 6030000, "数据库错误", HttpStatus.INTERNAL_SERVER_ERROR, true); set(DataAccessException.class, 6030000, "数据库错误", HttpStatus.INTERNAL_SERVER_ERROR, true);

View File

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.util.RestfulResult; import xyz.zhouxy.plusone.commons.util.RestfulResult;
import xyz.zhouxy.plusone.exception.SysException; import xyz.zhouxy.plusone.exception.SysException;
@@ -15,7 +16,7 @@ import xyz.zhouxy.plusone.exception.SysException;
@Slf4j @Slf4j
public class SysExceptionHandler extends BaseExceptionHandler { public class SysExceptionHandler extends BaseExceptionHandler {
public SysExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { public SysExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
super(exceptionInfoHolder); super(exceptionInfoHolder);
} }

View File

@@ -44,12 +44,12 @@
<dependency> <dependency>
<groupId>xyz.zhouxy.plusone</groupId> <groupId>xyz.zhouxy.plusone</groupId>
<artifactId>plusone-validator</artifactId> <artifactId>plusone-validator</artifactId>
<version>0.1.2-SNAPSHOT</version> <version>0.1.3-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>xyz.zhouxy.plusone</groupId> <groupId>xyz.zhouxy.plusone</groupId>
<artifactId>plusone-exception-handler</artifactId> <artifactId>plusone-exception-handler</artifactId>
<version>0.0.7-SNAPSHOT</version> <version>0.0.9-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -2,4 +2,8 @@ package xyz.zhouxy.plusone.constant;
public class ErrorCodeConsts { public class ErrorCodeConsts {
public static final int DEFAULT_ERROR_CODE = 9999999; public static final int DEFAULT_ERROR_CODE = 9999999;
private ErrorCodeConsts() {
throw new IllegalStateException("Utility class");
}
} }

View File

@@ -1,5 +1,9 @@
package xyz.zhouxy.plusone.constant; package xyz.zhouxy.plusone.constant;
import java.util.Collection;
import javax.annotation.Nonnull;
import xyz.zhouxy.plusone.commons.util.Enumeration; import xyz.zhouxy.plusone.commons.util.Enumeration;
/** /**
@@ -9,24 +13,22 @@ import xyz.zhouxy.plusone.commons.util.Enumeration;
*/ */
public final class EntityStatus extends Enumeration<EntityStatus> { public final class EntityStatus extends Enumeration<EntityStatus> {
private EntityStatus(int value, String name) { private EntityStatus(int id, @Nonnull String name) {
super(value, name); super(id, name);
} }
// 常量 // 常量
public static final EntityStatus AVAILABLE = new EntityStatus(0, "正常"); public static final EntityStatus AVAILABLE = new EntityStatus(0, "正常");
public static final EntityStatus DISABLED = new EntityStatus(1, "禁用"); public static final EntityStatus DISABLED = new EntityStatus(1, "禁用");
private static final EnumerationValuesHolder<EntityStatus> ENUMERATION_VALUES = new EnumerationValuesHolder<>( private static final ValueSet<EntityStatus> VALUE_SET = new ValueSet<>(
AVAILABLE, AVAILABLE, DISABLED);
DISABLED);
public static EntityStatus of(int value) { public static EntityStatus of(int id) {
return ENUMERATION_VALUES.get(value); return VALUE_SET.get(id);
} }
@Override public static Collection<EntityStatus> constants() {
public String toString() { return VALUE_SET.getValues();
return "EntityStatus" + super.toString();
} }
} }

View File

@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import xyz.zhouxy.plusone.constant.ErrorCodeConsts; import xyz.zhouxy.plusone.constant.ErrorCodeConsts;
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler.ExceptionInfoHolder; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler.ExceptionInfoHolder;
@Configuration @Configuration
public class PlusoneExceptionHandlerConfig { public class PlusoneExceptionHandlerConfig {

View File

@@ -1,13 +1,15 @@
package xyz.zhouxy.plusone.validator; package xyz.zhouxy.plusone.validator;
import javax.annotation.Nonnull;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
@RestControllerAdvice @RestControllerAdvice
public class InvalidInputExceptionHandler extends BaseExceptionHandler { public class InvalidInputExceptionHandler extends BaseExceptionHandler {
public InvalidInputExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { public InvalidInputExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
super(exceptionInfoHolder); super(exceptionInfoHolder);
set(InvalidInputException.class, InvalidInputException.ERROR_CODE, "无效的用户输入"); set(InvalidInputException.class, InvalidInputException.ERROR_CODE, "无效的用户输入");
} }

View File

@@ -1,5 +1,7 @@
package xyz.zhouxy.plusone; package xyz.zhouxy.plusone;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -25,6 +27,7 @@ class TestAop {
command.setPrincipal("Code108"); command.setPrincipal("Code108");
command.setPassword("2333"); command.setPassword("2333");
command.setRememberMe(false); command.setRememberMe(false);
assertNotNull(service);
LoginInfoViewObject loginInfo = service.loginByPassword(command); LoginInfoViewObject loginInfo = service.loginByPassword(command);
System.err.println(loginInfo); System.err.println(loginInfo);
} }

View File

@@ -6,14 +6,14 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.system.application.exception.AccountLoginException; import xyz.zhouxy.plusone.system.application.exception.AccountLoginException;
import xyz.zhouxy.plusone.commons.util.RestfulResult; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.exception.handler.RestfulResult;
@RestControllerAdvice @RestControllerAdvice
public class AccountLoginExceptionHandler extends BaseExceptionHandler { public class AccountLoginExceptionHandler extends BaseExceptionHandler {
public AccountLoginExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { public AccountLoginExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
super(exceptionInfoHolder); super(exceptionInfoHolder);
} }

View File

@@ -1,5 +1,7 @@
package xyz.zhouxy.plusone.system.application.exception.handler; package xyz.zhouxy.plusone.system.application.exception.handler;
import javax.annotation.Nonnull;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -14,8 +16,8 @@ import cn.dev33.satoken.exception.NotSafeException;
import cn.dev33.satoken.exception.SaTokenException; import cn.dev33.satoken.exception.SaTokenException;
import cn.dev33.satoken.exception.SameTokenInvalidException; import cn.dev33.satoken.exception.SameTokenInvalidException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
import xyz.zhouxy.plusone.commons.util.RestfulResult; import xyz.zhouxy.plusone.commons.exception.handler.RestfulResult;
/** /**
* Sa-Token 异常处理器 * Sa-Token 异常处理器
@@ -27,7 +29,7 @@ import xyz.zhouxy.plusone.commons.util.RestfulResult;
public class SaTokenExceptionHandler extends BaseExceptionHandler { public class SaTokenExceptionHandler extends BaseExceptionHandler {
public SaTokenExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { public SaTokenExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
super(exceptionInfoHolder); super(exceptionInfoHolder);
set(NotPermissionException.class, 4030103, "会话未能通过权限认证", HttpStatus.FORBIDDEN); set(NotPermissionException.class, 4030103, "会话未能通过权限认证", HttpStatus.FORBIDDEN);
set(NotRoleException.class, 4030103, "会话未能通过角色认证", HttpStatus.FORBIDDEN); set(NotRoleException.class, 4030103, "会话未能通过角色认证", HttpStatus.FORBIDDEN);

View File

@@ -2,6 +2,8 @@ package xyz.zhouxy.plusone.system.application.query;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import xyz.zhouxy.plusone.commons.util.PageDTO; import xyz.zhouxy.plusone.commons.util.PageDTO;
@@ -23,6 +25,7 @@ public interface AccountQueries {
return PageDTO.of(content, total); return PageDTO.of(content, total);
} }
@Nonnull
List<AccountOverview> queryAccountOverview(AccountQueryParams queryParams); List<AccountOverview> queryAccountOverview(AccountQueryParams queryParams);
long count(AccountQueryParams queryParams); long count(AccountQueryParams queryParams);

View File

@@ -109,7 +109,7 @@ public class MenuViewObject implements IWithOrderNumber {
viewObject.icon = menu.getIcon(); viewObject.icon = menu.getIcon();
viewObject.hidden = menu.isHidden(); viewObject.hidden = menu.isHidden();
viewObject.orderNumber = menu.getOrderNumber(); viewObject.orderNumber = menu.getOrderNumber();
viewObject.status = menu.getStatus().getValue(); viewObject.status = menu.getStatus().getId();
viewObject.remarks = menu.getRemarks(); viewObject.remarks = menu.getRemarks();
if (viewObject.type == MenuType.MENU_ITEM.ordinal()) { if (viewObject.type == MenuType.MENU_ITEM.ordinal()) {
viewObject.component = menu.getComponent(); viewObject.component = menu.getComponent();

View File

@@ -1,5 +1,9 @@
package xyz.zhouxy.plusone.system.domain.model.account; package xyz.zhouxy.plusone.system.domain.model.account;
import java.util.Collection;
import javax.annotation.Nonnull;
import lombok.Getter; import lombok.Getter;
import xyz.zhouxy.plusone.commons.util.Enumeration; import xyz.zhouxy.plusone.commons.util.Enumeration;
import xyz.zhouxy.plusone.domain.IValueObject; import xyz.zhouxy.plusone.domain.IValueObject;
@@ -12,18 +16,22 @@ import xyz.zhouxy.plusone.domain.IValueObject;
@Getter @Getter
public final class AccountStatus extends Enumeration<AccountStatus> implements IValueObject { public final class AccountStatus extends Enumeration<AccountStatus> implements IValueObject {
private AccountStatus(int value, String name) { private AccountStatus(int id, @Nonnull String name) {
super(value, name); super(id, name);
} }
public static final AccountStatus AVAILABLE = new AccountStatus(0, "账号正常"); public static final AccountStatus AVAILABLE = new AccountStatus(0, "账号正常");
public static final AccountStatus LOCKED = new AccountStatus(1, "账号被锁定"); public static final AccountStatus LOCKED = new AccountStatus(1, "账号被锁定");
private static final EnumerationValuesHolder<AccountStatus> ENUMERATION_VALUES = new EnumerationValuesHolder<>( private static final ValueSet<AccountStatus> VALUE_SET = new ValueSet<>(
AVAILABLE, AVAILABLE,
LOCKED); LOCKED);
public static AccountStatus of(int value) { public static AccountStatus of(int id) {
return ENUMERATION_VALUES.get(value); return VALUE_SET.get(id);
}
public static Collection<AccountStatus> constants() {
return VALUE_SET.getValues();
} }
} }

View File

@@ -1,5 +1,7 @@
package xyz.zhouxy.plusone.system.domain.model.account; package xyz.zhouxy.plusone.system.domain.model.account;
import java.util.Collection;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import xyz.zhouxy.plusone.commons.util.Enumeration; import xyz.zhouxy.plusone.commons.util.Enumeration;
@@ -18,16 +20,17 @@ public final class Sex extends Enumeration<Sex> implements IValueObject {
@Nonnull @Nonnull
public static final Sex FEMALE = new Sex(2, "女性"); public static final Sex FEMALE = new Sex(2, "女性");
private Sex(int value, String name) { private Sex(int id, @Nonnull String name) {
super(value, name); super(id, name);
} }
private static EnumerationValuesHolder<Sex> values = new EnumerationValuesHolder<>( private static final ValueSet<Sex> VALUE_SET = new ValueSet<>(UNSET, MALE, FEMALE);
UNSET,
MALE,
FEMALE);
public static Sex of(int value) { public static Sex of(int value) {
return values.get(value); return VALUE_SET.get(value);
}
public static Collection<Sex> constants() {
return VALUE_SET.getValues();
} }
} }

View File

@@ -206,9 +206,9 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
.addValue("password", entity.getPassword().value()) .addValue("password", entity.getPassword().value())
.addValue("salt", entity.getPassword().getSalt()) .addValue("salt", entity.getPassword().getSalt())
.addValue("avatar", accountInfo.getAvatar().toString()) .addValue("avatar", accountInfo.getAvatar().toString())
.addValue("sex", accountInfo.getSex().getValue()) .addValue("sex", accountInfo.getSex().getId())
.addValue("nickname", getValueOrNull(accountInfo.getNickname())) .addValue("nickname", getValueOrNull(accountInfo.getNickname()))
.addValue("status", entity.getStatus().getValue()) .addValue("status", entity.getStatus().getId())
.addValue("createdBy", entity.getCreatedBy()) .addValue("createdBy", entity.getCreatedBy())
.addValue("createTime", now) .addValue("createTime", now)
.addValue("updatedBy", entity.getUpdatedBy()) .addValue("updatedBy", entity.getUpdatedBy())

View File

@@ -188,7 +188,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport<Menu, Long> implem
.addValue("icon", entity.getIcon()) .addValue("icon", entity.getIcon())
.addValue("hidden", entity.isHidden()) .addValue("hidden", entity.isHidden())
.addValue("orderNumber", entity.getOrderNumber()) .addValue("orderNumber", entity.getOrderNumber())
.addValue("status", entity.getStatus().getValue()) .addValue("status", entity.getStatus().getId())
.addValue("remarks", entity.getRemarks()) .addValue("remarks", entity.getRemarks())
.addValue("component", entity.getComponent()) .addValue("component", entity.getComponent())
.addValue("cache", entity.getCache()) .addValue("cache", entity.getCache())

View File

@@ -135,7 +135,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport<Role, Long> implem
.addValue("id", id) .addValue("id", id)
.addValue("name", entity.getName()) .addValue("name", entity.getName())
.addValue("identifier", entity.getIdentifier()) .addValue("identifier", entity.getIdentifier())
.addValue("status", entity.getStatus().getValue()) .addValue("status", entity.getStatus().getId())
.addValue("remarks", entity.getRemarks()) .addValue("remarks", entity.getRemarks())
.addValue("createTime", now) .addValue("createTime", now)
.addValue("createdBy", loginId) .addValue("createdBy", loginId)

View File

@@ -25,9 +25,9 @@
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<spring-boot.version>2.7.9</spring-boot.version> <spring-boot.version>2.7.10</spring-boot.version>
<sa-token.version>1.34.0</sa-token.version> <sa-token.version>1.34.0</sa-token.version>
<hutool.version>5.8.15</hutool.version> <hutool.version>5.8.16</hutool.version>
<mybatis-starter.version>3.0.1</mybatis-starter.version> <mybatis-starter.version>3.0.1</mybatis-starter.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version> <mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<commons-io.version>2.11.0</commons-io.version> <commons-io.version>2.11.0</commons-io.version>