|
@ -1,13 +1,14 @@
|
|
package com.yihu.hos.system.service;
|
|
package com.yihu.hos.system.service;
|
|
|
|
|
|
import com.yihu.hos.common.constants.ContextAttributes;
|
|
import com.yihu.hos.common.constants.ContextAttributes;
|
|
import com.yihu.hos.tenant.model.TenantSession;
|
|
|
|
import com.yihu.hos.web.framework.model.Result;
|
|
|
|
import com.yihu.hos.system.model.SystemUser;
|
|
import com.yihu.hos.system.model.SystemUser;
|
|
import com.yihu.hos.system.service.intf.ISystemManager;
|
|
import com.yihu.hos.system.service.intf.ISystemManager;
|
|
import com.yihu.hos.system.service.intf.IUserManager;
|
|
import com.yihu.hos.system.service.intf.IUserManager;
|
|
|
|
import com.yihu.hos.tenant.model.TenantSession;
|
|
|
|
import com.yihu.hos.web.framework.model.ActionResult;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
import javax.servlet.http.HttpSession;
|
|
@ -21,12 +22,16 @@ public class SystemManager implements ISystemManager {
|
|
@Autowired
|
|
@Autowired
|
|
private IUserManager userManager;
|
|
private IUserManager userManager;
|
|
|
|
|
|
|
|
@Value("${spring.administrators}")
|
|
|
|
private String saasAdmin;
|
|
|
|
|
|
/*
|
|
/*
|
|
登录操作
|
|
登录操作
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result loginAction(HttpSession session,String user,String password) throws Exception
|
|
|
|
|
|
public ActionResult loginAction(HttpSession session,String user,String password) throws Exception
|
|
{
|
|
{
|
|
|
|
ActionResult result = null;
|
|
TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
|
|
TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
|
|
//特殊账户
|
|
//特殊账户
|
|
if(user.equals("admin") && password.equals("JKZL"))
|
|
if(user.equals("admin") && password.equals("JKZL"))
|
|
@ -35,29 +40,39 @@ public class SystemManager implements ISystemManager {
|
|
userInfo.setLoginCode("admin");
|
|
userInfo.setLoginCode("admin");
|
|
userInfo.setUserName("管理员");
|
|
userInfo.setUserName("管理员");
|
|
session.setAttribute("userInfo",userInfo);
|
|
session.setAttribute("userInfo",userInfo);
|
|
tenantSession.setUserCode("admin");
|
|
|
|
|
|
tenantSession.setUserCode("admin");//设置租户code
|
|
|
|
tenantSession.setRole("admin");//标识为管理员账号
|
|
session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
|
|
session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
|
|
return Result.success("登录成功!");
|
|
|
|
|
|
result = new ActionResult(true,"登录成功!");
|
|
|
|
result.setData(tenantSession);
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
//根据用户名/密码到总平台校验
|
|
//根据用户名/密码到总平台校验
|
|
SystemUser userInfo = userManager.getUserByLoginCode(user);
|
|
SystemUser userInfo = userManager.getUserByLoginCode(user);
|
|
if(userInfo==null)
|
|
if(userInfo==null)
|
|
{
|
|
{
|
|
return Result.error("登录失败!用户不存在!");
|
|
|
|
|
|
result = new ActionResult(false,"登录失败!用户不存在!");
|
|
|
|
return result;
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
String saltValue =userInfo.getSaltValue();
|
|
String saltValue =userInfo.getSaltValue();
|
|
String userPassword = userInfo.getPassword();
|
|
String userPassword = userInfo.getPassword();
|
|
if(userPassword.equals(DigestUtils.md5Hex(password + saltValue)))
|
|
if(userPassword.equals(DigestUtils.md5Hex(password + saltValue)))
|
|
{
|
|
{
|
|
|
|
if (saasAdmin.equals(user)){
|
|
|
|
tenantSession.setRole("admin");//标识为管理员账号
|
|
|
|
}
|
|
tenantSession.setUserCode(user);
|
|
tenantSession.setUserCode(user);
|
|
session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
|
|
session.setAttribute(ContextAttributes.TENANT_SESSION, tenantSession);
|
|
session.setAttribute("userInfo",userInfo);
|
|
session.setAttribute("userInfo",userInfo);
|
|
return Result.success("登录成功!");
|
|
|
|
|
|
result = new ActionResult(true,"登录成功!");
|
|
|
|
result.setData(tenantSession);
|
|
|
|
return result;
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
return Result.error("登录失败!密码错误!");
|
|
|
|
|
|
result = new ActionResult(false,"登录失败!密码错误!");
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|