Browse Source

树形优化

home 2 years ago
parent
commit
e5fe914ca8

+ 1 - 1
hx-common/code-generator/src/main/java/com/fjhx/modular/Victoriatourist.java

@@ -12,7 +12,7 @@ public class Victoriatourist {
         CodeGenerator.MODULAR_NAME = "victoriatourist";
 
         // 需要生成的表名称,多表用,隔开
-        CodeGenerator.INCLUDE = "supplier";
+        CodeGenerator.INCLUDE = "supplier_price";
 
         // mysql连接
         CodeGenerator.MYSQL_URL = "36.134.91.96:17330";

+ 8 - 8
hx-common/common-tool/src/main/java/com/fjhx/base/BaseService.java

@@ -94,20 +94,20 @@ public interface BaseService<T> extends IService<T> {
     }
 
 
-    default long count(Consumer<IWrapper<T>> consumer) {
-        return count(IWrapper.<T>getWrapper().func(consumer));
+    default long count(Consumer<LambdaQueryWrapper<T>> consumer) {
+        return count(Wrappers.<T>lambdaQuery().func(consumer));
     }
 
-    default T getOne(Consumer<IWrapper<T>> consumer) {
-        return getOne(IWrapper.<T>getWrapper().func(consumer).last("limit 1"));
+    default T getOne(Consumer<LambdaQueryWrapper<T>> consumer) {
+        return getOne(Wrappers.<T>lambdaQuery().func(consumer).last("limit 1"));
     }
 
-    default List<T> list(Consumer<IWrapper<T>> consumer) {
-        return list(IWrapper.<T>getWrapper().func(consumer));
+    default List<T> list(Consumer<LambdaQueryWrapper<T>> consumer) {
+        return list(Wrappers.<T>lambdaQuery().func(consumer));
     }
 
-    default List<Map<String, Object>> listMaps(Consumer<IWrapper<T>> consumer) {
-        return listMaps(IWrapper.<T>getWrapper().func(consumer));
+    default List<Map<String, Object>> listMaps(Consumer<LambdaQueryWrapper<T>> consumer) {
+        return listMaps(Wrappers.<T>lambdaQuery().func(consumer));
     }
 
     default <V> List<V> listObj(SFunction<T, V> mapper, Consumer<LambdaQueryWrapper<T>> consumer) {

+ 2 - 1
hx-common/library-product/src/main/java/com/fjhx/controller/ClassifyController.java

@@ -1,5 +1,6 @@
 package com.fjhx.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.entity.Classify;
 import com.fjhx.service.ClassifyService;
 import org.springblade.core.tool.api.R;
@@ -29,7 +30,7 @@ public class ClassifyController {
 
     @PostMapping("/tree")
     public R page(@RequestBody Map<String, String> condition) {
-        List<Map<String, Object>> result = classifyService.getTree(condition);
+        List<JSONObject> result = classifyService.getTree(condition);
         return R.success(result);
     }
 

+ 2 - 1
hx-common/library-product/src/main/java/com/fjhx/service/ClassifyService.java

@@ -1,5 +1,6 @@
 package com.fjhx.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.base.BaseService;
 import com.fjhx.entity.Classify;
 
@@ -16,7 +17,7 @@ import java.util.Map;
  */
 public interface ClassifyService extends BaseService<Classify> {
 
-    List<Map<String, Object>> getTree(Map<String, String> condition);
+    List<JSONObject> getTree(Map<String, String> condition);
 
     void add(Classify classify);
 

+ 2 - 1
hx-common/library-product/src/main/java/com/fjhx/service/impl/ClassifyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fjhx.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.base.BaseEntity;
 import com.fjhx.entity.Classify;
@@ -39,7 +40,7 @@ public class ClassifyServiceImpl extends ServiceImpl<ClassifyMapper, Classify> i
     private MaterialService materialService;
 
     @Override
-    public List<Map<String, Object>> getTree(Map<String, String> condition) {
+    public List<JSONObject> getTree(Map<String, String> condition) {
 
         String type = condition.get("type");
         Assert.notEmpty(type, "分类类型不能为空");

+ 2 - 1
hx-common/service-video/src/main/java/com/fjhx/controller/video/VideoClassifyController.java

@@ -1,5 +1,6 @@
 package com.fjhx.controller.video;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.params.video.VideoClassifyVo;
 import com.fjhx.service.video.VideoClassifyService;
 import org.springblade.core.tool.api.R;
@@ -29,7 +30,7 @@ public class VideoClassifyController {
 
     @PostMapping("/tree")
     public R tree(@RequestBody Map<String, String> condition) {
-        List<Map<String, Object>> result = videoClassifyService.getTree(condition);
+        List<JSONObject> result = videoClassifyService.getTree(condition);
         return R.success(result);
     }
 

+ 2 - 1
hx-common/service-video/src/main/java/com/fjhx/service/video/VideoClassifyService.java

@@ -1,5 +1,6 @@
 package com.fjhx.service.video;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.base.BaseService;
 import com.fjhx.entity.video.VideoClassify;
 import com.fjhx.params.video.VideoClassifyVo;
@@ -17,7 +18,7 @@ import java.util.Map;
  */
 public interface VideoClassifyService extends BaseService<VideoClassify> {
 
-    List<Map<String, Object>> getTree(Map<String, String> condition);
+    List<JSONObject> getTree(Map<String, String> condition);
 
     void add(VideoClassifyVo videoClassifyVo);
 

+ 2 - 1
hx-common/service-video/src/main/java/com/fjhx/service/video/impl/VideoClassifyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fjhx.service.video.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.base.BaseEntity;
 import com.fjhx.entity.video.VideoClassify;
@@ -30,7 +31,7 @@ import java.util.stream.Collectors;
 public class VideoClassifyServiceImpl extends ServiceImpl<VideoClassifyMapper, VideoClassify> implements VideoClassifyService {
 
     @Override
-    public List<Map<String, Object>> getTree(Map<String, String> condition) {
+    public List<JSONObject> getTree(Map<String, String> condition) {
 
         // 分类名称
         String name = condition.get("name");

+ 2 - 2
hx-service/storage-restructure/src/main/java/com/fjhx/controller/material/MaterialClassifyController.java

@@ -1,5 +1,6 @@
 package com.fjhx.controller.material;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.params.material.MaterialClassifyVo;
 import com.fjhx.service.material.MaterialClassifyService;
 import org.springblade.core.tool.api.R;
@@ -10,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -29,7 +29,7 @@ public class MaterialClassifyController {
 
     @PostMapping("/tree")
     public R tree() {
-        List<Map<String, Object>> result = materialClassifyService.tree();
+        List<JSONObject> result = materialClassifyService.tree();
         return R.success(result);
     }
 

+ 2 - 3
hx-service/storage-restructure/src/main/java/com/fjhx/service/material/MaterialClassifyService.java

@@ -1,12 +1,11 @@
 package com.fjhx.service.material;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.alibaba.fastjson.JSONObject;
 import com.fjhx.entity.material.MaterialClassify;
 import com.fjhx.params.material.MaterialClassifyVo;
 import com.fjhx.base.StorageBaseService;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -18,7 +17,7 @@ import java.util.Map;
  */
 public interface MaterialClassifyService extends StorageBaseService<MaterialClassify> {
 
-    List<Map<String,Object>> tree();
+    List<JSONObject> tree();
 
     void add(MaterialClassifyVo materialClassifyVo);
 

+ 2 - 2
hx-service/storage-restructure/src/main/java/com/fjhx/service/material/impl/MaterialClassifyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fjhx.service.material.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.entity.material.MaterialClassify;
 import com.fjhx.mapper.material.MaterialClassifyMapper;
@@ -11,7 +12,6 @@ import com.fjhx.utils.TreeUtil;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -25,7 +25,7 @@ import java.util.Map;
 public class MaterialClassifyServiceImpl extends ServiceImpl<MaterialClassifyMapper, MaterialClassify> implements MaterialClassifyService {
 
     @Override
-    public List<Map<String, Object>> tree() {
+    public List<JSONObject> tree() {
         return TreeUtil.buildTreeObj(list());
     }
 

+ 8 - 6
hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/impl/SupplierServiceImpl.java

@@ -95,14 +95,16 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
     public void add(SupplierVo supplierVo) {
         String code = supplierVo.getCode();
 
-        if (ObjectUtil.isEmpty(code)) {
-            supplierVo.setCode(createCode());
-        } else {
-            Long count = count(Supplier::getCode, code);
-            Assert.eqZero(count, "供应商编码已存在");
+        synchronized (this) {
+            if (ObjectUtil.isEmpty(code)) {
+                supplierVo.setCode(createCode());
+            } else {
+                Long count = count(Supplier::getCode, code);
+                Assert.eqZero(count, "供应商编码已存在");
+            }
+            save(supplierVo);
         }
 
-        save(supplierVo);
         // 绑定附件
         FileClientUtil.bindingFile(supplierVo.getId(), supplierVo.getFileInfoList());
     }