| | |
| | | import com.baomidou.mybatisplus.extension.api.R;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | import com.ycl.entity.NewsColumnInformation;
|
| | | import com.ycl.entity.NewsInformation;
|
| | | import com.ycl.service.NewsColumnInformationService;
|
| | | import com.ycl.service.NewsInformationService;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.Serializable;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @RestController
|
| | | @RequestMapping("newsColumnInformation")
|
| | | @Api(tags = "栏目咨询中间表控制层")
|
| | | public class NewsColumnInformationController extends ApiController {
|
| | | /**
|
| | | * 服务对象
|
| | |
| | | @Resource
|
| | | private NewsColumnInformationService newsColumnInformationService;
|
| | |
|
| | | @Autowired
|
| | | private NewsInformationService newsInformationService;
|
| | | /**
|
| | | * 分页查询所有数据
|
| | | *
|
| | |
| | | * @return 所有数据
|
| | | */
|
| | | @GetMapping
|
| | | @ApiOperation(value = "查询所有数据")
|
| | | public R selectAll(Page<NewsColumnInformation> page, NewsColumnInformation newsColumnInformation) {
|
| | | return success(this.newsColumnInformationService.page(page, new QueryWrapper<>(newsColumnInformation)));
|
| | | }
|
| | |
| | | * @return 单条数据
|
| | | */
|
| | | @GetMapping("{id}")
|
| | | @ApiOperation(value = "按id查询数据")
|
| | | public R selectOne(@PathVariable Serializable id) {
|
| | | return success(this.newsColumnInformationService.getById(id));
|
| | | }
|
| | |
| | | * @return 新增结果
|
| | | */
|
| | | @PostMapping
|
| | | @ApiOperation(value = "新增数据")
|
| | | public R insert(@RequestBody NewsColumnInformation newsColumnInformation) {
|
| | | return success(this.newsColumnInformationService.save(newsColumnInformation));
|
| | | }
|
| | |
| | | * @return 修改结果
|
| | | */
|
| | | @PutMapping
|
| | | @ApiOperation(value = "修改数据")
|
| | | public R update(@RequestBody NewsColumnInformation newsColumnInformation) {
|
| | | return success(this.newsColumnInformationService.updateById(newsColumnInformation));
|
| | | }
|
| | |
| | | * @return 删除结果
|
| | | */
|
| | | @DeleteMapping
|
| | | @ApiOperation(value = "删除数据")
|
| | | public R delete(@RequestParam("idList") List<Long> idList) {
|
| | | return success(this.newsColumnInformationService.removeByIds(idList));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过栏目id查对应资讯
|
| | | *
|
| | | * @param id 栏目id
|
| | | * @return 资讯查询结果
|
| | | */
|
| | | @GetMapping("column/{id}")
|
| | | @ApiOperation(value = "按")
|
| | | public R selectInformationByColumnId(@PathVariable Serializable id) {
|
| | | List<NewsColumnInformation> newsColumnInformationList = newsColumnInformationService.list(new QueryWrapper<NewsColumnInformation>().eq("column_id", id));
|
| | | List<NewsInformation> resultList=new ArrayList<>();
|
| | | for (NewsColumnInformation newsColumnInformation:newsColumnInformationList){
|
| | | resultList.add(newsInformationService.selectInformationById(newsColumnInformation.getInformationId()));
|
| | | }
|
| | | return success(resultList);
|
| | | }}
|
| | |
|