|
@ -0,0 +1,111 @@
|
|
1
|
package com.ai.ipu.show.bean;
|
|
2
|
|
|
3
|
|
|
4
|
import com.ai.ipu.basic.net.http.HttpTool;
|
|
5
|
import com.ai.ipu.show.core.bean.IpuAppBean;
|
|
6
|
import com.ai.ipu.show.core.context.IpuContextData;
|
|
7
|
import com.ai.ipu.show.core.session.IpuSessionManager;
|
|
8
|
import com.ai.ipu.show.util.Constant;
|
|
9
|
import com.ailk.common.data.IData;
|
|
10
|
import com.ailk.common.data.impl.DataMap;
|
|
11
|
//import org.slf4j.Logger;
|
|
12
|
//import org.slf4j.LoggerFactory;
|
|
13
|
|
|
14
|
public class VideoLoginBean extends IpuAppBean {
|
|
15
|
// private static final Logger logger= LoggerFactory.getLogger(LoginBean.class);
|
|
16
|
/**
|
|
17
|
* 邮箱后缀列表
|
|
18
|
*/
|
|
19
|
private static final String[] MAIL_SUFFIX_ARR = {"@asiainfo.com",
|
|
20
|
"@asiainfo-sec.com"};
|
|
21
|
|
|
22
|
public static final String srtUlr="http://47.104.28.129:9000/api/v1/oauth-clients/local";
|
|
23
|
|
|
24
|
public static final String tokenUlr="http://47.104.28.129:9000/api/v1/users/token";
|
|
25
|
|
|
26
|
public static final String baseUlr="http://47.104.28.129:9000";
|
|
27
|
|
|
28
|
public static final String user="Tony";
|
|
29
|
|
|
30
|
public static final String pwd="123456";
|
|
31
|
|
|
32
|
public IData shortVideoToken(IData params) throws Exception {
|
|
33
|
String srtresponse = HttpTool.httpRequest(srtUlr, null, "GET");
|
|
34
|
IData data = new DataMap(srtresponse);
|
|
35
|
String clientId = data.getString("client_id");
|
|
36
|
String clientSecret = data.getString("client_secret");
|
|
37
|
StringBuilder sb = new StringBuilder();
|
|
38
|
sb.append("client_id=").append(HttpTool.postDataEncode(clientId)).append("&")
|
|
39
|
.append("client_secret=").append(HttpTool.postDataEncode(clientSecret)).append("&")
|
|
40
|
.append("grant_type=").append("password").append("&")
|
|
41
|
.append("response_type=").append("code").append("&")
|
|
42
|
.append("username=").append(HttpTool.postDataEncode(user)).append("&")
|
|
43
|
.append("password=").append(HttpTool.postDataEncode(pwd));
|
|
44
|
String tokendata = sb.toString();
|
|
45
|
String response = HttpTool.httpRequest(tokenUlr, tokendata, "POST");
|
|
46
|
IData re = new DataMap(response);
|
|
47
|
re.put("baseUrl",baseUlr);
|
|
48
|
return re;
|
|
49
|
}
|
|
50
|
|
|
51
|
/**
|
|
52
|
* 登录
|
|
53
|
*
|
|
54
|
* @param param
|
|
55
|
* @return
|
|
56
|
* @throws Exception
|
|
57
|
*/
|
|
58
|
public IData login(IData param) throws Exception {
|
|
59
|
//创建返回对象
|
|
60
|
IData resultData = createReturnData();
|
|
61
|
//模拟验证码校验
|
|
62
|
String verificationCode = param.getString("verificationCode");
|
|
63
|
boolean validateResult = false;
|
|
64
|
if(verificationCode!=null&&!("").equals(verificationCode)){
|
|
65
|
validateResult= true;
|
|
66
|
}
|
|
67
|
if(!validateResult){
|
|
68
|
resultData.put(Constant.RETURN_CODE_KEY, Constant.ReturnCode.FAIL);
|
|
69
|
resultData.put(Constant.RETURN_MESSAGE_KEY, "验证码错误!");
|
|
70
|
return resultData;
|
|
71
|
}
|
|
72
|
|
|
73
|
//模拟返回数据
|
|
74
|
String userId = "10086";
|
|
75
|
|
|
76
|
//生成context对象
|
|
77
|
IpuContextData contextData = new IpuContextData();
|
|
78
|
contextData.setStaffId(userId);
|
|
79
|
contextData.setUserAccount(param.getString("userAccount"));
|
|
80
|
String sessionId = IpuSessionManager.getInstance().createSession(contextData);
|
|
81
|
|
|
82
|
//返回前端数据
|
|
83
|
resultData.put("SESSION_ID", sessionId);
|
|
84
|
resultData.put("USER_ID", userId);// 员工号
|
|
85
|
resultData = createSuccessMsg(resultData, "登录成功!");
|
|
86
|
return resultData;
|
|
87
|
|
|
88
|
}
|
|
89
|
|
|
90
|
|
|
91
|
/**
|
|
92
|
* 发送验证码
|
|
93
|
* @param param
|
|
94
|
* @return
|
|
95
|
* @throws Exception
|
|
96
|
*/
|
|
97
|
public IData sendVerificationCode(IData param) throws Exception {
|
|
98
|
//创建返回对象
|
|
99
|
IData resultData = createReturnData();
|
|
100
|
// 模拟发送验证码,并放置session对象中
|
|
101
|
String phone = param.getString("phone");
|
|
102
|
// logger.debug("模拟发送验证码到"+phone);
|
|
103
|
boolean resultFlag= true;
|
|
104
|
if (resultFlag) {
|
|
105
|
return createSuccessMsg(resultData,"发送验证码成功");
|
|
106
|
} else {
|
|
107
|
return createErrorMsg(resultData,"发送验证码失败");
|
|
108
|
}
|
|
109
|
}
|
|
110
|
|
|
111
|
}
|