From 78694f580367d8825025a0d32beccbd9662764b7 Mon Sep 17 00:00:00 2001
From: whywhyo <1511349576@qq.com>
Date: 星期六, 13 五月 2023 21:33:54 +0800
Subject: [PATCH] 导入模板

---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetNoteServiceImpl.java |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetNoteServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetNoteServiceImpl.java
index f719a0e..00bca60 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetNoteServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfPetNoteServiceImpl.java
@@ -7,6 +7,8 @@
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.MapUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.domain.ZfEvent;
+import com.ruoyi.domain.ZfPet;
 import com.ruoyi.domain.ZfPetNote;
 import com.ruoyi.mapper.ZfPetNoteMapper;
 import com.ruoyi.service.ZfPetNoteService;
@@ -31,6 +33,7 @@
     @Override
     public AjaxResult selectPetNoteList(ZfPetNote zfPetNote, Integer pageNum, Integer pageSize) {
         LambdaQueryWrapper<ZfPetNote> lqw = buildCondition(zfPetNote);
+        lqw.orderByDesc(ZfPetNote::getCreateTime);
         Page<ZfPetNote> ZfPetNotePage = new Page<>(pageNum,pageSize);
         Page<ZfPetNote> pageResult = page(ZfPetNotePage, lqw);
         HashMap<String, Object> data = MapUtils.getResult(pageResult);
@@ -40,6 +43,7 @@
     @Override
     public List<ZfPetNote> selectByCondition(ZfPetNote zfPetNote) {
         LambdaQueryWrapper<ZfPetNote> lambdaQueryWrapper = buildCondition(zfPetNote);
+        lambdaQueryWrapper.orderByDesc(ZfPetNote::getCreateTime);
         List<ZfPetNote> list = list(lambdaQueryWrapper);
         log.info("杩斿洖鐨勬暟鎹负:{}",list);
         return list;
@@ -49,16 +53,46 @@
     public AjaxResult getAllPetNoteByPetId(Long pid) {
         LambdaQueryWrapper<ZfPetNote> lqw = new LambdaQueryWrapper<>();
         lqw.eq(ZfPetNote::getPid,pid);
+        lqw.orderByDesc(ZfPetNote::getCreateTime);
         List<ZfPetNote> list = list(lqw);
         return AjaxResult.success(list);
+    }
+
+    @Override
+    public AjaxResult mySave(ZfPetNote zfPetNote) {
+
+        //鍒ゆ柇鏄惁鏈夐噸澶嶆暟鎹�
+        LambdaQueryWrapper<ZfPetNote> lqw = uniqueCondition(zfPetNote);
+        List<ZfPetNote> list = list(lqw);
+        if(list.size()>0){
+            throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+        }
+
+        if(save(zfPetNote)){
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error();
+        }
+    }
+
+    private LambdaQueryWrapper<ZfPetNote> uniqueCondition(ZfPetNote zfPetNote) {
+        LambdaQueryWrapper<ZfPetNote> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(StringUtils.isNotEmpty(zfPetNote.getTitle()),ZfPetNote::getTitle,zfPetNote.getTitle());
+        lqw.eq(zfPetNote.getRemindTime()!=null,ZfPetNote::getRemindTime,zfPetNote.getRemindTime());
+        lqw.eq(zfPetNote.getHappenTime()!=null,ZfPetNote::getHappenTime,zfPetNote.getHappenTime());
+        lqw.eq(StringUtils.isNotEmpty(zfPetNote.getRemark()),ZfPetNote::getRemark,zfPetNote.getRemark());
+        return lqw;
     }
 
     private LambdaQueryWrapper<ZfPetNote> buildCondition(ZfPetNote zfPetNote) {
         LambdaQueryWrapper<ZfPetNote> lqw = new LambdaQueryWrapper<>();
         lqw.like(StringUtils.isNotEmpty(zfPetNote.getTitle()),ZfPetNote::getTitle,zfPetNote.getTitle());
-        lqw.like(zfPetNote.getCreateTime()!=null,ZfPetNote::getCreateTime,zfPetNote.getCreateTime());
         lqw.like(zfPetNote.getRemindTime()!=null,ZfPetNote::getRemindTime,zfPetNote.getRemindTime());
         lqw.like(StringUtils.isNotEmpty(zfPetNote.getRemark()),ZfPetNote::getRemark,zfPetNote.getRemark());
+        lqw.eq(zfPetNote.getHappenTime()!=null,ZfPetNote::getHappenTime,zfPetNote.getHappenTime());
+        lqw.eq(zfPetNote.getRemindTime()!=null,ZfPetNote::getRemindTime,zfPetNote.getRemindTime());
+        lqw.between(zfPetNote.getHappenStartTime() != null && zfPetNote.getHappenEndTime() != null, ZfPetNote::getHappenTime, zfPetNote.getHappenStartTime(), zfPetNote.getHappenEndTime());
+        lqw.between(zfPetNote.getRemindStartTime() != null && zfPetNote.getRemindEndTime() != null, ZfPetNote::getRemindTime, zfPetNote.getRemindStartTime(), zfPetNote.getRemindEndTime());
         return lqw;
     }
 }

--
Gitblit v1.9.1