Compare commits
9 Commits
feature/me
...
main
Author | SHA1 | Date | |
---|---|---|---|
8460b9da29 | |||
19fc97362c | |||
d91f818c96 | |||
ea7a8ee6a0 | |||
33d3d86393 | |||
1b551eeb4c | |||
1611bf38e8 | |||
17273b0bc6 | |||
2d02899372 |
@@ -1,10 +1,13 @@
|
||||
package xyz.zhouxy.plusone.exception.handler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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
|
||||
@@ -14,7 +17,7 @@ import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler.ExceptionInfoHo
|
||||
public class AllExceptionHandlerConfig {
|
||||
|
||||
@Bean
|
||||
AllExceptionHandler getAllExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
AllExceptionHandler getAllExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
return new AllExceptionHandler(exceptionInfoHolder);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package xyz.zhouxy.plusone.exception.handler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.core.Ordered;
|
||||
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 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)
|
||||
@Slf4j
|
||||
public class DefaultExceptionHandler extends BaseExceptionHandler {
|
||||
public DefaultExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
public DefaultExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
set(IllegalArgumentException.class, 4010000, "格式错误", HttpStatus.FORBIDDEN);
|
||||
set(DataAccessException.class, 6030000, "数据库错误", HttpStatus.INTERNAL_SERVER_ERROR, true);
|
||||
|
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
|
||||
@@ -15,7 +16,7 @@ import xyz.zhouxy.plusone.exception.SysException;
|
||||
@Slf4j
|
||||
public class SysExceptionHandler extends BaseExceptionHandler {
|
||||
|
||||
public SysExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
public SysExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>xyz.zhouxy.plusone</groupId>
|
||||
<artifactId>plusone-exception-handler</artifactId>
|
||||
<version>0.0.8-SNAPSHOT</version>
|
||||
<version>0.0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@@ -24,12 +24,10 @@ public final class EntityStatus extends Enumeration<EntityStatus> {
|
||||
private static final ValueSet<EntityStatus> VALUE_SET = new ValueSet<>(
|
||||
AVAILABLE, DISABLED);
|
||||
|
||||
@Nonnull
|
||||
public static EntityStatus of(int id) {
|
||||
return VALUE_SET.get(id);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Collection<EntityStatus> constants() {
|
||||
return VALUE_SET.getValues();
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import xyz.zhouxy.plusone.constant.ErrorCodeConsts;
|
||||
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler.ExceptionInfoHolder;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler.ExceptionInfoHolder;
|
||||
|
||||
@Configuration
|
||||
public class PlusoneExceptionHandlerConfig {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package xyz.zhouxy.plusone.sms;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
@@ -10,8 +8,11 @@ import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
import xyz.zhouxy.plusone.constant.ErrorCodeConsts;
|
||||
import xyz.zhouxy.plusone.exception.BizException;
|
||||
import xyz.zhouxy.plusone.sms.SmsProperties.SmsCredentialProperties;
|
||||
import xyz.zhouxy.plusone.sms.SmsProperties.SmsHttpProperties;
|
||||
import xyz.zhouxy.plusone.sms.SmsProperties.SmsProxyProperties;
|
||||
@@ -61,13 +62,14 @@ public class TencentSmsServiceImpl implements SmsService {
|
||||
var res = client.SendSms(req);
|
||||
|
||||
// 输出json格式的字符串回包
|
||||
log.info(SendSmsResponse.toJsonString(res));
|
||||
System.out.println(SendSmsResponse.toJsonString(res));
|
||||
|
||||
// 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
|
||||
// System.out.println(res.getRequestId());
|
||||
|
||||
} catch (TencentCloudSDKException e) {
|
||||
throw new SysException(e);
|
||||
log.error(e.getMessage(), e);
|
||||
throw new BizException(ErrorCodeConsts.DEFAULT_ERROR_CODE, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
package xyz.zhouxy.plusone.validator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class InvalidInputExceptionHandler extends BaseExceptionHandler {
|
||||
|
||||
public InvalidInputExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
public InvalidInputExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
set(InvalidInputException.class, InvalidInputException.ERROR_CODE, "无效的用户输入");
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams;
|
||||
import xyz.zhouxy.plusone.system.application.service.MenuManagementService;
|
||||
import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand;
|
||||
import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand;
|
||||
@@ -67,14 +66,7 @@ public class MenuManagementController {
|
||||
public RestfulResult findById(@PathVariable("id") Long id) {
|
||||
adminAuthLogic.checkPermission("sys-menu-details");
|
||||
var result = service.findById(id);
|
||||
return success("查询成功", result);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public RestfulResult queryMenuTree(MenuQueryParams queryParams) {
|
||||
adminAuthLogic.checkPermission("sys-menu-query");
|
||||
var result = service.queryMenuTree(queryParams);
|
||||
return success("查询成功", result);
|
||||
return RestfulResult.success("查询成功", result);
|
||||
}
|
||||
|
||||
@GetMapping("queryByAccountId")
|
||||
|
@@ -6,14 +6,14 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
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.commons.util.RestfulResult;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.RestfulResult;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class AccountLoginExceptionHandler extends BaseExceptionHandler {
|
||||
|
||||
public AccountLoginExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
public AccountLoginExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package xyz.zhouxy.plusone.system.application.exception.handler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.SameTokenInvalidException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.RestfulResult;
|
||||
|
||||
/**
|
||||
* Sa-Token 异常处理器
|
||||
@@ -27,7 +29,7 @@ import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
||||
public class SaTokenExceptionHandler extends BaseExceptionHandler {
|
||||
|
||||
|
||||
public SaTokenExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
public SaTokenExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
set(NotPermissionException.class, 4030103, "会话未能通过权限认证", HttpStatus.FORBIDDEN);
|
||||
set(NotRoleException.class, 4030103, "会话未能通过角色认证", HttpStatus.FORBIDDEN);
|
||||
|
@@ -2,6 +2,8 @@ package xyz.zhouxy.plusone.system.application.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import xyz.zhouxy.plusone.commons.util.PageDTO;
|
||||
@@ -23,6 +25,7 @@ public interface AccountQueries {
|
||||
return PageDTO.of(content, total);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
List<AccountOverview> queryAccountOverview(AccountQueryParams queryParams);
|
||||
|
||||
long count(AccountQueryParams queryParams);
|
||||
|
@@ -1,23 +0,0 @@
|
||||
package xyz.zhouxy.plusone.system.application.query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams;
|
||||
import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
@Component
|
||||
public class MenuQueries {
|
||||
|
||||
public List<MenuViewObject> queryMenuTree(MenuQueryParams queryParams) {
|
||||
// TODO【添加】 实现该查询
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package xyz.zhouxy.plusone.system.application.query;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
public interface PermissionQueries {
|
||||
// TODO【添加】 权限信息查询器
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package xyz.zhouxy.plusone.system.application.query.params;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import xyz.zhouxy.plusone.constant.EntityStatus;
|
||||
|
||||
@ToString
|
||||
public class MenuQueryParams {
|
||||
private @Getter @Setter String name;
|
||||
private @Getter @Setter String path;
|
||||
private @Getter @Setter String title;
|
||||
private @Getter @Setter Boolean hidden;
|
||||
private @Getter @Setter EntityStatus status;
|
||||
private @Getter @Setter String component;
|
||||
private @Getter @Setter Boolean cache;
|
||||
private @Getter @Setter String resource;
|
||||
}
|
@@ -25,28 +25,60 @@ import xyz.zhouxy.plusone.system.domain.model.menu.Menu.MenuType;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class MenuViewObject implements IWithOrderNumber {
|
||||
|
||||
private @Getter @Setter Integer type;
|
||||
@Getter
|
||||
@Setter
|
||||
Integer type;
|
||||
|
||||
private @Getter @Setter String typeName;
|
||||
@Getter
|
||||
@Setter
|
||||
String typeName;
|
||||
|
||||
private @Getter @Setter Long id;
|
||||
private @Getter @Setter Long parentId;
|
||||
@Getter
|
||||
@Setter
|
||||
Long id;
|
||||
@Getter
|
||||
@Setter
|
||||
Long parentId;
|
||||
|
||||
private @Getter @Setter String name;
|
||||
@Getter
|
||||
@Setter
|
||||
String name;
|
||||
// 若 type 为 MENU_ITEM 且 path 以 http:// 或 https:// 开头则被识别为外链
|
||||
private @Getter @Setter String path;
|
||||
private @Getter @Setter String title;
|
||||
private @Getter @Setter String icon;
|
||||
private @Getter @Setter boolean hidden;
|
||||
private @Getter @Setter int orderNumber;
|
||||
private @Getter @Setter Integer status;
|
||||
private @Getter @Setter String remarks;
|
||||
@Getter
|
||||
@Setter
|
||||
String path;
|
||||
@Getter
|
||||
@Setter
|
||||
String title;
|
||||
@Getter
|
||||
@Setter
|
||||
String icon;
|
||||
@Getter
|
||||
@Setter
|
||||
boolean hidden;
|
||||
@Getter
|
||||
@Setter
|
||||
int orderNumber;
|
||||
@Getter
|
||||
@Setter
|
||||
Integer status;
|
||||
@Getter
|
||||
@Setter
|
||||
String remarks;
|
||||
|
||||
// MENU_ITEM
|
||||
private @Getter @Setter String component;
|
||||
private @Getter @Setter Boolean cache;
|
||||
private @Getter @Setter String resource;
|
||||
private @Getter @Setter List<Action> actions;
|
||||
@Getter
|
||||
@Setter
|
||||
String component;
|
||||
@Getter
|
||||
@Setter
|
||||
Boolean cache;
|
||||
@Getter
|
||||
@Setter
|
||||
String resource;
|
||||
@Getter
|
||||
@Setter
|
||||
List<Action> actions;
|
||||
|
||||
// MENU_LIST
|
||||
List<MenuViewObject> children;
|
||||
|
@@ -17,8 +17,6 @@ import xyz.zhouxy.plusone.constant.EntityStatus;
|
||||
import xyz.zhouxy.plusone.domain.IWithOrderNumber;
|
||||
import xyz.zhouxy.plusone.exception.DataNotExistException;
|
||||
import xyz.zhouxy.plusone.system.application.exception.UnsupportedMenuTypeException;
|
||||
import xyz.zhouxy.plusone.system.application.query.MenuQueries;
|
||||
import xyz.zhouxy.plusone.system.application.query.params.MenuQueryParams;
|
||||
import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject;
|
||||
import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand;
|
||||
import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand;
|
||||
@@ -38,12 +36,10 @@ public class MenuManagementService {
|
||||
|
||||
private final MenuService menuService;
|
||||
private final MenuRepository menuRepository;
|
||||
private final MenuQueries menuQueries;
|
||||
|
||||
MenuManagementService(MenuService menuService, MenuRepository menuRepository, MenuQueries menuQueries) {
|
||||
this.menuService = menuService;
|
||||
MenuManagementService(MenuService roleRepository, MenuRepository menuRepository) {
|
||||
this.menuService = roleRepository;
|
||||
this.menuRepository = menuRepository;
|
||||
this.menuQueries = menuQueries;
|
||||
}
|
||||
|
||||
// ==================== create ====================
|
||||
@@ -127,11 +123,6 @@ public class MenuManagementService {
|
||||
return MenuViewObject.of(menu.orElseThrow(DataNotExistException::new));
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public List<MenuViewObject> queryMenuTree(MenuQueryParams queryParams) {
|
||||
return menuQueries.queryMenuTree(queryParams);
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public List<MenuViewObject> queryByAccountId(Long accountId) {
|
||||
var menus = menuService.queryAllMenuListByAccountId(accountId);
|
||||
|
@@ -7,7 +7,9 @@ import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.constant.ErrorCodeConsts;
|
||||
import xyz.zhouxy.plusone.exception.BizException;
|
||||
import xyz.zhouxy.plusone.util.RandomUtil;
|
||||
|
||||
/**
|
||||
@@ -15,6 +17,7 @@ import xyz.zhouxy.plusone.util.RandomUtil;
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public final class PasswordUtil {
|
||||
private static final char[] SALT_BASE_CHAR_ARRAY = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_-+={}[]|\\:;\"',.<>?/"
|
||||
.toCharArray();
|
||||
@@ -32,12 +35,12 @@ public final class PasswordUtil {
|
||||
int i = length > 0 ? length / 2 : 0;
|
||||
var passwordWithSalt = salt.substring(0, i)
|
||||
+ password
|
||||
+ salt.substring(i);
|
||||
try {
|
||||
return sha512Hex(passwordWithSalt);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SysException(e);
|
||||
+ salt.substring(1);
|
||||
String sha512Hex = sha512Hex(passwordWithSalt);
|
||||
if (sha512Hex == null) {
|
||||
throw new BizException(ErrorCodeConsts.DEFAULT_ERROR_CODE, "未知错误:哈希加密失败!");
|
||||
}
|
||||
return sha512Hex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,12 +57,15 @@ public final class PasswordUtil {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SuppressWarnings("null")
|
||||
private static String sha512Hex(String data) throws NoSuchAlgorithmException {
|
||||
private static String sha512Hex(String data) {
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
|
||||
messageDigest.update(data.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] result = messageDigest.digest();
|
||||
return new BigInteger(1, result).toString(16);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error("{}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ public final class AccountStatus extends Enumeration<AccountStatus> implements I
|
||||
return VALUE_SET.get(id);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Collection<AccountStatus> constants() {
|
||||
return VALUE_SET.getValues();
|
||||
}
|
||||
|
@@ -8,8 +8,9 @@ import javax.annotation.Nonnull;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import xyz.zhouxy.plusone.commons.constant.PatternConsts;
|
||||
import xyz.zhouxy.plusone.constant.ErrorCodeConsts;
|
||||
import xyz.zhouxy.plusone.domain.IValueObject;
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
import xyz.zhouxy.plusone.exception.BizException;
|
||||
import xyz.zhouxy.plusone.system.util.PasswordUtil;
|
||||
|
||||
/**
|
||||
@@ -36,7 +37,7 @@ public class Password implements IValueObject {
|
||||
}
|
||||
var salt = PasswordUtil.generateRandomSalt();
|
||||
if (salt == null) {
|
||||
throw new SysException("未知错误:生成随机盐失败");
|
||||
throw new BizException(ErrorCodeConsts.DEFAULT_ERROR_CODE, "未知错误:生成随机盐失败");
|
||||
}
|
||||
this.saltVal = salt;
|
||||
this.passwordVal = PasswordUtil.hashPassword(password, salt);
|
||||
|
@@ -26,12 +26,10 @@ public final class Sex extends Enumeration<Sex> implements IValueObject {
|
||||
|
||||
private static final ValueSet<Sex> VALUE_SET = new ValueSet<>(UNSET, MALE, FEMALE);
|
||||
|
||||
@Nonnull
|
||||
public static Sex of(int value) {
|
||||
return VALUE_SET.get(value);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Collection<Sex> constants() {
|
||||
return VALUE_SET.getValues();
|
||||
}
|
||||
|
Reference in New Issue
Block a user