|
|
|
@ -27,9 +27,11 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
LoginPersonModel model = new LoginPersonModel();
|
|
|
|
|
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
public void doLogin(String username, String password) {
|
|
|
|
|
public void doLogin(String username, String password, String platform) {
|
|
|
|
|
if (StrKit.isBlank(platform)) {
|
|
|
|
|
platform = "WEB";
|
|
|
|
|
}
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
try {
|
|
|
|
|
if (StrKit.isBlank(username)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "用户名不允许为空!");
|
|
|
|
@ -100,21 +102,23 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
CookieUtil.set(getResponse(), "person_id", loginMap.get("person_id").toString(), false, true);
|
|
|
|
|
CookieUtil.set(getResponse(), "bureau_id", loginMap.get("bureau_id").toString(), false, true);
|
|
|
|
|
CookieUtil.set(getResponse(), "token", token, false, true);
|
|
|
|
|
|
|
|
|
|
//添加返回的Token JWT
|
|
|
|
|
String jwtToken = JwtUtil.generateToken(Integer.parseInt(loginMap.get("identity_id").toString()), loginMap.get("person_id").toString(), loginMap.get("bureau_id").toString());
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|
resultJson.put("identity_id", loginMap.get("identity_id").toString());
|
|
|
|
|
resultJson.put("person_id", loginMap.get("person_id").toString());
|
|
|
|
|
resultJson.put("bureau_id", loginMap.get("bureau_id").toString());
|
|
|
|
|
resultJson.put("person_name", loginMap.get("person_name").toString());
|
|
|
|
|
resultJson.put("jwt", jwtToken);
|
|
|
|
|
//将此人员的权限信息写入Pika,如果后面的要求登录互踢,可以用来处理互踢
|
|
|
|
|
//处理逻辑就是:检查此jwt是不是在Pika中存在,存在就是系统派发出去,并且是最后一次用户在此平台登录的TOKEN
|
|
|
|
|
//如果不存在,就表示此token已过期,踢出即可。
|
|
|
|
|
RedisKit.set("jwt_" + platform + "_" + loginMap.get("person_id").toString(), jwtToken);
|
|
|
|
|
//根据人员id,获取所有单位信息
|
|
|
|
|
Record r = bm.getBureauInfoByPersonId(loginMap.get("person_id").toString());
|
|
|
|
|
if (r != null) resultJson.put("bureau_name", r.getStr("bureau_name"));
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "登录异常!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|