NewsController.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.keao.edu.cms.controller;
  2. import com.keao.edu.cms.controller.queryinfo.NewsInformationQueryInfo;
  3. import io.swagger.annotations.Api;
  4. import io.swagger.annotations.ApiImplicitParam;
  5. import io.swagger.annotations.ApiOperation;
  6. import java.util.Date;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.MediaType;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import com.keao.edu.cms.dal.entity.SysNewsInformation;
  15. import com.keao.edu.cms.service.SysNewsInformationService;
  16. import com.keao.edu.common.controller.BaseController;
  17. @RestController
  18. @RequestMapping("news")
  19. @Api(tags = "资讯服务")
  20. public class NewsController extends BaseController {
  21. @Autowired
  22. private SysNewsInformationService sysNewsInformationService;
  23. @ApiOperation("资讯列表分页查询")
  24. @GetMapping(value = "/list")
  25. public Object getList(NewsInformationQueryInfo queryInfo) {
  26. if(queryInfo.getTenantId() == null){
  27. queryInfo.setTenantId(1);
  28. }
  29. return succeed(sysNewsInformationService.queryPage(queryInfo));
  30. }
  31. @ApiOperation("资讯列表分页查询")
  32. @GetMapping(value = "/homeList")
  33. public Object getHomeList(NewsInformationQueryInfo queryInfo) {
  34. queryInfo.setRows(5);
  35. return succeed(sysNewsInformationService.getHomeList(queryInfo));
  36. }
  37. @ApiOperation("查询资讯详情")
  38. @ApiImplicitParam(name = "id", value = "资讯ID编号", required = true, dataType = "Long", paramType = "path")
  39. @GetMapping(value = "/query")
  40. public Object query(Long id) {
  41. return succeed(sysNewsInformationService.get(id));
  42. }
  43. @ApiOperation("新增资讯")
  44. @PostMapping(value = "/add", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  45. public Object add(SysNewsInformation newsInfo) {
  46. return succeed(sysNewsInformationService.insert(newsInfo));
  47. }
  48. @ApiOperation("更新资讯")
  49. @PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  50. public Object update(SysNewsInformation newsInfo) {
  51. Date date = new Date();
  52. newsInfo.setUpdateTime(date);
  53. return succeed(sysNewsInformationService.update(newsInfo));
  54. }
  55. @ApiOperation("删除")
  56. @PostMapping(value = "/del/{id}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  57. public Object add(@PathVariable("id") Long id) {
  58. return succeed(sysNewsInformationService.deleteWithLogical(id));
  59. }
  60. }