mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-08-25 01:52:41 +00:00
refactor: 基于 novel 项目 & Spring Cloud 2022 & Spring Cloud Alibaba 2022 重构
This commit is contained in:
35
novel-user/novel-user-api/pom.xml
Normal file
35
novel-user/novel-user-api/pom.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>novel-user</artifactId>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>novel-user-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,26 @@
|
||||
package io.github.xxyopen.novel.user.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户信息 DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UserInfoDto implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package io.github.xxyopen.novel.user.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* 用户信息更新 请求DTO
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoUptReqDto {
|
||||
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "昵称")
|
||||
@Length(min = 2,max = 10)
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "头像地址")
|
||||
@Pattern(regexp="^/[^\s]{10,}\\.(png|PNG|jpg|JPG|jpeg|JPEG|gif|GIF|bpm|BPM)$")
|
||||
private String userPhoto;
|
||||
|
||||
@Schema(description = "性别")
|
||||
@Min(value = 0)
|
||||
@Max(value = 1)
|
||||
private Integer userSex;
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package io.github.xxyopen.novel.user.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录 请求DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/16
|
||||
*/
|
||||
@Data
|
||||
public class UserLoginReqDto {
|
||||
|
||||
@Schema(description = "手机号", required = true, example = "18888888888")
|
||||
@NotBlank(message = "手机号不能为空!")
|
||||
@Pattern(regexp = "^1[3|4|5|6|7|8|9][0-9]{9}$", message = "手机号格式不正确!")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", required = true, example = "123456")
|
||||
@NotBlank(message = "密码不能为空!")
|
||||
private String password;
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package io.github.xxyopen.novel.user.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* 用户注册 请求DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/16
|
||||
*/
|
||||
@Data
|
||||
public class UserRegisterReqDto {
|
||||
|
||||
@Schema(description = "手机号", required = true)
|
||||
@NotBlank(message="手机号不能为空!")
|
||||
@Pattern(regexp="^1[3|4|5|6|7|8|9][0-9]{9}$",message="手机号格式不正确!")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", required = true)
|
||||
@NotBlank(message="密码不能为空!")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "验证码", required = true)
|
||||
@NotBlank(message="验证码不能为空!")
|
||||
@Pattern(regexp="^\\d{4}$",message="验证码格式不正确!")
|
||||
private String velCode;
|
||||
|
||||
/**
|
||||
* 请求会话标识,用来标识图形验证码属于哪个会话
|
||||
* */
|
||||
@Schema(description = "sessionId", required = true)
|
||||
@NotBlank
|
||||
@Length(min = 32,max = 32)
|
||||
private String sessionId;
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package io.github.xxyopen.novel.user.dto.resp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户信息 响应DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UserInfoRespDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
* */
|
||||
@Schema(description = "昵称")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
* */
|
||||
@Schema(description = "用户头像")
|
||||
private String userPhoto;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
* */
|
||||
@Schema(description = "用户性别")
|
||||
private Integer userSex;
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package io.github.xxyopen.novel.user.dto.resp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录 响应DTO
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UserLoginRespDto {
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "用户token")
|
||||
private String token;
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package io.github.xxyopen.novel.user.dto.resp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户注册 响应DTO
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class UserRegisterRespDto {
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "用户token")
|
||||
private String token;
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package io.github.xxyopen.novel.user.feign;
|
||||
|
||||
import io.github.xxyopen.novel.common.constant.ApiRouterConsts;
|
||||
import io.github.xxyopen.novel.common.resp.RestResp;
|
||||
import io.github.xxyopen.novel.user.dto.resp.UserInfoRespDto;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户微服务调用客户端
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2023/3/29
|
||||
*/
|
||||
@Component
|
||||
@FeignClient(value = "novel-user-service", fallback = UserFeign.UserFeignFallback.class)
|
||||
public interface UserFeign {
|
||||
|
||||
/**
|
||||
* 批量查询用户信息
|
||||
*/
|
||||
@PostMapping(ApiRouterConsts.API_INNER_USER_URL_PREFIX + "/listUserInfoByIds")
|
||||
RestResp<List<UserInfoRespDto>> listUserInfoByIds(List<Long> userIds);
|
||||
|
||||
@Component
|
||||
class UserFeignFallback implements UserFeign {
|
||||
|
||||
@Override
|
||||
public RestResp<List<UserInfoRespDto>> listUserInfoByIds(List<Long> userIds) {
|
||||
|
||||
return RestResp.ok(new ArrayList<>(0));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user