Kaynağa Gözat

合同支付项排序

qianxb 8 ay önce
ebeveyn
işleme
5b1d1bc62a

+ 8 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MidPayItemController.java

@@ -658,4 +658,12 @@ public class MidPayItemController extends BladeController {
         return R.fail("操作失败");
     }
 
+    @PostMapping("/contract/sort")
+    @ApiOperationSupport(order = 28)
+    @ApiOperation(value = "合同中期支付项排序", notes = "传入节点ids逗号拼接字符串,按照顺序从上到下")
+    public R<Object> contractSort(@RequestParam String ids) {
+        payItemContractService.sort(ids);
+        return R.success("操作成功");
+    }
+
 }

+ 1 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/MidPayItemContractService.java

@@ -4,4 +4,5 @@ import org.springblade.core.mp.base.BaseService;
 import org.springblade.meter.entity.MeterMidPayItemContract;
 
 public interface MidPayItemContractService extends BaseService<MeterMidPayItemContract> {
+    void sort(String ids);
 }

+ 20 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MidPayItemContractServiceImpl.java

@@ -1,8 +1,13 @@
 package org.springblade.meter.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.api.R;
 import org.springblade.meter.entity.MeterMidPayItemContract;
+import org.springblade.meter.entity.MeterTreeContract;
 import org.springblade.meter.mapper.MidPayItemContractMapper;
 import org.springblade.meter.service.MidPayItemContractService;
 import org.springframework.stereotype.Service;
@@ -11,4 +16,19 @@ import org.springframework.stereotype.Service;
 @AllArgsConstructor
 public class MidPayItemContractServiceImpl extends BaseServiceImpl<MidPayItemContractMapper, MeterMidPayItemContract> implements MidPayItemContractService {
 
+    @Override
+    public void sort(String ids) {
+        if (StringUtils.isNotBlank(ids)) {
+            String[] split = ids.split(",");
+            int sort = 1;
+            for (String id : split) {
+                this.update(Wrappers.<MeterMidPayItemContract>lambdaUpdate()
+                        .set(MeterMidPayItemContract::getSort, sort++)
+                        .eq(MeterMidPayItemContract::getId, id)
+                );
+            }
+        }else {
+            throw new ServiceException("请传入ids");
+        }
+    }
 }