| | |
| | | import com.baomidou.mybatisplus.extension.api.R;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | import com.ycl.entity.NewsPolice;
|
| | | import com.ycl.service.NewsAdminService;
|
| | | import com.ycl.service.NewsPoliceService;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.Serializable;
|
| | | import java.sql.SQLException;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @RestController
|
| | | @RequestMapping("newsPolice")
|
| | | @Api(tags = "警员管理")
|
| | | public class NewsPoliceController extends ApiController {
|
| | | /**
|
| | | * 服务对象
|
| | | */
|
| | | @Resource
|
| | | private NewsPoliceService newsPoliceService;
|
| | |
|
| | | @Autowired
|
| | | private NewsAdminService newsAdminService;
|
| | |
|
| | | /**
|
| | | * 分页查询所有数据
|
| | |
| | | * @return 所有数据
|
| | | */
|
| | | @GetMapping
|
| | | @ApiOperation(value = "查询所有数据")
|
| | | public R selectAll(Page<NewsPolice> page, NewsPolice newsPolice) {
|
| | | return success(this.newsPoliceService.page(page, new QueryWrapper<>(newsPolice)));
|
| | | }
|
| | |
| | | * @return 单条数据
|
| | | */
|
| | | @GetMapping("{id}")
|
| | | @ApiOperation(value = "按id查询数据")
|
| | | public R selectOne(@PathVariable Serializable id) {
|
| | | return success(this.newsPoliceService.getById(id));
|
| | | }
|
| | |
| | | * @param newsPolice 实体对象
|
| | | * @return 新增结果
|
| | | */
|
| | | @Transactional(rollbackFor = SQLException.class)
|
| | | @PostMapping
|
| | | @ApiOperation(value = "新增警员并注册")
|
| | | public R insert(@RequestBody NewsPolice newsPolice) {
|
| | | return success(this.newsPoliceService.save(newsPolice));
|
| | | this.newsPoliceService.save(newsPolice);
|
| | | return success(newsAdminService.autoCreateAdmin(newsPolice));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @return 修改结果
|
| | | */
|
| | | @PutMapping
|
| | | @ApiOperation(value = "修改数据")
|
| | | public R update(@RequestBody NewsPolice newsPolice) {
|
| | | return success(this.newsPoliceService.updateById(newsPolice));
|
| | | }
|
| | |
| | | * @return 删除结果
|
| | | */
|
| | | @DeleteMapping
|
| | | @ApiOperation(value = "删除数据")
|
| | | public R delete(@RequestParam("idList") List<Long> idList) {
|
| | | return success(this.newsPoliceService.removeByIds(idList));
|
| | | }
|