|
@@ -6,6 +6,7 @@ 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.CacheConstants;
|
|
|
import com.ruoyi.common.constant.HttpStatus;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -70,6 +71,8 @@ public class CommunityArticleController extends BaseController {
|
|
|
@Autowired
|
|
|
private CommunityCircleMapper communityCircleMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CommunityCircleAssociationMapper communityCircleAssociationMapper;
|
|
|
@Autowired
|
|
|
private CommunityClassCircleMapper communityClassCircleMapper;
|
|
|
|
|
@@ -864,7 +867,10 @@ public class CommunityArticleController extends BaseController {
|
|
|
if (!circleIds.isEmpty()) {
|
|
|
communityCircles = communityCircleMapper.selectList(new QueryWrapper<CommunityCircle>()
|
|
|
.in("id", circleIds)
|
|
|
- .like("circle_name", circleName));
|
|
|
+ .like("circle_name", circleName)
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
}
|
|
|
|
|
|
//为空返回空值
|
|
@@ -882,7 +888,6 @@ public class CommunityArticleController extends BaseController {
|
|
|
communityCircle.setHeat(size);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
log.info(e.getMessage());
|
|
|
throw new ProjectException();
|
|
@@ -891,6 +896,106 @@ public class CommunityArticleController extends BaseController {
|
|
|
return AjaxResult.success("获取成功!", communityCircles);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("编辑圈子")
|
|
|
+ @PostMapping("/editCircle")
|
|
|
+ @Transactional
|
|
|
+ //@Anonymous
|
|
|
+ public AjaxResult editCircle(@RequestBody CommunityCircleEditVo communityCircleEditVo) {
|
|
|
+ if (Objects.isNull(communityCircleEditVo.getOneId())) {
|
|
|
+ return AjaxResult.error("圈子一级ID不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(communityCircleEditVo.getType())) {
|
|
|
+ return AjaxResult.error("编辑类型不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //圈子
|
|
|
+ CommunityCircle communityCircle = new CommunityCircle();
|
|
|
+ //关联关系
|
|
|
+ CommunityCircleAssociation communityCircleAssociation = new CommunityCircleAssociation();
|
|
|
+
|
|
|
+ String type = String.valueOf(communityCircleEditVo.getType());
|
|
|
+ try {
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case "1":
|
|
|
+ //查询圈子
|
|
|
+ CommunityCircle circle = communityCircleMapper.selectOne(new QueryWrapper<CommunityCircle>()
|
|
|
+ .eq("circle_name", communityCircleEditVo.getTwoName())
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+ if (circle != null){
|
|
|
+ return AjaxResult.success("圈子名称已经存在无法添加");
|
|
|
+ }
|
|
|
+ //增加圈子
|
|
|
+ communityCircle.setCircleName(communityCircleEditVo.getTwoName());
|
|
|
+ communityCircle.setImageUrl(communityCircleEditVo.getTwoImg());
|
|
|
+ communityCircle.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityCircle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCircleMapper.insert(communityCircle);
|
|
|
+
|
|
|
+ //增加圈子的关联关系
|
|
|
+ communityCircleAssociation.setCircleId(communityCircle.getId());
|
|
|
+ communityCircleAssociation.setExpandId(communityCircleEditVo.getOneId());
|
|
|
+ communityCircleAssociation.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityCircleAssociation.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCircleAssociationMapper.insert(communityCircleAssociation);
|
|
|
+
|
|
|
+ return AjaxResult.success("添加成功");
|
|
|
+ case "2":
|
|
|
+ //查询圈子
|
|
|
+ CommunityCircle editCircle = communityCircleMapper.selectOne(new QueryWrapper<CommunityCircle>()
|
|
|
+ .eq("id", communityCircleEditVo.getTwoId())
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+
|
|
|
+ //编辑圈子
|
|
|
+ if (!Objects.isNull(communityCircleEditVo.getTwoName())) {
|
|
|
+ editCircle.setCircleName(communityCircleEditVo.getTwoName());
|
|
|
+ }
|
|
|
+ if (!Objects.isNull(communityCircleEditVo.getTwoImg())) {
|
|
|
+ editCircle.setImageUrl(communityCircleEditVo.getTwoImg());
|
|
|
+ }
|
|
|
+
|
|
|
+ editCircle.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ editCircle.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCircleMapper.updateById(editCircle);
|
|
|
+
|
|
|
+ //查询关联关系ID
|
|
|
+ communityCircleAssociation = communityCircleAssociationMapper.selectOne(new QueryWrapper<CommunityCircleAssociation>()
|
|
|
+ .eq("circle_id", communityCircleEditVo.getTwoId()));
|
|
|
+
|
|
|
+ //修改圈子的关联关系
|
|
|
+ communityCircleAssociation.setExpandId(communityCircleEditVo.getOneId());
|
|
|
+ communityCircleAssociation.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityCircleAssociation.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCircleAssociationMapper.updateById(communityCircleAssociation);
|
|
|
+
|
|
|
+ return AjaxResult.success("编辑成功");
|
|
|
+ case "3":
|
|
|
+ //删除圈子 关联关系不用删 直接给圈子变更
|
|
|
+ CommunityCircle deleteCircle = communityCircleMapper.selectOne(new QueryWrapper<CommunityCircle>()
|
|
|
+ .eq("id", communityCircleEditVo.getTwoId())
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+
|
|
|
+ deleteCircle.setIsDelete(true);
|
|
|
+ deleteCircle.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ deleteCircle.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
+ communityCircleMapper.updateById(deleteCircle);
|
|
|
+ return AjaxResult.success("删除成功");
|
|
|
+ default:
|
|
|
+ return AjaxResult.error("无效的操作类型");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info(e.getMessage());
|
|
|
+ return AjaxResult.error("操作失败");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@ApiOperation("收藏/取关圈子")
|
|
|
@PostMapping("/circle")
|
|
@@ -1153,7 +1258,7 @@ public class CommunityArticleController extends BaseController {
|
|
|
@ApiOperation("用户合集")
|
|
|
@GetMapping("/userCollection")
|
|
|
@Anonymous
|
|
|
- public AjaxResult createCollection(Long userId, Long articleId) {
|
|
|
+ public AjaxResult userCollection(Long userId, Long articleId) {
|
|
|
if (Objects.isNull(userId)) {
|
|
|
return AjaxResult.error("参数异常!");
|
|
|
}
|