|
@@ -1,5 +1,7 @@
|
|
|
package com.ruoyi.generator.controller;
|
|
|
|
|
|
+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.constant.HttpStatus;
|
|
@@ -86,6 +88,9 @@ public class CommunityArticleController extends BaseController {
|
|
|
@Autowired
|
|
|
private CommunityTagMapper communityTagMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CommunityCircleExpandMapper communityCircleExpandMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取文章列表信息
|
|
|
*/
|
|
@@ -171,17 +176,43 @@ public class CommunityArticleController extends BaseController {
|
|
|
@ApiOperation("获取文章圈子列表")
|
|
|
//@Anonymous
|
|
|
public AjaxResult getCircleList() {
|
|
|
- List<CommunityCircle> communityClasses = null;
|
|
|
+ List<CommunityCircleExpand> communityCircleExpands = null;
|
|
|
+ JSONArray sumArray = new JSONArray();
|
|
|
try {
|
|
|
- communityClasses = communityCircleMapper.selectList(new QueryWrapper<CommunityCircle>());
|
|
|
- for (CommunityCircle communityCircle : communityClasses) {
|
|
|
- String className = communityClassCircleMapper.getClassNameByCircleId(communityCircle.getId());
|
|
|
- communityCircle.setCircleName(className + "·" + communityCircle.getCircleName());
|
|
|
+ communityCircleExpands = communityCircleExpandMapper.selectList(new QueryWrapper<CommunityCircleExpand>());
|
|
|
+
|
|
|
+ for (CommunityCircleExpand communityCircleExpand : communityCircleExpands) {
|
|
|
+ String circleName = communityCircleExpand.getCircleName();
|
|
|
+ Long id = communityCircleExpand.getId();
|
|
|
+
|
|
|
+ JSONObject oneObject = new JSONObject(); // 每次循环创建新的 JSONObject
|
|
|
+ oneObject.put("oneName", circleName);
|
|
|
+
|
|
|
+ JSONArray twoArray = new JSONArray();
|
|
|
+ List<CommunityCircle> classNameByCircleId = communityClassCircleMapper.getClassNameByCircleId(id);
|
|
|
+ // 将 List<CommunityCircle> 转换为 JSONArray
|
|
|
+ for (CommunityCircle communityCircle : classNameByCircleId) {
|
|
|
+ JSONObject twoObject = new JSONObject();
|
|
|
+ twoObject.put("twoName", communityCircle.getCircleName());
|
|
|
+ twoObject.put("twoImg", communityCircle.getImageUrl()); // 假设有这个方法
|
|
|
+ twoArray.add(twoObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ oneObject.put("one", twoArray);
|
|
|
+ sumArray.add(oneObject); // 添加到 sumArray
|
|
|
+ System.out.println("twoArray:" + twoArray);
|
|
|
+ System.out.println("sumArray:" + sumArray);
|
|
|
}
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
- throw new ProjectException();
|
|
|
+ e.printStackTrace();
|
|
|
+ // 这里可以选择抛出自定义异常或者记录日志
|
|
|
+ // throw new ProjectException();
|
|
|
+ } finally {
|
|
|
+ // 可以在这里进行资源清理操作,如果有的话
|
|
|
}
|
|
|
- return AjaxResult.success(communityClasses);
|
|
|
+
|
|
|
+ return AjaxResult.success(sumArray);
|
|
|
}
|
|
|
|
|
|
|