Browse Source

Merge branch 'yellow' of http://39.105.160.25:10880/post-project-api/post into yellow

sjx 2 years ago
parent
commit
d57d427215

+ 9 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsController.java

@@ -65,7 +65,15 @@ public class PostCollectionsController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody PostCollectionsVo postCollectionsVo)
     {
-
+        //截止时间早于起售时间,套系售卖截止时间早于创建时间
+        if (postCollectionsVo.getStartTime().after(postCollectionsVo.getEndTime())||
+                postCollectionsVo.getEndTime().before(DateUtils.getNowDate())){
+            return warn("请设置正确的套系时间");
+        }
+        //判断套系名称是否重复
+        if (postCollectionsService.selectPostCollectionsByName(postCollectionsVo) > 0){
+            return warn("该套系名称已存在");
+        }
         return toAjax(postCollectionsService.insertPostCollections(postCollectionsVo));
     }
 

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostCollectionsMapper.java

@@ -60,4 +60,11 @@ public interface PostCollectionsMapper
      * @return 结果
      */
     public int deletePostCollectionsByIds(Long[] ids);
+    /**
+     * 根据藏品名称查询藏品数量
+     *
+     * @param postCollectionsVo 藏品
+     * @return 结果
+     */
+    public int selectPostCollectionsByName(PostCollectionsVo postCollectionsVo);
 }

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPostCollectionsService.java

@@ -60,6 +60,13 @@ public interface IPostCollectionsService
      * @return 结果
      */
     public int deletePostCollectionsById(Long id);
+    /**
+     * 根据藏品名称查询藏品数量
+     *
+     * @param postCollectionsVo 藏品
+     * @return 结果
+     */
+    public int selectPostCollectionsByName(PostCollectionsVo postCollectionsVo);
 
 
 }

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsServiceImpl.java

@@ -139,4 +139,14 @@ public class PostCollectionsServiceImpl implements IPostCollectionsService
     {
         return postCollectionsMapper.deletePostCollectionsById(id);
     }
+    /**
+     * 根据藏品名称查询藏品数量
+     *
+     * @param postCollectionsVo 藏品
+     * @return 结果
+     */
+    @Override
+    public int selectPostCollectionsByName(PostCollectionsVo postCollectionsVo) {
+        return postCollectionsMapper.selectPostCollectionsByName(postCollectionsVo);
+    }
 }

+ 4 - 0
ruoyi-system/src/main/resources/mapper/system/PostCollectionsMapper.xml

@@ -113,4 +113,8 @@
             #{id}
         </foreach>
     </delete>
+    <!--根据藏品名称查询藏品数量-->
+    <select id="selectPostCollectionsByName" parameterType="PostCollectionsVo" resultType="int">
+        select COUNT(name) FROM post_collections where name =  #{name} and del_flag = '0'
+    </select>
 </mapper>