FusionGuideController.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.fdkankan.fusion.controller;
  2. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  3. import com.fdkankan.common.constant.ErrorCode;
  4. import com.fdkankan.common.response.ResultData;
  5. import com.fdkankan.fusion.entity.FusionGuide;
  6. import com.fdkankan.fusion.exception.BusinessException;
  7. import com.fdkankan.fusion.service.IFusionGuideService;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. /**
  11. * <p>
  12. * 前端控制器
  13. * </p>
  14. *
  15. * @author
  16. * @since 2022-08-11
  17. */
  18. @RestController
  19. @RequestMapping("/fusionGuide")
  20. public class FusionGuideController {
  21. @Autowired
  22. IFusionGuideService fusionGuideService;
  23. @GetMapping("/allList")
  24. public ResultData allList(@RequestParam(required = false) Integer fusionId){
  25. return ResultData.ok(fusionGuideService.getAllList(fusionId));
  26. }
  27. @PostMapping("/add")
  28. public ResultData add(@RequestBody FusionGuide fusionGuide){
  29. fusionGuideService.add(fusionGuide);
  30. return ResultData.ok();
  31. }
  32. @PostMapping("/updateSort")
  33. public ResultData updateSort(@RequestBody FusionGuide fusionGuide){
  34. if(fusionGuide.getFusionGuideId() == null || fusionGuide.getSort() == null){
  35. throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
  36. }
  37. LambdaUpdateWrapper<FusionGuide> wrapper = new LambdaUpdateWrapper<>();
  38. wrapper.eq(FusionGuide::getFusionGuideId,fusionGuide.getFusionGuideId());
  39. wrapper.set(FusionGuide::getSort,fusionGuide.getSort());
  40. fusionGuideService.update(wrapper);
  41. return ResultData.ok();
  42. }
  43. @PostMapping("/delete")
  44. public ResultData delete(@RequestBody FusionGuide fusionGuide){
  45. if(fusionGuide.getFusionGuideId() == null){
  46. throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
  47. }
  48. fusionGuideService.removeById(fusionGuide.getFusionGuideId());
  49. return ResultData.ok();
  50. }
  51. }