自定义菜单处理
This commit is contained in:
parent
fe3a18ca36
commit
fd673ed1e6
@ -42,6 +42,6 @@ public class WeChatBeans {
|
||||
return service;
|
||||
}
|
||||
|
||||
// public WxMpInMemoryConfigStorage
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ public class WeXinConfigure {
|
||||
|
||||
private String aesKey;
|
||||
|
||||
private String menuFilePath;
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
@ -53,4 +55,13 @@ public class WeXinConfigure {
|
||||
public void setAesKey(String aesKey) {
|
||||
this.aesKey = aesKey;
|
||||
}
|
||||
|
||||
public String getMenuFilePath() {
|
||||
return menuFilePath;
|
||||
}
|
||||
|
||||
@Value("${menu.file_path}")
|
||||
public void setMenuFilePath(String menuFilePath) {
|
||||
this.menuFilePath = menuFilePath;
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,6 @@ public class WeXinController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,11 @@ package com.zeekling.solo.wechat.service;
|
||||
/**
|
||||
* @author zeekling [lingzhaohui@zeekling.cn]
|
||||
* @version 1.0
|
||||
* @apiNote
|
||||
* @apiNote 微信菜单相关处理
|
||||
* @since 2020-03-18
|
||||
*/
|
||||
public interface WeChatService {
|
||||
public interface WeChatMenuService {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.zeekling.solo.wechat.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author zeekling [lingzhaohui@zeekling.cn]
|
||||
* @version 1.0
|
||||
* @apiNote
|
||||
* @since 2020-03-21
|
||||
*/
|
||||
@Service
|
||||
public class WeChatMenuServiceImpl implements WeChatMenuService {
|
||||
|
||||
|
||||
}
|
@ -1,10 +1,63 @@
|
||||
package com.zeekling.solo.wechat.util;
|
||||
|
||||
import org.apache.commons.lang3.text.StrBuilder;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author zeekling [lingzhaohui@zeekling.cn]
|
||||
* @version 1.0
|
||||
* @apiNote
|
||||
* @apiNote 主要用来操作文件相关
|
||||
* @since 2020-03-21
|
||||
*/
|
||||
public class FileUtils {
|
||||
public final class FileUtils {
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FileUtils.class);
|
||||
|
||||
private FileUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件
|
||||
*
|
||||
* @param filePath 文件地址
|
||||
* @return 文件内容
|
||||
*/
|
||||
public String readFile(String filePath) {
|
||||
StrBuilder sb = new StrBuilder();
|
||||
byte[] buffer = new byte[1024];
|
||||
try {
|
||||
FileInputStream inputStream = new FileInputStream(filePath);
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
int idx = -1;
|
||||
while ((idx = bufferedInputStream.read(buffer)) != -1) {
|
||||
sb.append(new String(buffer, 0, idx));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.warn("file read error,fileName:{}, error:{}", filePath, e);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件,并且将文件转换成json对象
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
* @return 转换后的json对象
|
||||
*/
|
||||
public JSONObject readJsonFile(String filePath) {
|
||||
String str = readFile(filePath);
|
||||
|
||||
try {
|
||||
return new JSONObject(str);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("str to json error,str:{}, error:{}", str, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,4 +5,6 @@ logging.file=/home/zeek/project/solo-weixin/logs/weixin.log
|
||||
wx.mp.appId=wxa1de154d148ffc9e
|
||||
wx.mp.secret=3b988f265ea9d5056657b5f5fc3ad566
|
||||
wx.mp.token=zeekling
|
||||
wx.mp.aesKey=MhHpsysI44QIZkEPTiIvTf96XbEJY3QAGUHyxF1Vp9W
|
||||
wx.mp.aesKey=MhHpsysI44QIZkEPTiIvTf96XbEJY3QAGUHyxF1Vp9W
|
||||
|
||||
menu.file_path = /home/zeek/project/solo-weixin/src/main/resources/menu.json
|
Loading…
Reference in New Issue
Block a user