重构底层框架
This commit is contained in:
+8
-33
@@ -15,45 +15,20 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>patbond-common</name>
|
||||
<description>Common dependencies and shared code for Patbond services</description>
|
||||
<description>Stable cross-module contracts and base types for Patbond services</description>
|
||||
|
||||
<!-- Contract-only module: keep dependencies to the validation API the shared
|
||||
DTOs are annotated with. Web, messaging, and Feign concerns live in the
|
||||
service modules that actually need them (development-plan 4.1). -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.patbond.patbond.common.user;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class CreateUserRequest {
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.patbond.patbond.common.user;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class VerifyPasswordRequest {
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.patbond.patbond.common.response;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ApiResponseTest {
|
||||
|
||||
@Test
|
||||
void successWrapsDataWithCodeZero() {
|
||||
ApiResponse<String> response = ApiResponse.success("payload");
|
||||
|
||||
assertThat(response.getCode()).isZero();
|
||||
assertThat(response.getMessage()).isEqualTo("success");
|
||||
assertThat(response.getData()).isEqualTo("payload");
|
||||
assertThat(response.isSuccess()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void failureCarriesCodeAndMessageWithoutData() {
|
||||
ApiResponse<Object> response = ApiResponse.failure(409, "用户名已存在");
|
||||
|
||||
assertThat(response.getCode()).isEqualTo(409);
|
||||
assertThat(response.getMessage()).isEqualTo("用户名已存在");
|
||||
assertThat(response.getData()).isNull();
|
||||
assertThat(response.isSuccess()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultInstanceIsNotSuccess() {
|
||||
assertThat(new ApiResponse<String>().isSuccess()).isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user