|
|
@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@Api(tags = "cms首页") |
|
|
|
@Api(tags = "cms首页") |
|
|
|
@RestController |
|
|
|
@RestController |
|
|
@ -69,53 +69,35 @@ public class CmsHomePageController /*extends JeecgController<CmsColumn, ICmsColu |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "用于首页的新闻资讯", notes = "新闻资讯") |
|
|
|
@ApiOperation(value = "用于首页的要问速报", notes = "用于首页的要问速报") |
|
|
|
@GetMapping(value = "/getindexnew") |
|
|
|
@GetMapping(value = "/indexywsb") |
|
|
|
public Result<?> getindexnew(CmsArticle cmsArticle, |
|
|
|
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "6") Integer pageSize, |
|
|
|
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
|
|
|
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap()); |
|
|
|
|
|
|
|
queryWrapper.eq("status", "1"); |
|
|
|
|
|
|
|
queryWrapper.eq("column_id", "1717099205205401602"); |
|
|
|
|
|
|
|
queryWrapper.last("order by publish_time desc"); |
|
|
|
|
|
|
|
Page<CmsArticle> page = new Page<CmsArticle>(pageNo, pageSize); |
|
|
|
|
|
|
|
IPage<CmsArticle> pageList = cmsArticleService.page(page, queryWrapper); |
|
|
|
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "用于首页的竞赛导航", notes = "竞赛导航") |
|
|
|
|
|
|
|
@GetMapping(value = "/getindexcomp") |
|
|
|
|
|
|
|
public Result<?> getindexcomp(CmsArticle cmsArticle, |
|
|
|
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "8") Integer pageSize, |
|
|
|
|
|
|
|
HttpServletRequest req) { |
|
|
|
|
|
|
|
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap()); |
|
|
|
|
|
|
|
queryWrapper.eq("status", "1"); |
|
|
|
|
|
|
|
queryWrapper.eq("column_id", "1712301393339650049"); |
|
|
|
|
|
|
|
queryWrapper.last("order by publish_time desc"); |
|
|
|
|
|
|
|
Page<CmsArticle> page = new Page<CmsArticle>(pageNo, pageSize); |
|
|
|
|
|
|
|
IPage<CmsArticle> pageList = cmsArticleService.page(page, queryWrapper); |
|
|
|
|
|
|
|
return Result.OK(pageList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "用于首页的研究成果", notes = "研究成果") |
|
|
|
|
|
|
|
@GetMapping(value = "/getindexaward") |
|
|
|
|
|
|
|
public Result<?> getindexaward(CmsArticle cmsArticle, |
|
|
|
public Result<?> getindexaward(CmsArticle cmsArticle, |
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
@RequestParam(name = "pageSize", defaultValue = "3") Integer pageSize, |
|
|
|
@RequestParam(name = "pageSize", defaultValue = "3") Integer pageSize, |
|
|
|
HttpServletRequest req) { |
|
|
|
HttpServletRequest req) { |
|
|
|
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap()); |
|
|
|
QueryWrapper<CmsArticle> queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap()); |
|
|
|
queryWrapper.eq("status", "1"); |
|
|
|
queryWrapper.eq("status", "1"); |
|
|
|
queryWrapper.eq("column_id", "1717099355382456322"); |
|
|
|
List<CmsArticle> allArticles = cmsArticleService.list(queryWrapper); |
|
|
|
queryWrapper.last("order by publish_time desc"); |
|
|
|
|
|
|
|
Page<CmsArticle> page = new Page<CmsArticle>(pageNo, pageSize); |
|
|
|
if (allArticles.size() <= 3) { |
|
|
|
IPage<CmsArticle> pageList = cmsArticleService.page(page, queryWrapper); |
|
|
|
return Result.OK(allArticles); |
|
|
|
return Result.OK(pageList); |
|
|
|
} else { |
|
|
|
|
|
|
|
// 随机选择3条记录
|
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
List<CmsArticle> randomArticles = new ArrayList<>(3); |
|
|
|
|
|
|
|
Set<Integer> selectedIndices = new HashSet<>(3); // 使用Set来确保索引的唯一性
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (selectedIndices.size() < 3) { |
|
|
|
|
|
|
|
int index = random.nextInt(allArticles.size()); |
|
|
|
|
|
|
|
selectedIndices.add(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (Integer index : selectedIndices) { |
|
|
|
|
|
|
|
randomArticles.add(allArticles.get(index)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Result.OK(randomArticles); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "查询全部新闻", notes = "查询全部新闻") |
|
|
|
@ApiOperation(value = "查询全部新闻", notes = "查询全部新闻") |
|
|
|
@GetMapping(value = "/cmsfindallnews") |
|
|
|
@GetMapping(value = "/cmsfindallnews") |
|
|
|
public Result<?> cmsfindallnews(CmsArticle cmsArticle, |
|
|
|
public Result<?> cmsfindallnews(CmsArticle cmsArticle, |
|
|
|