添加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);
|
||||
|
||||
@@ -40,3 +40,16 @@ security:
|
||||
secret: "change-this-secret-to-a-long-random-string-please"
|
||||
access-token-minutes: 30
|
||||
refresh-token-days: 7
|
||||
|
||||
# Swagger/OpenAPI 配置
|
||||
springdoc:
|
||||
api-docs:
|
||||
path: /api-docs
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
doc-expansion: none
|
||||
disable-swagger-default-url: true
|
||||
display-request-duration: true
|
||||
packages-to-scan: com.gameplatform.server.controller
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
<id property="id" column="id" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="username" column="username" />
|
||||
<result property="displayName" column="display_name" />
|
||||
<result property="passwordHash" column="password_hash" />
|
||||
<result property="role" column="role" />
|
||||
<result property="status" column="status" />
|
||||
<result property="pointsBalance" column="points_balance" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
@@ -15,7 +13,7 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="findByUsernameAndType" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
SELECT id, user_type, username, password_hash, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
WHERE username = #{username}
|
||||
AND user_type = #{userType}
|
||||
@@ -23,30 +21,29 @@
|
||||
</select>
|
||||
|
||||
<select id="findByUsername" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
SELECT id, user_type, username, password_hash, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
WHERE username = #{username}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
SELECT id, user_type, username, password_hash, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.account.UserAccount" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO user_account (user_type, username, display_name, password_hash, role, status, points_balance)
|
||||
VALUES (#{userType}, #{username}, #{displayName}, #{passwordHash}, #{role}, #{status}, #{pointsBalance})
|
||||
INSERT INTO user_account (user_type, username, password_hash, status, points_balance)
|
||||
VALUES (#{userType}, #{username}, #{passwordHash}, #{status}, #{pointsBalance})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.gameplatform.server.model.entity.account.UserAccount">
|
||||
UPDATE user_account
|
||||
<set>
|
||||
<if test="displayName != null">display_name = #{displayName},</if>
|
||||
<if test="role != null">role = #{role},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="pointsBalance != null">points_balance = #{pointsBalance},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
@@ -64,22 +61,20 @@
|
||||
<where>
|
||||
<if test="userType != null and userType != ''">AND user_type = #{userType}</if>
|
||||
<if test="status != null and status != ''">AND status = #{status}</if>
|
||||
<if test="role != null and role != ''">AND role = #{role}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (username LIKE CONCAT('%', #{keyword}, '%') OR display_name LIKE CONCAT('%', #{keyword}, '%'))
|
||||
AND username LIKE CONCAT('%', #{keyword}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="listByFilter" resultMap="UserAccountMap">
|
||||
SELECT id, user_type, username, display_name, password_hash, role, status, points_balance, created_at, updated_at
|
||||
SELECT id, user_type, username, password_hash, status, points_balance, created_at, updated_at
|
||||
FROM user_account
|
||||
<where>
|
||||
<if test="userType != null and userType != ''">AND user_type = #{userType}</if>
|
||||
<if test="status != null and status != ''">AND status = #{status}</if>
|
||||
<if test="role != null and role != ''">AND role = #{role}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (username LIKE CONCAT('%', #{keyword}, '%') OR display_name LIKE CONCAT('%', #{keyword}, '%'))
|
||||
AND username LIKE CONCAT('%', #{keyword}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY id DESC
|
||||
|
||||
67
src/main/resources/mapper/admin/AnnouncementMapper.xml
Normal file
67
src/main/resources/mapper/admin/AnnouncementMapper.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gameplatform.server.mapper.admin.AnnouncementMapper">
|
||||
<resultMap id="AnnouncementMap" type="com.gameplatform.server.model.entity.admin.Announcement">
|
||||
<id property="id" column="id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content" />
|
||||
<result property="enabled" column="enabled" />
|
||||
<result property="jumpUrl" column="jump_url" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="updatedAt" column="updated_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="AnnouncementMap">
|
||||
SELECT id, title, content, enabled, jump_url, created_at, updated_at
|
||||
FROM announcement
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.admin.Announcement" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO announcement (title, content, enabled, jump_url)
|
||||
VALUES (#{title}, #{content}, #{enabled}, #{jumpUrl})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.gameplatform.server.model.entity.admin.Announcement">
|
||||
UPDATE announcement
|
||||
<set>
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="enabled != null">enabled = #{enabled},</if>
|
||||
<if test="jumpUrl != null">jump_url = #{jumpUrl},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById" parameterType="long">
|
||||
DELETE FROM announcement WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="findAll" resultMap="AnnouncementMap">
|
||||
SELECT id, title, content, enabled, jump_url, created_at, updated_at
|
||||
FROM announcement
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countAll" resultType="long">
|
||||
SELECT COUNT(1) FROM announcement
|
||||
</select>
|
||||
|
||||
<select id="findByEnabled" resultMap="AnnouncementMap">
|
||||
SELECT id, title, content, enabled, jump_url, created_at, updated_at
|
||||
FROM announcement
|
||||
WHERE enabled = #{enabled}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByEnabled" resultType="long">
|
||||
SELECT COUNT(1) FROM announcement WHERE enabled = #{enabled}
|
||||
</select>
|
||||
|
||||
<update id="updateEnabled">
|
||||
UPDATE announcement SET enabled = #{enabled} WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
74
src/main/resources/mapper/admin/OperationLogMapper.xml
Normal file
74
src/main/resources/mapper/admin/OperationLogMapper.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gameplatform.server.mapper.admin.OperationLogMapper">
|
||||
<resultMap id="OperationLogMap" type="com.gameplatform.server.model.entity.admin.OperationLog">
|
||||
<id property="id" column="id" />
|
||||
<result property="actorType" column="actor_type" />
|
||||
<result property="actorId" column="actor_id" />
|
||||
<result property="codeNo" column="code_no" />
|
||||
<result property="op" column="op" />
|
||||
<result property="detail" column="detail" />
|
||||
<result property="clientIp" column="client_ip" />
|
||||
<result property="userAgent" column="user_agent" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="OperationLogMap">
|
||||
SELECT id, actor_type, actor_id, code_no, op, detail, client_ip, user_agent, created_at
|
||||
FROM operation_log
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.admin.OperationLog" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO operation_log (actor_type, actor_id, code_no, op, detail, client_ip, user_agent)
|
||||
VALUES (#{actorType}, #{actorId}, #{codeNo}, #{op}, #{detail}, #{clientIp}, #{userAgent})
|
||||
</insert>
|
||||
|
||||
<select id="findByCodeNo" resultMap="OperationLogMap">
|
||||
SELECT id, actor_type, actor_id, code_no, op, detail, client_ip, user_agent, created_at
|
||||
FROM operation_log
|
||||
WHERE code_no = #{codeNo}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByCodeNo" resultType="long">
|
||||
SELECT COUNT(1) FROM operation_log WHERE code_no = #{codeNo}
|
||||
</select>
|
||||
|
||||
<select id="findByActorId" resultMap="OperationLogMap">
|
||||
SELECT id, actor_type, actor_id, code_no, op, detail, client_ip, user_agent, created_at
|
||||
FROM operation_log
|
||||
WHERE actor_id = #{actorId}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByActorId" resultType="long">
|
||||
SELECT COUNT(1) FROM operation_log WHERE actor_id = #{actorId}
|
||||
</select>
|
||||
|
||||
<select id="findByActorType" resultMap="OperationLogMap">
|
||||
SELECT id, actor_type, actor_id, code_no, op, detail, client_ip, user_agent, created_at
|
||||
FROM operation_log
|
||||
WHERE actor_type = #{actorType}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByActorType" resultType="long">
|
||||
SELECT COUNT(1) FROM operation_log WHERE actor_type = #{actorType}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="OperationLogMap">
|
||||
SELECT id, actor_type, actor_id, code_no, op, detail, client_ip, user_agent, created_at
|
||||
FROM operation_log
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countAll" resultType="long">
|
||||
SELECT COUNT(1) FROM operation_log
|
||||
</select>
|
||||
</mapper>
|
||||
52
src/main/resources/mapper/agent/AgentPointsTxMapper.xml
Normal file
52
src/main/resources/mapper/agent/AgentPointsTxMapper.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gameplatform.server.mapper.agent.AgentPointsTxMapper">
|
||||
<resultMap id="AgentPointsTxMap" type="com.gameplatform.server.model.entity.agent.AgentPointsTx">
|
||||
<id property="id" column="id" />
|
||||
<result property="accountId" column="account_id" />
|
||||
<result property="type" column="type" />
|
||||
<result property="beforePoints" column="before_points" />
|
||||
<result property="deltaPoints" column="delta_points" />
|
||||
<result property="afterPoints" column="after_points" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="refId" column="ref_id" />
|
||||
<result property="operatorId" column="operator_id" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="AgentPointsTxMap">
|
||||
SELECT id, account_id, type, before_points, delta_points, after_points, reason, ref_id, operator_id, created_at
|
||||
FROM agent_points_tx
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.agent.AgentPointsTx" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO agent_points_tx (account_id, type, before_points, delta_points, after_points, reason, ref_id, operator_id)
|
||||
VALUES (#{accountId}, #{type}, #{beforePoints}, #{deltaPoints}, #{afterPoints}, #{reason}, #{refId}, #{operatorId})
|
||||
</insert>
|
||||
|
||||
<select id="findByAccountId" resultMap="AgentPointsTxMap">
|
||||
SELECT id, account_id, type, before_points, delta_points, after_points, reason, ref_id, operator_id, created_at
|
||||
FROM agent_points_tx
|
||||
WHERE account_id = #{accountId}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByAccountId" resultType="long">
|
||||
SELECT COUNT(1) FROM agent_points_tx WHERE account_id = #{accountId}
|
||||
</select>
|
||||
|
||||
<select id="findByAccountIdAndType" resultMap="AgentPointsTxMap">
|
||||
SELECT id, account_id, type, before_points, delta_points, after_points, reason, ref_id, operator_id, created_at
|
||||
FROM agent_points_tx
|
||||
WHERE account_id = #{accountId} AND type = #{type}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByAccountIdAndType" resultType="long">
|
||||
SELECT COUNT(1) FROM agent_points_tx WHERE account_id = #{accountId} AND type = #{type}
|
||||
</select>
|
||||
</mapper>
|
||||
49
src/main/resources/mapper/agent/LinkBatchMapper.xml
Normal file
49
src/main/resources/mapper/agent/LinkBatchMapper.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gameplatform.server.mapper.agent.LinkBatchMapper">
|
||||
<resultMap id="LinkBatchMap" type="com.gameplatform.server.model.entity.agent.LinkBatch">
|
||||
<id property="id" column="id" />
|
||||
<result property="agentId" column="agent_id" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="times" column="times" />
|
||||
<result property="batchSize" column="batch_size" />
|
||||
<result property="deductPoints" column="deduct_points" />
|
||||
<result property="operatorId" column="operator_id" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="LinkBatchMap">
|
||||
SELECT id, agent_id, quantity, times, batch_size, deduct_points, operator_id, created_at
|
||||
FROM link_batch
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.agent.LinkBatch" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO link_batch (agent_id, quantity, times, batch_size, deduct_points, operator_id)
|
||||
VALUES (#{agentId}, #{quantity}, #{times}, #{batchSize}, #{deductPoints}, #{operatorId})
|
||||
</insert>
|
||||
|
||||
<select id="findByAgentId" resultMap="LinkBatchMap">
|
||||
SELECT id, agent_id, quantity, times, batch_size, deduct_points, operator_id, created_at
|
||||
FROM link_batch
|
||||
WHERE agent_id = #{agentId}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByAgentId" resultType="long">
|
||||
SELECT COUNT(1) FROM link_batch WHERE agent_id = #{agentId}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="LinkBatchMap">
|
||||
SELECT id, agent_id, quantity, times, batch_size, deduct_points, operator_id, created_at
|
||||
FROM link_batch
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countAll" resultType="long">
|
||||
SELECT COUNT(1) FROM link_batch
|
||||
</select>
|
||||
</mapper>
|
||||
113
src/main/resources/mapper/agent/LinkTaskMapper.xml
Normal file
113
src/main/resources/mapper/agent/LinkTaskMapper.xml
Normal file
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gameplatform.server.mapper.agent.LinkTaskMapper">
|
||||
<resultMap id="LinkTaskMap" type="com.gameplatform.server.model.entity.agent.LinkTask">
|
||||
<id property="id" column="id" />
|
||||
<result property="batchId" column="batch_id" />
|
||||
<result property="agentId" column="agent_id" />
|
||||
<result property="codeNo" column="code_no" />
|
||||
<result property="tokenHash" column="token_hash" />
|
||||
<result property="expireAt" column="expire_at" />
|
||||
<result property="status" column="status" />
|
||||
<result property="region" column="region" />
|
||||
<result property="machineId" column="machine_id" />
|
||||
<result property="loginAt" column="login_at" />
|
||||
<result property="refundAt" column="refund_at" />
|
||||
<result property="revokedAt" column="revoked_at" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="updatedAt" column="updated_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE id = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findByCodeNo" parameterType="string" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE code_no = #{codeNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findByTokenHash" parameterType="string" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE token_hash = #{tokenHash}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.gameplatform.server.model.entity.agent.LinkTask" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO link_task (batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at)
|
||||
VALUES (#{batchId}, #{agentId}, #{codeNo}, #{tokenHash}, #{expireAt}, #{status}, #{region}, #{machineId}, #{loginAt}, #{refundAt}, #{revokedAt})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.gameplatform.server.model.entity.agent.LinkTask">
|
||||
UPDATE link_task
|
||||
<set>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="region != null">region = #{region},</if>
|
||||
<if test="machineId != null">machine_id = #{machineId},</if>
|
||||
<if test="loginAt != null">login_at = #{loginAt},</if>
|
||||
<if test="refundAt != null">refund_at = #{refundAt},</if>
|
||||
<if test="revokedAt != null">revoked_at = #{revokedAt},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStatus">
|
||||
UPDATE link_task SET status = #{status} WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStatusAndMachine">
|
||||
UPDATE link_task
|
||||
SET status = #{status}, region = #{region}, machine_id = #{machineId}, login_at = #{loginAt}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="findByAgentId" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE agent_id = #{agentId}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByAgentId" resultType="long">
|
||||
SELECT COUNT(1) FROM link_task WHERE agent_id = #{agentId}
|
||||
</select>
|
||||
|
||||
<select id="findByAgentIdAndStatus" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE agent_id = #{agentId} AND status = #{status}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByAgentIdAndStatus" resultType="long">
|
||||
SELECT COUNT(1) FROM link_task WHERE agent_id = #{agentId} AND status = #{status}
|
||||
</select>
|
||||
|
||||
<select id="findByBatchId" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE batch_id = #{batchId}
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{size} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countByBatchId" resultType="long">
|
||||
SELECT COUNT(1) FROM link_task WHERE batch_id = #{batchId}
|
||||
</select>
|
||||
|
||||
<select id="findExpiredTasks" resultMap="LinkTaskMap">
|
||||
SELECT id, batch_id, agent_id, code_no, token_hash, expire_at, status, region, machine_id, login_at, refund_at, revoked_at, created_at, updated_at
|
||||
FROM link_task
|
||||
WHERE expire_at <= #{expireTime} AND status IN ('NEW', 'USING')
|
||||
ORDER BY expire_at ASC
|
||||
LIMIT #{size}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user