|
@@ -1,42 +1,124 @@
|
|
|
|
|
|
package com.redxun.knowledge.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.redxun.common.annotation.ClassDefine;
|
|
|
import com.redxun.common.base.db.BaseService;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.redxun.common.base.entity.JsonPageResult;
|
|
|
import com.redxun.common.base.entity.JsonResult;
|
|
|
-import com.redxun.common.tool.StringUtils;
|
|
|
+import com.redxun.common.base.entity.QueryData;
|
|
|
+import com.redxun.common.base.search.QueryFilter;
|
|
|
+import com.redxun.common.base.search.QueryFilterBuilder;
|
|
|
+import com.redxun.common.model.JPaasUser;
|
|
|
+import com.redxun.common.utils.ExceptionUtil;
|
|
|
+import com.redxun.common.utils.SysUserUtil;
|
|
|
import com.redxun.knowledge.entity.dao.News;
|
|
|
+import com.redxun.knowledge.entity.vo.NewsPcVo;
|
|
|
import com.redxun.knowledge.service.NewsServiceImpl;
|
|
|
import com.redxun.web.controller.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import java.util.Arrays;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/knowledge/news")
|
|
|
@Api(tags = "业务--新闻表")
|
|
|
-@ClassDefine(title = "业务--新闻表",alias = "NewsController",path = "/knowledge/news",packages = "",packageName = "子系统名称")
|
|
|
+@ClassDefine(title = "业务--新闻表", alias = "NewsController", path = "/knowledge/news", packages = "", packageName = "子系统名称")
|
|
|
public class NewsController extends BaseController<News> {
|
|
|
|
|
|
-@Autowired
|
|
|
-NewsServiceImpl newsService;
|
|
|
+ @Autowired
|
|
|
+ NewsServiceImpl newsService;
|
|
|
|
|
|
|
|
|
-@Override
|
|
|
-public BaseService getBaseService() {
|
|
|
-return newsService;
|
|
|
-}
|
|
|
+ @Override
|
|
|
+ public BaseService getBaseService() {
|
|
|
+ return newsService;
|
|
|
+ }
|
|
|
|
|
|
-@Override
|
|
|
-public String getComment() {
|
|
|
-return "业务--新闻表";
|
|
|
-}
|
|
|
+ @Override
|
|
|
+ public String getComment() {
|
|
|
+ return "业务--新闻表";
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新闻列表(后台)")
|
|
|
+ @ApiImplicitParam(name = "queryData", value = "查询条件")
|
|
|
+ @PostMapping("findAllNews")
|
|
|
+ public JsonPageResult findAllNews(@RequestBody QueryData queryData) {
|
|
|
+ JsonPageResult jsonResult = JsonPageResult.getSuccess("返回数据成功!");
|
|
|
+ try {
|
|
|
+ QueryFilter filter = QueryFilterBuilder.createQueryFilter(queryData);
|
|
|
+ IPage page = newsService.findAllNews(filter);
|
|
|
+ this.handlePage(page);
|
|
|
+ jsonResult.setPageData(page);
|
|
|
+ } catch (Exception e) {
|
|
|
+ jsonResult.setSuccess(false);
|
|
|
+ this.logger.error(ExceptionUtil.getExceptionMessage(e));
|
|
|
+ jsonResult.setMessage(ExceptionUtil.getExceptionMessage(e));
|
|
|
+ }
|
|
|
+ return jsonResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新闻资讯(无分页,前台)")
|
|
|
+ @GetMapping("getAllList")
|
|
|
+ public JsonPageResult getAllList() {
|
|
|
+ JsonPageResult jsonResult = JsonPageResult.getSuccess("返回数据成功!");
|
|
|
+ List<NewsPcVo> newsPcVoList = newsService.getAllList();
|
|
|
+ jsonResult.setData(newsPcVoList);
|
|
|
+ return jsonResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "前台新闻列表")
|
|
|
+ @PostMapping("findAllPcNews")
|
|
|
+ public JsonPageResult findAllPcNews(@RequestBody QueryData queryData) {
|
|
|
+ JsonPageResult jsonResult = JsonPageResult.getSuccess("返回数据成功!");
|
|
|
+ try {
|
|
|
+ QueryFilter filter = QueryFilterBuilder.createQueryFilter(queryData);
|
|
|
+ IPage page = newsService.findAllPcNews(filter);
|
|
|
+ this.handlePage(page);
|
|
|
+ jsonResult.setPageData(page);
|
|
|
+ } catch (Exception e) {
|
|
|
+ jsonResult.setSuccess(false);
|
|
|
+ this.logger.error(ExceptionUtil.getExceptionMessage(e));
|
|
|
+ jsonResult.setMessage(ExceptionUtil.getExceptionMessage(e));
|
|
|
+ }
|
|
|
+ return jsonResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("前台新闻详情")
|
|
|
+ @GetMapping("findByIdPcNews/{newsId}")
|
|
|
+ public JsonResult getAllList(@PathVariable("newsId") String newsId) {
|
|
|
+ JsonResult<News> newsJsonResult = this.get(newsId);
|
|
|
+ // 统计浏览数量
|
|
|
+ newsService.countViews(queryLoginUser(),newsId);
|
|
|
+ return newsJsonResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取登录员工信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String queryLoginUser() {
|
|
|
+ String loginUserId = null;
|
|
|
+ try {
|
|
|
+ JPaasUser jPaasUser = SysUserUtil.getLoginUser();
|
|
|
+ if (jPaasUser == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ loginUserId = jPaasUser.getUserId();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(ExceptionUtil.getExceptionMessage(e));
|
|
|
+ }
|
|
|
+ return loginUserId;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|