package com.fdkankan.fusion.controller; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fdkankan.common.constant.ErrorCode; import com.fdkankan.common.response.ResultData; import com.fdkankan.fusion.entity.FusionGuide; import com.fdkankan.fusion.exception.BusinessException; import com.fdkankan.fusion.service.IFusionGuideService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** *

* 前端控制器 *

* * @author * @since 2022-08-11 */ @RestController @RequestMapping("/fusionGuide") public class FusionGuideController { @Autowired IFusionGuideService fusionGuideService; @GetMapping("/allList") public ResultData allList(@RequestParam(required = false) Integer fusionId){ return ResultData.ok(fusionGuideService.getAllList(fusionId)); } @PostMapping("/add") public ResultData add(@RequestBody FusionGuide fusionGuide){ fusionGuideService.add(fusionGuide); return ResultData.ok(); } @PostMapping("/updateSort") public ResultData updateSort(@RequestBody FusionGuide fusionGuide){ if(fusionGuide.getFusionGuideId() == null || fusionGuide.getSort() == null){ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS); } LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(FusionGuide::getFusionGuideId,fusionGuide.getFusionGuideId()); wrapper.set(FusionGuide::getSort,fusionGuide.getSort()); fusionGuideService.update(wrapper); return ResultData.ok(); } @PostMapping("/delete") public ResultData delete(@RequestBody FusionGuide fusionGuide){ if(fusionGuide.getFusionGuideId() == null){ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS); } fusionGuideService.removeById(fusionGuide.getFusionGuideId()); return ResultData.ok(); } }