添加Swagger/OpenAPI依赖并更新用户账户管理相关的API文档注释,优化用户和管理员账户控制器的接口描述,移除不必要的字段和参数,调整数据库映射以简化用户账户管理逻辑。
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.gameplatform.server.config;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public OpenAPI customOpenAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("游戏平台 API 文档")
|
||||
.description("游戏平台后端服务 API 接口文档")
|
||||
.version("1.0.0")
|
||||
.contact(new Contact()
|
||||
.name("游戏平台开发团队")
|
||||
.email("dev@gameplatform.com")
|
||||
.url("https://gameplatform.com"))
|
||||
.license(new License()
|
||||
.name("MIT License")
|
||||
.url("https://opensource.org/licenses/MIT")))
|
||||
.servers(List.of(
|
||||
new Server()
|
||||
.url("http://localhost:8080")
|
||||
.description("本地开发环境"),
|
||||
new Server()
|
||||
.url("https://api.gameplatform.com")
|
||||
.description("生产环境")
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import com.gameplatform.server.model.dto.account.AccountResponse;
|
||||
import com.gameplatform.server.model.dto.account.AccountUpdateRequest;
|
||||
import com.gameplatform.server.model.dto.common.PageResult;
|
||||
import com.gameplatform.server.service.account.AccountService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -16,6 +19,7 @@ import reactor.core.publisher.Mono;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
@Tag(name = "用户账户管理", description = "用户账户的增删改查操作")
|
||||
public class UserController {
|
||||
private final AccountService accountService;
|
||||
|
||||
@@ -27,7 +31,8 @@ public class UserController {
|
||||
* 根据ID获取用户账户信息
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public Mono<AccountResponse> getById(@PathVariable Long id) {
|
||||
@Operation(summary = "获取用户详情", description = "根据用户ID获取用户详细信息")
|
||||
public Mono<AccountResponse> getById(@Parameter(description = "用户ID") @PathVariable Long id) {
|
||||
return accountService.get(id);
|
||||
}
|
||||
|
||||
@@ -35,15 +40,15 @@ public class UserController {
|
||||
* 分页查询用户列表
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "获取用户列表", description = "分页获取用户列表,支持按用户类型、状态、关键词筛选")
|
||||
public Mono<PageResult<AccountResponse>> list(
|
||||
@RequestParam(value = "userType", required = false) String userType,
|
||||
@RequestParam(value = "status", required = false) String status,
|
||||
@RequestParam(value = "role", required = false) String role,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "20") Integer size
|
||||
@Parameter(description = "用户类型:ADMIN 或 AGENT") @RequestParam(value = "userType", required = false) String userType,
|
||||
@Parameter(description = "账户状态:ENABLED 或 DISABLED") @RequestParam(value = "status", required = false) String status,
|
||||
@Parameter(description = "搜索关键词") @RequestParam(value = "keyword", required = false) String keyword,
|
||||
@Parameter(description = "页码,默认1") @RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页大小,默认20") @RequestParam(value = "size", defaultValue = "20") Integer size
|
||||
) {
|
||||
return accountService.list(userType, status, role, keyword, page, size);
|
||||
return accountService.list(userType, status, keyword, page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,6 +56,7 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@Operation(summary = "创建用户", description = "创建新的代理用户账户")
|
||||
public Mono<AccountResponse> create(@Valid @RequestBody AccountCreateRequest request) {
|
||||
return accountService.create(request);
|
||||
}
|
||||
@@ -59,7 +65,8 @@ public class UserController {
|
||||
* 更新用户账户信息
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
public Mono<AccountResponse> update(@PathVariable Long id, @Valid @RequestBody AccountUpdateRequest request) {
|
||||
@Operation(summary = "更新用户", description = "更新用户账户信息")
|
||||
public Mono<AccountResponse> update(@Parameter(description = "用户ID") @PathVariable Long id, @Valid @RequestBody AccountUpdateRequest request) {
|
||||
return accountService.update(id, request);
|
||||
}
|
||||
|
||||
@@ -68,7 +75,8 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/{id}/enable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> enable(@PathVariable Long id) {
|
||||
@Operation(summary = "启用用户", description = "启用指定用户账户")
|
||||
public Mono<Void> enable(@Parameter(description = "用户ID") @PathVariable Long id) {
|
||||
return accountService.setStatus(id, "ENABLED").then();
|
||||
}
|
||||
|
||||
@@ -77,7 +85,8 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/{id}/disable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> disable(@PathVariable Long id) {
|
||||
@Operation(summary = "禁用用户", description = "禁用指定用户账户")
|
||||
public Mono<Void> disable(@Parameter(description = "用户ID") @PathVariable Long id) {
|
||||
return accountService.setStatus(id, "DISABLED").then();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.gameplatform.server.controller.admin;
|
||||
import com.gameplatform.server.model.dto.account.*;
|
||||
import com.gameplatform.server.model.dto.common.PageResult;
|
||||
import com.gameplatform.server.service.account.AccountService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,6 +13,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/accounts")
|
||||
@Tag(name = "管理员账户管理", description = "管理员账户的增删改查操作")
|
||||
public class AccountController {
|
||||
private final AccountService accountService;
|
||||
|
||||
@@ -18,48 +22,54 @@ public class AccountController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "获取账户列表", description = "分页获取账户列表,支持按用户类型、状态、关键词筛选")
|
||||
public Mono<PageResult<AccountResponse>> list(
|
||||
@RequestParam(value = "userType", required = false) String userType,
|
||||
@RequestParam(value = "status", required = false) String status,
|
||||
@RequestParam(value = "role", required = false) String role,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size
|
||||
@Parameter(description = "用户类型:ADMIN 或 AGENT") @RequestParam(value = "userType", required = false) String userType,
|
||||
@Parameter(description = "账户状态:ENABLED 或 DISABLED") @RequestParam(value = "status", required = false) String status,
|
||||
@Parameter(description = "搜索关键词") @RequestParam(value = "keyword", required = false) String keyword,
|
||||
@Parameter(description = "页码,默认1") @RequestParam(value = "page", required = false) Integer page,
|
||||
@Parameter(description = "每页大小,默认20,最大200") @RequestParam(value = "size", required = false) Integer size
|
||||
) {
|
||||
return accountService.list(userType, status, role, keyword, page, size);
|
||||
return accountService.list(userType, status, keyword, page, size);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@Operation(summary = "创建账户", description = "创建新的管理员或代理账户")
|
||||
public Mono<AccountResponse> create(@Valid @RequestBody AccountCreateRequest req) {
|
||||
return accountService.create(req);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Mono<AccountResponse> detail(@PathVariable Long id) {
|
||||
@Operation(summary = "获取账户详情", description = "根据账户ID获取账户详细信息")
|
||||
public Mono<AccountResponse> detail(@Parameter(description = "账户ID") @PathVariable Long id) {
|
||||
return accountService.get(id);
|
||||
}
|
||||
|
||||
@PatchMapping("/{id}")
|
||||
public Mono<AccountResponse> update(@PathVariable Long id, @Valid @RequestBody AccountUpdateRequest req) {
|
||||
@Operation(summary = "更新账户", description = "更新账户信息")
|
||||
public Mono<AccountResponse> update(@Parameter(description = "账户ID") @PathVariable Long id, @Valid @RequestBody AccountUpdateRequest req) {
|
||||
return accountService.update(id, req);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/enable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> enable(@PathVariable Long id) {
|
||||
@Operation(summary = "启用账户", description = "启用指定账户")
|
||||
public Mono<Void> enable(@Parameter(description = "账户ID") @PathVariable Long id) {
|
||||
return accountService.setStatus(id, "ENABLED").then();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/disable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> disable(@PathVariable Long id) {
|
||||
@Operation(summary = "禁用账户", description = "禁用指定账户")
|
||||
public Mono<Void> disable(@Parameter(description = "账户ID") @PathVariable Long id) {
|
||||
return accountService.setStatus(id, "DISABLED").then();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/reset-password")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> resetPassword(@PathVariable Long id, @Valid @RequestBody ResetPasswordRequest req) {
|
||||
@Operation(summary = "重置密码", description = "重置指定账户的密码")
|
||||
public Mono<Void> resetPassword(@Parameter(description = "账户ID") @PathVariable Long id, @Valid @RequestBody ResetPasswordRequest req) {
|
||||
return accountService.resetPassword(id, req.getNewPassword(), Boolean.TRUE.equals(req.getForceLogout()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,10 @@ public interface UserAccountMapper {
|
||||
|
||||
long countByFilter(@Param("userType") String userType,
|
||||
@Param("status") String status,
|
||||
@Param("role") String role,
|
||||
@Param("keyword") String keyword);
|
||||
|
||||
java.util.List<UserAccount> listByFilter(@Param("userType") String userType,
|
||||
@Param("status") String status,
|
||||
@Param("role") String role,
|
||||
@Param("keyword") String keyword,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gameplatform.server.mapper.admin;
|
||||
|
||||
import com.gameplatform.server.model.entity.admin.Announcement;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnnouncementMapper {
|
||||
Announcement findById(@Param("id") Long id);
|
||||
|
||||
int insert(Announcement announcement);
|
||||
|
||||
int update(Announcement announcement);
|
||||
|
||||
int deleteById(@Param("id") Long id);
|
||||
|
||||
List<Announcement> findAll(@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countAll();
|
||||
|
||||
List<Announcement> findByEnabled(@Param("enabled") Boolean enabled,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByEnabled(@Param("enabled") Boolean enabled);
|
||||
|
||||
int updateEnabled(@Param("id") Long id, @Param("enabled") Boolean enabled);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gameplatform.server.mapper.admin;
|
||||
|
||||
import com.gameplatform.server.model.entity.admin.OperationLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OperationLogMapper {
|
||||
OperationLog findById(@Param("id") Long id);
|
||||
|
||||
int insert(OperationLog operationLog);
|
||||
|
||||
List<OperationLog> findByCodeNo(@Param("codeNo") String codeNo,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByCodeNo(@Param("codeNo") String codeNo);
|
||||
|
||||
List<OperationLog> findByActorId(@Param("actorId") Long actorId,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByActorId(@Param("actorId") Long actorId);
|
||||
|
||||
List<OperationLog> findByActorType(@Param("actorType") String actorType,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByActorType(@Param("actorType") String actorType);
|
||||
|
||||
List<OperationLog> findAll(@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countAll();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.gameplatform.server.model.entity.agent.AgentPointsTx;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AgentPointsTxMapper {
|
||||
AgentPointsTx findById(@Param("id") Long id);
|
||||
|
||||
int insert(AgentPointsTx agentPointsTx);
|
||||
|
||||
List<AgentPointsTx> findByAccountId(@Param("accountId") Long accountId,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByAccountId(@Param("accountId") Long accountId);
|
||||
|
||||
List<AgentPointsTx> findByAccountIdAndType(@Param("accountId") Long accountId,
|
||||
@Param("type") String type,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByAccountIdAndType(@Param("accountId") Long accountId,
|
||||
@Param("type") String type);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.gameplatform.server.model.entity.agent.LinkBatch;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkBatchMapper {
|
||||
LinkBatch findById(@Param("id") Long id);
|
||||
|
||||
int insert(LinkBatch linkBatch);
|
||||
|
||||
List<LinkBatch> findByAgentId(@Param("agentId") Long agentId,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByAgentId(@Param("agentId") Long agentId);
|
||||
|
||||
List<LinkBatch> findAll(@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countAll();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.gameplatform.server.model.entity.agent.LinkTask;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkTaskMapper {
|
||||
LinkTask findById(@Param("id") Long id);
|
||||
|
||||
LinkTask findByCodeNo(@Param("codeNo") String codeNo);
|
||||
|
||||
LinkTask findByTokenHash(@Param("tokenHash") String tokenHash);
|
||||
|
||||
int insert(LinkTask linkTask);
|
||||
|
||||
int update(LinkTask linkTask);
|
||||
|
||||
int updateStatus(@Param("id") Long id, @Param("status") String status);
|
||||
|
||||
int updateStatusAndMachine(@Param("id") Long id,
|
||||
@Param("status") String status,
|
||||
@Param("region") String region,
|
||||
@Param("machineId") String machineId,
|
||||
@Param("loginAt") LocalDateTime loginAt);
|
||||
|
||||
List<LinkTask> findByAgentId(@Param("agentId") Long agentId,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByAgentId(@Param("agentId") Long agentId);
|
||||
|
||||
List<LinkTask> findByAgentIdAndStatus(@Param("agentId") Long agentId,
|
||||
@Param("status") String status,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByAgentIdAndStatus(@Param("agentId") Long agentId,
|
||||
@Param("status") String status);
|
||||
|
||||
List<LinkTask> findByBatchId(@Param("batchId") Long batchId,
|
||||
@Param("size") int size,
|
||||
@Param("offset") int offset);
|
||||
|
||||
long countByBatchId(@Param("batchId") Long batchId);
|
||||
|
||||
List<LinkTask> findExpiredTasks(@Param("expireTime") LocalDateTime expireTime,
|
||||
@Param("size") int size);
|
||||
}
|
||||
@@ -1,20 +1,32 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "账户创建请求")
|
||||
public class AccountCreateRequest {
|
||||
@NotBlank
|
||||
@Schema(description = "用户类型", example = "AGENT", allowableValues = {"ADMIN", "AGENT"})
|
||||
@NotBlank(message = "userType 不能为空")
|
||||
@Pattern(regexp = "^(ADMIN|AGENT)$", message = "userType 只能是 ADMIN 或 AGENT")
|
||||
private String userType; // ADMIN | AGENT
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 64)
|
||||
|
||||
@Schema(description = "用户名", example = "newuser", minLength = 3, maxLength = 64)
|
||||
@NotBlank(message = "username 不能为空")
|
||||
@Size(min = 3, max = 64, message = "username 长度必须在 3-64 字符之间")
|
||||
@Pattern(regexp = "^[a-zA-Z0-9_]+$", message = "username 只能包含字母、数字、下划线")
|
||||
private String username;
|
||||
|
||||
private String status = "ENABLED"; // ENABLED | DISABLED
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 128)
|
||||
@Schema(description = "密码", example = "123456", minLength = 6, maxLength = 128)
|
||||
@NotBlank(message = "password 不能为空")
|
||||
@Size(min = 6, max = 128, message = "password 长度必须在 6-128 字符之间")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "账户状态", example = "ENABLED", allowableValues = {"ENABLED", "DISABLED"}, defaultValue = "ENABLED")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "积分余额", example = "1000", minimum = "0", defaultValue = "0")
|
||||
@Min(0)
|
||||
private Long pointsBalance = 0L; // for AGENT
|
||||
private Long pointsBalance; // for AGENT
|
||||
|
||||
public String getUserType() { return userType; }
|
||||
public void setUserType(String userType) { this.userType = userType; }
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "账户响应")
|
||||
public class AccountResponse {
|
||||
@Schema(description = "账户ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户类型", example = "AGENT", allowableValues = {"ADMIN", "AGENT"})
|
||||
private String userType;
|
||||
|
||||
@Schema(description = "用户名", example = "newuser")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "账户状态", example = "ENABLED", allowableValues = {"ENABLED", "DISABLED"})
|
||||
private String status;
|
||||
|
||||
@Schema(description = "积分余额", example = "1000")
|
||||
private Long pointsBalance;
|
||||
|
||||
@Schema(description = "创建时间", example = "2025-08-24T18:30:00.000")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "更新时间", example = "2025-08-24T18:30:00.000")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
@Schema(description = "账户更新请求")
|
||||
public class AccountUpdateRequest {
|
||||
|
||||
private String status; // ENABLED | DISABLED
|
||||
@Schema(description = "账户状态", example = "ENABLED", allowableValues = {"ENABLED", "DISABLED"})
|
||||
@Pattern(regexp = "^(ENABLED|DISABLED)$", message = "status 只能是 ENABLED 或 DISABLED")
|
||||
private String status;
|
||||
|
||||
|
||||
public String getStatus() { return status; }
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "重置密码请求")
|
||||
public class ResetPasswordRequest {
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 128)
|
||||
@Schema(description = "新密码", example = "NewPassword123!", minLength = 6, maxLength = 128)
|
||||
@NotBlank(message = "newPassword 不能为空")
|
||||
@Size(min = 6, max = 128, message = "newPassword 长度必须在 6-128 字符之间")
|
||||
private String newPassword;
|
||||
|
||||
@Schema(description = "是否强制登出", example = "true", defaultValue = "true")
|
||||
private Boolean forceLogout = Boolean.TRUE;
|
||||
|
||||
public String getNewPassword() { return newPassword; }
|
||||
|
||||
@@ -6,9 +6,7 @@ public class UserAccount {
|
||||
private Long id;
|
||||
private String userType; // ADMIN | AGENT
|
||||
private String username; // 登录名(admin/agent 共用)
|
||||
|
||||
private String passwordHash; // BCrypt 或 PLAIN:xxx(初始化用)
|
||||
|
||||
private String status; // ENABLED / DISABLED
|
||||
private Long pointsBalance; // 仅 AGENT 使用
|
||||
private LocalDateTime createdAt;
|
||||
@@ -20,10 +18,8 @@ public class UserAccount {
|
||||
public void setUserType(String userType) { this.userType = userType; }
|
||||
public String getUsername() { return username; }
|
||||
public void setUsername(String username) { this.username = username; }
|
||||
|
||||
public String getPasswordHash() { return passwordHash; }
|
||||
public void setPasswordHash(String passwordHash) { this.passwordHash = passwordHash; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public Long getPointsBalance() { return pointsBalance; }
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gameplatform.server.model.entity.admin;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Announcement {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Boolean enabled;
|
||||
private String jumpUrl;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
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 Boolean getEnabled() { return enabled; }
|
||||
public void setEnabled(Boolean enabled) { this.enabled = enabled; }
|
||||
|
||||
public String getJumpUrl() { return jumpUrl; }
|
||||
public void setJumpUrl(String jumpUrl) { this.jumpUrl = jumpUrl; }
|
||||
|
||||
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; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gameplatform.server.model.entity.admin;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class OperationLog {
|
||||
private Long id;
|
||||
private String actorType; // admin | agent | system | user
|
||||
private Long actorId;
|
||||
private String codeNo;
|
||||
private String op;
|
||||
private String detail; // JSON字符串
|
||||
private String clientIp;
|
||||
private String userAgent;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public String getActorType() { return actorType; }
|
||||
public void setActorType(String actorType) { this.actorType = actorType; }
|
||||
|
||||
public Long getActorId() { return actorId; }
|
||||
public void setActorId(Long actorId) { this.actorId = actorId; }
|
||||
|
||||
public String getCodeNo() { return codeNo; }
|
||||
public void setCodeNo(String codeNo) { this.codeNo = codeNo; }
|
||||
|
||||
public String getOp() { return op; }
|
||||
public void setOp(String op) { this.op = op; }
|
||||
|
||||
public String getDetail() { return detail; }
|
||||
public void setDetail(String detail) { this.detail = detail; }
|
||||
|
||||
public String getClientIp() { return clientIp; }
|
||||
public void setClientIp(String clientIp) { this.clientIp = clientIp; }
|
||||
|
||||
public String getUserAgent() { return userAgent; }
|
||||
public void setUserAgent(String userAgent) { this.userAgent = userAgent; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class AgentPointsTx {
|
||||
private Long id;
|
||||
private Long accountId;
|
||||
private String type; // ADD | DEDUCT
|
||||
private Long beforePoints;
|
||||
private Long deltaPoints;
|
||||
private Long afterPoints;
|
||||
private String reason; // create_links | manual | refund_no_rollback | other
|
||||
private Long refId;
|
||||
private Long operatorId;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getAccountId() { return accountId; }
|
||||
public void setAccountId(Long accountId) { this.accountId = accountId; }
|
||||
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
|
||||
public Long getBeforePoints() { return beforePoints; }
|
||||
public void setBeforePoints(Long beforePoints) { this.beforePoints = beforePoints; }
|
||||
|
||||
public Long getDeltaPoints() { return deltaPoints; }
|
||||
public void setDeltaPoints(Long deltaPoints) { this.deltaPoints = deltaPoints; }
|
||||
|
||||
public Long getAfterPoints() { return afterPoints; }
|
||||
public void setAfterPoints(Long afterPoints) { this.afterPoints = afterPoints; }
|
||||
|
||||
public String getReason() { return reason; }
|
||||
public void setReason(String reason) { this.reason = reason; }
|
||||
|
||||
public Long getRefId() { return refId; }
|
||||
public void setRefId(Long refId) { this.refId = refId; }
|
||||
|
||||
public Long getOperatorId() { return operatorId; }
|
||||
public void setOperatorId(Long operatorId) { this.operatorId = operatorId; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class LinkBatch {
|
||||
private Long id;
|
||||
private Long agentId;
|
||||
private Integer quantity;
|
||||
private Integer times;
|
||||
private Integer batchSize;
|
||||
private Long deductPoints;
|
||||
private Long operatorId;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getAgentId() { return agentId; }
|
||||
public void setAgentId(Long agentId) { this.agentId = agentId; }
|
||||
|
||||
public Integer getQuantity() { return quantity; }
|
||||
public void setQuantity(Integer quantity) { this.quantity = quantity; }
|
||||
|
||||
public Integer getTimes() { return times; }
|
||||
public void setTimes(Integer times) { this.times = times; }
|
||||
|
||||
public Integer getBatchSize() { return batchSize; }
|
||||
public void setBatchSize(Integer batchSize) { this.batchSize = batchSize; }
|
||||
|
||||
public Long getDeductPoints() { return deductPoints; }
|
||||
public void setDeductPoints(Long deductPoints) { this.deductPoints = deductPoints; }
|
||||
|
||||
public Long getOperatorId() { return operatorId; }
|
||||
public void setOperatorId(Long operatorId) { this.operatorId = operatorId; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class LinkTask {
|
||||
private Long id;
|
||||
private Long batchId;
|
||||
private Long agentId;
|
||||
private String codeNo;
|
||||
private String tokenHash;
|
||||
private LocalDateTime expireAt;
|
||||
private String status; // NEW | USING | LOGGED_IN | REFUNDED | EXPIRED
|
||||
private String region; // Q | V
|
||||
private String machineId;
|
||||
private LocalDateTime loginAt;
|
||||
private LocalDateTime refundAt;
|
||||
private LocalDateTime revokedAt;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getBatchId() { return batchId; }
|
||||
public void setBatchId(Long batchId) { this.batchId = batchId; }
|
||||
|
||||
public Long getAgentId() { return agentId; }
|
||||
public void setAgentId(Long agentId) { this.agentId = agentId; }
|
||||
|
||||
public String getCodeNo() { return codeNo; }
|
||||
public void setCodeNo(String codeNo) { this.codeNo = codeNo; }
|
||||
|
||||
public String getTokenHash() { return tokenHash; }
|
||||
public void setTokenHash(String tokenHash) { this.tokenHash = tokenHash; }
|
||||
|
||||
public LocalDateTime getExpireAt() { return expireAt; }
|
||||
public void setExpireAt(LocalDateTime expireAt) { this.expireAt = expireAt; }
|
||||
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
|
||||
public String getMachineId() { return machineId; }
|
||||
public void setMachineId(String machineId) { this.machineId = machineId; }
|
||||
|
||||
public LocalDateTime getLoginAt() { return loginAt; }
|
||||
public void setLoginAt(LocalDateTime loginAt) { this.loginAt = loginAt; }
|
||||
|
||||
public LocalDateTime getRefundAt() { return refundAt; }
|
||||
public void setRefundAt(LocalDateTime refundAt) { this.refundAt = refundAt; }
|
||||
|
||||
public LocalDateTime getRevokedAt() { return revokedAt; }
|
||||
public void setRevokedAt(LocalDateTime revokedAt) { this.revokedAt = revokedAt; }
|
||||
|
||||
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; }
|
||||
}
|
||||
@@ -46,15 +46,15 @@ public class UserService {
|
||||
/**
|
||||
* 分页查询用户列表
|
||||
*/
|
||||
public Mono<PageResult<AccountResponse>> list(String userType, String status, String role, String keyword,
|
||||
public Mono<PageResult<AccountResponse>> list(String userType, String status, String keyword,
|
||||
Integer page, Integer size) {
|
||||
int p = (page == null || page < 1) ? 1 : page;
|
||||
int s = (size == null || size < 1 || size > 200) ? 20 : size;
|
||||
int offset = (p - 1) * s;
|
||||
|
||||
return Mono.fromCallable(() -> {
|
||||
long total = userAccountMapper.countByFilter(userType, status, role, keyword);
|
||||
List<UserAccount> list = userAccountMapper.listByFilter(userType, status, role, keyword, s, offset);
|
||||
long total = userAccountMapper.countByFilter(userType, status, keyword);
|
||||
List<UserAccount> list = userAccountMapper.listByFilter(userType, status, keyword, s, offset);
|
||||
List<AccountResponse> items = list.stream()
|
||||
.map(this::toAccountResponse)
|
||||
.collect(Collectors.toList());
|
||||
@@ -81,8 +81,6 @@ public class UserService {
|
||||
response.setId(account.getId());
|
||||
response.setUserType(account.getUserType());
|
||||
response.setUsername(account.getUsername());
|
||||
response.setDisplayName(account.getDisplayName());
|
||||
response.setRole(account.getRole());
|
||||
response.setStatus(account.getStatus());
|
||||
response.setPointsBalance(account.getPointsBalance());
|
||||
response.setCreatedAt(account.getCreatedAt());
|
||||
|
||||
@@ -31,8 +31,8 @@ public class AccountService {
|
||||
int s = (size == null || size < 1 || size > 200) ? 20 : size;
|
||||
int offset = (p - 1) * s;
|
||||
return Mono.fromCallable(() -> {
|
||||
long total = mapper.countByFilter(userType, status, null, keyword);
|
||||
List<UserAccount> list = mapper.listByFilter(userType, status, null, keyword, s, offset);
|
||||
long total = mapper.countByFilter(userType, status, keyword);
|
||||
List<UserAccount> list = mapper.listByFilter(userType, status, keyword, s, offset);
|
||||
List<AccountResponse> items = list.stream().map(this::toResp).collect(Collectors.toList());
|
||||
return new PageResult<>(items, total, p, s);
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AuthService {
|
||||
if (acc == null) {
|
||||
log.warn("login account not found username={}", req.getUsername());
|
||||
} else {
|
||||
log.debug("login account loaded id={}, status={}, role={} userType={}", acc.getId(), acc.getStatus(), acc.getRole(), acc.getUserType());
|
||||
log.debug("login account loaded id={}, status={}, userType={}", acc.getId(), acc.getStatus(), acc.getUserType());
|
||||
}
|
||||
})
|
||||
.flatMap(acc -> validatePasswordAndBuild(acc, req.getPassword()))
|
||||
@@ -73,7 +73,7 @@ public class AuthService {
|
||||
String token = jwtService.generateToken(
|
||||
userType + ":" + acc.getId(),
|
||||
userType, acc.getId(), acc.getUsername(),
|
||||
"admin".equals(userType) ? Map.of("role", acc.getRole()) : Map.of("displayName", acc.getDisplayName())
|
||||
Map.of()
|
||||
);
|
||||
LoginResponse resp = new LoginResponse();
|
||||
resp.setAccessToken(token);
|
||||
|
||||
Reference in New Issue
Block a user