Browse Source

修改接口

DESKTOP-USV654P\pc 1 year ago
parent
commit
2deb2936a4

+ 28 - 0
src/main/java/com/xjrsoft/common/utils/WeChatUtil.java

@@ -113,4 +113,32 @@ public class WeChatUtil {
         System.out.printf(result);
         return true;
     }
+
+    //{
+    //           "touser":"OPENID",
+    //           "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
+    //           "url":"http://weixin.qq.com/download",
+    //           "miniprogram":{
+    //             "appid":"xiaochengxuappid12345",
+    //             "pagepath":"index?foo=bar"
+    //           },
+    //           "client_msg_id":"MSG_000001",
+    //           "data":{
+    //                   "keyword1":{
+    //                       "value":"巧克力"
+    //                   },
+    //                   "keyword2": {
+    //                       "value":"39.8元"
+    //                   },
+    //                   "keyword3": {
+    //                       "value":"2014年9月22日"
+    //                   }
+    //           }
+    //       }
+    public Boolean sendTemplateMessage(JSONObject object){
+        String token = this.getToken(2);
+        String result = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token, JSONObject.toJSONString(object));
+        System.out.printf(result);
+        return true;
+    }
 }

+ 1 - 1
src/main/java/com/xjrsoft/module/oa/controller/NewsController.java

@@ -133,7 +133,7 @@ public class NewsController {
                 new MPJLambdaWrapper<NewsAppendix>().eq(NewsAppendix::getNewsId, id)
                         .select(NewsRelation::getId)
                         .select(NewsAppendix.class, x -> VoToColumnUtil.fieldsToColumns(NewsAppendixVo.class).contains(x.getProperty()))
-                        .leftJoin(File.class, File::getId, NewsAppendix::getFileId, ext -> ext.selectAs(File::getFileName, NewsAppendixVo::getFileName))
+                        .leftJoin(File.class, File::getId, NewsAppendix::getFileId, ext -> ext.selectAs(File::getFileName, NewsAppendixVo::getFileName).selectAs(File::getFolderId,NewsAppendixVo::getFolderId))
         );
 
         if (newsAppendixVoList.size() > 0) {

+ 3 - 0
src/main/java/com/xjrsoft/module/oa/vo/NewsAppendixVo.java

@@ -17,4 +17,7 @@ public class NewsAppendixVo {
 
     @ApiModelProperty("文件名称")
     private String fileName;
+
+    @ApiModelProperty("附件夹主键")
+    private Long folderId;
 }

+ 30 - 1
src/main/java/com/xjrsoft/module/organization/controller/WechatController.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.organization.controller;
 
 
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.xjrsoft.common.constant.GlobalConstant;
@@ -10,6 +11,7 @@ import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.common.utils.WeChatUtil;
 import com.xjrsoft.module.organization.dto.WeChatDepartPageDto;
 import com.xjrsoft.module.organization.dto.WeChatPageDto;
 import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
@@ -44,6 +46,8 @@ public class WechatController {
 
     private final RedisUtil redisUtil;
 
+    private final WeChatUtil weChatUtil;
+
     @PutMapping("/sync-user")
     @ApiOperation(value="微信信息更新")
     public R updateInfo(){
@@ -75,7 +79,32 @@ public class WechatController {
     @ApiOperation(value="微信公众号发送消息")
     public R sendMessage(WeChatSendMessageDto dto){
 
-        WeChatService.sendMessage(dto);
+        JSONObject object = new JSONObject();
+        object.put("touser","o8d_c6c-0yamdT-sEvX1Umgof1fE");
+        object.put("template_id","sHsmz7LRj7HLd7GSTS3r2uKMhE2f1iDAW15RqSK_6KM");
+        object.put("url","");
+        object.put("client_msg_id","MSG_000001");
+
+        JSONObject data=new JSONObject();
+
+        JSONObject data1=new JSONObject();
+        data1.put("value","关于某某事项的审批");
+        data.put("thing2",data1);
+
+        JSONObject data2=new JSONObject();
+        data2.put("value","张三");
+        data.put("phrase5",data2);
+
+        JSONObject data3=new JSONObject();
+        data3.put("value","2022-02-22 11:24:00");
+        data.put("time3",data3);
+
+        object.put("data",data);
+
+        weChatUtil.sendTemplateMessage(object);
+
+
+
         return R.ok();
     }