Update pom.xml for MyBatis Plus integration and downgrade Spring Boot version; refactor validation imports from Jakarta to Javax; modify mappers to extend BaseMapper for CRUD operations; clean up unused MyBatis-Flex mappers; adjust application.yml for MyBatis Plus configuration.
This commit is contained in:
16
pom.xml
16
pom.xml
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<version>2.7.18</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<mybatis.spring.boot.version>3.0.3</mybatis.spring.boot.version>
|
||||
<mybatis-plus.version>3.5.8</mybatis-plus.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -33,11 +33,11 @@
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis starter (JDBC, blocking) -->
|
||||
<!-- MyBatis Plus starter -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>${mybatis.spring.boot.version}</version>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MySQL JDBC driver -->
|
||||
@@ -88,8 +88,8 @@
|
||||
<!-- Swagger/OpenAPI Documentation -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<artifactId>springdoc-openapi-webflux-ui</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Commons Codec for SHA-256 and hex utils -->
|
||||
|
||||
@@ -6,7 +6,7 @@ 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 javax.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.gameplatform.server.security.JwtService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import jakarta.validation.Valid;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.gameplatform.server.service.link.LinkStatusService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import javax.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.springframework.web.server.ServerWebInputException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@@ -92,7 +92,7 @@ public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(ResponseStatusException.class)
|
||||
public Object handleRse(ResponseStatusException e) {
|
||||
var status = e.getStatusCode();
|
||||
var status = e.getStatus();
|
||||
log.warn("{} ResponseStatusException: {} - Stack: {}",
|
||||
status, e.getReason(), getStackTrace(e));
|
||||
return body(status.value(), e.getReason());
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.gameplatform.server.mapper.account;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.account.UserAccount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface UserAccountMapper {
|
||||
@Mapper
|
||||
public interface UserAccountMapper extends BaseMapper<UserAccount> {
|
||||
UserAccount findByUsernameAndType(@Param("username") String username,
|
||||
@Param("userType") String userType);
|
||||
UserAccount findByUsername(@Param("username") String username);
|
||||
UserAccount findById(@Param("id") Long id);
|
||||
int insert(UserAccount account);
|
||||
int update(UserAccount account);
|
||||
int setStatus(@Param("id") Long id, @Param("status") String status);
|
||||
int updatePassword(@Param("id") Long id, @Param("passwordHash") String passwordHash);
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gameplatform.server.mapper.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.admin.Announcement;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnnouncementMapper {
|
||||
@Mapper
|
||||
public interface AnnouncementMapper extends BaseMapper<Announcement> {
|
||||
Announcement findById(@Param("id") Long id);
|
||||
|
||||
int insert(Announcement announcement);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gameplatform.server.mapper.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.admin.OperationLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OperationLogMapper {
|
||||
@Mapper
|
||||
public interface OperationLogMapper extends BaseMapper<OperationLog> {
|
||||
OperationLog findById(@Param("id") Long id);
|
||||
|
||||
int insert(OperationLog operationLog);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gameplatform.server.mapper.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.admin.SystemConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SystemConfigMapper {
|
||||
@Mapper
|
||||
public interface SystemConfigMapper extends BaseMapper<SystemConfig> {
|
||||
SystemConfig findById(@Param("id") Long id);
|
||||
|
||||
SystemConfig findByKey(@Param("configKey") String configKey);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.agent.AgentPointsTx;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AgentPointsTxMapper {
|
||||
@Mapper
|
||||
public interface AgentPointsTxMapper extends BaseMapper<AgentPointsTx> {
|
||||
AgentPointsTx findById(@Param("id") Long id);
|
||||
|
||||
int insert(AgentPointsTx agentPointsTx);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.agent.LinkBatch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkBatchMapper {
|
||||
@Mapper
|
||||
public interface LinkBatchMapper extends BaseMapper<LinkBatch> {
|
||||
LinkBatch findById(@Param("id") Long id);
|
||||
|
||||
int insert(LinkBatch linkBatch);
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.agent.LinkTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkTaskMapper {
|
||||
@Mapper
|
||||
public interface LinkTaskMapper extends BaseMapper<LinkTask> {
|
||||
LinkTask findById(@Param("id") Long id);
|
||||
|
||||
LinkTask findByCodeNo(@Param("codeNo") String codeNo);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.agent.LinkBatch;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* MyBatis-Flex Mapper for LinkBatch
|
||||
* 提供高性能的查询构建器和自动生成的基础CRUD操作
|
||||
*/
|
||||
@Mapper
|
||||
public interface LinkBatchFlexMapper extends BaseMapper<LinkBatch> {
|
||||
// MyBatis-Flex 会自动提供完整的CRUD操作
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.gameplatform.server.mapper.agent;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.gameplatform.server.model.entity.agent.LinkTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* MyBatis-Flex Mapper for LinkTask
|
||||
* 提供高性能的查询构建器和自动生成的基础CRUD操作
|
||||
*/
|
||||
@Mapper
|
||||
public interface LinkTaskFlexMapper extends BaseMapper<LinkTask> {
|
||||
// MyBatis-Flex 会自动提供以下方法:
|
||||
// - selectById
|
||||
// - selectByMap
|
||||
// - selectByCondition
|
||||
// - selectListByCondition
|
||||
// - selectCountByCondition
|
||||
// - selectPageByCondition
|
||||
// - insert
|
||||
// - insertBatch
|
||||
// - update
|
||||
// - updateByCondition
|
||||
// - delete
|
||||
// - deleteByCondition
|
||||
// 等等...
|
||||
|
||||
// 如果需要自定义 SQL,可以在这里添加方法并在 XML 文件中实现
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "账户创建请求")
|
||||
public class AccountCreateRequest {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gameplatform.server.model.dto.account;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "账户更新请求")
|
||||
public class AccountUpdateRequest {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "重置密码请求")
|
||||
public class ResetPasswordRequest {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gameplatform.server.model.dto.auth;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
public class LoginRequest {
|
||||
@NotBlank
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gameplatform.server.model.dto.link;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
package com.gameplatform.server.model.entity.account;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("user_account")
|
||||
public class UserAccount {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("user_type")
|
||||
private String userType; // ADMIN | AGENT
|
||||
|
||||
private String username; // 登录名(admin/agent 共用)
|
||||
|
||||
@TableField("password_hash")
|
||||
private String passwordHash; // BCrypt 或 PLAIN:xxx(初始化用)
|
||||
|
||||
private String status; // ENABLED / DISABLED
|
||||
|
||||
@TableField("points_balance")
|
||||
private Long pointsBalance; // 仅 AGENT 使用
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
package com.gameplatform.server.model.entity.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("announcement")
|
||||
public class Announcement {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
@TableField("jump_url")
|
||||
private String jumpUrl;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,16 +1,36 @@
|
||||
package com.gameplatform.server.model.entity.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("operation_log")
|
||||
public class OperationLog {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("actor_type")
|
||||
private String actorType; // admin | agent | system | user
|
||||
|
||||
@TableField("actor_id")
|
||||
private Long actorId;
|
||||
|
||||
@TableField("code_no")
|
||||
private String codeNo;
|
||||
|
||||
private String op;
|
||||
|
||||
private String detail; // JSON字符串
|
||||
|
||||
@TableField("client_ip")
|
||||
private String clientIp;
|
||||
|
||||
@TableField("user_agent")
|
||||
private String userAgent;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
package com.gameplatform.server.model.entity.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("system_config")
|
||||
public class SystemConfig {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("config_key")
|
||||
private String configKey;
|
||||
|
||||
@TableField("config_value")
|
||||
private String configValue;
|
||||
|
||||
@TableField("config_type")
|
||||
private String configType;
|
||||
|
||||
private String description;
|
||||
|
||||
@TableField("is_system")
|
||||
private Boolean isSystem;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,17 +1,39 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("agent_points_tx")
|
||||
public class AgentPointsTx {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("account_id")
|
||||
private Long accountId;
|
||||
|
||||
private String type; // ADD | DEDUCT
|
||||
|
||||
@TableField("before_points")
|
||||
private Long beforePoints;
|
||||
|
||||
@TableField("delta_points")
|
||||
private Long deltaPoints;
|
||||
|
||||
@TableField("after_points")
|
||||
private Long afterPoints;
|
||||
|
||||
private String reason; // create_links | manual | refund_no_rollback | other
|
||||
|
||||
@TableField("ref_id")
|
||||
private Long refId;
|
||||
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("link_batch")
|
||||
public class LinkBatch {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("agent_id")
|
||||
private Long agentId;
|
||||
|
||||
private Integer quantity;
|
||||
|
||||
private Integer times;
|
||||
|
||||
@TableField("operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -1,21 +1,50 @@
|
||||
package com.gameplatform.server.model.entity.agent;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("link_task")
|
||||
public class LinkTask {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@TableField("batch_id")
|
||||
private Long batchId;
|
||||
|
||||
@TableField("agent_id")
|
||||
private Long agentId;
|
||||
|
||||
@TableField("code_no")
|
||||
private String codeNo;
|
||||
|
||||
@TableField("token_hash")
|
||||
private String tokenHash;
|
||||
|
||||
@TableField("expire_at")
|
||||
private LocalDateTime expireAt;
|
||||
|
||||
private String status; // NEW | USING | LOGGED_IN | REFUNDED | EXPIRED
|
||||
|
||||
private String region; // Q | V
|
||||
|
||||
@TableField("machine_id")
|
||||
private String machineId;
|
||||
|
||||
@TableField("login_at")
|
||||
private LocalDateTime loginAt;
|
||||
|
||||
@TableField("refund_at")
|
||||
private LocalDateTime refundAt;
|
||||
|
||||
@TableField("revoked_at")
|
||||
private LocalDateTime revokedAt;
|
||||
|
||||
@TableField("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UserService {
|
||||
* 根据ID获取用户账户
|
||||
*/
|
||||
public Mono<AccountResponse> getById(Long id) {
|
||||
return Mono.fromCallable(() -> userAccountMapper.findById(id))
|
||||
return Mono.fromCallable(() -> userAccountMapper.selectById(id))
|
||||
.subscribeOn(Schedulers.boundedElastic())
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::toAccountResponse);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AccountService {
|
||||
}
|
||||
|
||||
public Mono<AccountResponse> get(Long id) {
|
||||
return Mono.fromCallable(() -> mapper.findById(id))
|
||||
return Mono.fromCallable(() -> mapper.selectById(id))
|
||||
.subscribeOn(Schedulers.boundedElastic())
|
||||
.map(this::toResp);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class AccountService {
|
||||
@Transactional
|
||||
public Mono<AccountResponse> update(Long id, AccountUpdateRequest req) {
|
||||
return Mono.fromCallable(() -> {
|
||||
UserAccount db = mapper.findById(id);
|
||||
UserAccount db = mapper.selectById(id);
|
||||
if (db == null) return null;
|
||||
|
||||
// 验证用户名唯一性(如果要更新用户名)
|
||||
@@ -120,8 +120,8 @@ public class AccountService {
|
||||
}
|
||||
}
|
||||
|
||||
mapper.update(patch);
|
||||
return mapper.findById(id);
|
||||
mapper.updateById(patch);
|
||||
return mapper.selectById(id);
|
||||
})
|
||||
.subscribeOn(Schedulers.boundedElastic())
|
||||
.map(this::toResp);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LinkGenerationService {
|
||||
}
|
||||
|
||||
// 获取操作者账户信息
|
||||
UserAccount operator = userAccountMapper.findById(operatorId);
|
||||
UserAccount operator = userAccountMapper.selectById(operatorId);
|
||||
if (operator == null) {
|
||||
throw new IllegalArgumentException("操作者账户不存在");
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class LinkGenerationService {
|
||||
UserAccount patch = new UserAccount();
|
||||
patch.setId(operator.getId());
|
||||
patch.setPointsBalance(after);
|
||||
userAccountMapper.update(patch);
|
||||
userAccountMapper.updateById(patch);
|
||||
}
|
||||
|
||||
GenerateResult result = new GenerateResult();
|
||||
|
||||
@@ -12,11 +12,18 @@ spring:
|
||||
minimum-idle: 2
|
||||
connection-timeout: 30000
|
||||
|
||||
mybatis:
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:mapper/**/*.xml
|
||||
type-aliases-package: com.gameplatform.server.model
|
||||
type-aliases-package: com.gameplatform.server.model.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
logic-delete-field: deleted
|
||||
logic-delete-value: 1
|
||||
logic-not-delete-value: 0
|
||||
|
||||
server:
|
||||
port: 18080
|
||||
@@ -31,7 +38,7 @@ logging:
|
||||
level:
|
||||
root: info
|
||||
com.gameplatform.server: debug
|
||||
org.mybatis: debug
|
||||
com.baomidou.mybatisplus: debug
|
||||
org.apache.ibatis: debug
|
||||
com.zaxxer.hikari: info
|
||||
|
||||
|
||||
@@ -27,26 +27,7 @@
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findById" parameterType="long" resultMap="UserAccountMap">
|
||||
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, 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="status != null">status = #{status},</if>
|
||||
<if test="pointsBalance != null">points_balance = #{pointsBalance},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="setStatus">
|
||||
UPDATE user_account SET status = #{status} WHERE id = #{id}
|
||||
|
||||
Reference in New Issue
Block a user