一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP + Servlert + html+ css + JavaScript + JQuery + Ajax 等等;
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
map.put("type","error");
map.put("msg","两次密码不一致");
return map;
}
}
/**
* 查看个人信息
* @param httpSession
* @return
*/
@RequestMapping("inforEmployee.do")
public @ResponseBody EmployeeCustomVo getInforEmployee(HttpSession httpSession){
Integer id = (Integer) httpSession.getAttribute("employeeId");
EmployeeCustomVo employeeCustomVo = userInforService.getInforEmployee(id);
return employeeCustomVo;
}
/**
* 修改个人信息
* @param httpSession
* @param employee
* @return
*/
@ResponseBody
@RequestMapping("updateInforEmployee.do")
public Message updateInforEmployee(HttpSession httpSession, Employee employee){
@RequestMapping(value = "/adminLogin.do")
@ResponseBody
public Message adminLogin(HttpSession httpSession, String username,
String password, String identifyingcode)
{
if(StringUtils.isEmpty(username)) {
return Message.error("请填写账号");
}
if(StringUtils.isEmpty(password)) {
return Message.error("请填写密码");
}
if(StringUtils.isEmpty(identifyingcode)) {
return Message.error("请填写验证码");
}
String code = (String) httpSession.getAttribute("identifyingCode");
if(identifyingcode.equalsIgnoreCase(code)){
SystemManager manager = loginService.findSystemManagerByIdAndPassword(username, password);
if(manager==null) {
return Message.error("账号或密码错误");
}
// 保存到session
httpSession.setAttribute("admin",manager);
return Message.success("登录成功");
}else {
}
个人中心Controller:
/**
* 个人中心Controller
*/
@Controller
public class UserInforController {
@Autowired
private UserInforServiceImpl userInforService = null;
/**
* 修改密码 *** 作
* @param oldPassword
* @param newPassword
* @param rePassword
* @param httpSession
* @return
*/
@RequestMapping("changePassword.do")
@ResponseBody
public Map<String, String> changePassword(String oldPassword, String newPassword,
String rePassword, HttpSession httpSession){
HashMap<String, String> map = new HashMap<String, String>();
if (newPassword.equals(rePassword)){
SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
if (encodeByMD5.equals(admin.getSmPassword())){
// SystemManager manager = loginService.findSystemManagerById(id);
return systemManager.getSmAccount();
}
@RequestMapping(value = "/getEmployeeAccount.do")
@ResponseBody
public Map<String,String> getEmployeeAccount(HttpSession httpSession){
Integer id = (Integer) httpSession.getAttribute("employeeId");
Employee employee = loginService.findEmployeeById(id);
HashMap<String, String> map = new HashMap<String, String>();
map.put("account",employee.geteAccount());
map.put("name",employee.geteName());
return map;
}
@RequestMapping(value = "/logout.do")
public String logout(HttpSession httpSession){
httpSession.removeAttribute("employeeId");
return "redirect:/";
}
@RequestMapping(value = "/logoutAdmin.do")
public String logoutAdmin(HttpSession httpSession){
httpSession.removeAttribute("admin");
return "redirect:/admin.do";
}
}
用户管理 *** 作:
/**
* 用户管理 *** 作
return MapControl.getInstance().error("请填写用户名").getMap();
}
if(StringUtils.isEmpty(user.getName())){
return MapControl.getInstance().error("请填写名称").getMap();
}
if(StringUtils.isEmpty(user.getUserPwd())){
return MapControl.getInstance().error("请填写密码").getMap();
}
int result = userService.update(user);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
/**
* 根据id查询,跳转修改页面
* @param id
* @param modelMap
* @return
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap modelMap) {
User user = userService.detail(id);
modelMap.addAttribute("user", user);
return "user/edit";
*/
@Controller
public class UserInforController {
@Autowired
private UserInforServiceImpl userInforService = null;
/**
* 修改密码 *** 作
* @param oldPassword
* @param newPassword
* @param rePassword
* @param httpSession
* @return
*/
@RequestMapping("changePassword.do")
@ResponseBody
public Map<String, String> changePassword(String oldPassword, String newPassword,
String rePassword, HttpSession httpSession){
HashMap<String, String> map = new HashMap<String, String>();
if (newPassword.equals(rePassword)){
@ResponseBody
public Map<String, Object> delete(String ids) {
int result = userService.delete(ids);
if (result <= 0) {
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
/**
* 编辑用户信息 *** 作
* @param user
* @return
*/
@PostMapping("/edit")
@ResponseBody
public Map<String, Object> edit(@RequestBody User user) {
if(StringUtils.isEmpty(user.getUserName())){
return MapControl.getInstance().error("请填写用户名").getMap();
}
return employeeSalaryVO;
}
}
管理员和员工登陆控制:
/**
* @Author: admin
* @Description: 管理员和员工登陆控制
**/
@Controller
public class LoginController {
@Autowired
private LoginServiceImpl loginService = null;
/**
* @Author: admin
* @Description: 验证码变更
* @Date: 14:33 2021/10/5
* @Param: [request, response]
* @Return: void
**/
@RequestMapping(value = "/changeCode.do")
@RequestMapping(value = "/changeCode.do")
@ResponseBody
public void getIdentifyingCode(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// 验证码存储在session的identifyingCode,属性中
CaptchaUtil.outputCaptcha(request, response);
}
// 获取员工登陆界面
@RequestMapping("/")
public String getLoginPage(){
return "employee/login.html";
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)