1.登录监听
This commit is contained in:
parent
66f24a575e
commit
7b28553a4e
6
pom.xml
6
pom.xml
@ -76,6 +76,12 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>basic-interface</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>login-wechat</artifactId>
|
||||
|
@ -0,0 +1,40 @@
|
||||
package cn.com.tenlion.xzszwhy.base.listener.login;
|
||||
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.expand.login.ILoginAppHandlerService;
|
||||
import ink.wgink.pojo.bos.LoginAppUser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* app登录监听
|
||||
* @author : LY
|
||||
* @date :2023-3-15 15:40
|
||||
* @description :
|
||||
* @modyified By:
|
||||
*/
|
||||
@Service
|
||||
public class AppLoginListener implements ILoginAppHandlerService {
|
||||
/** 系统用户 */
|
||||
private static final String sys_user_type = "1";
|
||||
/** app标识 */
|
||||
private static final String app_type_oa = "oa";
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Override
|
||||
public void handle(LoginAppUser loginAppUser) throws Exception {
|
||||
String appType = httpServletRequest.getHeader("APP-TYPE");
|
||||
if(app_type_oa.equals(appType)){
|
||||
if(!sys_user_type.equals(String.valueOf(loginAppUser.getUserType()))){
|
||||
throw new SearchException("暂无权限登录");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.com.tenlion.xzszwhy.base.listener.login;
|
||||
|
||||
import ink.wgink.common.component.SecurityComponent;
|
||||
import ink.wgink.interfaces.expand.login.ILoginHandlerService;
|
||||
import ink.wgink.pojo.bos.LoginUser;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* web登录监听
|
||||
* @author : LY
|
||||
* @date :2023-3-13 17:53
|
||||
* @description :
|
||||
* @modyified By:
|
||||
*/
|
||||
@Service
|
||||
public class WebLoginListener implements ILoginHandlerService {
|
||||
|
||||
// 登录接口
|
||||
private static final String web_url = "http://www.xzszwhy.cn/module/app/contentcensusrelease/log?requestUrl=网页USER";
|
||||
|
||||
@Override
|
||||
public void handle(LoginUser loginUser) throws Exception {
|
||||
// 请求登录统计接口
|
||||
String url = web_url + loginUser.getUserId();
|
||||
CloseableHttpClient client = HttpClientBuilder.create().build();
|
||||
HttpGet get = new HttpGet(url);
|
||||
try {
|
||||
HttpResponse response = client.execute(get);
|
||||
String res = EntityUtils.toString(response.getEntity());
|
||||
System.out.println("==================请求登录接口==================" + res);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user