|
@@ -0,0 +1,82 @@
|
|
|
+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.FusionMeter;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
+import com.fdkankan.fusion.service.IFusionMeterService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-08-11
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/fusionMeter")
|
|
|
+public class FusionMeterController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IFusionMeterService fusionMeterService;
|
|
|
+
|
|
|
+ @GetMapping("/allList")
|
|
|
+ public ResultData allList(@RequestParam(required = false) Integer fusionId,
|
|
|
+ @RequestParam(required = false) String meterTitle){
|
|
|
+ if(fusionId == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ return ResultData.ok(fusionMeterService.getListByFusionId(fusionId,meterTitle));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ public ResultData add(@RequestBody FusionMeter fusionMeter){
|
|
|
+ fusionMeterService.add(fusionMeter);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/updateMeterTitle")
|
|
|
+ public ResultData updateMeterTitle(@RequestBody FusionMeter fusionMeter){
|
|
|
+ if(fusionMeter.getFusionMeterId() == null || StringUtils.isEmpty(fusionMeter.getMeterTitle())){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<FusionMeter> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(FusionMeter::getFusionMeterId,fusionMeter.getFusionMeterId())
|
|
|
+ .set(FusionMeter::getMeterTitle,fusionMeter.getMeterTitle());
|
|
|
+ fusionMeterService.update(wrapper);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+ @PostMapping("/hide")
|
|
|
+ public ResultData hide( @RequestBody FusionMeter fusionMeter){
|
|
|
+ if((fusionMeter.getFusionMeterId() == null&& fusionMeter.getFusionId()== null) || fusionMeter.getHide()== null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<FusionMeter> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ if(fusionMeter.getFusionId()!=null){
|
|
|
+ wrapper.eq(FusionMeter::getFusionId,fusionMeter.getFusionId());
|
|
|
+ }
|
|
|
+ if(fusionMeter.getFusionMeterId()!=null){
|
|
|
+ wrapper.eq(FusionMeter::getFusionMeterId,fusionMeter.getFusionMeterId());
|
|
|
+ }
|
|
|
+ wrapper.set(FusionMeter::getHide,fusionMeter.getHide());
|
|
|
+ fusionMeterService.update(wrapper);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public ResultData delete(@RequestBody FusionMeter fusionMeter){
|
|
|
+ if(fusionMeter.getFusionMeterId() == null ){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ fusionMeterService.removeById(fusionMeter.getFusionMeterId());
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|