Bläddra i källkod

新增添加、修改标准编号重复检查
管理员权限BUG修复

anderx 1 år sedan
förälder
incheckning
aa068a00d9

+ 3 - 0
src/main/java/com/goafanti/common/dao/StandardDocumentMapper.java

@@ -24,4 +24,7 @@ public interface StandardDocumentMapper {
     int updateByPrimaryKey(StandardDocument record);
 
     OutStandardDocument selectDetailsById(Integer id);
+
+
+    StandardDocument selectByNumber(StandardDocument in);
 }

+ 8 - 4
src/main/java/com/goafanti/common/mapper/PermissionMapper.xml

@@ -326,12 +326,16 @@
 		  		select
 					id,
 					name,
-					url
+					url,
+                    super_id superId,
+					type
 				from
 					permission
-				where
-					super_id = #{superId,jdbcType=VARCHAR}
-                    and d.type in (1,2)
+				where type in (1,2)
+                <if test="superId != null">
+                    and d.super_id = #{superId,jdbcType=VARCHAR}
+                </if>
+
   			</when>
   			<otherwise>
 				select

+ 6 - 1
src/main/java/com/goafanti/common/mapper/StandardDocumentMapper.xml

@@ -180,7 +180,12 @@
         where  1=1
         <include refid="standardSql"/>
     </select>
-
+    <select id="selectByNumber"  resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from standard_document
+        where  serial_number= #{serialNumber}
+    </select>
 
 
 </mapper>

+ 8 - 0
src/main/java/com/goafanti/standard/controller/StandardApiController.java

@@ -52,6 +52,10 @@ public class StandardApiController extends CertifyApiController {
             res.error(buildError("操作权限不正确。"));
             return res;
         }
+        if(standardService.inspectNumber(in)){
+            res.error(buildError("标准编号已存在。"));
+            return res;
+        }
         return res.data(standardService.add(in));
     }
 
@@ -78,6 +82,10 @@ public class StandardApiController extends CertifyApiController {
             res.error(buildError("操作权限不正确。"));
             return res;
         }
+        if(standardService.inspectNumber(in)){
+            res.error(buildError("标准编号已存在。"));
+            return res;
+        }
         return res.data(standardService.update(in));
     }
 

+ 2 - 0
src/main/java/com/goafanti/standard/service/StandardService.java

@@ -15,4 +15,6 @@ public interface StandardService {
     Pagination<OutStandardDocument> list(InputStandardList in);
 
     Object get(StandardDocument in);
+
+    boolean inspectNumber(StandardDocument in);
 }

+ 8 - 0
src/main/java/com/goafanti/standard/service/impl/StandardServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 @Service
 public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper> implements StandardService {
@@ -104,4 +105,11 @@ public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper>
         return standardDocumentMapper.selectDetailsById(in.getId());
 
     }
+
+    @Override
+    public boolean inspectNumber(StandardDocument in) {
+        StandardDocument out = standardDocumentMapper.selectByNumber(in);
+        if (in.getId()==null&&out!=null) return true;
+        else return in.getId() != null && out != null && !Objects.equals(out.getId(), in.getId());
+    }
 }