| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
| | | import com.baomidou.mybatisplus.extension.api.ApiController;
|
| | | import com.baomidou.mybatisplus.extension.api.R;
|
| | | import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | import com.ycl.entity.NewsColumnInformation;
|
| | | import com.ycl.entity.NewsInformation;
|
| | | import com.ycl.entity.NewsInformationPolice;
|
| | | import com.ycl.entity.NewsPolice;
|
| | | import com.ycl.service.*;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.apache.commons.io.IOUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import sun.nio.ch.IOUtil;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.Serializable;
|
| | | import java.sql.SQLException;
|
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | /**
|
| | | * 资讯表(NewsInformation)表控制层
|
| | |
| | | */
|
| | | @RestController
|
| | | @RequestMapping("newsInformation")
|
| | | @Api(tags = "资讯管理")
|
| | | public class NewsInformationController extends ApiController {
|
| | | /**
|
| | | * 服务对象
|
| | |
| | | /**
|
| | | * 分页查询所有数据
|
| | | *
|
| | | * @param page 分页对象
|
| | | * @param newsInformation 查询实体
|
| | | * @return 所有数据
|
| | | */
|
| | | @GetMapping
|
| | | public R selectAll(Page<NewsInformation> page, NewsInformation newsInformation) {
|
| | | return success(this.newsInformationService.page(page, new QueryWrapper<>(newsInformation).orderByDesc("publish_time")));
|
| | | @ApiOperation(value = "查询所有数据")
|
| | | public R selectAll() {
|
| | | return success(this.newsInformationService.selectAllInformation());
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @return 单条数据
|
| | | */
|
| | | @GetMapping("{id}")
|
| | | @ApiOperation(value = "按id查询数据")
|
| | | public R selectOne(@PathVariable Serializable id) {
|
| | | return success(this.newsInformationService.getById(id));
|
| | | }
|
| | |
| | | */
|
| | | @Transactional(rollbackFor = SQLException.class)
|
| | | @PostMapping
|
| | | @ApiOperation(value = "新增数据")
|
| | | public R insert(@RequestBody NewsInformation newsInformation) {
|
| | | Integer saveResult = this.newsInformationService.insertOneInformation(newsInformation);
|
| | | Integer informationId=newsInformation.getId();
|
| | |
| | | * @return 修改结果
|
| | | */
|
| | | @PutMapping
|
| | | @ApiOperation(value = "修改数据")
|
| | | @Transactional
|
| | | public R update(@RequestBody NewsInformation newsInformation) {
|
| | | Integer informationId = newsInformation.getId();
|
| | | if (newsInformation.getIsSign()==0){
|
| | |
| | | for (String columnId:newsInformation.getColumnId()){
|
| | | newsColumnInformationService.save(NewsColumnInformation.builder().columnId(Integer.parseInt(columnId)).informationId(informationId).build());
|
| | | }
|
| | | return success(this.newsInformationService.updateById(newsInformation));
|
| | | return success(this.newsInformationService.updateInformationById(newsInformation));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @return 删除结果
|
| | | */
|
| | | @DeleteMapping
|
| | | @ApiOperation(value = "删除数据")
|
| | | public R delete(@RequestParam("idList") List<Long> idList) {
|
| | | return success(this.newsInformationService.removeByIds(idList));
|
| | | }
|