Commit ed3c6bf2 by caoyin

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

parent 380eb5fe
......@@ -13,7 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author liuys
......@@ -76,4 +79,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