12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.keao.edu.cms.controller;
- import com.keao.edu.cms.controller.queryinfo.NewsInformationQueryInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiOperation;
- import java.util.Date;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.keao.edu.cms.dal.entity.SysNewsInformation;
- import com.keao.edu.cms.service.SysNewsInformationService;
- import com.keao.edu.common.controller.BaseController;
- @RestController
- @RequestMapping("news")
- @Api(tags = "资讯服务")
- public class NewsController extends BaseController {
- @Autowired
- private SysNewsInformationService sysNewsInformationService;
-
- @ApiOperation("资讯列表分页查询")
- @GetMapping(value = "/list")
- public Object getList(NewsInformationQueryInfo queryInfo) {
- if(queryInfo.getTenantId() == null){
- queryInfo.setTenantId(1);
- }
-
- return succeed(sysNewsInformationService.queryPage(queryInfo));
- }
- @ApiOperation("资讯列表分页查询")
- @GetMapping(value = "/homeList")
- public Object getHomeList(NewsInformationQueryInfo queryInfo) {
- queryInfo.setRows(5);
- return succeed(sysNewsInformationService.getHomeList(queryInfo));
- }
- @ApiOperation("查询资讯详情")
- @ApiImplicitParam(name = "id", value = "资讯ID编号", required = true, dataType = "Long", paramType = "path")
- @GetMapping(value = "/query")
- public Object query(Long id) {
- return succeed(sysNewsInformationService.get(id));
- }
- @ApiOperation("新增资讯")
- @PostMapping(value = "/add", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- public Object add(SysNewsInformation newsInfo) {
- return succeed(sysNewsInformationService.insert(newsInfo));
- }
- @ApiOperation("更新资讯")
- @PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- public Object update(SysNewsInformation newsInfo) {
- Date date = new Date();
- newsInfo.setUpdateTime(date);
- return succeed(sysNewsInformationService.update(newsInfo));
- }
- @ApiOperation("删除")
- @PostMapping(value = "/del/{id}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- public Object add(@PathVariable("id") Long id) {
- return succeed(sysNewsInformationService.deleteWithLogical(id));
- }
- }
|