lee-zt 2 weeks ago
commit fa9627a9de

File diff suppressed because it is too large Load Diff

@ -0,0 +1,21 @@
package com.luojia_channel.common.config;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.OpenAPI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("珞珈岛API文档")
.version("1.0")
.description("API文档")
);
}
}

@ -19,7 +19,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
"/post/list",
"/post/detail",
"/comment/list",
"/comment/list/reply"
"/comment/list/reply",
"/openapi/luojia-channel"
);
}

@ -1,12 +1,19 @@
package com.luojia_channel.common.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
// 统一返回前端的结果
@Data
@Schema(description = "统一返回前端的结果")
public class Result<T> {
@Schema(description = "状态码")
private int code;
@Schema(description = "提示消息")
private String msg;
@Schema(description = "响应数据")
private T data;
public Result(int code, String msg, T data) {
this.code = code;

@ -112,6 +112,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- openAPI -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.8</version>
</dependency>
</dependencies>
<build>

@ -1,5 +1,6 @@
package com.luojia_channel.modules.file.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -8,10 +9,23 @@ import org.springframework.web.multipart.MultipartFile;
@Data
@AllArgsConstructor
@Builder
@Schema(description = "上传文件DTO")
public class UploadFileDTO {
@Schema(
description = "文件名",
required = true
)
private MultipartFile file;
// 文件类型image or video
@Schema(
description = "文件类型"
)
private String fileType;
// 文件md5
@Schema(
description = "文件md5"
)
private String fileMd5;
}

@ -2,6 +2,8 @@ package com.luojia_channel.modules.interact.controller;
import com.luojia_channel.modules.message.dto.MessageRequest;
import com.luojia_channel.modules.message.server.WebSocketServer;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -10,11 +12,17 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@Tag(name = "聊天模块", description = "好友聊天模块相关接口")
public class ChatController {
private WebSocketServer webSocketServer;
@PostMapping("/sendPrivateMessage")
@Operation(
summary = "发送私信",
description = "发送私信给指定用户",
tags = {"聊天模块"}
)
public String sendPrivateMessage(@RequestParam Long senderId, @RequestBody MessageRequest request) {
try {
webSocketServer.sendPrivateMessage(senderId, request);

@ -3,6 +3,8 @@ package com.luojia_channel.modules.interact.controller;
import com.luojia_channel.common.domain.Result;
import com.luojia_channel.common.domain.UserDTO;
import com.luojia_channel.modules.interact.service.FollowService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -12,19 +14,35 @@ import java.util.List;
@RestController
@RequestMapping("/follow")
@RequiredArgsConstructor
@Tag(name = "关注模块", description = "用户之间互相关注模块")
public class FollowController {
private final FollowService followService;
@PutMapping("/{id}/{isFollow}")
@Operation(
summary = "关注用户",
description = "关注用户传入用户id和是否关注的状态",
tags = {"关注模块"}
)
public Result<Void> follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow){
followService.follow(followUserId, isFollow);
return Result.success();
}
@GetMapping("/or/not/{id}")
@Operation(
summary = "是否关注用户",
description = "传入用户id返回是否关注该用户",
tags = {"关注模块"}
)
public Result<Boolean> isFollow(@PathVariable("id") Long followUserId){
return Result.success(followService.isFollow(followUserId));
}
@GetMapping("/common/{id}")
@Operation(
summary = "关注列表",
description = "传入用户id返回该用户的关注列表",
tags = {"关注模块"}
)
public Result<List<UserDTO>> followCommons(@PathVariable("id") Long id){
return Result.success(followService.followCommons(id));
}

@ -3,6 +3,7 @@ package com.luojia_channel.modules.interact.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@ -10,6 +11,7 @@ import java.time.LocalDateTime;
@Data
@TableName("follow")
@Schema(description = "关注表")
public class Follow implements Serializable {
@ -22,16 +24,25 @@ public class Follow implements Serializable {
/**
* id
*/
@Schema(
description = "用户id"
)
private Long userId;
/**
* id
*/
@Schema(
description = "关联的用户id"
)
private Long followUserId;
/**
*
*/
@Schema(
description = "创建时间"
)
private LocalDateTime createTime;

@ -1,5 +1,6 @@
package com.luojia_channel.modules.message.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -9,10 +10,38 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "消息请求对象")
public class MessageRequest {
@Schema(
description = "消息类型0-私信1-系统通知",
allowableValues = {"0", "1"},
example = "0",
implementation = Integer.class
)
private Integer messageType; // 私信0系统通知1
@Schema(
description = "消息内容",
required = true,
minLength = 1,
maxLength = 500
)
private String content; // 消息内容
@Schema(
description = "接收者ID"
)
private Long receiverId; // 接收者ID
@Schema(
description = "发送者用户名",
required = true
)
private String senderName; // 用户名
@Schema(
description = "发送者头像",
required = true
)
private String senderAvatar; // 用户头像
}

@ -1,5 +1,6 @@
package com.luojia_channel.modules.message.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -11,12 +12,48 @@ import java.time.LocalDateTime;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "消息返回对象")
public class MessageResponse {
@Schema(
description = "消息类型0-私信1-系统通知",
allowableValues = {"0", "1"},
example = "0",
implementation = Integer.class
)
private Integer messageType; // 私信0系统通知1
@Schema(
description = "消息内容",
required = true,
minLength = 1,
maxLength = 500
)
private String content; // 消息内容
@Schema(
description = "发送者ID"
)
private Long senderId;
@Schema(
description = "接收者ID"
)
private Long receiverId; // 接收者ID
@Schema(
description = "发送者用户名",
required = true
)
private String senderName; // 用户名
@Schema(
description = "发送者头像",
required = true
)
private String senderAvatar; // 用户头像
@Schema(
description = "消息创建时间"
)
private LocalDateTime createTime;
}

@ -9,6 +9,10 @@ import com.luojia_channel.modules.post.dto.resp.CommentInfoDTO;
import com.luojia_channel.modules.post.entity.Comment;
import com.luojia_channel.modules.post.service.CommentService;
import com.luojia_channel.modules.post.utils.ValidatePostUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -18,12 +22,21 @@ import java.util.List;
@RequiredArgsConstructor
@RestController
@RequestMapping("/comment")
@Tag(name = "评论模块", description = "评论相关接口")
public class CommentController {
private final CommentService commentService;
// 创建评论
@PostMapping
@Operation(
summary = "创建评论",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "创建成功"),
@ApiResponse(responseCode = "500", description = "创建失败,请稍后重试")
})
public Result<Void> saveComment(@RequestBody CommentSaveDTO commentSaveDTO) {
commentService.saveComment(commentSaveDTO);
return Result.success();
@ -31,6 +44,14 @@ public class CommentController {
// 更新评论
@PutMapping
@Operation(
summary = "更新评论",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "更新成功"),
@ApiResponse(responseCode = "500", description = "更新失败,请稍后重试")
})
public Result<Void> updateComment(@RequestBody CommentSaveDTO commentSaveDTO) {
commentService.updateComment(commentSaveDTO);
return Result.success();
@ -38,6 +59,14 @@ public class CommentController {
// 删除评论
@DeleteMapping
@Operation(
summary = "删除评论",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "删除成功"),
@ApiResponse(responseCode = "500", description = "删除失败,评论不存在或被删除")
})
public Result<Void> deleteComment(@RequestParam("id") Long id) {
commentService.deleteComment(id);
return Result.success();
@ -45,6 +74,14 @@ public class CommentController {
// 根据帖子ID分页获取根评论
@GetMapping("/list")
@Operation(
summary = "根据帖子ID分页获取根评论",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "获取成功"),
@ApiResponse(responseCode = "500", description = "获取失败帖子ID不合法")
})
public Result<PageResponse<CommentInfoDTO>> getCommentsByPostId(@RequestBody CommentPageQueryDTO commentPageQueryDTO) {
PageResponse<CommentInfoDTO> commentList = commentService.getCommentsByPostId(commentPageQueryDTO);
return Result.success(commentList);
@ -53,6 +90,14 @@ public class CommentController {
// 根据评论ID获取回复
@GetMapping("/list/reply")
@Operation(
summary = "根据评论ID获取回复",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "获取成功"),
@ApiResponse(responseCode = "500", description = "获取失败评论ID不合法")
})
public Result<PageResponse<CommentInfoDTO>> getReplyById(@RequestBody CommentPageQueryDTO commentPageQueryDTO) {
PageResponse<CommentInfoDTO> commentInfoDTOList = commentService.getReplyById(commentPageQueryDTO);
return Result.success(commentInfoDTOList);
@ -60,6 +105,14 @@ public class CommentController {
// 点赞评论
@PutMapping("/like/{id}")
@Operation(
summary = "点赞评论",
tags = {"评论模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "点赞成功"),
@ApiResponse(responseCode = "500", description = "点赞失败,评论不存在或被删除")
})
public Result<Void> likeComment(@PathVariable("id") Long id) {
commentService.likeComment(id);
return Result.success();

@ -8,6 +8,10 @@ import com.luojia_channel.modules.post.dto.req.PostPageQueryDTO;
import com.luojia_channel.modules.post.dto.resp.PostBasicInfoDTO;
import com.luojia_channel.modules.post.dto.resp.PostInfoDTO;
import com.luojia_channel.modules.post.service.PostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -15,12 +19,21 @@ import org.springframework.web.multipart.MultipartFile;
@RequiredArgsConstructor
@RestController
@RequestMapping("/post")
@Tag(name = "帖子模块", description = "帖子相关接口")
public class PostController {
private final PostService postService;
// 创建帖子
@PostMapping
@Operation(
summary = "创建帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "创建成功"),
@ApiResponse(responseCode = "500", description = "创建失败,请稍后重试")
})
public Result<Void> savePost(@RequestBody PostSaveDTO postSaveDTO) {
postService.savePost(postSaveDTO);
return Result.success();
@ -28,12 +41,28 @@ public class PostController {
// 设置帖子封面
@PostMapping("/cover")
@Operation(
summary = "设置帖子封面",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "设置成功"),
@ApiResponse(responseCode = "500", description = "设置失败,请稍后重试")
})
public Result<String> setCover(@RequestParam("file") MultipartFile file){
return Result.success(postService.setCover(file));
}
// 更新帖子
@PutMapping
@Operation(
summary = "更新帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "更新成功"),
@ApiResponse(responseCode = "500", description = "更新失败,请稍后重试")
})
public Result<Void> updatePost(@RequestBody PostSaveDTO postSaveDTO) {
postService.updatePost(postSaveDTO);
return Result.success();
@ -41,6 +70,14 @@ public class PostController {
// 删除帖子
@DeleteMapping
@Operation(
summary = "删除帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "删除成功"),
@ApiResponse(responseCode = "500", description = "删除失败,请稍后重试")
})
public Result<Void> deletePost(@RequestParam("id") Long id) {
postService.deletePost(id);
return Result.success();
@ -48,24 +85,56 @@ public class PostController {
// 根据ID获取帖子详情
@GetMapping("/detail")
@Operation(
summary = "根据ID获取帖子详情",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "获取成功"),
@ApiResponse(responseCode = "500", description = "获取失败,帖子不存在或被删除")
})
public PostInfoDTO getPostDetail(@RequestParam("id") Long id) {
return postService.getPostDetail(id);
}
// 分页查询帖子
@GetMapping("/list")
@Operation(
summary = "分页查询帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "获取成功"),
@ApiResponse(responseCode = "500", description = "获取失败,请稍后重试")
})
public Result<PageResponse<PostBasicInfoDTO>> pagePost(@RequestBody PostPageQueryDTO postPageQueryDTO) {
return Result.success(postService.pagePost(postPageQueryDTO));
}
// 查看自己的帖子
@GetMapping("/of/me")
@Operation(
summary = "查看自己的帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "获取成功"),
@ApiResponse(responseCode = "500", description = "获取失败,请稍后重试")
})
public Result<PageResponse<PostBasicInfoDTO>> pagePostOfMe(@RequestBody PostPageQueryDTO postPageQueryDTO) {
return Result.success(postService.pagePostOfMe(postPageQueryDTO));
}
// 点赞帖子
@PutMapping("/like/{id}")
@Operation(
summary = "点赞帖子",
tags = {"帖子模块"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "点赞成功"),
@ApiResponse(responseCode = "500", description = "点赞失败,帖子不存在或被删除")
})
public Result<Void> likePost(@PathVariable("id") Long id) {
postService.likePost(id);
return Result.success();

@ -1,10 +1,15 @@
package com.luojia_channel.modules.post.dto.req;
import com.luojia_channel.common.domain.page.PageRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(title = "分页查询评论请求DTO")
public class CommentPageQueryDTO extends PageRequest {
@Schema(title = "帖子ID")
private Long postId;
@Schema(title = "评论ID")
private Long commentId;
}

@ -1,5 +1,6 @@
package com.luojia_channel.modules.post.dto.req;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -11,10 +12,34 @@ import java.time.LocalDateTime;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Schema(description = "评论保存DTO")
public class CommentSaveDTO {
@Schema(
description = "评论id"
)
private Long id;
@Schema(
description = "评论内容",
required = true,
minLength = 1,
maxLength = 500,
example = "+3"
)
private String content;
@Schema(
description = "评论的帖子id"
)
private Long postId;
@Schema(
description = "该评论的父评论id"
)
private Long parentCommentId;
@Schema(
description = "该评论的顶级评论id"
)
private Long topId;
}

@ -1,13 +1,49 @@
package com.luojia_channel.modules.post.dto.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "帖子保存DTO")
public class PostSaveDTO {
@Schema(
description = "帖子ID"
)
private Long id;
@Schema(
description = "帖子标题",
required = true,
minLength = 3,
maxLength = 16,
example = "帖子标题三个字"
)
private String title;
@Schema(
description = "帖子封面图"
)
private String image;
@Schema(
description = "帖子内容",
required = true,
minLength = 4,
maxLength = 10000,
example = "zsbd"
)
private String content;
@Schema(
description = "帖子类型id"
)
private Long categoryId;
@Schema(
description = "是否匿名发布1-匿名0-不匿名",
allowableValues = {"0", "1"},
example = "0",
implementation = Integer.class
)
private Integer status; // 是否匿名
}

@ -1,5 +1,6 @@
package com.luojia_channel.modules.post.dto.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -12,21 +13,69 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Schema(description = "评论信息")
public class CommentInfoDTO {
@Schema(
description = "评论id"
)
private Long id;
@Schema(
description = "评论内容",
minLength = 1,
maxLength = 500,
example = "+3"
)
private String content;
@Schema(
description = "评论点赞数"
)
private Long likeCount;
@Schema(
description = "评论回复数"
)
private Long replyCount;
@Schema(
description = "评论用户id"
)
private Long userId;
@Schema(
description = "评论对应的帖子id"
)
private Long postId;
@Schema(
description = "评论对应的父级评论id"
)
private Long parentCommentId;
@Schema(
description = "评论对应的顶级评论id"
)
private Long topId;
@Schema(
description = "评论创建时间"
)
private LocalDateTime createTime;
@Schema(
description = "当前用户是否对评论点过赞,1-已点赞0-未点赞",
allowableValues = {"0", "1"},
example = "1",
implementation = Boolean.class
)
private Boolean isLike;
private String userName;
private String userAvatar;
@Schema(
description = "子评论列表"
)
private List<CommentInfoDTO> commentInfoDTOList;
}

@ -1,20 +1,65 @@
package com.luojia_channel.modules.post.dto.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "帖子基本信息")
public class PostBasicInfoDTO {
@Schema(
description = "帖子ID"
)
private Long id;
@Schema(
description = "帖子封面图"
)
private String image;
@Schema(
description = "帖子标题",
required = true,
minLength = 3,
maxLength = 16,
example = "帖子标题三个字"
)
private String title;
@Schema(
description = "点赞数"
)
private Integer likeCount;
@Schema(
description = "评论数"
)
private Integer commentCount;
@Schema(
description = "收藏数"
)
private Integer favoriteCount;
@Schema(
description = "是否点赞,1-已点赞,0-未点赞",
allowableValues = {"0", "1"},
example = "1",
implementation = Boolean.class
)
private Boolean isLike;
@Schema(
description = "对应的用户ID"
)
private Long userId;
// 对于匿名的帖子,下述字段进行了处理,如匿名默认名称,头像
@Schema(
description = "匿名情况下用户名"
)
private String userName;
@Schema(
description = "匿名情况下用户头像"
)
private String userAvatar;
}

@ -1,21 +1,75 @@
package com.luojia_channel.modules.post.dto.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "修改帖子信息")
public class PostInfoDTO {
@Schema(
description = "帖子ID"
)
private Long id;
@Schema(
description = "帖子封面图"
)
private String image;
@Schema(
description = "帖子标题",
required = true,
minLength = 3,
maxLength = 16,
example = "帖子标题三个字"
)
private String title;
@Schema(
description = "帖子内容",
required = true,
minLength = 4,
maxLength = 10000,
example = "zsbd"
)
private String content;
@Schema(
description = "点赞数"
)
private Integer likeCount;
@Schema(
description = "评论数"
)
private Integer commentCount;
@Schema(
description = "收藏数"
)
private Integer favoriteCount;
@Schema(
description = "是否点赞,1-已点赞0-未点赞",
allowableValues = {"0", "1"},
example = "1",
implementation = Boolean.class
)
private Boolean isLike;
@Schema(
description = "对应用户ID"
)
private Long userId;
// 对于匿名的帖子,下述字段进行了处理,如匿名默认名称,头像
@Schema(
description = "匿名情况下用户名"
)
private String userName;
@Schema(
description = "匿名情况下用户头像"
)
private String userAvatar;
}

@ -4,6 +4,10 @@ import com.luojia_channel.common.domain.Result;
import com.luojia_channel.modules.file.dto.UploadFileDTO;
import com.luojia_channel.modules.user.dto.UserChangeInfoDTO;
import com.luojia_channel.modules.user.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -11,21 +15,46 @@ import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/user/info")
@RequiredArgsConstructor
@Tag(name = "用户信息管理", description = "用户修改个人信息相关接口")
public class UserInfoController {
private final UserInfoService userInfoService;
@PostMapping("/update")
@Operation(
summary="修改用户信息",
tags = {"用户信息管理"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "修改成功"),
@ApiResponse(responseCode = "500", description = "修改失败,请稍后重试")
})
public Result<Void> updateInfo(@RequestBody UserChangeInfoDTO userChangeInfoDTO){
userInfoService.updateInfo(userChangeInfoDTO);
return Result.success();
}
@PostMapping("/password")
@Operation(
summary="用户修改密码",
tags = {"用户信息管理"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "修改成功"),
@ApiResponse(responseCode = "500", description = "修改失败,请稍后重试")
})
public Result<Void> updatePassword(@RequestParam String password){
userInfoService.updatePassword(password);
return Result.success();
}
@PostMapping("/avatar")
@Operation(
summary="用户上传头像",
tags = {"用户信息管理"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "上传成功"),
@ApiResponse(responseCode = "500", description = "上传失败,请稍后重试")
})
public Result<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
return Result.success(userInfoService.uploadAvatar(file));
}

@ -5,6 +5,13 @@ import com.luojia_channel.common.domain.UserDTO;
import com.luojia_channel.modules.user.dto.UserLoginDTO;
import com.luojia_channel.modules.user.dto.UserRegisterDTO;
import com.luojia_channel.modules.user.service.UserLoginService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -12,25 +19,50 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Tag(name = "用户管理", description = "用户登陆注册相关接口")
public class UserLoginController {
private final UserLoginService userLoginService;
@PostMapping("/login")
@Operation(
summary = "用户登录",
description = "支持用户名/手机号/邮箱登录",
tags = {"用户管理"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "登录成功",content = @Content(schema = @Schema(implementation = UserDTO.class))),
@ApiResponse(responseCode = "500", description = "登录失败,用户名或密码错误")
})
public Result<UserDTO> login(@RequestBody UserLoginDTO userLoginDTO){
return Result.success(userLoginService.login(userLoginDTO));
}
@PostMapping("/register")
@Operation(
summary = "用户注册",
description = "支持用户名/手机号/邮箱注册",
tags = {"用户管理"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "注册成功"),
@ApiResponse(responseCode = "500", description = "注册失败,请稍后重试")
})
public Result<UserDTO> register(@RequestBody UserRegisterDTO userRegisterDTO){
return Result.success(userLoginService.register(userRegisterDTO));
}
@PostMapping("/logout")
@Operation(
summary = "用户登出",
tags = {"用户管理"}
)
public Result<Void> logout(HttpServletRequest request){
userLoginService.logout(request);
return Result.success();
}
@Hidden
@PostMapping("/hello")
@Operation(summary = "测试接口")
public Result<String> hello(){
return Result.success("hello");
}

@ -1,20 +1,46 @@
package com.luojia_channel.modules.user.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "用户修改信息DTO")
public class UserChangeInfoDTO {
@Schema(
description = "用户名"
)
private String username;
@Schema(
description = "手机号,11位数字"
)
private String phone;
@Schema(
description = "邮箱"
)
private String email;
@Schema(
description = "学生学号"
)
private String studentId;
@Schema(
description = "头像url"
)
private String avatar;
@Schema(
description = "性别,0-未知1-男2-女",
allowableValues = {"0", "1", "2"},
example = "1",
implementation = Integer.class
)
private Integer gender;
@Schema(
description = "学院"
)
private String college;
}

@ -1,11 +1,22 @@
package com.luojia_channel.modules.user.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "用户登录DTO")
public class UserLoginDTO {
// 用户标志,支持学号,手机号,邮箱
@Schema(
description = "用户登录用标志,支持用户名,手机号,邮箱"
)
private String userFlag;
@Schema(
description = "用户登陆用密码",
required = true,
minLength = 6,
maxLength = 16
)
private String password;
}

@ -1,16 +1,44 @@
package com.luojia_channel.modules.user.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "用户注册DTO")
public class UserRegisterDTO {
@Schema(
description = "用户名",
example = "ttt",
required = true,
minLength = 1,
maxLength = 15
)
private String username;
@Schema(
description = "密码",
example = "123456",
required = true,
minLength = 6,
maxLength = 16,
format = "password"
)
private String password;
@Schema(
description = "手机号",
example = "12345678901",
pattern = "^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\\d{8}$"
)
private String phone;
@Schema(
description = "邮箱",
example = "123456@qq.com",
pattern = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
)
private String email;
@Schema(description = "学生学号,暂不需要")
private String studentId;
}

@ -1,36 +1,36 @@
# 本地开发环境
# lj:
# db:
# host: localhost
# password: 123456
# redis:
# host: localhost
# port: 6379
# password: 123456
# rabbitmq:
# host: localhost
# port: 15672
# username: root
# password: 123456
# minio:
# endpoint: http://localhost:9000
# accessKey: minioadmin
# secretKey: minioadmin
lj:
#本地开发环境
lj:
db:
host: 192.168.59.129
password: Forely123!
host: localhost
password: 123456
redis:
host: 192.168.59.129
host: localhost
port: 6379
password: Forely123!
password: 123456
rabbitmq:
host: 192.168.59.129
port: 5672
username: admin
password: Forely123!
host: localhost
port: 15672
username: root
password: 123456
minio:
endpoint: http://192.168.59.129:9000
accessKey: forely
secretKey: Forely123!
endpoint: http://localhost:9000
accessKey: minioadmin
secretKey: minioadmin
#lj:
# db:
# host: 192.168.59.129
# password: Forely123!
# redis:
# host: 192.168.59.129
# port: 6379
# password: Forely123!
# rabbitmq:
# host: 192.168.59.129
# port: 5672
# username: admin
# password: Forely123!
# minio:
# endpoint: http://192.168.59.129:9000
# accessKey: forely
# secretKey: Forely123!

@ -1,5 +1,8 @@
server:
port: 8081
springdoc:
api-docs:
path: /openapi/luojia-channel
spring:
application:
name: service

@ -1,36 +1,36 @@
# 本地开发环境
# lj:
# db:
# host: localhost
# password: 123456
# redis:
# host: localhost
# port: 6379
# password: 123456
# rabbitmq:
# host: localhost
# port: 15672
# username: root
# password: 123456
# minio:
# endpoint: http://localhost:9000
# accessKey: minioadmin
# secretKey: minioadmin
lj:
#本地开发环境
lj:
db:
host: 192.168.59.129
password: Forely123!
host: localhost
password: 123456
redis:
host: 192.168.59.129
host: localhost
port: 6379
password: Forely123!
password: 123456
rabbitmq:
host: 192.168.59.129
port: 5672
username: admin
password: Forely123!
host: localhost
port: 15672
username: root
password: 123456
minio:
endpoint: http://192.168.59.129:9000
accessKey: forely
secretKey: Forely123!
endpoint: http://localhost:9000
accessKey: minioadmin
secretKey: minioadmin
#lj:
# db:
# host: 192.168.59.129
# password: Forely123!
# redis:
# host: 192.168.59.129
# port: 6379
# password: Forely123!
# rabbitmq:
# host: 192.168.59.129
# port: 5672
# username: admin
# password: Forely123!
# minio:
# endpoint: http://192.168.59.129:9000
# accessKey: forely
# secretKey: Forely123!

@ -1,5 +1,8 @@
server:
port: 8081
springdoc:
api-docs:
path: /openapi/luojia-channel
spring:
application:
name: service

@ -222,7 +222,7 @@ export default {
}else{
//
ElMessage({
message: '登陆失败,请检查用户名或密码',
message: '登陆失败,用户名或密码错误',
type: 'error',
duration: 500
});

@ -241,7 +241,7 @@ export default {
emit('toggleForm');
} else {
ElMessage({
message: '注册失败',
message: '注册失败,请稍后重试',
type: 'error',
duration: 500
});

Loading…
Cancel
Save