|
@@ -122,11 +122,10 @@ public class CommunityArticleController extends BaseController {
|
|
|
@Transactional
|
|
|
//@Anonymous
|
|
|
public AjaxResult article(@RequestBody CommunityArticle communityArticle) {
|
|
|
- if (communityArticle.getClassIds().isEmpty()) {
|
|
|
- return AjaxResult.error("板块不能为空");
|
|
|
- }
|
|
|
-
|
|
|
try {
|
|
|
+ if (communityArticle.getClassIds().isEmpty()) {
|
|
|
+ return AjaxResult.error("板块不能为空");
|
|
|
+ }
|
|
|
communityArticleService.insertCommunityArticle(communityArticle);
|
|
|
} catch (Exception e) {
|
|
|
throw new ProjectException();
|
|
@@ -177,39 +176,31 @@ public class CommunityArticleController extends BaseController {
|
|
|
//@Anonymous
|
|
|
public AjaxResult getCircleList() {
|
|
|
List<CommunityCircleExpand> communityCircleExpands = null;
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
JSONArray sumArray = new JSONArray();
|
|
|
try {
|
|
|
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> classNameByCircleId = communityClassCircleMapper.getClassNameByCircleId(userId,id);
|
|
|
// 将 List<CommunityCircle> 转换为 JSONArray
|
|
|
for (CommunityCircle communityCircle : classNameByCircleId) {
|
|
|
JSONObject twoObject = new JSONObject();
|
|
|
twoObject.put("twoName", communityCircle.getCircleName());
|
|
|
- twoObject.put("twoImg", communityCircle.getImageUrl()); // 假设有这个方法
|
|
|
+ twoObject.put("twoImg", communityCircle.getImageUrl());
|
|
|
+ twoObject.put("isCare",communityCircle.getIsCare());
|
|
|
+ twoObject.put("heat",communityCircle.getHeat());
|
|
|
twoArray.add(twoObject);
|
|
|
}
|
|
|
-
|
|
|
oneObject.put("one", twoArray);
|
|
|
sumArray.add(oneObject); // 添加到 sumArray
|
|
|
- System.out.println("twoArray:" + twoArray);
|
|
|
- System.out.println("sumArray:" + sumArray);
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- // 这里可以选择抛出自定义异常或者记录日志
|
|
|
- // throw new ProjectException();
|
|
|
- } finally {
|
|
|
- // 可以在这里进行资源清理操作,如果有的话
|
|
|
+ throw new ProjectException();
|
|
|
}
|
|
|
|
|
|
return AjaxResult.success(sumArray);
|