|
@@ -15,35 +15,26 @@ import com.xjrsoft.common.model.result.R;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
-import com.xjrsoft.module.authority.entity.DataAuth;
|
|
|
-import com.xjrsoft.module.authority.vo.DataAuthListVo;
|
|
|
-import com.xjrsoft.module.authority.vo.DataAuthPageVo;
|
|
|
import com.xjrsoft.module.oa.dto.*;
|
|
|
import com.xjrsoft.module.oa.entity.News;
|
|
|
import com.xjrsoft.module.oa.entity.NewsAppendix;
|
|
|
import com.xjrsoft.module.oa.entity.NewsRelation;
|
|
|
+import com.xjrsoft.module.oa.entity.NewsRelationConfig;
|
|
|
import com.xjrsoft.module.oa.service.INewsAppendixService;
|
|
|
+import com.xjrsoft.module.oa.service.INewsRelationConfigService;
|
|
|
import com.xjrsoft.module.oa.service.INewsRelationService;
|
|
|
import com.xjrsoft.module.oa.service.INewsService;
|
|
|
-import com.xjrsoft.module.oa.vo.NewsAppendixVo;
|
|
|
-import com.xjrsoft.module.oa.vo.NewsPageVo;
|
|
|
-import com.xjrsoft.module.oa.vo.NewsRelationVo;
|
|
|
-import com.xjrsoft.module.oa.vo.NewsVo;
|
|
|
-import com.xjrsoft.module.organization.entity.User;
|
|
|
-import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
-import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
-import com.xjrsoft.module.student.entity.BaseStudentUser;
|
|
|
-import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
+import com.xjrsoft.module.oa.vo.*;
|
|
|
import com.xjrsoft.module.system.entity.File;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -64,6 +55,7 @@ public class NewsController {
|
|
|
|
|
|
private INewsRelationService newsRelationService;
|
|
|
private INewsAppendixService newsAppendixService;
|
|
|
+ private INewsRelationConfigService newsRelationConfigService;
|
|
|
|
|
|
|
|
|
@GetMapping
|
|
@@ -97,6 +89,7 @@ public class NewsController {
|
|
|
return R.ok(pageOutput);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping
|
|
|
@ApiOperation(value = "新增新闻")
|
|
|
public R add(@RequestBody AddNewsDto addNewsDto) {
|
|
@@ -241,13 +234,29 @@ public class NewsController {
|
|
|
PageOutput<NewsRelationVo> pageOutput = ConventPage.getPageOutput(page);
|
|
|
return R.ok(pageOutput);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/page-relation-config")
|
|
|
+ @ApiOperation(value = "获取新闻权限分页")
|
|
|
+ public R pageRelationConfig(NewsRelationPageDto dto) {
|
|
|
+ Wrapper<NewsRelationConfig> wrapper = Wrappers.<NewsRelationConfig>query().lambda()
|
|
|
+ .eq(NewsRelationConfig::getNewsId, dto.getNewsId())
|
|
|
+ .select(NewsRelationConfig.class, x -> VoToColumnUtil.fieldsToColumns(NewsRelationConfigVo.class).contains(x.getProperty()));
|
|
|
+
|
|
|
+ IPage<NewsRelationConfig> page = newsRelationConfigService.page(ConventPage.getPage(dto), wrapper);
|
|
|
+ PageOutput<NewsRelationConfigVo> pageOutput = ConventPage.getPageOutput(page, NewsRelationConfigVo.class);
|
|
|
+ return R.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/count-relation")
|
|
|
@ApiOperation(value = "新闻阅读权限统计")
|
|
|
- public R countRelation(@RequestParam Long id) {
|
|
|
+ public R countRelation(@RequestParam Long id) {
|
|
|
Long total = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getNewsId, id));
|
|
|
Long notRead = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getNewsId, id).eq(NewsRelation::getReadMark, 0));
|
|
|
Long isRead = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getNewsId, id).eq(NewsRelation::getReadMark, 1));
|
|
|
- Long[] arrayRefVar = {total, notRead, isRead};
|
|
|
+ Long isReply = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getNewsId, id).isNull(NewsRelation::getReplyContent));
|
|
|
+ Long notReply = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getNewsId, id).isNotNull(NewsRelation::getReplyContent));
|
|
|
+ Long[] arrayRefVar = {total, notRead, isRead, isReply, notReply};
|
|
|
return R.ok(arrayRefVar);
|
|
|
}
|
|
|
|
|
@@ -262,4 +271,24 @@ public class NewsController {
|
|
|
public R deleteRelation(@RequestBody DeleteNewsRelationDto deleteNewsRelationDto) {
|
|
|
return R.ok(newsService.deleteRelation(deleteNewsRelationDto));
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/count-type")
|
|
|
+ @ApiOperation(value = "未读类型统计")
|
|
|
+ public R countType() {
|
|
|
+ List<NewsCountTypeVo> newsCountTypeVoList = new ArrayList<>();
|
|
|
+ Integer typeIds[] = {1, 2, 3};
|
|
|
+ for (Integer typeId : typeIds) {
|
|
|
+ Long totalType = newsRelationService.count(Wrappers.<NewsRelation>query().lambda().eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong()).eq(NewsRelation::getReadMark, 0).in(NewsRelation::getNewsId, "SELECT id from xjr_oa_news where type_id=" + typeId));
|
|
|
+ NewsCountTypeVo newsCountTypeVo = new NewsCountTypeVo();
|
|
|
+ newsCountTypeVo.setTypeId(typeId);
|
|
|
+ newsCountTypeVo.setTotal(totalType);
|
|
|
+ News news = newsService.getOne(Wrappers.<News>query().lambda().eq(News::getTypeId, typeId).orderByDesc(News::getReleaseTime).last("limit 1"));
|
|
|
+ if (news != null) {
|
|
|
+ newsCountTypeVo.setTime(news.getReleaseTime());
|
|
|
+ newsCountTypeVo.setTitle(news.getBriefHead());
|
|
|
+ }
|
|
|
+ newsCountTypeVoList.add(newsCountTypeVo);
|
|
|
+ }
|
|
|
+ return R.ok(newsCountTypeVoList);
|
|
|
+ }
|
|
|
}
|