|
@ -6,6 +6,7 @@ import com.alibaba.nacos.client.config.utils.IOUtils; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
import com.epmet.constant.ModuleConstant; |
|
|
import com.epmet.constant.ModuleConstant; |
|
|
import com.epmet.constant.ThirdRedisKeyConstant; |
|
|
import com.epmet.constant.ThirdRedisKeyConstant; |
|
@ -31,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.lang.reflect.Field; |
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; |
|
|
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; |
|
@ -175,7 +175,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
public void disposeAuthResult(Map<String,String> result){ |
|
|
public void disposeAuthResult(Map<String,String> result){ |
|
|
Map tempMap = result; |
|
|
Map tempMap = result; |
|
|
Map<String,Object> data = tempMap; |
|
|
Map<String,Object> data = tempMap; |
|
|
AuthResultRecordFormDTO authResultRecord = mapToEntity(data, AuthResultRecordFormDTO.class); |
|
|
AuthResultRecordFormDTO authResultRecord = ConvertUtils.mapToEntity(data, AuthResultRecordFormDTO.class); |
|
|
authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); |
|
|
authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); |
|
|
if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { |
|
|
if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { |
|
|
authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME))); |
|
|
authResultRecord.setExpiredTime(this.sToDate(result.get(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME))); |
|
@ -285,7 +285,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); |
|
|
HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class); |
|
|
HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class); |
|
|
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); |
|
|
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); |
|
|
authorizationInfoResultDTO = mapToEntity(map, AuthorizationInfoResultDTO.class); |
|
|
authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class); |
|
|
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); |
|
|
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); |
|
|
log.info("授权信息:"+map); |
|
|
log.info("授权信息:"+map); |
|
|
String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); |
|
|
String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); |
|
@ -433,7 +433,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); |
|
|
boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); |
|
|
if (keyExist == true){ |
|
|
if (keyExist == true){ |
|
|
log.info("授权方为小程序 并 开始插入信息"); |
|
|
log.info("授权方为小程序 并 开始插入信息"); |
|
|
MiniInfoFormDTO miniInfoFormDTO = this.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); |
|
|
MiniInfoFormDTO miniInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); |
|
|
miniInfoFormDTO.setCustomerId(customerId); |
|
|
miniInfoFormDTO.setCustomerId(customerId); |
|
|
miniInfoFormDTO.setClientType(clientType); |
|
|
miniInfoFormDTO.setClientType(clientType); |
|
|
//基础信息插入
|
|
|
//基础信息插入
|
|
@ -485,7 +485,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
} |
|
|
} |
|
|
}else { |
|
|
}else { |
|
|
log.info("授权方为公众号 并 开始插入信息"); |
|
|
log.info("授权方为公众号 并 开始插入信息"); |
|
|
PaInfoFormDTO paInfoFormDTO = this.mapToEntity(authorizerInfo, PaInfoFormDTO.class); |
|
|
PaInfoFormDTO paInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, PaInfoFormDTO.class); |
|
|
//公众号基本信息插入
|
|
|
//公众号基本信息插入
|
|
|
paInfoDao.insertPaInfo(paInfoFormDTO); |
|
|
paInfoDao.insertPaInfo(paInfoFormDTO); |
|
|
String primaryId = paInfoFormDTO.getId(); |
|
|
String primaryId = paInfoFormDTO.getId(); |
|
@ -611,36 +611,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description map 转 Entity |
|
|
|
|
|
* @param map |
|
|
|
|
|
* @param entity |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
*/ |
|
|
|
|
|
public <T> T mapToEntity(Map<String, Object> map, Class<T> entity) { |
|
|
|
|
|
T t = null; |
|
|
|
|
|
try { |
|
|
|
|
|
t = entity.newInstance(); |
|
|
|
|
|
for(Field field : entity.getDeclaredFields()) { |
|
|
|
|
|
if (map.containsKey(field.getName())) { |
|
|
|
|
|
boolean flag = field.isAccessible(); |
|
|
|
|
|
field.setAccessible(true); |
|
|
|
|
|
Object object = map.get(field.getName()); |
|
|
|
|
|
if (object!= null && field.getType().isAssignableFrom(object.getClass())) { |
|
|
|
|
|
field.set(t, object); |
|
|
|
|
|
} |
|
|
|
|
|
field.setAccessible(flag); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return t; |
|
|
|
|
|
} catch (InstantiationException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
return t; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 转换过期时间 |
|
|
* @Description 转换过期时间 |
|
|
* @param expiresIn |
|
|
* @param expiresIn |
|
|