修复了平台与账号之间无法关联的问题
This commit is contained in:
parent
f9352afd41
commit
677b57b16a
@ -1,5 +1,6 @@
|
|||||||
package com.zayac.admin.system.mapper;
|
package com.zayac.admin.system.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
import top.continew.starter.data.mybatis.plus.base.BaseMapper;
|
import top.continew.starter.data.mybatis.plus.base.BaseMapper;
|
||||||
import com.zayac.admin.system.model.entity.PlatformDO;
|
import com.zayac.admin.system.model.entity.PlatformDO;
|
||||||
|
|
||||||
@ -9,4 +10,10 @@ import com.zayac.admin.system.model.entity.PlatformDO;
|
|||||||
* @author zayac
|
* @author zayac
|
||||||
* @since 2024/05/14 12:28
|
* @since 2024/05/14 12:28
|
||||||
*/
|
*/
|
||||||
public interface PlatformMapper extends BaseMapper<PlatformDO> {}
|
public interface PlatformMapper extends BaseMapper<PlatformDO> {
|
||||||
|
@Select("SELECT * FROM sys_platform WHERE name = #{name}")
|
||||||
|
PlatformDO selectByName(String name);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM sys_platform WHERE platform_id = #{platformId}")
|
||||||
|
PlatformDO selectByPlatformId(Integer platformId);
|
||||||
|
}
|
@ -61,5 +61,6 @@ public class AccountDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 平台ID
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Long platformId;
|
private Long platformId;
|
||||||
}
|
}
|
@ -3,6 +3,15 @@ package com.zayac.admin.system.model.req;
|
|||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import cn.crane4j.annotation.AssembleMethod;
|
||||||
|
import cn.crane4j.annotation.ContainerMethod;
|
||||||
|
import cn.crane4j.annotation.Mapping;
|
||||||
|
import com.zayac.admin.common.enums.DisEnableStatusEnum;
|
||||||
|
import com.zayac.admin.system.enums.AccountTypeEnum;
|
||||||
|
import com.zayac.admin.system.model.resp.DeptResp;
|
||||||
|
import com.zayac.admin.system.model.resp.PlatformResp;
|
||||||
|
import com.zayac.admin.system.service.DeptService;
|
||||||
|
import com.zayac.admin.system.service.PlatformService;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -31,7 +40,7 @@ public class AccountReq extends BaseReq {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "账号昵称")
|
@Schema(description = "账号昵称")
|
||||||
@Length(max = 60, message = "账号昵称长度不能超过 {max} 个字符")
|
@Length(max = 60, message = "账号昵称长度不能超过 {max} 个字符")
|
||||||
private String name;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号
|
* 账号
|
||||||
@ -42,23 +51,37 @@ public class AccountReq extends BaseReq {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号类型(0:开云,1:华体会,2:九游,3:爱游戏)
|
* 密码
|
||||||
*/
|
*/
|
||||||
@Schema(description = "账号类型(0:开云,1:华体会,2:九游,3:爱游戏)")
|
@Schema(description = "密码")
|
||||||
@NotNull(message = "账号类型(0:开云,1:华体会,2:九游,3:爱游戏)不能为空")
|
@NotBlank(message = "密码不能为空")
|
||||||
private Boolean type;
|
@Length(max = 64, message = "密码长度不能超过 {max} 个字符")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号类型(1:开云,2:华体会,3:九游,4:爱游戏)
|
||||||
|
*/
|
||||||
|
@Schema(description = "账号类型(1:开云,2:华体会,3:九游,4:爱游戏)", type = "Integer", allowableValues = {"1", "2", "3", "4"}, example = "1")
|
||||||
|
@NotNull(message = "账号类型不能为空")
|
||||||
|
@AssembleMethod(targetType = PlatformService.class, method = @ContainerMethod(bindMethod = "getByPlatformId", resultType = PlatformResp.class), prop="id:platformId")
|
||||||
|
private AccountTypeEnum type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(1:启用;2:禁用)
|
* 状态(1:启用;2:禁用)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "状态(1:启用;2:禁用)")
|
@Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1")
|
||||||
@NotNull(message = "状态(1:启用;2:禁用)不能为空")
|
@NotNull(message = "状态(1:启用;2:禁用)不能为空")
|
||||||
private Integer status;
|
private DisEnableStatusEnum status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应平台的url
|
* 所属用户ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "对应平台的url")
|
@Schema(description = "所属用户", example = "123456789")
|
||||||
@Length(max = 100, message = "对应平台的url长度不能超过 {max} 个字符")
|
private Long userId;
|
||||||
private String url;
|
|
||||||
|
/**
|
||||||
|
* 所属平台ID
|
||||||
|
*/
|
||||||
|
private Long platformId;
|
||||||
|
|
||||||
}
|
}
|
@ -100,7 +100,7 @@ public class UserReq extends BaseReq {
|
|||||||
/**
|
/**
|
||||||
* 私聊消息ID
|
* 私聊消息ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "邮箱", example = "123456789")
|
@Schema(description = "私聊信息ID", example = "123456789")
|
||||||
private Long chatId;
|
private Long chatId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,8 @@ package com.zayac.admin.system.model.resp;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import com.zayac.admin.common.enums.DisEnableStatusEnum;
|
||||||
|
import com.zayac.admin.system.enums.AccountTypeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@ -30,7 +32,7 @@ public class AccountDetailResp extends BaseDetailResp {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "账号昵称")
|
@Schema(description = "账号昵称")
|
||||||
@ExcelProperty(value = "账号昵称")
|
@ExcelProperty(value = "账号昵称")
|
||||||
private String name;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号
|
* 账号
|
||||||
@ -47,11 +49,11 @@ public class AccountDetailResp extends BaseDetailResp {
|
|||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号类型(0:开云,1:华体会,2:九游,3:爱游戏)
|
* 账号类型(1:开云,2:华体会,3:九游,4:爱游戏)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "账号类型(0:开云,1:华体会,2:九游,3:爱游戏)")
|
@Schema(description = "账号类型(1:开云,2:华体会,3:九游,4:爱游戏)", type = "Integer", allowableValues = {"1", "2", "3", "4"}, example = "1")
|
||||||
@ExcelProperty(value = "账号类型(0:开云,1:华体会,2:九游,3:爱游戏)")
|
@ExcelProperty(value = "账号类型")
|
||||||
private Boolean type;
|
private AccountTypeEnum type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* headers
|
* headers
|
||||||
@ -63,16 +65,10 @@ public class AccountDetailResp extends BaseDetailResp {
|
|||||||
/**
|
/**
|
||||||
* 状态(1:启用;2:禁用)
|
* 状态(1:启用;2:禁用)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "状态(1:启用;2:禁用)")
|
@Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1")
|
||||||
@ExcelProperty(value = "状态(1:启用;2:禁用)")
|
@ExcelProperty(value = "状态(1:启用;2:禁用)")
|
||||||
private Integer status;
|
private DisEnableStatusEnum status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 对应平台的url
|
|
||||||
*/
|
|
||||||
@Schema(description = "对应平台的url")
|
|
||||||
@ExcelProperty(value = "对应平台的url")
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package com.zayac.admin.system.model.resp;
|
package com.zayac.admin.system.model.resp;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
|
import cn.crane4j.annotation.AssembleMethod;
|
||||||
|
import cn.crane4j.annotation.ContainerMethod;
|
||||||
|
import cn.crane4j.annotation.Mapping;
|
||||||
import com.zayac.admin.common.enums.DisEnableStatusEnum;
|
import com.zayac.admin.common.enums.DisEnableStatusEnum;
|
||||||
import com.zayac.admin.system.enums.AccountTypeEnum;
|
import com.zayac.admin.system.enums.AccountTypeEnum;
|
||||||
|
import com.zayac.admin.system.service.UserService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import top.continew.starter.extension.crud.model.resp.BaseResp;
|
import top.continew.starter.extension.crud.model.resp.BaseResp;
|
||||||
|
import top.continew.starter.security.mask.annotation.JsonMask;
|
||||||
|
import top.continew.starter.security.mask.enums.MaskType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号信息
|
* 账号信息
|
||||||
@ -36,6 +41,13 @@ public class AccountResp extends BaseResp {
|
|||||||
@Schema(description = "账号", example = "ky3tg107001")
|
@Schema(description = "账号", example = "ky3tg107001")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
@Schema(description = "密码", example = "tg666888")
|
||||||
|
@JsonMask(MaskType.PASSWORD)
|
||||||
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台(0:开云,1:华体会,2:九游,3:爱游戏)
|
* 平台(0:开云,1:华体会,2:九游,3:爱游戏)
|
||||||
*/
|
*/
|
||||||
@ -51,19 +63,20 @@ public class AccountResp extends BaseResp {
|
|||||||
/**
|
/**
|
||||||
* 状态(1:启用;2:禁用)
|
* 状态(1:启用;2:禁用)
|
||||||
*/
|
*/
|
||||||
@Schema(description = "状态(1:启用;2:禁用)")
|
@Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1")
|
||||||
private DisEnableStatusEnum status;
|
private DisEnableStatusEnum status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 对应平台的url
|
|
||||||
*/
|
|
||||||
@Schema(description = "平台地址")
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "用户ID")
|
@Schema(description = "用户ID")
|
||||||
|
@AssembleMethod(targetType = UserService.class, method = @ContainerMethod(bindMethod = "get", resultType = UserResp.class), props = @Mapping(src = "username", ref = "ownerName"))
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属用户
|
||||||
|
*/
|
||||||
|
@Schema(description = "所属用户", example = "张三")
|
||||||
|
private String ownerName;
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.zayac.admin.system.service;
|
package com.zayac.admin.system.service;
|
||||||
|
|
||||||
|
import com.zayac.admin.system.model.entity.PlatformDO;
|
||||||
import top.continew.starter.extension.crud.service.BaseService;
|
import top.continew.starter.extension.crud.service.BaseService;
|
||||||
import com.zayac.admin.system.model.query.PlatformQuery;
|
import com.zayac.admin.system.model.query.PlatformQuery;
|
||||||
import com.zayac.admin.system.model.req.PlatformReq;
|
import com.zayac.admin.system.model.req.PlatformReq;
|
||||||
@ -12,4 +13,8 @@ import com.zayac.admin.system.model.resp.PlatformResp;
|
|||||||
* @author zayac
|
* @author zayac
|
||||||
* @since 2024/05/14 12:28
|
* @since 2024/05/14 12:28
|
||||||
*/
|
*/
|
||||||
public interface PlatformService extends BaseService<PlatformResp, PlatformDetailResp, PlatformQuery, PlatformReq> {}
|
public interface PlatformService extends BaseService<PlatformResp, PlatformDetailResp, PlatformQuery, PlatformReq> {
|
||||||
|
PlatformDO getByName(String name);
|
||||||
|
|
||||||
|
PlatformDO getByPlatformId(Integer platformId);
|
||||||
|
}
|
@ -21,4 +21,14 @@ import com.zayac.admin.system.service.PlatformService;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PlatformServiceImpl extends BaseServiceImpl<PlatformMapper, PlatformDO, PlatformResp, PlatformDetailResp, PlatformQuery, PlatformReq> implements PlatformService {}
|
public class PlatformServiceImpl extends BaseServiceImpl<PlatformMapper, PlatformDO, PlatformResp, PlatformDetailResp, PlatformQuery, PlatformReq> implements PlatformService {
|
||||||
|
@Override
|
||||||
|
public PlatformDO getByName(String name) {
|
||||||
|
return baseMapper.selectByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformDO getByPlatformId(Integer platformId) {
|
||||||
|
return baseMapper.selectByPlatformId(platformId);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,19 @@
|
|||||||
package com.zayac.admin.webapi.system;
|
package com.zayac.admin.webapi.system;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ReUtil;
|
||||||
|
import com.zayac.admin.common.constant.RegexConstants;
|
||||||
|
import com.zayac.admin.common.util.SecureUtils;
|
||||||
import com.zayac.admin.system.model.query.AccountQuery;
|
import com.zayac.admin.system.model.query.AccountQuery;
|
||||||
import com.zayac.admin.system.model.req.AccountReq;
|
import com.zayac.admin.system.model.req.AccountReq;
|
||||||
|
import com.zayac.admin.system.model.req.UserReq;
|
||||||
import com.zayac.admin.system.model.resp.AccountDetailResp;
|
import com.zayac.admin.system.model.resp.AccountDetailResp;
|
||||||
import com.zayac.admin.system.model.resp.AccountResp;
|
import com.zayac.admin.system.model.resp.AccountResp;
|
||||||
import com.zayac.admin.system.service.AccountService;
|
import com.zayac.admin.system.service.AccountService;
|
||||||
|
import com.zayac.admin.system.service.PlatformService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import top.continew.starter.core.util.ExceptionUtils;
|
||||||
|
import top.continew.starter.core.util.validate.ValidationUtils;
|
||||||
import top.continew.starter.extension.crud.enums.Api;
|
import top.continew.starter.extension.crud.enums.Api;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -13,6 +22,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||||
import top.continew.starter.extension.crud.controller.BaseController;
|
import top.continew.starter.extension.crud.controller.BaseController;
|
||||||
|
import top.continew.starter.extension.crud.util.ValidateGroup;
|
||||||
|
import top.continew.starter.web.model.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,4 +35,28 @@ import top.continew.starter.extension.crud.controller.BaseController;
|
|||||||
@Tag(name = "账号管理 API")
|
@Tag(name = "账号管理 API")
|
||||||
@RestController
|
@RestController
|
||||||
@CrudRequestMapping(value = "/system/account", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
|
@CrudRequestMapping(value = "/system/account", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
|
||||||
public class AccountController extends BaseController<AccountService, AccountResp, AccountDetailResp, AccountQuery, AccountReq> {}
|
@RequiredArgsConstructor
|
||||||
|
public class AccountController extends BaseController<AccountService, AccountResp, AccountDetailResp, AccountQuery, AccountReq> {
|
||||||
|
private final PlatformService platformService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody AccountReq req) {
|
||||||
|
// String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword()));
|
||||||
|
// ValidationUtils.throwIfNull(rawPassword, "密码解密失败");
|
||||||
|
ValidationUtils.throwIf(!ReUtil
|
||||||
|
.isMatch(RegexConstants.PASSWORD, req.getPassword()), "密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字");
|
||||||
|
req.setPlatformId(platformService.getByPlatformId(req.getType().getValue()).getId());
|
||||||
|
return super.add(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<Void> update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody AccountReq req, @PathVariable Long id) {
|
||||||
|
// String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword()));
|
||||||
|
// ValidationUtils.throwIfNull(rawPassword, "密码解密失败");
|
||||||
|
ValidationUtils.throwIf(!ReUtil
|
||||||
|
.isMatch(RegexConstants.PASSWORD, req.getPassword()), "密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字");
|
||||||
|
req.setPlatformId(platformService.getByPlatformId(req.getType().getValue()).getId());
|
||||||
|
return super.update(req, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user