|
@@ -1,5 +1,6 @@
|
|
|
package com.usky.dxtop.controller.web;
|
|
|
|
|
|
+import com.usky.dxtop.common.core.domain.AjaxResult;
|
|
|
import com.usky.dxtop.service.api.TopApiConfiger;
|
|
|
import com.usky.dxtop.service.api.WxApi;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -8,8 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.util.TreeMap;
|
|
|
-
|
|
|
/**
|
|
|
* @author yq
|
|
|
* @date 2021/9/22 10:04
|
|
@@ -24,12 +23,8 @@ public class WxController {
|
|
|
@Autowired
|
|
|
private WxApi wxApi;
|
|
|
@GetMapping("/wxLogin")
|
|
|
- public String wxLogin(@RequestParam String jsCode,@RequestParam Integer type){
|
|
|
- if (1 == type){
|
|
|
- return wxApi.wxLogin(topApiConfiger.getWxAppId(),topApiConfiger.getWxAppSecret(),jsCode);
|
|
|
- }else {
|
|
|
- return wxApi.wxLogin(WxApi.APP_ID,WxApi.SECRET,jsCode);
|
|
|
- }
|
|
|
+ public String wxLogin(@RequestParam String jsCode){
|
|
|
+ return wxApi.wxLogin(topApiConfiger.getWxAppId(),topApiConfiger.getWxAppSecret(),jsCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -38,8 +33,8 @@ public class WxController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/wxAccToken")
|
|
|
- public TreeMap<String, String> getAccToken(@RequestParam String url){
|
|
|
- return wxApi.getPayParam(topApiConfiger.getWxAppId(),topApiConfiger.getWxAppSecret(),url);
|
|
|
+ public AjaxResult getAccToken(@RequestParam String url){
|
|
|
+ return AjaxResult.success(wxApi.getPayParam(topApiConfiger.getWxAppId(), topApiConfiger.getWxAppSecret(), url));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -47,12 +42,14 @@ public class WxController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/accentToken")
|
|
|
- public String getToken(@RequestParam Integer type){
|
|
|
+ public AjaxResult getToken(@RequestParam Integer type){
|
|
|
+ String token;
|
|
|
if (1 == type){
|
|
|
- return wxApi.getToken(topApiConfiger.getWxAppId(),topApiConfiger.getWxAppSecret());
|
|
|
+ token = wxApi.getToken(topApiConfiger.getWxAppId(),topApiConfiger.getWxAppSecret());
|
|
|
}else {
|
|
|
- return wxApi.getToken(WxApi.APP_ID,WxApi.SECRET);
|
|
|
+ token = wxApi.getToken(WxApi.APP_ID,WxApi.SECRET);
|
|
|
}
|
|
|
+ return AjaxResult.success(token);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -64,10 +61,20 @@ public class WxController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/offSendMessage")
|
|
|
- public String offSendMessageT(@RequestParam String openId,
|
|
|
+ public AjaxResult offSendMessageT(@RequestParam String openId,
|
|
|
@RequestParam Object data,
|
|
|
@RequestParam String templateId,
|
|
|
@RequestParam(required = false) String detailUrl){
|
|
|
- return wxApi.sendMessageApi(openId,data,wxApi.getToken(WxApi.APP_ID,WxApi.SECRET),templateId,detailUrl);
|
|
|
+ return AjaxResult.success(wxApi.sendMessageApi(openId, data, wxApi.getToken(WxApi.APP_ID, WxApi.SECRET), templateId, detailUrl));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公众号获取openid
|
|
|
+ * @param code
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/offOpenId")
|
|
|
+ public AjaxResult getOpenId(@RequestParam String code){
|
|
|
+ return AjaxResult.success(wxApi.getOpenId(WxApi.APP_ID, WxApi.SECRET, code));
|
|
|
}
|
|
|
}
|