소스 검색

规则消息关系方法

yu_ber 4 년 전
부모
커밋
3301b64f08

+ 10 - 0
mpwechatApp/src/main/java/com/liangjian11/wx/mp/controller/WxKeywordController.java

@@ -106,5 +106,15 @@ public class WxKeywordController {
           return new ResultInfo(ResultInfo.TYPE_RESULT_FAIL,222,"添加失败");
         }
     }
+
+    /**
+     * 根据规则ID查询对应发送的消息ID
+     * @param KeywordId
+     * @return
+     */
+    @GetMapping("/getMsgId")
+    public List<Integer> selectMsgId(Integer KeywordId){
+        return keywordMessageRefService.getMessageIdByKeywordId(KeywordId);
+    }
 }
 

+ 1 - 1
mpwechatApp/src/main/java/com/liangjian11/wx/mp/modle/KeywordMessageRef.java

@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 
 /**
- * @Author: 黄树文
+ * @Author: zyy
  * @Date: 2020/6/1 13:37
  */
 @TableName("keyWordMessageRef")

+ 22 - 1
mpwechatApp/src/main/java/com/liangjian11/wx/mp/service/KeywordMessageRefService.java

@@ -3,9 +3,30 @@ package com.liangjian11.wx.mp.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.liangjian11.wx.mp.modle.KeywordMessageRef;
 
+import java.util.List;
+
 /**
- * @Author: 黄树文
+ * @Author: zyy
  * @Date: 2020/6/1 14:07
  */
 public interface KeywordMessageRefService extends IService<KeywordMessageRef> {
+    /**
+     * 根据规则ID查询对应发送的消息ID
+     * @param KeywordId
+     * @return
+     */
+    List<Integer> getMessageIdByKeywordId(Integer KeywordId);
+    /**
+     * 根据规则ID和对应发送的消息ID查询是否已经插入
+     * @param keyWordId
+     * @param messageId
+     * @return
+     */
+    int selectCount(int keyWordId,int messageId);
+
+    int insert(KeywordMessageRef keywordMessageRef);
+
+    int update(KeywordMessageRef keywordMessageRef);
+
+    int delete(Integer id);
 }

+ 34 - 1
mpwechatApp/src/main/java/com/liangjian11/wx/mp/service/impl/KeywordMessageRefServiceImpl.java

@@ -1,5 +1,6 @@
 package com.liangjian11.wx.mp.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.liangjian11.wx.mp.mapper.KeywordMessageRefMapper;
 import com.liangjian11.wx.mp.modle.KeywordMessageRef;
@@ -7,8 +8,11 @@ import com.liangjian11.wx.mp.service.KeywordMessageRefService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
- * @Author: 黄树文
+ * @Author: zyy
  * @Date: 2020/6/1 14:08
  */
 @Service
@@ -16,4 +20,33 @@ public class KeywordMessageRefServiceImpl extends ServiceImpl<KeywordMessageRefM
     @Autowired
     private KeywordMessageRefMapper keywordMessageRefMapper;
 
+    @Override
+    public List<Integer> getMessageIdByKeywordId(Integer KeywordId) {
+        ArrayList<Integer> msgList = new ArrayList<>();
+        List<KeywordMessageRef> list = keywordMessageRefMapper.selectList(new QueryWrapper<KeywordMessageRef>().eq("KeywordId", KeywordId));
+        for (KeywordMessageRef keywordMessageRef : list) {
+            msgList.add(keywordMessageRef.getMessageId());
+        }
+        return msgList;
+    }
+
+    @Override
+    public int selectCount(int keyWordId, int messageId) {
+        return keywordMessageRefMapper.selectCount(new QueryWrapper<KeywordMessageRef>().eq("keyWordId",keyWordId).eq("messageId",messageId));
+    }
+
+    @Override
+    public int insert(KeywordMessageRef keywordMessageRef) {
+        return keywordMessageRefMapper.insert(keywordMessageRef);
+    }
+
+    @Override
+    public int update(KeywordMessageRef keywordMessageRef) {
+        return keywordMessageRefMapper.updateById(keywordMessageRef);
+    }
+
+    @Override
+    public int delete(Integer id) {
+        return keywordMessageRefMapper.deleteById(id);
+    }
 }