-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from stick-i/stick
Stick
- Loading branch information
Showing
78 changed files
with
3,049 additions
and
690 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
blog_main/src/main/java/cn/sticki/blog/config/MybatisPlusConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
blog_main/src/main/java/cn/sticki/blog/controller/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package cn.sticki.blog.controller; | ||
|
||
import cn.sticki.blog.exception.userException.UserArgumentException; | ||
import cn.sticki.blog.pojo.domain.Comment; | ||
import cn.sticki.blog.pojo.domain.User; | ||
import cn.sticki.blog.pojo.vo.CommentListVO; | ||
import cn.sticki.blog.pojo.vo.RestTemplate; | ||
import cn.sticki.blog.security.AuthenticationFacade; | ||
import cn.sticki.blog.service.CommentService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.annotation.Resource; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/comment") | ||
public class CommentController { | ||
|
||
@Resource | ||
private AuthenticationFacade authenticationFacade; | ||
|
||
@Resource | ||
private CommentService commentService; | ||
|
||
/** | ||
* 新增评论 | ||
* | ||
* @param comment 必须传入被评论的博客id和评论内容 | ||
*/ | ||
@PostMapping | ||
public RestTemplate createComment(@RequestBody Comment comment) { | ||
if (comment.getBlogId() == null || comment.getContent() == null) | ||
throw new UserArgumentException(); | ||
User user = authenticationFacade.getUser(); | ||
comment.setUserId(user.getId()); | ||
commentService.create(comment); | ||
return new RestTemplate(); | ||
} | ||
|
||
/** | ||
* 删除评论 | ||
* | ||
* @param id 评论id | ||
*/ | ||
@DeleteMapping | ||
public RestTemplate deleteComment(@RequestParam Integer id) { | ||
User user = authenticationFacade.getUser(); | ||
commentService.checkAndDelete(user.getId(), id); | ||
return new RestTemplate(); | ||
} | ||
|
||
/** | ||
* 获取评论列表 | ||
* | ||
* @param blogId 评论的博客id | ||
*/ | ||
@GetMapping("/list") | ||
public RestTemplate getCommentList(@RequestParam Integer blogId, @RequestParam Integer page, @RequestParam(defaultValue = "3") Integer pageSize) { | ||
CommentListVO commentListVO = commentService.getList(blogId, page, pageSize); | ||
return new RestTemplate(commentListVO); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
blog_main/src/main/java/cn/sticki/blog/controller/UserFollowController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cn.sticki.blog.controller; | ||
|
||
import cn.sticki.blog.pojo.domain.FansBasic; | ||
import cn.sticki.blog.pojo.domain.FollowBasic; | ||
import cn.sticki.blog.pojo.domain.User; | ||
import cn.sticki.blog.pojo.vo.ListVO; | ||
import cn.sticki.blog.pojo.vo.RestTemplate; | ||
import cn.sticki.blog.security.AuthenticationFacade; | ||
import cn.sticki.blog.service.UserFollowService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.annotation.Resource; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/user") | ||
public class UserFollowController { | ||
|
||
// 默认每页20条 | ||
private final int pageSize = 20; | ||
|
||
@Resource | ||
private AuthenticationFacade authenticationFacade; | ||
|
||
@Resource | ||
private UserFollowService userFollowService; | ||
|
||
@GetMapping("/follow") | ||
public RestTemplate getFollowList(@RequestParam(defaultValue = "1") int page) { | ||
User user = authenticationFacade.getUser(); | ||
ListVO<FollowBasic> listVO = userFollowService.getFollowList(user.getId(), page, pageSize); | ||
return new RestTemplate(listVO); | ||
} | ||
|
||
@GetMapping("/fans") | ||
public RestTemplate getFansList(@RequestParam(defaultValue = "1") int page) { | ||
User user = authenticationFacade.getUser(); | ||
ListVO<FansBasic> listVO = userFollowService.getFansList(user.getId(), page, pageSize); | ||
return new RestTemplate(listVO); | ||
} | ||
|
||
@PostMapping("/follow") | ||
public RestTemplate doFollow(@NotNull Integer followId) { | ||
User user = authenticationFacade.getUser(); | ||
try { | ||
boolean result = userFollowService.follow(user.getId(), followId); | ||
return new RestTemplate(200, "success", result, true); | ||
} catch (Exception e) { | ||
return new RestTemplate(200, "fail", null, false); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.