|
@@ -4,11 +4,11 @@ import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.ruoyi.common.annotation.Anonymous;
|
|
|
import com.ruoyi.common.constant.HttpStatus;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
-import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.exception.user.ProjectException;
|
|
@@ -109,15 +109,18 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("获取文章列表")
|
|
|
@GetMapping("/list")
|
|
|
- //@Anonymous
|
|
|
- public TableDataInfo communityList(CommunityArticle communityArticle) {
|
|
|
+ @Anonymous
|
|
|
+ public TableDataInfo communityList(CommunityArticle communityArticle, @RequestParam(required = false) Long userId) {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
|
|
|
TableDataInfo rspData = null;
|
|
|
+ if (userId == null) {
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
+ }
|
|
|
try {
|
|
|
rspData = new TableDataInfo();
|
|
|
- List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(rspData, communityArticle, pageNum, pageSize, searchType);
|
|
|
+ List<CommunityArticleVo> list = communityArticleService.selectCommunityArticleList(userId, rspData, communityArticle, pageNum, pageSize, searchType);
|
|
|
rspData.setCode(HttpStatus.SUCCESS);
|
|
|
rspData.setMsg("查询成功");
|
|
|
rspData.setRows(list);
|
|
@@ -617,7 +620,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
@ApiOperation("关注/取关用户")
|
|
|
@PostMapping("/likeUser")
|
|
|
@Transactional
|
|
|
- public AjaxResult userLike(@RequestParam("likeUserId") Long likeUserId) {
|
|
|
+ public AjaxResult likeUser(@RequestParam("likeUserId") Long likeUserId) {
|
|
|
if (Objects.isNull(likeUserId)) {
|
|
|
return AjaxResult.error("参数失效!");
|
|
|
}
|
|
@@ -639,12 +642,13 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("获取用户信息")
|
|
|
@GetMapping("/userInfo")
|
|
|
+ @Anonymous
|
|
|
public AjaxResult userInfo(@RequestParam(required = false) Long userId) {
|
|
|
if (Objects.isNull(userId)) {
|
|
|
userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
}
|
|
|
//如果登录的是本人刷新下IP地址
|
|
|
- if (userId != null && userId.equals(SecurityUtils.getLoginUser().getUserId())){
|
|
|
+ if (userId != null && userId.equals(SecurityUtils.getLoginUser().getUserId())) {
|
|
|
SysUser sysUser = new SysUser();
|
|
|
sysUser.setUserId(userId);
|
|
|
sysUser.setLoginIp(IpUtils.getIpAddr());
|
|
@@ -717,13 +721,17 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("获取关注列表")
|
|
|
@GetMapping("/likeUserList")
|
|
|
- public AjaxResult likeUserList(String userName) {
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult likeUserList(String userName, @RequestParam(required = false) Long userId) {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
|
|
|
List<CommunityUserLikeVo> communityUserLikeVos = null;
|
|
|
+ if (userId == null) {
|
|
|
+ userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ }
|
|
|
try {
|
|
|
- communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(SecurityUtils.getLoginUser().getUserId(), userName, pageNum, pageSize, searchType);
|
|
|
+ communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(userId, userName, pageNum, pageSize, searchType);
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
@@ -813,6 +821,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("用户合集")
|
|
|
@GetMapping("/userCollection")
|
|
|
+ @Anonymous
|
|
|
public AjaxResult createCollection(Long userId, Long articleId) {
|
|
|
if (Objects.isNull(userId)) {
|
|
|
return AjaxResult.error("参数异常!");
|
|
@@ -1051,6 +1060,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("查询用户合集")
|
|
|
@GetMapping("/getCollection")
|
|
|
+ @Anonymous
|
|
|
public AjaxResult getCollection(Long collectionId, Long searchType) {
|
|
|
if (Objects.isNull(collectionId)) {
|
|
|
return AjaxResult.error("合集不存在!");
|
|
@@ -1134,13 +1144,16 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("个人喜欢文章")
|
|
|
@GetMapping("/userLike")
|
|
|
- public AjaxResult userLike() {
|
|
|
+ public AjaxResult userLike(@RequestParam(required = false) Long userId) {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 1);
|
|
|
List<CommunityArticleVo> communityArticleVos = null;
|
|
|
+ if (userId == null) {
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
+ }
|
|
|
try {
|
|
|
- communityArticleVos = communityArticleService.selectUserLike(pageNum, pageSize, searchType);
|
|
|
+ communityArticleVos = communityArticleService.selectUserLike(userId, pageNum, pageSize, searchType);
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
@@ -1150,15 +1163,18 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("个人收藏文章")
|
|
|
@GetMapping("/userCollect")
|
|
|
- public AjaxResult userCollect() {
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult userCollect(@RequestParam(required = false) Long userId) {
|
|
|
int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
|
|
int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
|
|
int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 1);
|
|
|
|
|
|
List<CommunityArticleVo> communityArticleVos = null;
|
|
|
try {
|
|
|
- communityArticleVos = communityArticleService.selectUserCollect(pageNum, pageSize, searchType);
|
|
|
-
|
|
|
+ if (userId == null) {
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
+ }
|
|
|
+ communityArticleVos = communityArticleService.selectUserCollect(userId, pageNum, pageSize, searchType);
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
@@ -1168,10 +1184,11 @@ public class CommunityArticleController extends BaseController {
|
|
|
|
|
|
@ApiOperation("个人陪伴信息")
|
|
|
@GetMapping("/userAccompany")
|
|
|
+ @Anonymous
|
|
|
public AjaxResult userAccompany(Long userId) {
|
|
|
|
|
|
if (Objects.isNull(userId)) {
|
|
|
- userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
}
|
|
|
|
|
|
CommunityAccompany communityAccompany = null;
|