package com.singulee.carschool.controller;
import com.singulee.carschool.pojo.Student;
import com.singulee.carschool.pojo.Teacher;
import com.singulee.carschool.pojo.User;
import com.singulee.carschool.service.StudentService;
import com.singulee.carschool.service.TeacherService;
import com.singulee.carschool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Created with IntelliJ IDEA.
* User: lishuai
* Date: 2019/03/19
* Description:
* Version: V1.0
*/
@Controller
@RequestMapping("/login")
public class LoginController {
final private StudentService studentService;
final private TeacherService teacherService;
final private UserService userService;
@Autowired
public LoginController(StudentService studentService, TeacherService teacherService, UserService userService) {
this.studentService = studentService;
this.teacherService = teacherService;
this.userService = userService;
}
/**
* 登录 返回格式
*
* @param map
* @param request
* @return
*/
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> login(@RequestBody Map<String, String> map, HttpServletRequest request) {
boolean flag = false;
String phone = map.get("phone");
String password = map.get("password");
User user = userService.findByUsername(phone);
if (null != user && user.getPassword().equals(password)) {
Integer userType = user.getUserType();
if (userType == 1) {
Student student = studentService.getByPhone(phone);
if (student != null) {
flag = true;
student.setStupwd(user.getPassword());
request.getSession().setAttribute("user", student);
}
} else {
Teacher teacher = new Teacher();
teacher.setTeaphone(phone);
Integer roleTmp = user.getUserType() == 3 ? 1 : 0;
teacher.setTearole(roleTmp);
Teacher teacherRe = teacherService.selectByPone(teacher);
if (teacherRe != null) {
flag = true;
teacher.setTeapwd(user.getPassword());
request.getSession().setAttribute("user", teacherRe);
}
}
}
Map<String, Object> mapjson = new HashMap<>();
if (flag) {
mapjson.put("code", 200);
mapjson.put("role", user.getUserType());
} else {
mapjson.put("code", 201);
}
return mapjson;
}
/**
* 教练 管理员的修改用户信息
*
* @param request
* @return
*/
@RequestMapping(value = "/teacherInfo", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> teacherInfo(HttpServletRequest request) {
Map<String, Object> mapjson = new HashMap<>();
Teacher teacher = (Teacher) request.getSession().getAttribute("user");
teacher.setTeapwd("");
mapjson.put("code", 200);
mapjson.put("data", teacher);
return mapjson;
}
/**
* 注销登录
*
* @param request
* @return
*/
@RequestMapping(value = "/logout")
public String loginOut(HttpServletRequest request) {
request.getSession().removeAttribute("user");
return "/login.html";
}
/**
* @param request
* @return
*/
@RequestMapping(value = "/getStudentInfo", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getStudentInfo(HttpServletRequest request) {
Map<String, Object> mapjson = new HashMap<>();
Student student = (Student) request.getSession().getAttribute("user");
student.setStupwd("");
mapjson.put("code", 200);
mapjson.put("data", student);
return mapjson;
}
/**
* 获得验证码
*
* @param map
* @param request
* @return
*/
@RequestMapping(value = "/getCode", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getCode(@RequestBody Map<String, String> map, HttpServletRequest request) {
String phone = map.get("phone");
Map<String, Object> mapCode = new HashMap<>();
Map<String, Object> mapjson = new HashMap<>();
int mobileCode = (int) ((Math.random() * 9 + 1) * 100000);
mapCode.put("number", mobileCode + "");
mapCode.put("phone", phone);
boolean flag = false;
User user = userService.findByUsername(phone);
if (user != null) {
flag = true;
}
// if (flag&& Send.sendCode(mobileCode,phone)){
if (flag) {
//发送手机号到手机
mapjson.put("code", 200);
mapjson.put("number", mobileCode);
mapCode.put("time", System.currentTimeMillis());
System.out.println(mobileCode);
request.getSession().setAttribute("smscode", mapCode);
} else {
mapjson.put("code", 201);
mapjson.put("msg", "手机号不存在,请查证");
}
return mapjson;
}
/**
* 获得验证码 公用
*
* @param map
* @param request
* @return
*/
@RequestMapping(value = "/getPhoneCode", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getPhoneCode(@RequestBody Map<String, String> map, HttpServletRequest request) {
String phone = map.get("phone");
Teacher teacher = new Teacher();
teacher.setTeaphone(phone);
Map<String, Object> mapCode = new HashMap<>();
Map<String, Object> mapjson = new HashMap<>();
int mobileCode = (int) ((Math.random() * 9 + 1) * 100000);
mapCode.put("number", mobileCode + "");
mapCode.put("phone", phone);
boolean flag = false;
// if (flag&& Send.sendCode(mobileCode,phone)){
mapCode.put("time", System.currentTimeMillis() + "");
mapjson.put("code", 200);
mapjson.put("number", mobileCode + "");
request.getSession().setAttribute("smscode", mapCode);
// }
return mapjson;
}
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> updatePhone(@RequestBody Map<String, String> map, HttpServletRequest request) {
String phone = map.get("phone");
String number = map.get("number");
Map<String, Object> mapjson = new HashMap<>();
Object object = request.getSession().getAttribute("user");
//判断验证码手机是否合法
Map<String, Object> mapSession = (Map<String, Object>) request.getSession().getAttribute("smscode");
System.out.println(mapSession);
System.out.println(map);
if (mapSession.get("phone").toString().equals(phone) && mapSession.get("number").toString().equals(number) &&
System.currentTimeMillis() - Long.parseLong(mapSession.get("time").toString()) < 60 * 1000) {
if (object instanceof Student) {
Student student = (Student) object;
Student studenttmp = studentService.getByPhone(student.getStuphone());
studenttmp.setStuphone(phone);
request.getSession().setAttribute("user", studenttmp);
return studentService.updateStudent(studenttmp);
} else {
Teacher teacher = (Teacher) object;
Teacher teachertmp = teacherService.selectByPone(teacher);
tea
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA驾校预约管理系统源码+数据库,后端采用SpringBoot+Mysql,前端使用jQuery框架
共212个文件
gif:75个
java:49个
js:26个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 42 浏览量
2023-01-09
10:40:15
上传
评论
收藏 1.1MB ZIP 举报
温馨提示
JAVA驾校预约管理系统,后端采用SpringBoot+Mysql,前端使用jQuery框架
资源推荐
资源详情
资源评论
收起资源包目录
JAVA驾校预约管理系统源码+数据库,后端采用SpringBoot+Mysql,前端使用jQuery框架 (212个子文件)
bootstrap.css 134KB
bootstrap.min.css 111KB
layui.css 58KB
bootstrap-theme.css 21KB
bootstrap-theme.min.css 19KB
layer.css 14KB
layui.mobile.css 10KB
laydate.css 7KB
bootstrap-fileupload.min.css 2KB
code.css 1KB
iconfont.eot 38KB
glyphicons-halflings-regular.eot 20KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
studentManger.html 25KB
teacherManger.html 25KB
courseManager.html 22KB
mystudent.html 20KB
cartManger.html 19KB
userInfo.html 17KB
relationshipManager.html 17KB
userInfo.html 17KB
userInfo.html 16KB
courseHistory.html 15KB
mycart.html 13KB
login.html 11KB
repairManger.html 9KB
共 212 条
- 1
- 2
- 3
资源评论
Python代码大全
- 粉丝: 2726
- 资源: 689
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功