| | |
| | | package com.example.jz.controller; |
| | | |
| | | |
| | | |
| | | 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.plugins.pagination.Page; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.entity.Publicity; |
| | | import com.example.jz.modle.R; |
| | | import com.example.jz.service.PublicityService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 公共宣传表(Publicity)表控制层 |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("publicity") |
| | | public class PublicityController extends ApiController { |
| | | @Api(tags = "公共宣传接口") |
| | | public class PublicityController { |
| | | /** |
| | | * 服务对象 |
| | | */ |
| | |
| | | /** |
| | | * 分页查询所有数据 |
| | | * |
| | | * @param page 分页对象 |
| | | * @param page 分页对象 |
| | | * @param publicity 查询实体 |
| | | * @return 所有数据 |
| | | */ |
| | | @GetMapping |
| | | public R selectAll(Page<Publicity> page, Publicity publicity) { |
| | | return success(this.publicityService.page(page, new QueryWrapper<>(publicity))); |
| | | @ApiOperation("分页查询所有数据") |
| | | public R<IPage<Publicity>> selectAll(PageParam<Publicity> page, Publicity publicity) { |
| | | return R.ok(publicityService.page(page, new QueryWrapper<>(publicity))); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 单条数据 |
| | | */ |
| | | @GetMapping("{id}") |
| | | public R selectOne(@PathVariable Serializable id) { |
| | | return success(this.publicityService.getById(id)); |
| | | @ApiOperation("通过主键查询单条数据") |
| | | public R<Publicity> selectOne(@PathVariable Serializable id) { |
| | | return R.ok(publicityService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 新增结果 |
| | | */ |
| | | @PostMapping |
| | | public R insert(@RequestBody Publicity publicity) { |
| | | return success(this.publicityService.save(publicity)); |
| | | @ApiOperation("添加公共宣传") |
| | | public R<Boolean> insert(@RequestBody Publicity publicity) { |
| | | publicity.setCtime(new Date()); |
| | | return R.ok(publicityService.save(publicity)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 修改结果 |
| | | */ |
| | | @PutMapping |
| | | public R update(@RequestBody Publicity publicity) { |
| | | return success(this.publicityService.updateById(publicity)); |
| | | @ApiOperation("修改公共宣传内容") |
| | | public R<Boolean> update(@RequestBody Publicity publicity) { |
| | | return R.ok(publicityService.updateById(publicity)); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据 |
| | | * 下架公共宣传 |
| | | * |
| | | * @param idList 主键结合 |
| | | * @return 删除结果 |
| | | * @param id 主键结合 |
| | | * @return 执行结果 |
| | | */ |
| | | @DeleteMapping |
| | | public R delete(@RequestParam("idList") List<Long> idList) { |
| | | return success(this.publicityService.removeByIds(idList)); |
| | | @GetMapping("offline/{id}") |
| | | @ApiOperation("下架公共宣传") |
| | | public R<Boolean> offline(@PathVariable Serializable id) { |
| | | return R.ok(publicityService.undercarriage(id)); |
| | | } |
| | | |
| | | /** |
| | | * 上架公共宣传 |
| | | * |
| | | * @param id 主键结合 |
| | | * @return 执行结果 |
| | | */ |
| | | @GetMapping("release/{id}") |
| | | @ApiOperation("上架公共宣传") |
| | | public R<Boolean> release(@PathVariable Serializable id) { |
| | | return R.ok(publicityService.grounding(id)); |
| | | } |
| | | |
| | | /** |
| | | * 删除公共宣传 |
| | | * |
| | | * @param id 主键结合 |
| | | * @return 执行结果 |
| | | */ |
| | | @DeleteMapping("{id}") |
| | | @ApiOperation("删除公共宣传") |
| | | public R<Boolean> delete(@PathVariable Serializable id) { |
| | | return R.ok(publicityService.removeById(id)); |
| | | } |
| | | } |
| | | |