|
@@ -10,10 +10,11 @@ import com.ruoyi.common.exception.user.ProjectException;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
-import com.ruoyi.generator.domain.Community.CommunityTag;
|
|
|
|
-import com.ruoyi.generator.domain.Community.CommunityTagBlock;
|
|
|
|
|
|
+import com.ruoyi.generator.domain.Community.*;
|
|
import com.ruoyi.generator.mapper.community.CommunityTagBlockMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityTagBlockMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityTagMapper;
|
|
import com.ruoyi.generator.mapper.community.CommunityTagMapper;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityUserCircleMapper;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityUserTagMapper;
|
|
import com.ruoyi.generator.service.ICommunityTagService;
|
|
import com.ruoyi.generator.service.ICommunityTagService;
|
|
import com.ruoyi.generator.vo.CommunityTagVo;
|
|
import com.ruoyi.generator.vo.CommunityTagVo;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -51,6 +52,11 @@ public class CommunityTagController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommunityUserCircleMapper communityUserCircleMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommunityUserTagMapper communityUserTagMapper;
|
|
/**
|
|
/**
|
|
* 获取标签信息
|
|
* 获取标签信息
|
|
*/
|
|
*/
|
|
@@ -77,6 +83,113 @@ public class CommunityTagController extends BaseController {
|
|
return AjaxResult.success(communityTags);
|
|
return AjaxResult.success(communityTags);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取我创建的标签
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("我创建的标签")
|
|
|
|
+ @GetMapping("/createdTags")
|
|
|
|
+ @Transactional
|
|
|
|
+ //@Anonymous
|
|
|
|
+ public AjaxResult createdTags(String tagName,Long userId) {
|
|
|
|
+ if (userId == null) {
|
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
|
+ }
|
|
|
|
+ List<CommunityTag> communityTags = null;
|
|
|
|
+ try {
|
|
|
|
+ Page<CommunityTag> page = new Page<>(1, 20);
|
|
|
|
+ communityTags = communityTagService.page(page, new QueryWrapper<CommunityTag>().and((wrapper) -> {
|
|
|
|
+ wrapper.ne("is_delete", 1)
|
|
|
|
+ .or()
|
|
|
|
+ .isNull("is_delete");
|
|
|
|
+ })
|
|
|
|
+ .like("tag_name", tagName)
|
|
|
|
+ .eq("create_by", userId)
|
|
|
|
+ .orderByDesc("tag_hot")).getRecords();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(communityTags);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation("收藏/取关标签")
|
|
|
|
+ @PostMapping("/likeTag")
|
|
|
|
+ @Transactional
|
|
|
|
+ //@Anonymous
|
|
|
|
+ public AjaxResult likeTag(@RequestBody CommunityUserTag communityUserTag) {
|
|
|
|
+ if (Objects.isNull(communityUserTag.getTagId())) {
|
|
|
|
+ return AjaxResult.error("关注圈子异常,请刷新页面重试!");
|
|
|
|
+ }
|
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
+ String msg = "";
|
|
|
|
+ try {
|
|
|
|
+ CommunityUserTag userTag = communityUserTagMapper
|
|
|
|
+ .selectOne(new QueryWrapper<CommunityUserTag>()
|
|
|
|
+ .eq("tag_id", communityUserTag.getTagId())
|
|
|
|
+ .eq("user_id", userId)
|
|
|
|
+ .eq("is_delete", 0));
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(userTag) || Objects.isNull(userTag.getId())) {
|
|
|
|
+ //如果未找到数据,则进行关注
|
|
|
|
+ userTag = new CommunityUserTag();
|
|
|
|
+ userTag.setTagId(communityUserTag.getTagId());
|
|
|
|
+ userTag.setUserId(userId);
|
|
|
|
+ userTag.setCreateBy(userId);
|
|
|
|
+ userTag.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityUserTagMapper.insert(userTag);
|
|
|
|
+ msg = "已关注";
|
|
|
|
+ } else {
|
|
|
|
+ //更新删除标识
|
|
|
|
+ userTag.setDelete(true);
|
|
|
|
+ userTag.setUpdateBy(userId);
|
|
|
|
+ userTag.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityUserTagMapper.updateById(userTag);
|
|
|
|
+ msg = "已取关";
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(msg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取我关注的标签
|
|
|
|
+ */
|
|
|
|
+ @ApiOperation("我关注的标签")
|
|
|
|
+ @GetMapping("/likeTags")
|
|
|
|
+ @Transactional
|
|
|
|
+ //@Anonymous
|
|
|
|
+ public AjaxResult likeTags(String tagName,Long userId) {
|
|
|
|
+ if (userId == null) {
|
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
|
+ }
|
|
|
|
+ List<CommunityTag> communityTags = null;
|
|
|
|
+ try {
|
|
|
|
+ //获取关注的圈子ID
|
|
|
|
+ List<CommunityUserTag> userTags = communityUserTagMapper
|
|
|
|
+ .selectList(new QueryWrapper<CommunityUserTag>()
|
|
|
|
+ .eq("user_id", userId)
|
|
|
|
+ .eq("is_delete", 0));
|
|
|
|
+
|
|
|
|
+ List<Long> tagList = userTags.stream().map(CommunityUserTag::getTagId).collect(Collectors.toList());
|
|
|
|
+ communityTags= communityTagMapper.selectList(new QueryWrapper<CommunityTag>()
|
|
|
|
+ .in("id", tagList)
|
|
|
|
+ .and((wrapper) -> {
|
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
+ throw new ProjectException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(communityTags);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取标签信息(当前用户是否已拉黑)
|
|
* 获取标签信息(当前用户是否已拉黑)
|