|
@@ -1,13 +1,16 @@
|
|
|
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.entity.FusionGuidePath;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.service.IFusionGuidePathService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -25,7 +28,41 @@ public class FusionGuidePathController {
|
|
|
IFusionGuidePathService fusionGuidePathService;
|
|
|
|
|
|
@GetMapping("/allList")
|
|
|
- public ResultData allList(){
|
|
|
+ public ResultData allList(@RequestParam(required = false) Integer guideId){
|
|
|
+ return ResultData.ok(fusionGuidePathService.getListByGuideId(guideId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ public ResultData add(@RequestBody FusionGuidePath fusionGuidePath){
|
|
|
+
|
|
|
+ return ResultData.ok(fusionGuidePathService.add(fusionGuidePath));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ public ResultData update(@RequestBody FusionGuidePath fusionGuidePath){
|
|
|
+ if(fusionGuidePath.getGuidePathId() == null ||
|
|
|
+ (fusionGuidePath.getSort() == null && StringUtils.isEmpty(fusionGuidePath.getCover())) ){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<FusionGuidePath> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(FusionGuidePath::getGuidePathId,fusionGuidePath.getGuidePathId());
|
|
|
+ if(fusionGuidePath.getSort()!=null){
|
|
|
+ wrapper.set(FusionGuidePath::getSort,fusionGuidePath.getSort());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(fusionGuidePath.getCover())){
|
|
|
+ wrapper.set(FusionGuidePath::getCover,fusionGuidePath.getCover());
|
|
|
+ }
|
|
|
+ fusionGuidePathService.update(wrapper);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public ResultData delete(@RequestBody FusionGuidePath fusionGuidePath){
|
|
|
+ if(fusionGuidePath.getGuidePathId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ fusionGuidePathService.removeById(fusionGuidePath.getGuidePathId());
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
}
|