|
@@ -8,6 +8,7 @@ import cc.smtweb.framework.core.common.R; |
|
|
import cc.smtweb.framework.core.common.SwConsts; |
|
|
import cc.smtweb.framework.core.common.SwConsts; |
|
|
import cc.smtweb.framework.core.common.SwMap; |
|
|
import cc.smtweb.framework.core.common.SwMap; |
|
|
import cc.smtweb.framework.core.container.base.SwParameter; |
|
|
import cc.smtweb.framework.core.container.base.SwParameter; |
|
|
|
|
|
import cc.smtweb.framework.core.container.base.SwReturn; |
|
|
import cc.smtweb.framework.core.container.factory.ListenerFactory; |
|
|
import cc.smtweb.framework.core.container.factory.ListenerFactory; |
|
|
import cc.smtweb.framework.core.db.DbEngine; |
|
|
import cc.smtweb.framework.core.db.DbEngine; |
|
|
import cc.smtweb.framework.core.exception.BizException; |
|
|
import cc.smtweb.framework.core.exception.BizException; |
|
@@ -16,6 +17,7 @@ import cc.smtweb.framework.core.session.UserSession; |
|
|
import cc.smtweb.system.bpm.web.sys.user.party.Party; |
|
|
import cc.smtweb.system.bpm.web.sys.user.party.Party; |
|
|
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache; |
|
|
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache; |
|
|
import cc.smtweb.system.bpm.web.sys.user.user.User; |
|
|
import cc.smtweb.system.bpm.web.sys.user.user.User; |
|
|
|
|
|
import cc.smtweb.system.bpm.web.sys.user.user.UserCache; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
@@ -44,7 +46,41 @@ public class AuthService { |
|
|
} |
|
|
} |
|
|
return R.success(list); |
|
|
return R.success(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 映射登录 |
|
|
|
|
|
public R mappingLogin(@SwBody MappingUserParam mappingUserParam){ |
|
|
|
|
|
SwMap data = new SwMap(); |
|
|
|
|
|
try { |
|
|
|
|
|
SwParameter parameter = new SwParameter(); |
|
|
|
|
|
parameter.setSingleParam(mappingUserParam); |
|
|
|
|
|
SwReturn result = new SwReturn(); |
|
|
|
|
|
ListenerFactory.fireListener(SwConsts.EventConst.LOGIN_MAPPING,parameter,result); |
|
|
|
|
|
MappingUserRet mappingUserRet = (MappingUserRet)result.getSingleResult(); |
|
|
|
|
|
User user = UserCache.getInstance().get(mappingUserRet.getUserId()); |
|
|
|
|
|
if(user==null){ |
|
|
|
|
|
data.put("isOk", false); |
|
|
|
|
|
data.put("msg", "映射登录失败!"); |
|
|
|
|
|
return R.success(data); |
|
|
|
|
|
} |
|
|
|
|
|
UserSession userSession = LoginHelper.simpleLogin(mappingUserRet.getUserId()); |
|
|
|
|
|
LoginAckVO loginAckVO = createLoginAckVO(user,userSession); |
|
|
|
|
|
data.put("user", loginAckVO); |
|
|
|
|
|
data.put("token", loginAckVO.getToken()); |
|
|
|
|
|
data.put("isOk", true); |
|
|
|
|
|
data.put("msg", ""); |
|
|
|
|
|
// 发布登录成功事件 |
|
|
|
|
|
SwParameter parameter1 = new SwParameter(); |
|
|
|
|
|
LoginSuccessParam loginSuccessParam = new LoginSuccessParam(); |
|
|
|
|
|
loginSuccessParam.setUs(userSession); |
|
|
|
|
|
loginSuccessParam.setExtra(mappingUserParam.getExtra()); |
|
|
|
|
|
parameter.setSingleParam(loginSuccessParam); |
|
|
|
|
|
ListenerFactory.fireListenerAsyc(SwConsts.EventConst.LOGIN_SUCCESS,parameter1); |
|
|
|
|
|
return R.success(data); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
data.put("isOk", false); |
|
|
|
|
|
data.put("msg", "映射登录失败!"); |
|
|
|
|
|
return R.success(data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
public R login(@SwBody LoginVO loginPO) { |
|
|
public R login(@SwBody LoginVO loginPO) { |
|
|
SwMap data = new SwMap(); |
|
|
SwMap data = new SwMap(); |
|
|
User user = null; |
|
|
User user = null; |
|
@@ -79,17 +115,7 @@ public class AuthService { |
|
|
user.setId(1); |
|
|
user.setId(1); |
|
|
user.setName("系统管理员"); |
|
|
user.setName("系统管理员"); |
|
|
} |
|
|
} |
|
|
LoginAckVO loginAckVO = new LoginAckVO(); |
|
|
|
|
|
loginAckVO.setUserId(user.getId()); |
|
|
|
|
|
loginAckVO.setUserName(user.getName()); |
|
|
|
|
|
loginAckVO.setRealName(user.getName()); |
|
|
|
|
|
loginAckVO.setPartyId(userSession.getPartyId()); |
|
|
|
|
|
loginAckVO.setAvatar(""); |
|
|
|
|
|
loginAckVO.setDesc(user.getSign()); |
|
|
|
|
|
loginAckVO.setToken(sessionManager.login(userSession)); |
|
|
|
|
|
loginAckVO.setUserLevel(user.getLevel() + ""); |
|
|
|
|
|
loginAckVO.setUserNicky(user.getNicky()); |
|
|
|
|
|
loginAckVO.setUserTel(user.getTel()); |
|
|
|
|
|
|
|
|
LoginAckVO loginAckVO = createLoginAckVO(user,userSession); |
|
|
data.put("user", loginAckVO); |
|
|
data.put("user", loginAckVO); |
|
|
data.put("token", loginAckVO.getToken()); |
|
|
data.put("token", loginAckVO.getToken()); |
|
|
data.put("isOk", true); |
|
|
data.put("isOk", true); |
|
@@ -128,10 +154,19 @@ public class AuthService { |
|
|
return R.success(); |
|
|
return R.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// defaultRun 命名的函数是默认函数 |
|
|
|
|
|
// @SwPerm(SwPerm.NONE) |
|
|
|
|
|
// public R defaultRun(@SwPathParam String path) { |
|
|
|
|
|
// return R.success(path).put("dao", authDao); |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建前端登录对象值对象 |
|
|
|
|
|
private LoginAckVO createLoginAckVO(User user,UserSession userSession){ |
|
|
|
|
|
LoginAckVO loginAckVO = new LoginAckVO(); |
|
|
|
|
|
loginAckVO.setUserId(user.getId()); |
|
|
|
|
|
loginAckVO.setUserName(user.getName()); |
|
|
|
|
|
loginAckVO.setRealName(user.getName()); |
|
|
|
|
|
loginAckVO.setPartyId(userSession.getPartyId()); |
|
|
|
|
|
loginAckVO.setAvatar(""); |
|
|
|
|
|
loginAckVO.setDesc(user.getSign()); |
|
|
|
|
|
loginAckVO.setToken(sessionManager.login(userSession)); |
|
|
|
|
|
loginAckVO.setUserLevel(user.getLevel() + ""); |
|
|
|
|
|
loginAckVO.setUserNicky(user.getNicky()); |
|
|
|
|
|
loginAckVO.setUserTel(user.getTel()); |
|
|
|
|
|
return loginAckVO; |
|
|
|
|
|
} |
|
|
} |
|
|
} |