Browse Source

新增套系1.3

sjx 2 years ago
parent
commit
7074413b1c

+ 4 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -93,8 +93,10 @@ public class PostCollectionsSystemController extends BaseController
         if (postCollectionsSystem.getEndTime().before(DateUtils.getNowDate())){
             return warn("请设置正确的套系时间");
         }
-
-
+        //判断套系名称是否重复
+        if (postCollectionsSystemService.selectPostCollectionsSystemByName(postCollectionsSystem) > 0){
+            return warn("该套系名称已存在");
+        }
         return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
     }
 

+ 6 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsSystemMapper.java

@@ -66,8 +66,13 @@ public interface PostCollectionsSystemMapper
     List<PostCollectionsSystem> selectPostListByTitleOrTime(@Param("title") String title,
                                                             @Param("timeLeft") Date timeLeft,
                                                             @Param("timeRight") Date timeRight);
-
+    // 获取套系藏品 数量
     Integer getCopiesById(Long id);
 
+    // 获取套系全部id
     List<Long> selectPostCollectionsSystemId(PostCollectionsSystem postCollectionsSystem);
+
+    // 查询该套系名 数量
+    int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
+
 }

+ 18 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/IPostCollectionsSystemService.java

@@ -66,9 +66,25 @@ public interface IPostCollectionsSystemService
     //搜索功能
     public List<PostCollectionsSystem> selectByTitleAndTime(String title, Date timeLeft, Date timeRight);
 
-
+    /**
+     *  分页
+     * @param postCollectionsSystem
+     * @return
+     */
+    List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem);
+    /**
+     *  获取藏品数量
+     * @param id
+     * @return 该套系下藏品数量
+     */
     public int getCopies(Long id);
 
-    List<CollectionsVo> selectPostCollectionsSystemListPage(PostCollectionsSystem postCollectionsSystem);
+    /**
+     *  用套系名称进行查询
+     * @param postCollectionsSystem
+     */
+    int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem);
 }
 
+
+

+ 8 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsSystemServiceImpl.java

@@ -81,9 +81,9 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
         }
 
         //补充字段
-        postCollectionsSystem.setCreateBy(getUsername());
+        postCollectionsSystem.setCreateUser(getUsername());
         postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
-        postCollectionsSystem.setUpdateBy(getUsername());
+        postCollectionsSystem.setUpdateUser(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.insertPostCollectionsSystem(postCollectionsSystem);
     }
@@ -98,7 +98,7 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     public int updatePostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
     {
         //补充字段
-        postCollectionsSystem.setUpdateBy(getUsername());
+        postCollectionsSystem.setUpdateUser(getUsername());
         postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
     }
@@ -188,4 +188,9 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
         }).collect(Collectors.toList());
         return collectionsVos;
     }
+
+    @Override
+    public int selectPostCollectionsSystemByName(PostCollectionsSystem postCollectionsSystem) {
+        return postCollectionsSystemMapper.selectPostCollectionsSystemByName(postCollectionsSystem);
+    }
 }

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/PostCollectionsSystemMapper.xml

@@ -119,7 +119,7 @@
 
 
     <select id="getCopiesById" parameterType="Long" resultType="Integer">
-       SELECT SUM(collections_number) FROM post_collections where system_id = #{id}
+       SELECT COUNt(system_id) FROM post_collections where system_id = #{id}
     </select>
 
     <select id="selectPostCollectionsSystemId" parameterType="PostCollectionsSystem" resultType="Long">
@@ -137,4 +137,9 @@
             and del_flag = '0'
         </where>
     </select>
+
+    <!--用藏品名称进行查询数量-->
+    <select id="selectPostCollectionsSystemByName" parameterType="PostCollectionsSystem" resultType="int">
+        SELECT COUNT(name) FROM post_collections_system where name =  #{name} and del_flag = '0'
+    </select>
 </mapper>