Przeglądaj źródła

新增接口 检查手机号码和类型是否存在

ms-blue 1 miesiąc temu
rodzic
commit
9fe783a6c6

+ 16 - 0
src/main/java/com/jsh/erp/controller/SupplierController.java

@@ -137,6 +137,22 @@ public class SupplierController extends BaseController {
         return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
     }
 
+    @GetMapping(value = "/checkIsTelephoneAndTypeExist")
+    @ApiOperation(value = "检查手机号码和类型是否存在")
+    public String checkIsTelephoneAndTypeExist(@RequestParam Long id,
+                                          @RequestParam(value ="telephone", required = false) String telephone,
+                                          @RequestParam(value ="type") String type,
+                                          HttpServletRequest request){
+        Map<String, Object> objectMap = new HashMap<>();
+        int exist = supplierService.checkIsTelephoneAndTypeExist(id, telephone, type);
+        if (exist > 0) {
+            objectMap.put("status", true);
+        } else {
+            objectMap.put("status", false);
+        }
+        return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+    }
+
     /**
      * 查找客户信息-下拉框
      * @param request

+ 2 - 0
src/main/java/com/jsh/erp/service/SupplierService.java

@@ -41,6 +41,8 @@ public interface SupplierService extends IService<Supplier> {
 
     int checkIsNameAndTypeExist(Long id, String name, String type)throws Exception;
 
+    int checkIsTelephoneAndTypeExist(Long id, String telephone, String type);
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     void updateAdvanceIn(Long supplierId);
 

+ 14 - 0
src/main/java/com/jsh/erp/service/impl/SupplierServiceImpl.java

@@ -282,6 +282,20 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
         return list==null?0:list.size();
     }
 
+    @Override
+    public int checkIsTelephoneAndTypeExist(Long id, String telephone, String type) {
+        telephone = (telephone == null) ? "" : telephone;
+        SupplierExample example = new SupplierExample();
+        example.createCriteria().andIdNotEqualTo(id).andTelephoneEqualTo(telephone).andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Supplier> list = null;
+        try {
+            list = supplierMapper.selectByExample(example);
+        } catch (Exception e) {
+            JshException.readFail(logger, e);
+        }
+        return list == null ? 0 : list.size();
+    }
+
     /**
      * 更新会员的预付款
      * @param supplierId