| | |
| | | @Resource
|
| | | private NewsChannelService newsChannelService;
|
| | |
|
| | | @Autowired
|
| | | private NewsChannelColumnService newsChannelColumnService;
|
| | |
|
| | | /**
|
| | | * 分页查询所有数据
|
| | |
| | | * @param id 主键
|
| | | * @return 单条数据
|
| | | */
|
| | | @GetMapping("{id}")
|
| | | @ApiOperation(value = "按id查询数据")
|
| | | public R selectOne(@PathVariable Serializable id) {
|
| | | return success(this.newsChannelService.getById(id));
|
| | | }
|
| | | // @GetMapping("{id}")
|
| | | // @ApiOperation(value = "按id查询数据")
|
| | | // public R selectOne(@PathVariable Serializable id) {
|
| | | // return success(this.newsChannelService.getById(id));
|
| | | // }
|
| | |
|
| | | /**
|
| | | * 新增数据
|
| | |
| | | @ApiOperation(value = "新增数据")
|
| | | public R insert(@RequestBody NewsChannel newsChannel) {
|
| | | int result = this.newsChannelService.insertOneChannel(newsChannel);
|
| | | List<String> columnId = newsChannel.getColumnId();
|
| | | columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build()));
|
| | | // List<String> columnId = newsChannel.getColumnId();
|
| | | // columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build()));
|
| | | return success(result);
|
| | | }
|
| | |
|
| | |
| | | @PutMapping
|
| | | @ApiOperation(value = "修改数据")
|
| | | public R update(@RequestBody NewsChannel newsChannel) {
|
| | | List<String> columnId = newsChannel.getColumnId();
|
| | | newsChannelColumnService.remove(new QueryWrapper<NewsChannelColumn>().eq("channel_id",newsChannel.getId()));
|
| | | columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build()));
|
| | | // List<String> columnId = newsChannel.getColumnId();
|
| | | // newsChannelColumnService.remove(new QueryWrapper<NewsChannelColumn>().eq("channel_id",newsChannel.getId()));
|
| | | // columnId.stream().forEach(item->newsChannelColumnService.save(NewsChannelColumn.builder().channelId(newsChannel.getId()).columnId(Integer.parseInt(item)).build()));
|
| | | return success(this.newsChannelService.updateById(newsChannel));
|
| | | }
|
| | |
|