123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.example.civilizedcity.controller;
-
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.example.civilizedcity.common.BaseController;
- import com.example.civilizedcity.common.ResponseBean;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import com.example.civilizedcity.entity.TdQuAnswer;
- import com.example.civilizedcity.service.TdQuAnswerService;
-
- /**
- * 点位问题答案;(td_loc_qu_answer)表控制层
- * @author : http://njyunzhi.com
- * @date : 2022-12-13
- */
- @Api(tags = "点位问题答案对象功能接口")
- @RestController
- @RequestMapping("/")
- public class TdQuAnswerController extends BaseController {
-
- @Autowired
- private TdQuAnswerService tdQuAnswerService;
-
- /**
- * 通过ID查询单条数据
- *
- * @param answerId 主键
- * @return 实例对象
- */
- @ApiOperation("通过ID查询单条数据")
- @GetMapping("/tdQuAnswer/{id}")
- public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
- return ResponseBean.success(tdQuAnswerService.getById(id));
- }
-
- /**
- * 分页查询
- *
- * @param pageNum 当前页码
- * @param pageSize 每页条数
- * @return 查询结果
- */
- @ApiOperation("分页查询")
- @GetMapping("/tdQuAnswer")
- public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
-
- IPage<TdQuAnswer> pg = new Page<>(pageNum, pageSize);
- // QueryWrapper<TdLocQuAnswer> queryWrapper = new QueryWrapper<>();
- // queryWrapper.orderByDesc("create_date");
- IPage<TdQuAnswer> result = tdQuAnswerService.page(pg);
-
- return ResponseBean.success(result);
- }
-
- /**
- * 新增数据
- *
- * @param tdQuAnswer 实例对象
- * @return 实例对象
- */
- @ApiOperation("新增数据")
- @PostMapping("/tdLocQuAnswer")
- public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer) throws Exception {
- tdQuAnswerService.save(tdQuAnswer);
- return ResponseBean.success(tdQuAnswer);
- }
-
- /**
- * 更新数据
- *
- * @param tdQuAnswer 实例对象
- * @return 实例对象
- */
- @ApiOperation("更新数据")
- @PutMapping("/tdQuAnswer/{id}")
- public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer,
- @ApiParam("对象ID") @PathVariable String id ) throws Exception {
- tdQuAnswerService.updateById(tdQuAnswer);
- return ResponseBean.success(tdQuAnswer);
- }
-
- /**
- * 通过主键删除数据
- *
- * @param answerId 主键
- * @return 是否成功
- */
- @ApiOperation("通过主键删除数据")
- @DeleteMapping("/tdQuAnswer/{id}")
- public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
- tdQuAnswerService.removeLogicById(id);
- return ResponseBean.success("success");
- }
- }
|