BusinessDevelopmentController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.ylx.web.controller.massage;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ylx.common.core.controller.BaseController;
  6. import com.ylx.common.core.domain.model.WxLoginUser;
  7. import com.ylx.massage.domain.BusinessDevelopment;
  8. import com.ylx.massage.service.BusinessDevelopmentService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.web.bind.annotation.*;
  12. import com.ylx.common.core.domain.R;
  13. import javax.annotation.Resource;
  14. import java.io.Serializable;
  15. import java.util.List;
  16. /**
  17. * 招商代理(BusinessDevelopment)表控制层
  18. *
  19. * @author makejava
  20. * @since 2024-07-29 16:42:47
  21. */
  22. @RestController
  23. @Api(tags = {"招商代理(BusinessDevelopment)表控制层"})
  24. @RequestMapping("businessDevelopment")
  25. public class BusinessDevelopmentController extends BaseController {
  26. /**
  27. * 服务对象
  28. */
  29. @Resource
  30. private BusinessDevelopmentService businessDevelopmentService;
  31. /**
  32. * 分页查询所有数据
  33. *
  34. * @param page 分页对象
  35. * @param businessDevelopment 查询实体
  36. * @return 所有数据
  37. */
  38. @GetMapping("selectAll")
  39. @ApiOperation("分页查询所有数据")
  40. public R selectAll(Page<BusinessDevelopment> page, BusinessDevelopment businessDevelopment) {
  41. return R.ok(this.businessDevelopmentService.page(page, new QueryWrapper<>(businessDevelopment)));
  42. }
  43. /**
  44. * 通过主键查询单条数据
  45. *
  46. * @param id 主键
  47. * @return 单条数据
  48. */
  49. @GetMapping("{id}")
  50. @ApiOperation("通过主键查询单条数据")
  51. public R selectOne(@PathVariable Serializable id) {
  52. return R.ok(this.businessDevelopmentService.getById(id));
  53. }
  54. /**
  55. * 新增数据
  56. *
  57. * @param businessDevelopment 实体对象
  58. * @return 新增结果
  59. */
  60. @PostMapping("add")
  61. @ApiOperation("新增数据")
  62. public R insert(@RequestBody BusinessDevelopment businessDevelopment) {
  63. WxLoginUser wxLoginUser = this.getWxLoginUser();
  64. LambdaQueryWrapper<BusinessDevelopment> queryWrapper = new LambdaQueryWrapper<>();
  65. queryWrapper.eq(BusinessDevelopment::getOpenId, wxLoginUser.getCOpenid());
  66. List<BusinessDevelopment> list = businessDevelopmentService.list(queryWrapper);
  67. if (!list.isEmpty()) {
  68. return R.fail("已提交过申请");
  69. }
  70. return R.ok(this.businessDevelopmentService.save(businessDevelopment));
  71. }
  72. /**
  73. * 修改数据
  74. *
  75. * @param businessDevelopment 实体对象
  76. * @return 修改结果
  77. */
  78. @PostMapping("update")
  79. @ApiOperation("修改数据")
  80. public R update(@RequestBody BusinessDevelopment businessDevelopment) {
  81. return R.ok(this.businessDevelopmentService.updateById(businessDevelopment));
  82. }
  83. /**
  84. * 删除数据
  85. *
  86. * @param idList 主键结合
  87. * @return 删除结果
  88. */
  89. @PostMapping("delete")
  90. @ApiOperation("删除数据")
  91. public R delete(@RequestBody List<String> idList) {
  92. return R.ok(this.businessDevelopmentService.removeByIds(idList));
  93. }
  94. }