当前位置:   article > 正文

JavaCRUD模板参考

JavaCRUD模板参考

Mapper层

  1. @Mapper
  2. public interface ExCategoryMapper extends BaseMapper<ExCategory> {
  3. }

Service层

  1. package co.yixiang.exam.service;
  2. import co.yixiang.exam.common.R;
  3. import co.yixiang.exam.entity.ExStudent;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import org.springframework.data.domain.Pageable;
  6. import java.util.List;
  7. /**
  8. * @author Mtz
  9. * @version 1.0
  10. * @2024/5/138:55
  11. * @function
  12. * @comment
  13. */
  14. public interface ExStudentService {
  15. /***
  16. * 学生模块分页查询
  17. * @param exStudent
  18. * @param pageable
  19. * @return
  20. */
  21. R<IPage<ExStudent>> selectInfo(ExStudent exStudent, Pageable pageable);
  22. /***
  23. * 学生模块添加
  24. * @param exStudent
  25. * @return R<Void>
  26. */
  27. R<Void> insertInfo(ExStudent exStudent);
  28. /***
  29. * 学生模块根据id修改
  30. * @param exStudent
  31. * @return
  32. */
  33. R<Void> saveInfo(ExStudent exStudent);
  34. /***
  35. * 学生模块根据id获取数据
  36. * @param exStudent
  37. * @return
  38. */
  39. R<ExStudent> getByIdInfo(ExStudent exStudent);
  40. /***
  41. * 学生模块根据集合id 批量删除数据
  42. * @param ids
  43. * @return R<Void>
  44. */
  45. R<Void> removeIdsInfo(List<Integer> ids);
  46. }

Controller层

  1. package co.yixiang.exam.controller;
  2. import co.yixiang.exam.common.R;
  3. import co.yixiang.exam.entity.ExStudent;
  4. import co.yixiang.exam.service.ExStudentService;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.data.domain.Pageable;
  8. import org.springframework.validation.annotation.Validated;
  9. import org.springframework.web.bind.annotation.*;
  10. import java.util.List;
  11. /**
  12. * @author Mtz
  13. * @version 1.0
  14. * @2024/5/139:35
  15. * @function
  16. * @comment 学生模块
  17. */
  18. @RestController
  19. @RequestMapping("/ex/student")
  20. public class ExStudentController {
  21. @Autowired
  22. private ExStudentService exStudentService;
  23. /***
  24. * 学生模块分页查询
  25. * @param exStudent
  26. * @param pageable
  27. * @return R<IPage < ExStudent>>
  28. */
  29. @GetMapping("/selectInfo")
  30. public R<IPage<ExStudent>> selectInfo(ExStudent exStudent, Pageable pageable) {
  31. return exStudentService.selectInfo(exStudent, pageable);
  32. }
  33. /***
  34. * 学生模块添加
  35. * @param exStudent
  36. * @return R<Void>
  37. */
  38. @PostMapping("/insertInfo")
  39. public R<Void> insertInfo(@RequestBody ExStudent exStudent) {
  40. return exStudentService.insertInfo(exStudent);
  41. }
  42. /***
  43. * 学生模块根据id修改数据
  44. * @param exStudent
  45. * @return
  46. */
  47. @PostMapping("/saveInfo")
  48. public R<Void> saveInfo(@Validated @RequestBody ExStudent exStudent) {
  49. return exStudentService.saveInfo(exStudent);
  50. }
  51. /***
  52. * 学生模块根据id获取数据
  53. * @param exStudent
  54. * @return
  55. */
  56. @GetMapping("/getByIdInfo")
  57. public R<ExStudent> getByIdInfo(@Validated ExStudent exStudent) {
  58. return exStudentService.getByIdInfo(exStudent);
  59. }
  60. /***
  61. * 学生模块根据集合id 批量删除数据
  62. * @param ids
  63. * @return R<Void>
  64. */
  65. @PostMapping("/removeIdsInfo")
  66. public R<Void> removeIdsInfo(@RequestBody List<Integer> ids) {
  67. return exStudentService.removeIdsInfo(ids);
  68. }
  69. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/568506
推荐阅读
相关标签
  

闽ICP备14008679号