系统一共分为3个角色分别是:管理员,司机,用户
- <%@ page language="java" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
- <c:set var="ctx" value="${pageContext.request.contextPath}"/>
- html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>搬家系统title>
- <link rel="stylesheet" type="text/css" href="${ctx}/static/css/bootstrap.min.css">
- <link rel="stylesheet" type="text/css" href="${ctx}/static/css/plugins/font-awesome.min.css"/>
- <link rel="stylesheet" type="text/css" href="${ctx}/static/css/plugins/simple-line-icons.css"/>
- <link rel="stylesheet" type="text/css" href="${ctx}/static/css/plugins/animate.min.css"/>
- <link rel="stylesheet" type="text/css" href="${ctx}/static/css/plugins/fullcalendar.min.css"/>
- <link href="${ctx}/static/css/style.css" rel="stylesheet">
-
- head>
- <body id="mimin" class="dashboard form-signin-wrapper">
- <div class="container">
- <form class="form-signin" id="login" method="post">
- <div class="panel periodic-login">
- <div class="panel-body text-center">
- <p class="atomic-mass">搬家系统登录p>
- <i class="icons icon-arrow-down">i>
- <div class="form-group form-animate-text" style="margin-top:40px;">
- <input type="text" class="form-text" name="loginname">
- <span class="bar">span>
- <label>账号label>
- div>
- <div class="form-group form-animate-text" style="margin-top:40px;">
- <input type="password" class="form-text" name="password">
- <span class="bar">span>
- <label>密码label>
- div>
- <div class="form-group form-animate-text" style="margin-top:15px; text-align: left">
- <input type="radio" name="juese" value="0" checked> 管理员
- <input type="radio" name="juese" value="1"> 司机
- <input type="radio" name="juese" value="2"> 用户
- div>
- <a href="${ctx}/user/page/reg">去注册a>
- <input type="button" class="btn col-md-12" value="登 录" onclick="login()"/>
- div>
- div>
- form>
- div>
- <script src="${ctx}/static/js/jquery.min.js">script>
- <script src="${ctx}/static/js/jquery.ui.min.js">script>
- <script src="${ctx}/static/js/bootstrap.min.js">script>
- <script src="${ctx}/static/js/plugins/jquery.nicescroll.js">script>
- <script src="${ctx}/static/js/main.js">script>
- <script src="${ctx}/static/js/common.js">script>
- <script>
- function login() {
- $.ajax({
- url: projectName + "/adminLogin",
- contentType: "application/json;charset=utf-8",
- dataType: "json",
- data: $('#login').serialize(),
- success: function (data) {
- if (data.code == 'success') {
- alert(data.msg);
- window.location.href = projectName + "/index";
- } else {
- alert(data.msg);
- }
- },
- error: function () {
- alert("请求失败,请稍后再试!");
- }
- });
- };
- script>
- body>
- html>
- @RequestMapping(value = "/adminLogin")
- @ResponseBody
- public String login(HttpSession session, String loginname, String password, Integer juese, ModelMap modelMap) {
- if(juese == 0){
- Admin admin = adminService.login(loginname, password);
- if(admin != null){
- setSession(admin.getId(), admin.getLoginname(), UserLevel.ADMIN);
- request.getSession().setAttribute("admin", admin);
-
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_SUCCESS));
- } else {
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_FAILURE));
- }
- }else if(juese == 1){
- Drivers drivers = driversService.login(loginname, password);
- if(drivers != null){
- setSession(drivers.getId(), drivers.getLoginname(), UserLevel.USER);
- request.getSession().setAttribute("drivers", drivers);
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_SUCCESS));
- } else {
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_FAILURE));
- }
- }else if(juese == 2){
- Users users = usersService.login(loginname, password);
- if(users != null){
- setSession(users.getId(), users.getLoginname(), UserLevel.STAFF);
- request.getSession().setAttribute("users", users);
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_SUCCESS));
- } else {
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_FAILURE));
- }
- }
- return FastjsonUtil.serialize(new ResponseVo(ResponseType.LOGON_FAILURE));
- }