package com.gxw.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.gxw.pojo.Admin; import com.gxw.service.AdminService; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; /** * 后台系统控制器 * * @author GXWadmin */ @RequestMapping("/system") @Controller public class SystemController { @Autowired private AdminService adminService; /** * 第一跳转页面 * * @author GXWadmin */ @RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView toindex(ModelAndView model) { model.setViewName("system/index"); return model; } /** * 跳转主页页面 * @value main * @author GXWadmin */ @RequestMapping(value = "/main", method = RequestMethod.GET) public ModelAndView tomain(ModelAndView model) { model.setViewName("system/main"); return model; } /** * 跳转到登录页面 * @value login * @author GXWadmin */ @RequestMapping(value = "/login", method = RequestMethod.GET) public ModelAndView tologin(ModelAndView model) { model.setViewName("system/login"); return model; } /** * 注销登录 * @value login_out * @param request * @return */ @RequestMapping(value = "/login_out",method=RequestMethod.GET) public String loginOut(HttpServletRequest request){ // request.getSession().setAttribute("admin", null); request.getSession().invalidate(); return "redirect:login"; } /** * 登录表单提交 * @value login_form * @return */ @RequestMapping(value = "/login_form", method = RequestMethod.POST) @ResponseBody public Map<String, String> login( @RequestParam(value = "aName", required = true) String aName, @RequestParam(value = "aPwd", required = true) String aPwd, HttpServletRequest request) { Map<String, String> map = new HashMap<String, String>(); if(StringUtils.isEmpty(aName)){ map.put("type", "error"); map.put("msg", "用户名不能为空!"); return map; } if(StringUtils.isEmpty(aPwd)){ map.put("type", "error"); map.put("msg", "密码不能为空!"); return map; } // 从数据库中去查找用户 // 管理员 Admin login = adminService.findByaName(aName); if (login == null) { map.put("type", "error"); map.put("msg", "用户名不存在!"); return map; } if (!aPwd.equals(login.getaPwd())) { map.put("type", "error"); map.put("msg", "密码不正确!"); return map; } request.getSession().setAttribute("admin", login); map.put("type", "success"); map.put("msg", "登录成功!"); System.out.println("已提交"); return map; } }
最近下载更多
tangguo666666 LV4
2023年6月5日
zxc131313 LV12
2022年10月23日
AlanLi LV18
2022年6月17日
109683670 LV9
2022年4月18日
java代写 LV7
2022年3月15日
wanglinddad LV54
2022年2月15日
lilong007 LV20
2021年12月20日
893213895 LV18
2021年12月16日
deck222 LV9
2021年12月12日
KSY247 LV5
2021年11月10日
最近浏览更多
爱丽淇 LV5
3月19日
a318888331 LV13
3月10日
FF加菲猫 LV4
2月15日
iiiiiiixiiiiii LV1
2023年12月28日
ziv5466123 LV7
2023年12月15日
cyz521213 LV1
2023年12月9日
mukoooo LV2
2023年12月5日
内心向阳 LV4
2023年11月8日
lyq6666666 LV5
2023年10月25日
沉默66666
2023年10月5日
暂无贡献等级