Commit 2c87140f by 徐高华

企微托管账号

parent 13910bf4
......@@ -47,6 +47,14 @@ public interface OpenStaffApiService {
public ServiceResponse<Void> logout(String uuid) ;
/**
* 校验验证码
* @param openStaffId
* @param validCode
* @return
*/
public ServiceResponse<Void> checkCode(Long openStaffId, String validCode) ;
/**
*
* @param uuid
* @param loginStatus
......
......@@ -65,7 +65,7 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
}
String wxEnterpriseId = openStaff.getWxEnterpriseId() ;
List<String> backWxEnterpriseIdList = this.wxEnterpriseService.getWxEnterpriseIdByName(corpName) ;
if(CollectionUtils.isNotEmpty(backWxEnterpriseIdList) || backWxEnterpriseIdList.size()>1 || !backWxEnterpriseIdList.get(0).equals(wxEnterpriseId)) {
if(CollectionUtils.isEmpty(backWxEnterpriseIdList) || backWxEnterpriseIdList.size()>1 || !backWxEnterpriseIdList.get(0).equals(wxEnterpriseId)) {
OpenUtils.logout(uuid);
log.info("登录的企业不对={},{}",uuid,corpName);
return ServiceResponse.failure("9999","登录错误") ;
......@@ -87,6 +87,15 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
}
@Override
public ServiceResponse<Void> checkCode(Long openStaffId, String validCode) {
TabOpenStaff tab = this.openStaffMapper.getById(openStaffId) ;
if(null == tab) {
return ServiceResponse.failure("9999","记录不存在") ;
}
return OpenUtils.checkCode(tab.getUuid(),tab.getKey1(),validCode) ;
}
@Override
public ServiceResponse<OpenStaffDTO> getById(Long openStaffId) {
TabOpenStaff openStaff = this.openStaffMapper.getById(openStaffId) ;
if(null == openStaff) {
......
......@@ -43,19 +43,33 @@ public class OpenUtils {
return ServiceResponse.success(initBO) ;
}
public static ServiceResponse<Void> checkCode(String uuid , String qrcodeKey ,String validCode) {
JSONObject json = new JSONObject() ;
json.put("uuid",uuid) ;
json.put("qrcodeKey",qrcodeKey) ;
json.put("code",validCode) ;
String backJson = HttpClient.sendPostJSON(String.format(openHost,"CheckCode"),json.toJSONString(),"utf-8") ;
logger.info("校验验证码={},uuid={}",backJson,uuid);
QwOpenResultBO bo = result(backJson) ;
if(!bo.isOk()) {
return ServiceResponse.failure("9999",bo.getErrmsg()) ;
}
return ServiceResponse.success() ;
}
public static void logout(String uuid) {
JSONObject json = new JSONObject() ;
json.put("uuid",uuid) ;
String callbackJson = HttpClient.sendPostJSON(String.format(openHost,"LoginOut"),json.toJSONString(),"utf-8") ;
logger.info("退出={},uuid={}",callbackJson,uuid);
String backJson = HttpClient.sendPostJSON(String.format(openHost,"LoginOut"),json.toJSONString(),"utf-8") ;
logger.info("退出={},uuid={}",backJson,uuid);
}
private static void setCallback(String uuid) {
JSONObject json = new JSONObject() ;
json.put("uuid",uuid) ;
json.put("url",gicCallbackHost) ;
String callbackJson = HttpClient.sendPostJSON(String.format(openHost,"SetCallbackUrl"),json.toJSONString(),"utf-8") ;
logger.info("设置回调={},uuid={}",callbackJson,uuid);
String backJson = HttpClient.sendPostJSON(String.format(openHost,"SetCallbackUrl"),json.toJSONString(),"utf-8") ;
logger.info("设置回调={},uuid={}",backJson,uuid);
}
private static ServiceResponse<QwOpenResultInitBO> getQrcode(String uuid , QwOpenResultInitBO initBO) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment