Commit e0f66d02 by libin

添加从工作桌面(前端)登录的方法

parent c1421d71
......@@ -15,7 +15,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author liuys
......@@ -81,4 +83,35 @@ public class AccessController {
return "logout";
}
//使用警号登录
@ResponseBody
@RequestMapping(value="/loginGzzm",method = {RequestMethod.POST, RequestMethod.GET})
public Map<String,Object> loginGzzm(HttpServletRequest request){
Map<String,Object> returnMap=new HashMap<>();
SysUser user = new SysUser();
String username = request.getParameter("username");
String password = request.getParameter("password");
user.setUsername(username);
user.setPassword(password);
try {
//用户登录
user = TokenUtil.login(user, false);
} catch (Exception e) {
e.printStackTrace();
returnMap.put("state","error");
returnMap.put("msg","登录异常!");
return returnMap;
}
if(user!=null){
request.getSession().setAttribute("user",user);//登录成功生成session
/*request.getSession().setAttribute("perurl",perurl);//权限url 放入session中*/
returnMap.put("state","success");
returnMap.put("msg","登陆成功!");
}else{
returnMap.put("state","failed");
returnMap.put("msg","用户名或密码错误!");
}
return returnMap;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment