TdQuAnswerController.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.example.civilizedcity.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.example.civilizedcity.common.BaseController;
  5. import com.example.civilizedcity.common.ResponseBean;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. import com.example.civilizedcity.entity.TdQuAnswer;
  12. import com.example.civilizedcity.service.TdQuAnswerService;
  13. /**
  14. * 点位问题答案;(td_loc_qu_answer)表控制层
  15. * @author : http://njyunzhi.com
  16. * @date : 2022-12-13
  17. */
  18. @Api(tags = "点位问题答案对象功能接口")
  19. @RestController
  20. @RequestMapping("/")
  21. public class TdQuAnswerController extends BaseController {
  22. @Autowired
  23. private TdQuAnswerService tdQuAnswerService;
  24. /**
  25. * 通过ID查询单条数据
  26. *
  27. * @param answerId 主键
  28. * @return 实例对象
  29. */
  30. @ApiOperation("通过ID查询单条数据")
  31. @GetMapping("/tdQuAnswer/{id}")
  32. public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
  33. return ResponseBean.success(tdQuAnswerService.getById(id));
  34. }
  35. /**
  36. * 分页查询
  37. *
  38. * @param pageNum 当前页码
  39. * @param pageSize 每页条数
  40. * @return 查询结果
  41. */
  42. @ApiOperation("分页查询")
  43. @GetMapping("/tdQuAnswer")
  44. public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
  45. @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
  46. IPage<TdQuAnswer> pg = new Page<>(pageNum, pageSize);
  47. // QueryWrapper<TdLocQuAnswer> queryWrapper = new QueryWrapper<>();
  48. // queryWrapper.orderByDesc("create_date");
  49. IPage<TdQuAnswer> result = tdQuAnswerService.page(pg);
  50. return ResponseBean.success(result);
  51. }
  52. /**
  53. * 新增数据
  54. *
  55. * @param tdQuAnswer 实例对象
  56. * @return 实例对象
  57. */
  58. @ApiOperation("新增数据")
  59. @PostMapping("/tdLocQuAnswer")
  60. public ResponseBean add(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer) throws Exception {
  61. tdQuAnswerService.save(tdQuAnswer);
  62. return ResponseBean.success(tdQuAnswer);
  63. }
  64. /**
  65. * 更新数据
  66. *
  67. * @param tdQuAnswer 实例对象
  68. * @return 实例对象
  69. */
  70. @ApiOperation("更新数据")
  71. @PutMapping("/tdQuAnswer/{id}")
  72. public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuAnswer tdQuAnswer,
  73. @ApiParam("对象ID") @PathVariable String id ) throws Exception {
  74. tdQuAnswerService.updateById(tdQuAnswer);
  75. return ResponseBean.success(tdQuAnswer);
  76. }
  77. /**
  78. * 通过主键删除数据
  79. *
  80. * @param answerId 主键
  81. * @return 是否成功
  82. */
  83. @ApiOperation("通过主键删除数据")
  84. @DeleteMapping("/tdQuAnswer/{id}")
  85. public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
  86. tdQuAnswerService.removeLogicById(id);
  87. return ResponseBean.success("success");
  88. }
  89. }