提交 16ba5568 作者: zhenjie

Merge branch 'master' of ssh://git.mmcuav.cn:8222/iuav/cms

......@@ -42,9 +42,7 @@ import java.util.Arrays;
* <p>
* <code>
* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
* &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It matches");<br />
* else<br />
* &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It does not match");<br />
* </code>
* <p>
* The gensalt() method takes an optional parameter (log_rounds)
......
......@@ -3,6 +3,7 @@ package com.mmc.iuav.user.controller;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.service.WxService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -18,6 +19,7 @@ import java.io.PrintWriter;
@Api(tags = "微信相关接口")
@RequestMapping("/wx/")
@RestController
@Slf4j
public class WxController extends BaseController {
@Autowired
......@@ -61,7 +63,7 @@ public class WxController extends BaseController {
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
PrintWriter out = resp.getWriter();
System.out.println("##########接收到微信事件推送############");
log.info("##########接收到微信事件推送############");
String msg = wxService.receiveSubAccountEvents(req);
out.println(msg);
}
......
......@@ -15,6 +15,7 @@ import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.model.vo.WxMsgVO;
import com.mmc.iuav.user.service.WxService;
import com.mmc.iuav.user.util.WxApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
......@@ -32,6 +33,7 @@ import java.util.concurrent.TimeUnit;
* @Date: 2023/5/16 13:44
*/
@Service
@Slf4j
public class WxServiceImpl implements WxService {
@Autowired
private UserSystemConstant userSystemConstant;
......@@ -68,7 +70,6 @@ public class WxServiceImpl implements WxService {
String accessTokenMsg = HttpsRequestUtil.httpsGet(getAccessTokenUrl, null);
JSONObject tokenResult = JSONObject.parseObject(accessTokenMsg);
if (accessTokenMsg.indexOf("access_token") == -1) {
System.out.println("获取小程序access_token有误:" + tokenResult);
return null;
}
accessToken = tokenResult.getString("access_token");
......@@ -90,7 +91,7 @@ public class WxServiceImpl implements WxService {
String accessTokenMsg = HttpsRequestUtil.httpsGet(getAccessTokenUrl, null);
JSONObject tokenResult = JSONObject.parseObject(accessTokenMsg);
if (accessTokenMsg.indexOf("access_token") == -1) {
System.out.println("获取公众号access_token有误:" + tokenResult);
log.info("获取公众号access_token有误:{}",tokenResult);
return null;
}
accessToken = tokenResult.getString("access_token");
......@@ -112,14 +113,10 @@ public class WxServiceImpl implements WxService {
this.subScribeUser(map);
} else if (WxConstant.unsubscribe.equals(event)) {
// 取消关注事件
System.out.println("############################");
System.out.println("###########取消关注############");
System.out.println("############################");
String openId = map.get("FromUserName");
userSubInfoDao.removeUserSubInfo(openId);
}
} catch (Exception e) {
System.out.println("接收消息异常" + e.getMessage());
return "error";
}
return "success";
......@@ -167,10 +164,6 @@ public class WxServiceImpl implements WxService {
// 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。
Integer subscribe = obj.getInteger("subscribe");
if (subscribe != null && subscribe == 1) {
System.out.println("###########access_token##########");
System.out.println(accessToken);
System.out.println("###########用户信息##########");
System.out.println(jsonStr);
UserSubInfoDO user = new UserSubInfoDO();
user.setOpenId(openid);
user.setUnionId(obj.getString("unionid"));
......@@ -179,7 +172,7 @@ public class WxServiceImpl implements WxService {
userSubInfoDao.updateUserSubInfo(user);
return;
} else {
System.out.println("未订阅公众号,无法拉取信息。");
log.info("未订阅公众号,无法拉取信息。");
return;
}
}catch (Exception e){
......@@ -190,19 +183,14 @@ public class WxServiceImpl implements WxService {
@Override
public ResultBody sendSubTemplateMsg(WxMsgVO ws) {
System.out.println("###########开始发送公众号消息##########");
String accessToken = null;
try {
accessToken = this.getSubAccessToken();
System.out.println("accesstoken:" + accessToken);
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
String param = ws.buildMsgJson();
System.out.println("参数:" + param);
String result = HttpHelper.httpPost(url, param);
System.out.println("###########结束发送公众号消息##########");
System.out.println(result);
} catch (Exception e) {
System.out.println("accessToken获取失败:" + e.getMessage());
log.error("accessToken获取失败:{}", e.getMessage());
return ResultBody.error(ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultCode(),
ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultMsg() + e.getMessage());
}
......@@ -231,7 +219,6 @@ public class WxServiceImpl implements WxService {
@Override
public ResultBody sendAppletMsg(AppletMsgVO appletMsgVO) {
System.out.println("###########开始发送-小程序-用户端消息##########");
String accessToken = this.getAccessToken();
if (StringUtils.isBlank(accessToken)){
return ResultBody.error(ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultCode(),
......@@ -241,12 +228,10 @@ public class WxServiceImpl implements WxService {
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
appletMsgVO.setData(WxApiUtil.buildMsgJson(appletMsgVO.getData()));
String param = JSONObject.toJSONString(appletMsgVO);
System.out.println("参数:" + param);
HttpHelper.httpPost(url, param);
} catch (Exception e){
System.out.println("系统异常:" + e.getMessage());
log.error("系统异常:{}" ,e.getMessage());
}
System.out.println("###########结束发送-小程序-消息##########");
return ResultBody.success();
}
......@@ -280,7 +265,6 @@ public class WxServiceImpl implements WxService {
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
String res = HttpHelper.httpPost(url, param.toString());
JSONObject result = JSONObject.parseObject(res);
System.out.println("用户授权手机号:" + res);
if (result.getString("errcode").equals("0")) {
String phone_info = result.getString("phone_info");
JSONObject phoneInfoObject = JSONObject.parseObject(phone_info);
......
......@@ -173,7 +173,6 @@ public class QccEntAuthUtil {
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.readValue(jsonString, Object.class);
String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
System.out.println(indented);
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
......
......@@ -5,3 +5,5 @@ metadata:
namespace: default
data:
SPRING_PROFILES_ACTIVE: default
SW_AGENT_COLLECTOR_BACKEND_SERVICES: "default-oap.skywalking-swck-system:11800"
SW_AGENT_NAME: cms
\ No newline at end of file
......@@ -14,6 +14,7 @@ spec:
metadata:
labels:
app: cms
swck-java-agent-injected: 'true'
spec:
containers:
- name: cms
......@@ -21,6 +22,9 @@ spec:
volumeMounts:
- name: log-of-app
mountPath: /var/log/app
- name: localtime
mountPath: /etc/localtime
readOnly: true
resources:
limits:
memory: 1024Mi
......@@ -33,7 +37,20 @@ spec:
configMapKeyRef:
name: cms-map
key: SPRING_PROFILES_ACTIVE
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
valueFrom:
configMapKeyRef:
name: cms-map
key: SW_AGENT_COLLECTOR_BACKEND_SERVICES
- name: SW_AGENT_NAME
valueFrom:
configMapKeyRef:
name: cms-map
key: SW_AGENT_NAME
volumes:
- name: log-of-app
hostPath:
path: /var/log/app
- name: localtime
hostPath:
path: /etc/localtime
\ No newline at end of file
......@@ -18,4 +18,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: 1892dbcdb20f1882a6eda0f2d3f299d03df97df9
newTag: 1aa583dee5935e765f3334169caca635c6f907b7
......@@ -18,4 +18,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly/cms
newTag: a66259b9b10f0a79a0dbee5a83e733d47cb89011
newTag: d38385144aaeecfff8c147e07aac460ea1f01b43
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论