|
@@ -14,10 +14,12 @@ import io.swagger.annotations.ApiParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
import org.jeecg.modules.aa.dto.AaCommodityDTO;
|
|
|
import org.jeecg.modules.aa.dto.AaCommodityDTO2;
|
|
|
+import org.jeecg.modules.aa.dto.AaNewsQueryDTO;
|
|
|
import org.jeecg.modules.aa.dto.SMDTO;
|
|
|
import org.jeecg.modules.aa.entity.*;
|
|
|
import org.jeecg.modules.aa.service.*;
|
|
@@ -28,6 +30,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.websocket.server.PathParam;
|
|
|
import java.math.BigInteger;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -408,9 +411,10 @@ public class APIIndexenterController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperationSupport(order = 31)
|
|
|
@ApiOperation(value = "获取新闻列表", notes = "获取新闻列表")
|
|
|
@PostMapping(value = "/getNewsList")
|
|
|
+ @Deprecated
|
|
|
public Result<List<AaNews>> getNewsList(@RequestBody AaCommodityDTO2 aaCommodityDTO) {
|
|
|
Result<List<AaNews>> result = new Result<List<AaNews>>();
|
|
|
try {
|
|
@@ -439,6 +443,23 @@ public class APIIndexenterController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperation(value="获取新闻分页列表", notes="获取新闻分页列表")
|
|
|
+ @GetMapping(value = "/getNewsPageList")
|
|
|
+ public Result<IPage<AaNews>> queryPageList(AaNews aaNews,
|
|
|
+ @ApiParam(name="pageNo",value="页数") @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @ApiParam(name="pageSize",value="每页数量") @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ if (aaNews!=null && !Strings.isNullOrEmpty(aaNews.getTitle())){
|
|
|
+ aaNews.setTitle("*"+aaNews.getTitle()+"*");
|
|
|
+ }
|
|
|
+ QueryWrapper<AaNews> queryWrapper = QueryGenerator.initQueryWrapper(aaNews, req.getParameterMap());
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ Page<AaNews> page = new Page<AaNews>(pageNo, pageSize);
|
|
|
+ IPage<AaNews> pageList = aaNewsService.page(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@ApiOperationSupport(order = 31)
|
|
|
@ApiOperation(value = "获取新闻详细", notes = "获取新闻详细")
|
|
@@ -535,44 +556,54 @@ public class APIIndexenterController {
|
|
|
@ApiOperationSupport(order = 33)
|
|
|
@ApiOperation(value = "下一篇新闻", notes = "下一篇新闻")
|
|
|
@PostMapping(value = "/getNast")
|
|
|
- public Result<List<AaNewsFl>> getNast() {
|
|
|
- Result<List<AaNewsFl>> result = new Result<List<AaNewsFl>>();
|
|
|
- try {
|
|
|
- List<AaNewsFl> list = aaNewsFlService.list();
|
|
|
- for (int i = 0;i<list.size();i++){
|
|
|
- list.get( i ).setPic( host + "/sys/common/static/"+list.get( i ).getPic() );
|
|
|
- }
|
|
|
- result.setMessage( "获取新闻分类成功" );
|
|
|
- result.setResult( list );
|
|
|
- result.setCode( 200 );
|
|
|
- return result;
|
|
|
- } catch (Exception e) {
|
|
|
- result.setMessage( "获取新闻分类失败" );
|
|
|
- result.setResult( null );
|
|
|
- result.setCode( 0 );
|
|
|
- return result;
|
|
|
+ public Result<AaNews> getNast(@RequestBody AaNewsQueryDTO aaNewsQueryDTO) {
|
|
|
+ if (aaNewsQueryDTO == null || Strings.isNullOrEmpty(aaNewsQueryDTO.getId())) {
|
|
|
+ return Result.error("找不到新闻编码!");
|
|
|
+ }
|
|
|
+ AaNews byId = aaNewsService.getById(aaNewsQueryDTO.getId());
|
|
|
+ if (byId == null){
|
|
|
+ return Result.error("没有查询到新闻!");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<AaNews> aaNewsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (aaNewsQueryDTO.getTypeId() != null && !Strings.isNullOrEmpty(aaNewsQueryDTO.getTypeId())) {
|
|
|
+ aaNewsLambdaQueryWrapper.eq(AaNews::getTypeId,aaNewsQueryDTO.getTypeId());
|
|
|
+ }
|
|
|
+ aaNewsLambdaQueryWrapper.lt(AaNews::getCreateTime,byId.getCreateTime())
|
|
|
+ .orderByDesc(AaNews::getCreateTime);
|
|
|
+ List<AaNews> list1 = aaNewsService.list(aaNewsLambdaQueryWrapper);
|
|
|
+ if (list1!=null && list1.size() > 0 ){
|
|
|
+ AaNews aaNews = list1.get(0);
|
|
|
+ aaNews.setPic(host + "/sys/common/static/"+ aaNews.getPic());
|
|
|
+ return Result.OK("成功!", aaNews);
|
|
|
+ } else {
|
|
|
+ return Result.OK("没有下一篇了", null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperationSupport(order = 34)
|
|
|
@ApiOperation(value = "上一篇新闻", notes = "上一篇新闻")
|
|
|
@PostMapping(value = "/getLast")
|
|
|
- public Result<List<AaNewsFl>> getLast() {
|
|
|
- Result<List<AaNewsFl>> result = new Result<List<AaNewsFl>>();
|
|
|
- try {
|
|
|
- List<AaNewsFl> list = aaNewsFlService.list();
|
|
|
- for (int i = 0;i<list.size();i++){
|
|
|
- list.get( i ).setPic( host + "/sys/common/static/"+list.get( i ).getPic() );
|
|
|
- }
|
|
|
- result.setMessage( "获取新闻分类成功" );
|
|
|
- result.setResult( list );
|
|
|
- result.setCode( 200 );
|
|
|
- return result;
|
|
|
- } catch (Exception e) {
|
|
|
- result.setMessage( "获取新闻分类失败" );
|
|
|
- result.setResult( null );
|
|
|
- result.setCode( 0 );
|
|
|
- return result;
|
|
|
+ public Result<AaNews> getLast(@RequestBody AaNewsQueryDTO aaNewsQueryDTO) {
|
|
|
+ if (aaNewsQueryDTO == null || Strings.isNullOrEmpty(aaNewsQueryDTO.getId())) {
|
|
|
+ return Result.error("找不到新闻编码!");
|
|
|
+ }
|
|
|
+ AaNews byId = aaNewsService.getById(aaNewsQueryDTO.getId());
|
|
|
+ if (byId == null){
|
|
|
+ return Result.error("没有查询到新闻!");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<AaNews> aaNewsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (aaNewsQueryDTO.getTypeId() != null && !Strings.isNullOrEmpty(aaNewsQueryDTO.getTypeId())) {
|
|
|
+ aaNewsLambdaQueryWrapper.eq(AaNews::getTypeId,aaNewsQueryDTO.getTypeId());
|
|
|
+ }
|
|
|
+ aaNewsLambdaQueryWrapper.gt(AaNews::getCreateTime,byId.getCreateTime())
|
|
|
+ .orderByAsc(AaNews::getCreateTime);
|
|
|
+ List<AaNews> list1 = aaNewsService.list(aaNewsLambdaQueryWrapper);
|
|
|
+ if (list1!=null && list1.size() > 0 ){
|
|
|
+ AaNews aaNews = list1.get(0);
|
|
|
+ aaNews.setPic(host + "/sys/common/static/"+ aaNews.getPic());
|
|
|
+ return Result.OK("成功!", aaNews);
|
|
|
+ } else {
|
|
|
+ return Result.OK("没有上一篇了", null);
|
|
|
}
|
|
|
}
|
|
|
|