Browse Source

v0817

master
zy_Java 5 years ago
parent
commit
b371712c2e
  1. 2
      mt/src/main/java/com/ccsens/mt/service/TopicService.java
  2. 4
      mt/src/main/resources/mapper_dao/TopicDao.xml
  3. 9
      tall/src/main/java/com/ccsens/tall/service/UserService.java
  4. 19
      util/src/main/java/com/ccsens/util/wx/WxGzhUtil.java

2
mt/src/main/java/com/ccsens/mt/service/TopicService.java

@ -69,6 +69,8 @@ public class TopicService implements ITopicService{
@Override
public List<TopicVo.GroupInfo> queryGroupByProject(TopicDto.GetGroup getGroup) {
log.info("查询分组:{}",getGroup.toString());
List<TopicVo.GroupInfo> groupInfoList = topicDao.queryGroupByProject(getGroup.getProjectId(),getGroup.getLinkType(),getGroup.getType());
// redisUtil.set()
return topicDao.queryGroupByProject(getGroup.getProjectId(),getGroup.getLinkType(),getGroup.getType());
}

4
mt/src/main/resources/mapper_dao/TopicDao.xml

@ -114,13 +114,13 @@
FROM
t_mt_group
WHERE
rec_status = 0
and
project_id = #{projectId}
and
advance_status = #{linkType}
and
`type` = #{type}
and
rec_status = 0
</select>
<select id="queryRanking" parameterType="java.util.Map" resultType="com.ccsens.mt.bean.vo.TopicVo$QueryRanking">

9
tall/src/main/java/com/ccsens/tall/service/UserService.java

@ -137,6 +137,9 @@ public class UserService implements IUserService {
private UserVo.UserSign wxH5Login(WebConstant.IDENTIFY_TYPE identifyType, String code) {
UserVo.UserSign userSignVo;
//获取微信信息
// WxGzhUtil wxGzhUtil = new WxGzhUtil();
// WxOauth2UserInfo wxOauth2UserInfo = wxGzhUtil.getOauth2UserInfo(identifyType, code);
WxOauth2UserInfo wxOauth2UserInfo = WxGzhUtil.getOauth2UserInfo(identifyType, code);
SysAuth theAuth;
@ -230,7 +233,10 @@ public class UserService implements IUserService {
UserVo.UserSign userSignVo;
//获取微信信息并保存
log.info("公众号登陆,{}", code);
// WxGzhUtil wxGzhUtil = new WxGzhUtil();
// WxOauth2UserInfo wxOauth2UserInfo = wxGzhUtil.getOauth2UserInfo(identifyType, code);
WxOauth2UserInfo wxOauth2UserInfo = WxGzhUtil.getOauth2UserInfo(identifyType, code);
log.info("获取用户的微信信息,{}", wxOauth2UserInfo);
SysAuth theAuth;
if (ObjectUtil.isNotNull(wxOauth2UserInfo)) {
@ -240,6 +246,7 @@ public class UserService implements IUserService {
List<SysAuth> authList = authDao.selectByExample(authExample);
if (CollectionUtil.isNotEmpty(authList)) {
theAuth = authList.get(0);
log.info("该用户已有公众号登录的auth信息,{}", theAuth);
} else {
SysAuthExample sysAuthExample = new SysAuthExample();
sysAuthExample.createCriteria().andCredentialEqualTo(wxOauth2UserInfo.getUnionId());
@ -284,6 +291,7 @@ public class UserService implements IUserService {
accountAuth.setSalt(ShiroKit.getRandomSalt(6));
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
authDao.insertSelective(accountAuth);
log.info("新建用户:{},新建auth:{}", user,theAuth);
}
}
} else {
@ -294,6 +302,7 @@ public class UserService implements IUserService {
userSignVo = new UserVo.UserSign();
userSignVo.setUserId(theAuth.getUserId());
userSignVo.setAuthId(theAuth.getId());
log.info("认证成功返回:{}", userSignVo);
return userSignVo;
}

19
util/src/main/java/com/ccsens/util/wx/WxGzhUtil.java

@ -1,10 +1,8 @@
package com.ccsens.util.wx;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.util.DateUtil;
@ -16,7 +14,7 @@ import com.ccsens.util.exception.BaseException;
import com.ccsens.util.exception.BusinessException;
import com.ccsens.util.exception.WxException;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@ -31,6 +29,7 @@ import java.util.Map;
/**
* @author __zHangSan
*/
@Slf4j
@Component
public class WxGzhUtil {
@ -201,7 +200,7 @@ public class WxGzhUtil {
String[] tmpArr = { TOKEN, timestamp, nonce };
Arrays.sort(tmpArr);
String sign = sha1Encode( arrayToString(tmpArr));
Console.log("sign:{} , signature: {}",sign,signature);
log.info("sign:{} , signature: {}",sign,signature);
if (sign.equalsIgnoreCase(signature)) {
return true;
}
@ -217,7 +216,7 @@ public class WxGzhUtil {
WxAccessToken wxAccessToken = null;
String url = String.format(URL_GET_ACCESS_TOKEN,"client_credential",appid_health,secret_health);
String response = HttpRequest.get(url).execute().body();
Console.log("getAccessToken: {}",response);
log.info("getAccessToken: {}",response);
try {
if(StrUtil.isEmpty(response) || null == (wxAccessToken = JacksonUtil.jsonToBean(response, WxAccessToken.class))) {
throw new BusinessException(-1,"the response of HttpRequest is empty.");
@ -246,7 +245,7 @@ public class WxGzhUtil {
public static String queryMenu() throws BaseException {
String url = String.format(URL_QUERY_MENU,getAccessToken());
String menuString = HttpRequest.get(url).execute().body();
Console.log("url:{}, menuString: {}",url,menuString);
log.info("url:{}, menuString: {}",url,menuString);
return menuString;
}
@ -258,7 +257,7 @@ public class WxGzhUtil {
String menuString = null;
try {
menuString = JacksonUtil.beanToJson(gzhMenu);
Console.log(menuString);
log.info(menuString);
} catch (JsonProcessingException e) {
e.printStackTrace();
throw new BusinessException(-1,e.getMessage());
@ -293,7 +292,7 @@ public class WxGzhUtil {
WxOauth2AccessToken wxOauth2AccessToken = null;
String url = String.format(URL_GET_OAUTH2_ACCESS_TOKEN,appId(identifyType),secret(identifyType),code);
String response = HttpRequest.get(url).execute().body();
Console.log("url: {}\nresponse: {}",url,response);
log.info("url: {}\nresponse: {}",url,response);
try {
if(StrUtil.isEmpty(response) || null == (wxOauth2AccessToken = JacksonUtil.jsonToBean(response,WxOauth2AccessToken.class))) {
throw new BusinessException(-1,"the response of HttpRequest is empty.");
@ -323,7 +322,7 @@ public class WxGzhUtil {
WxOauth2UserInfo wxOauth2UserInfo = null;
String url = String.format(URL_GET_OAUTH2_USERINFO,accessToken,openId);
String response = HttpRequest.get(url).execute().body();
Console.log("url: {}\nresponse: {}",url,response);
log.info("url: {}\nresponse: {}",url,response);
try {
if(StrUtil.isEmpty(response) || null == (wxOauth2UserInfo = JacksonUtil.jsonToBean(response,WxOauth2UserInfo.class))) {
throw new BusinessException(-1,"the response of HttpRequest is empty.");
@ -363,7 +362,7 @@ public class WxGzhUtil {
* @param response
*/
public static void pageResponseSuccess(String response) {
Console.log("返回结果:{}", response);
log.info("返回结果:{}", response);
JSONObject result;
try {
if(StrUtil.isEmpty(response) || null == (result = JSONObject.parseObject(response))) {

Loading…
Cancel
Save