Browse Source

套系新增1.1

sjx 2 years ago
parent
commit
0860f08dcb

+ 10 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostCollectionsSystemController.java

@@ -81,13 +81,17 @@ public class PostCollectionsSystemController extends BaseController
     public AjaxResult add(@RequestBody PostCollectionsSystem postCollectionsSystem)
     {
         if (!getUsername().equals("admin")){
-            return error("仅管理员拥有该权限");
+            //warn:601
+            return warn("仅管理员拥有该权限");
+        }
+        //截止时间早于起售时间
+        if (postCollectionsSystem.getStartTime().after(postCollectionsSystem.getEndTime())){
+            return warn("请设置正确的套系时间");
+        }
+        //当套系售卖截止时间早于创建时间
+        if (postCollectionsSystem.getEndTime().before(DateUtils.getNowDate())){
+            return warn("请设置正确的套系时间");
         }
-        //补充字段
-        postCollectionsSystem.setCreateBy(getUsername());
-        postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
-        postCollectionsSystem.setUpdateBy(getUsername());
-        postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
     }
 
@@ -100,9 +104,6 @@ public class PostCollectionsSystemController extends BaseController
     @PutMapping
     public AjaxResult edit(@RequestBody PostCollectionsSystem postCollectionsSystem)
     {
-        //补充字段
-        postCollectionsSystem.setUpdateBy(getUsername());
-        postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return toAjax(postCollectionsSystemService.updatePostCollectionsSystem(postCollectionsSystem));
 
     }

+ 2 - 2
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java

@@ -25,14 +25,14 @@ public class BaseEntity implements Serializable
     private String createBy;
 
     /** 创建时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
     /** 更新者 */
     private String updateBy;
 
     /** 更新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
 
     /** 备注 */

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/domain/PostCollectionsSystem.java

@@ -29,12 +29,12 @@ public class PostCollectionsSystem extends BaseEntity
     private String name;
 
     /** 开始展示时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
     @Excel(name = "开始展示时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date startTime;
 
     /** 结束展示时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
     @Excel(name = "结束展示时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date endTime;
 

+ 29 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostCollectionsSystemServiceImpl.java

@@ -9,6 +9,8 @@ import com.ruoyi.system.mapper.PostCollectionsSystemMapper;
 import com.ruoyi.system.domain.PostCollectionsSystem;
 import com.ruoyi.system.service.IPostCollectionsSystemService;
 
+import static com.ruoyi.common.utils.SecurityUtils.getUsername;
+
 /**
  * 藏品套系Service业务层处理
  *
@@ -54,7 +56,30 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     @Override
     public int insertPostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
     {
-        postCollectionsSystem.setCreateTime(DateUtils.getNowDate());
+        /**
+         * 判断时间 (在售0/预售1/已过期2)
+         * 根据当前时间,对比套系时间,当前小于套系时间,该套系藏品为“以过期”,
+         * 当前时间大于套系时间为“预售”
+         */
+        Date nowDate = DateUtils.getNowDate();
+        Date startTime = postCollectionsSystem.getStartTime();
+        Date endTime = postCollectionsSystem.getEndTime();
+        //当前时间早于套系时间 ->预售
+        if (nowDate.before(startTime)){
+            postCollectionsSystem.setType((long) 1);
+        }
+        else if (nowDate.after(endTime)){
+            postCollectionsSystem.setType((long) 2);
+        }
+        else {
+            postCollectionsSystem.setType((long) 0);
+        }
+
+        //补充字段
+        postCollectionsSystem.setCreateBy(getUsername());
+        postCollectionsSystem.setCreateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
+        postCollectionsSystem.setUpdateBy(getUsername());
+        postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.insertPostCollectionsSystem(postCollectionsSystem);
     }
 
@@ -67,7 +92,9 @@ public class PostCollectionsSystemServiceImpl implements IPostCollectionsSystemS
     @Override
     public int updatePostCollectionsSystem(PostCollectionsSystem postCollectionsSystem)
     {
-        postCollectionsSystem.setUpdateTime(DateUtils.getNowDate());
+        //补充字段
+        postCollectionsSystem.setUpdateBy(getUsername());
+        postCollectionsSystem.setUpdateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getTime()));
         return postCollectionsSystemMapper.updatePostCollectionsSystem(postCollectionsSystem);
     }