Explorar el Código

平台服务商+服务商模块

ZhangWenQiang hace 6 años
padre
commit
da0c8cee5a

+ 1 - 2
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgplatform/controller/HlgPlatformSubcontractorController.java

@@ -77,8 +77,7 @@ public class HlgPlatformSubcontractorController {
 	public Result<HlgPlatformSubcontractor> add(@RequestBody HlgPlatformSubcontractor hlgPlatformSubcontractor) {
 		Result<HlgPlatformSubcontractor> result = new Result<HlgPlatformSubcontractor>();
 		try {
-			hlgPlatformSubcontractorService.savePlatformSubcontractor(hlgPlatformSubcontractor);
-			result.success("添加成功!");
+			result = hlgPlatformSubcontractorService.savePlatformSubcontractor(hlgPlatformSubcontractor);
 		} catch (Exception e) {
 			log.error(e.getMessage(),e);
 			result.error500("操作失败");

+ 2 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgplatform/mapper/HlgPlatformSubcontractorMapper.java

@@ -19,4 +19,6 @@ import java.util.List;
 public interface HlgPlatformSubcontractorMapper extends BaseMapper<HlgPlatformSubcontractor> {
 
     List<HlgPlatformSubcontractor> findList(Page<HlgPlatformSubcontractor> pageList, @Param("hlgPlatformSubcontractor") HlgPlatformSubcontractor hlgPlatformSubcontractor, @Param(Constants.WRAPPER) QueryWrapper<HlgPlatformSubcontractor> queryWrapper);
+
+    int getCountForPlatformSubcontractor(@Param("hlgPlatformSubcontractor") HlgPlatformSubcontractor hlgPlatformSubcontractor);
 }

+ 6 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgplatform/mapper/xml/HlgPlatformSubcontractorMapper.xml

@@ -70,5 +70,11 @@
 		WHERE id = #{id}
 	</update>
 
+	<select id="getCountForPlatformSubcontractor" resultType="int">
+		select count(a.id)
+		from hlg_platform_subcontractor a
+		where a.platform_id = #{hlgPlatformSubcontractor.platformId}
+		and a.subcontractor_id = #{hlgPlatformSubcontractor.subcontractorId}
+	</select>
 
 </mapper>

+ 2 - 1
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgplatform/service/IHlgPlatformSubcontractorService.java

@@ -4,6 +4,7 @@ package org.jeecg.modules.hlgplatform.service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.hlgplatform.entity.HlgPlatformSubcontractor;
 
 /**
@@ -16,5 +17,5 @@ public interface IHlgPlatformSubcontractorService extends IService<HlgPlatformSu
 
     Page<HlgPlatformSubcontractor> pageList(Page<HlgPlatformSubcontractor> page, HlgPlatformSubcontractor hlgPlatformSubcontractor, QueryWrapper<HlgPlatformSubcontractor> queryWrapper);
 
-    void savePlatformSubcontractor(HlgPlatformSubcontractor hlgPlatformSubcontractor);
+    Result<HlgPlatformSubcontractor> savePlatformSubcontractor(HlgPlatformSubcontractor hlgPlatformSubcontractor);
 }

+ 12 - 2
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgplatform/service/impl/HlgPlatformSubcontractorServiceImpl.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.hlgplatform.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.hlgplatform.entity.HlgPlatformSubcontractor;
 import org.jeecg.modules.hlgplatform.mapper.HlgPlatformSubcontractorMapper;
 import org.jeecg.modules.hlgplatform.service.IHlgPlatformSubcontractorService;
@@ -13,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
 /**
  * @Description: 平台服务商表
  * @Author: jeecg-boot
- * @Date:   2020-02-18
+ * @Date: 2020-02-18
  * @Version: V1.0
  */
 @Service
@@ -26,8 +27,17 @@ public class HlgPlatformSubcontractorServiceImpl extends ServiceImpl<HlgPlatform
 
     @Override
     @Transactional
-    public void savePlatformSubcontractor(HlgPlatformSubcontractor hlgPlatformSubcontractor) {
+    public Result<HlgPlatformSubcontractor> savePlatformSubcontractor(HlgPlatformSubcontractor hlgPlatformSubcontractor) {
+        Result<HlgPlatformSubcontractor> result = new Result<HlgPlatformSubcontractor>();
+        //查看该平台是否已绑定该服务商
+        int count = baseMapper.getCountForPlatformSubcontractor(hlgPlatformSubcontractor);
+        if (count > 0) {
+            result.error500("服务商已存在,请勿重复添加");
+            return result;
+        }
         hlgPlatformSubcontractor.setIsOn("1");
         save(hlgPlatformSubcontractor);
+        result.success("添加成功!");
+        return result;
     }
 }