源码获取:博客首页 "资源" 里下载!
课程自动排课系统,该系统分两种角色:管理员与普通用户;
主要功能包括:
首页:查看分课、查看课表、查看空教室;
班级设置:添加班级、分配课程、编辑、删除课程;
教室设置:添加教室、编辑、删除;
课程设置:添加课程、编辑、删除;
教师设置:添加教师、编辑、删除;
排课管理:调整排课、删除排课;
用户管理:添加用户、编辑、删除;
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 8.0版本;
7.Redis数据库,redis配置已设置好,勿修改;
1. 后端:Springboot+redis
2. 前端:html+layui+thymeleaf
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.properties配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入http://localhost:8080/login.html 登录
@Controller
@RequestMapping("/User")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private PowerService powerService;
@Autowired
private RoleService roleService;
@Autowired
private NoticeService noticeService;
@RequestMapping("/Main")
public String res(HttpServletRequest request){
String time = DateUtil.getStringToday();
request.getSession().setAttribute("time", time);
Notice notice = new Notice();
List list = noticeService.queryAll(notice);
notice = list.get(0);
User user = userService.selectByPrimaryKey(notice.getUserid());
notice.setUserid(user.getName());
request.getSession().setAttribute("notice", notice);
return "Main";
}
@RequestMapping("/changePa")
public String res1(){
return "changePass";
}
@RequestMapping("/Login")
public ModelAndView login(HttpServletRequest request,String id,String password) throws Exception{
ModelAndView mav = new ModelAndView();
User user1 = userService.selectByPrimaryKey(id);
if(user1 == null || !password.equals(user1.getPassword())){
mav.setViewName("index");
request.getSession().setAttribute("info", "error");
return mav;
}else{
Role role = new Role();
role.setRoleid(user1.getRoleid());
List list =roleService.QueryAll(role);
role =list.get(0);
request.getSession().setAttribute("roleName", role.getRolename());
Power power = powerService.selectByPrimaryKey(role.getPowerid());
if(!StringUtil.isNullOrEmpty(power.getPower())){
request.getSession().setAttribute("power", power.getPower());
}
String time = DateUtil.getStringToday();
request.getSession().setAttribute("time", time);
request.getSession().setAttribute("user", user1);
mav.setViewName("redirect:/User/Main");
}
return mav;
}
@RequestMapping("/updateStudent")
public String update(User user){
userService.updateByPrimaryKey(user);
return "redirect:/User/student";
}
@RequestMapping("/updateTeacher")
public String updatet(User user){
userService.updateByPrimaryKey(user);
return "redirect:/User/teacher";
}
@RequestMapping("/updatePa")
public String updatePa(String userID,String password){
User user = new User();
System.out.println(userID);
User user1 = userService.selectByPrimaryKey(userID);
user1.setPassword(password);
userService.updateByPrimaryKey(user1);
return "Main";
}
@RequestMapping("/delete")
public String delete(String ID){
userService.deleteByPrimaryKey(ID);
return "redirect:/User/queryAll";
}
@RequestMapping("/teacher")
public String QueryAllTeacher(HttpServletRequest request,User user){
List list = userService.QueryAllTeacher(user);
request.setAttribute("list", list);
if(null != user.getName()){
request.setAttribute("name", user.getName());
}
if(null != user.getMobile()){
request.setAttribute("mobile", user.getMobile());
}
return "teacher";
}
@ResponseBody
@RequestMapping("/jsonteacher")
public String QueryAllTeacherjson(HttpServletRequest request,User user){
List list = userService.QueryAllTeacher(user);
JSONObject json = new JSONObject();
return json.toJSONString(list);
}
@RequestMapping("/student")
public String QueryAllStudent(HttpServletRequest request,User user){
List list = userService.QueryAllStudent(user);
request.setAttribute("list", list);
if(null != user.getName()){
request.setAttribute("name", user.getName());
}
if(null != user.getMobile()){
request.setAttribute("mobile", user.getMobile());
}
return "student";
}
@RequestMapping("/addteacher")
public String addUser(User user){
String passWord = "123456";
user.setPassword(passWord);
user.setType(Constans.TEACHER);
userService.insert(user);
return "redirect:/User/teacher";
}
@RequestMapping("/addstudent")
public String addStudent(User user){
String passWord = "123456";
user.setPassword(passWord);
user.setType(Constans.STUDENT);
userService.insert(user);
return "redirect:/User/student";
}
@ResponseBody
@RequestMapping("/queryOne")
public String queryOne(String ID){
User user = new User();
user.setId(ID);
List list = userService.QueryAll(user);
user = list.get(0);
JSONObject json = new JSONObject();
String data = json.toJSONString(user);
return data;
}
@RequestMapping("/quit")
public ModelAndView quit(HttpServletRequest request) throws Exception{
ModelAndView mav = new ModelAndView();
HttpSession session1 = request.getSession();
session1.invalidate();
request.getSession().setAttribute("info", "quit");
mav.setViewName("index");
return mav;
}
}
@Controller
@RequestMapping("/Role")
public class RoleController {
@Autowired
private RoleService depotService;
@Autowired
private PowerService powerService;
@RequestMapping("/update")
public String update(String id,String rolename,String powerContent){
Role role = new Role();
role.setRoleid(id);
role.setRolename(rolename);
depotService.update(role);
List list = depotService.QueryAll(role);
Role role1 = list.get(0);
Power power = new Power();
if(powerContent.indexOf("110") != -1){
powerContent = powerContent + ",1100";
}
if(powerContent.indexOf("120") != -1){
powerContent = powerContent + ",1200";
}
if(powerContent.indexOf("130") != -1){
powerContent = powerContent + ",1300";
}
if(powerContent.indexOf("140") != -1){
powerContent = powerContent + ",1400";
}
if(powerContent.indexOf("150") != -1){
powerContent = powerContent + ",1500";
}
power.setPower(powerContent);
power.setRoleid(role1.getPowerid());
powerService.update(power);
return "redirect:/Role/queryAll";
}
@RequestMapping("/delete")
public String delete(String ID){
depotService.deleteByPrimaryKey(ID);
return "redirect:/Role/queryAll";
}
@RequestMapping("/queryAll")
public String queryAll(HttpServletRequest request,Role role){
List list = depotService.QueryAll(role);
request.setAttribute("list", list);
if(null != role.getRolename()){
request.setAttribute("rolename", role.getRolename());
}
return "Role";
}
@RequestMapping("/add")
public String add(String roleid,String rolename,String powerContent){
Power power1 = new Power();
Role role = new Role();
String powerid = String.valueOf(Math.random()).substring(2, 8);
role.setRoleid(String.valueOf(Math.random()).substring(2, 6));
role.setPowerid(powerid);
role.setRolename(rolename);
power1.setPower(powerContent);
power1.setRoleid(powerid);
power1.setId(String.valueOf(Math.random()).substring(2, 8));
powerService.insert(power1);
depotService.insert(role);
return "redirect:/Role/queryAll";
}
@ResponseBody
@RequestMapping("/queryOne")
public String queryOne(String ID){
JSONObject json = new JSONObject();
Role depot = new Role();
Power power = new Power();
power.setId(ID);
System.out.println(ID);
depot.setRoleid(ID);
List list = depotService.QueryAll(depot);
Role role1 = list.get(0);
Power power1 = powerService.selectByPrimaryKey(role1.getPowerid());
String name = role1.getRolename();
role1.setPowerid(power1.getPower());
String data = json.toJSONString(role1);
return data;
}
@ResponseBody
@RequestMapping("/getAll")
public String getAll(Role role){
JSONObject json = new JSONObject();
List list = depotService.QueryAll(role);
String jsonq = json.toJSONString(list);
System.out.println(jsonq);
return jsonq;
}
}
@Controller
@RequestMapping("/Course")
public class CourseController {
@Autowired
private CourseService courseService;
@Autowired
private CurelationService curelationService;
@Autowired
private CoursecommentService coursecommentService;
@ResponseBody
@RequestMapping("/queryOneCom")
public String queryOneCom(String ID){
Coursecomment course = new Coursecomment();
course.setId(ID);
System.out.println("===================================="+ID);
List list = coursecommentService.queryAll(course);
course = list.get(0);
JSONObject json = new JSONObject();
return json.toJSONString(course);
}
@RequestMapping("addComment")
public String addComment(HttpServletRequest request, Coursecomment coursecomment){
User user = (User) request.getSession().getAttribute("user");
coursecomment.setCreatetime(DateUtil.getStringToday());
coursecomment.setUserid(user.getName());
coursecomment.setId(String.valueOf(Math.random()).substring(2,10));
coursecommentService.insert(coursecomment);
return "redirect:/Course/suggeetion";
}
@ResponseBody
@RequestMapping("jsoncourse")
public String jsoncourse(HttpServletRequest request, Curelation course){
User user = (User) request.getSession().getAttribute("user");
/*String type = "1";
if ("1".equals(user.getType())){
type="2";
}
course.setType(type);
course.setUserid(user.getId());*/
List curelationList = curelationService.queryAll(course);
List dataList = new ArrayList<>();
for (int i = 0; i < curelationList.size(); i++) {
Course curelation = courseService.selectByPrimaryKey(curelationList.get(i).getCourseid());
dataList.add(curelation);
}
JSONObject json = new JSONObject();
return json.toJSONString(dataList);
}
@RequestMapping("suggeetion")
public String suggeetion(HttpServletRequest request, Coursecomment coursecomment){
List coursecomments = coursecommentService.queryAll(coursecomment);
request.setAttribute("list",coursecomments);
return "suggeetion";
}
@RequestMapping("view")
public String view(HttpServletRequest request){
User user = (User) request.getSession().getAttribute("user");
String type = "1";
if ("1".equals(user.getType())){
type="2";
}
List
源码获取:博客首页 "资源" 里下载!