SSM框架+bootstrap;
代码已经上传github,下载地址:https://github.com/21503882
代码上传到githbu中了。下载地址:https://github.com/21503882/car
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hdxy.vehicle.base.Pagination;
import com.hdxy.vehicle.entity.SysUser;
import com.hdxy.vehicle.service.SysUserService;
import com.hdxy.vehicle.util.ActionResult;
@Controller
public class AdminAction {
@Autowired
SysUserService sysUserServiceImpl;
/**
* 登录判断
*
* @return
*/
@ResponseBody
@RequestMapping("admin/isLogin")
public ActionResult isLogin(SysUser sysUser, HttpSession session) {
ActionResult result = new ActionResult();
try {
if (StringUtils.isNotEmpty(sysUser.getAccount()) && StringUtils.isNotEmpty(sysUser.getPassword())) {
List
if (isAdmin.size() > 0 && isAdmin != null) {
session.setAttribute("sysUser", isAdmin.get(0));
isAdmin.get(0).setLogTime(new Date());
// 更新当前登录时间
sysUserServiceImpl.updateById(isAdmin.get(0));
result.setMsg("登录成功!");
result.setSuccess(true);
} else {
result.setMsg("登录失败,账号和密码不一致!");
}
} else {
result.setMsg("登录失败,账号或密码不能为空!");
}
} catch (Exception e) {
e.printStackTrace();
result.setMsg("登录失败,出现异常!");
}
return result;
}
/**
* 跳转后台主页面
*
* @return
*/
@RequestMapping("/isAdmin/main")
public ModelAndView main(HttpServletRequest request, HttpSession session) {
ModelAndView model = new ModelAndView();
SysUser sysUser = (SysUser) session.getAttribute("sysUser");
if (sysUser != null) {
if (sysUser.getType() == 1) {
sysUser.setTypeName("管理员");
} else if (sysUser.getType() == 0) {
sysUser.setTypeName("教练");
} else {
sysUser.setTypeName("无类型");
}
model.addObject("sysUser", sysUser);
}
model.setViewName("backstage/main");
return model;
}
// 通用的访问WEB-INT下的视图
@RequestMapping("/isAdmin/returnJsp/{jsp}")
public String returnJsp(@PathVariable("jsp") String jsp) {
return "backstage/" + jsp;
}
/**
* 退出登录
*
* @param session
* @return
*/
@RequestMapping("/isAdmin/exitLogin")
public String exitLogin(HttpSession session) {
session.removeAttribute("sysUser");
return "redirect:/adminLogin.jsp";
}
/**
* 管理员修改个人信息
*
* @param sysUser
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/upAdminInfo")
public ActionResult upAdminInfo(SysUser sysUser, HttpSession session) {
ActionResult result = new ActionResult();
try {
sysUserServiceImpl.updateById(sysUser);
SysUser admin = sysUserServiceImpl.findById(sysUser.getId());
session.setAttribute("sysUser", admin);
result.setSuccess(true);
result.setMsg("修改成功");
} catch (Exception e) {
e.printStackTrace();
result.setMsg("出现异常,修改失败");
}
return result;
}
// 修改密码
@ResponseBody
@RequestMapping("/isAdmin/upPassword")
public ActionResult updatePassword(String password, String newPassword, HttpSession session) {
ActionResult result = new ActionResult();
try {
if (StringUtils.isNoneBlank(password) && StringUtils.isNoneBlank(newPassword)) {
SysUser admin = (SysUser) session.getAttribute("sysUser");
if (admin != null) {
if (password.equals(admin.getPassword())) {
admin.setPassword(newPassword);
// 修改管理员密码
sysUserServiceImpl.updateById(admin);
// 更新session值
session.setAttribute("sysUser", admin);
result.setSuccess(true);
result.setMsg("修改成功");
System.out.println(11);
} else {
result.setMsg("原始密码不正确,修改失败");
}
}
} else {
result.setMsg("必填项不能为空,修改失败");
}
} catch (Exception e) {
e.printStackTrace();
result.setMsg("出现异常,修改失败");
}
return result;
}
/**
* 显示所用管理员信息并分页
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/findAdmin")
public Pagination
try {
return sysUserServiceImpl.findPageByCondition(entity);
} catch (Exception e) {
e.printStackTrace();
}
return new Pagination<>(0, new ArrayList<>());
}
/**
* 删除人员信息
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/delAdmin")
public ActionResult delAdmin(Integer id) {
ActionResult res = new ActionResult();
try {
sysUserServiceImpl.deleteById(id);
res.setSuccess(true);
res.setMsg("删除成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,删除失败");
}
return res;
}
/**
* 跳转编辑页面
*
* @param id
* @return
*/
@RequestMapping("/isAdmin/forwardEditAdmin")
public ModelAndView findAdmin(Integer id) {
ModelAndView model = new ModelAndView();
model.setViewName("backstage/editAdmin");
try {
SysUser sysUser = sysUserServiceImpl.findById(id);
model.addObject("sysUserEdit", sysUser);
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
/**
* 修改人员信息
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/upAdmin")
public ActionResult upAdmin(SysUser entity) {
ActionResult res = new ActionResult();
try {
sysUserServiceImpl.updateById(entity);
res.setSuccess(true);
res.setMsg("修改成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,修改失败");
}
return res;
}
/**
* 添加人员信息
*
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/isAdmin/addAdmin")
public ActionResult addAdmin(SysUser entity) {
ActionResult res = new ActionResult();
try {
entity.setCreateTime(new Date());
sysUserServiceImpl.save(entity);
res.setSuccess(true);
res.setMsg("添加成功");
} catch (Exception e) {
e.printStackTrace();
res.setMsg("出现异常,添加失败");
}
return res;
}
/**
* 查询所有人员信息
* @param entity
* @return
*/
@ResponseBody
@RequestMapping("/user/findAllSysUser")
public ActionResult findAllSysUser(SysUser entity) {
ActionResult res=new ActionResult();
try {
entity.setState(1);
List
res.put("list", list);
res.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
学车
学车预约
报名
学车报名
待开发
待开发
联系电话6825 1760 / 6825 3853
投诉电话6825 1288