添加日志

master
bynt 6 months ago
parent 1242153724
commit 23554c80f6

@ -48,65 +48,10 @@ public interface WeChatRequestConstants {
/**
* 退
*/
String WE_CHAT_LOGOUT = "/wechat/v1/batchLogout";
/**
*
*/
String WE_CHAT_SEND_TXT = "/wechat/v1/sendtext";
/**
*
*/
String WE_CHAT_SEND_PICTURE = "/wechat/v1/sendurlpic";
/**
* gif
*/
String WE_CHAT_SEND_GIF = "/wechat/v1/sendGif";
/**
*
*/
String WE_CHAT_SEND_VIDEO = "/wechat/v1/sendCdnVideoMsg";
/**
*
*/
String WE_CHAT_FRIEND_INFORMATION = "/wechat/v1/friendinfo";
/**
*
*/
String WE_CHAT_GET_CONTACT = "/wechat/v1/getAllContact";
/**
*
*/
String WE_CHAT_SYNC_CONTACT = "/wechat/v1/syncContact";
/** /**
* *
*/ */
String WE_CHAT_ADD_FRIEND = "/api/add-now-friend-phone/"; String WE_CHAT_ADD_FRIEND = "/api/add-now-friend-phone/";
/**
* 线
*/
String WE_CHAT_STATUS = "/wechat/v1/wecatstatus";
/**
*
*/
String WE_SEND_TEXT = "/wechat/v1/sendtext";
/**
*
*/
String WE_SEND_PIC = "/wechat/v1/sendurlpic";
/**
* gif
*/
String WE_SEND_GIF = "/wechat/v1/sendGif";
} }

@ -1,5 +1,7 @@
package com.baiye.modules.distribute.controller; package com.baiye.modules.distribute.controller;
import cn.hutool.http.HttpUtil;
import com.baiye.constant.WeChatRequestConstants;
import com.baiye.domain.PageParam; import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult; import com.baiye.domain.PageResult;
import com.baiye.modules.distribute.dto.CreateCodeDTO; import com.baiye.modules.distribute.dto.CreateCodeDTO;
@ -15,6 +17,7 @@ import com.baiye.modules.distribute.vo.StatisticsFriendVO;
import com.baiye.modules.distribute.vo.WeChatAccountVO; import com.baiye.modules.distribute.vo.WeChatAccountVO;
import com.baiye.result.R; import com.baiye.result.R;
import com.baiye.security.util.SecurityUtils; import com.baiye.security.util.SecurityUtils;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data; import lombok.Data;
@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Enzo * @author Enzo
@ -117,4 +121,13 @@ public class WeChatController {
} }
@GetMapping("/robot/logout")
@Operation(summary = "退出登录")
public R<Boolean> robotLogout(Integer robotId) {
return R.ok(weChatService.logoutByRobotId(robotId));
}
} }

@ -113,6 +113,19 @@ public interface WeChatService extends ExtendService<WeChatAccount> {
AccountStatisticsVO statisticsAccountByUserId(Long currentUserId); AccountStatisticsVO statisticsAccountByUserId(Long currentUserId);
/**
*
* @param wxId
* @param remark
* @return
*/
Boolean updateRemarkByWechatId(String wxId, String remark); Boolean updateRemarkByWechatId(String wxId, String remark);
/**
* 退
* @param robotId
* @return
*/
Boolean logoutByRobotId(Integer robotId);
} }

@ -45,7 +45,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -81,6 +80,7 @@ public class WeChatServiceImpl extends ExtendServiceImpl<WeChatAccountMapper, We
String getQrCodeResult = HttpUtil.get String getQrCodeResult = HttpUtil.get
(weChatProperties.getGatewayHost().concat(WeChatRequestConstants.GET_QR_CODE) (weChatProperties.getGatewayHost().concat(WeChatRequestConstants.GET_QR_CODE)
.concat(weChatProperties.getAppKey()), beanToMap); .concat(weChatProperties.getAppKey()), beanToMap);
log.info("=============== the response as {} =============", getQrCodeResult);
if (StringUtils.isNotBlank(getQrCodeResult)) { if (StringUtils.isNotBlank(getQrCodeResult)) {
WeChatResponse weChatResponse = JSONUtil.toBean(getQrCodeResult, WeChatResponse.class); WeChatResponse weChatResponse = JSONUtil.toBean(getQrCodeResult, WeChatResponse.class);
return weChatResponse.getMsg(); return weChatResponse.getMsg();
@ -114,6 +114,7 @@ public class WeChatServiceImpl extends ExtendServiceImpl<WeChatAccountMapper, We
String createEquipmentResult = HttpUtil.get String createEquipmentResult = HttpUtil.get
(weChatProperties.getGatewayHost().concat(WeChatRequestConstants.CREATE_EQUIPMENT) (weChatProperties.getGatewayHost().concat(WeChatRequestConstants.CREATE_EQUIPMENT)
.concat(weChatProperties.getAppKey()), map); .concat(weChatProperties.getAppKey()), map);
log.info("=============== the response as {} =============", createEquipmentResult);
if (StringUtils.isNotBlank(createEquipmentResult)) { if (StringUtils.isNotBlank(createEquipmentResult)) {
WeChatResponse weChatResponse = JSONUtil.toBean(createEquipmentResult, WeChatResponse.class); WeChatResponse weChatResponse = JSONUtil.toBean(createEquipmentResult, WeChatResponse.class);
if (weChatResponse.getStatus() == ResponseConstant.SUCCESS) { if (weChatResponse.getStatus() == ResponseConstant.SUCCESS) {
@ -151,6 +152,7 @@ public class WeChatServiceImpl extends ExtendServiceImpl<WeChatAccountMapper, We
String pushQrCodeResult = HttpUtil.get String pushQrCodeResult = HttpUtil.get
(weChatProperties.getGatewayHost().concat(WeChatRequestConstants.GET_PUSH_LOGIN) (weChatProperties.getGatewayHost().concat(WeChatRequestConstants.GET_PUSH_LOGIN)
.concat(weChatProperties.getAppKey()), beanToMap); .concat(weChatProperties.getAppKey()), beanToMap);
log.info("=============== the response as {} =============", pushQrCodeResult);
if (StringUtils.isNotBlank(pushQrCodeResult)) { if (StringUtils.isNotBlank(pushQrCodeResult)) {
WeChatResponse weChatResponse = JSONUtil.toBean(pushQrCodeResult, WeChatResponse.class); WeChatResponse weChatResponse = JSONUtil.toBean(pushQrCodeResult, WeChatResponse.class);
return weChatResponse.getMsg(); return weChatResponse.getMsg();
@ -285,7 +287,7 @@ public class WeChatServiceImpl extends ExtendServiceImpl<WeChatAccountMapper, We
Long friendNum = wechatFriendService.queryByUserId(currentUserId); Long friendNum = wechatFriendService.queryByUserId(currentUserId);
Integer abnormalNum = DefaultNumberConstants.ZERO_NUMBER; Integer abnormalNum = DefaultNumberConstants.ZERO_NUMBER;
Integer onlineNum = DefaultNumberConstants.ZERO_NUMBER; int onlineNum = DefaultNumberConstants.ZERO_NUMBER;
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
for (WeChatAccountVO weChatAccount : weChatAccounts) { for (WeChatAccountVO weChatAccount : weChatAccounts) {
map.put("robotId", weChatAccount.getRobotId()); map.put("robotId", weChatAccount.getRobotId());
@ -315,4 +317,22 @@ public class WeChatServiceImpl extends ExtendServiceImpl<WeChatAccountMapper, We
return this.baseMapper.updateRemark(wxId, remark); return this.baseMapper.updateRemark(wxId, remark);
} }
@Override
public Boolean logoutByRobotId(Integer robotId) {
List<Integer> arrayList = Lists.newArrayList(robotId);
Map<String, Object> map = Maps.newHashMap();
map.put("robotIds", arrayList);
String result = HttpUtil.post
(weChatProperties.getGatewayHost().concat(WeChatRequestConstants.ROBOT_LOGOUT)
.concat(weChatProperties.getAppKey()), map);
log.info("=============== the response as {} =============", result);
if (StringUtils.isNotBlank(result) && result.contains(ResponseCode.SUCCESS.getDesc())) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
} }

Loading…
Cancel
Save