项目介绍
采用SpringBoot+Spring+Mybatis+Thyeleaf实现的在线学习系统,一共2个身份。
管理员登录系统后可以管理所有用户信息,管理角色信息,添加修改管理课件信息,学生学习培训批次管理,成绩导入管理
学生登录系统后可以查询自己的个人信息,查询课件列表学习,查询我的培训记录,查询自己的成绩
采用SpringBoot框架实现 前台模板用的thymeleaf 数据库层采用mybatis框架 注解模式
upload文件夹放入D盘根目录!
项目运行
登录地址: http://localhost:8080/th/login
管理员账号和密码: admin admin
学生登录账号: 1314 密码: 123456
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
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<Role> list =roleService.QueryAll(role);
role =list.get(0);
request.getSession().setAttribute("roleName", role.getRolename());
Power power = powerService.selectByPrimaryKey(role.getPowerid());
public String receive(HttpServletRequest request, HttpServletResponse response, MultipartFile file){
try {
//也可以用request获取上传文件
//MultipartFile fileFile = request.getFile("file"); //这里是页面的name属性
//转换成输入流
InputStream is = file.getInputStream();
//得到excel
Workbook workbook = Workbook.getWorkbook(is);
//得到sheet
Sheet sheet = workbook.getSheet(0);
//得到列数
int colsNum = sheet.getColumns();
//得到行数
int rowsNum = sheet.getRows();
//单元格
Map<Integer, String> map = new HashMap<Integer, String>();
for (int i = 1; i < rowsNum; i++) {//我的excel第一行是标题,所以 i从1开始
cell = sheet.getCell(0,i);
cell1 = sheet.getCell(5,i);
Curelation curelation = new Curelation();
curelation.setId(cell.getContents());
curelation.setScore(cell1.getContents());
curelationService.updateByPrimaryKey(curelation);
}
} catch (IOException e) {
e.printStackTrace();
} catch (BiffException e) {
e.printStackTrace();
return mav;
}else{
Role role = new Role();
role.setRoleid(user1.getRoleid());
List<Role> 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){
@RequestMapping("/queryOneCom")
public String queryOneCom(String ID){
Coursecomment course = new Coursecomment();
course.setId(ID);
System.out.println("===================================="+ID);
List<Coursecomment> 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())){
public String delete(String ID){
courseService.deleteByPrimaryKey(ID);
return "redirect:/Course/queryAll";
}
@RequestMapping("update")
public String update(Course course){
courseService.updateByPrimaryKey(course);
return "redirect:/Course/queryAll";
}
@Transactional
@RequestMapping("update1")
public String update1(HttpServletRequest request,Course course){
course.setStatus("1");
courseService.updateByPrimaryKey(course);
User user = (User) request.getSession().getAttribute("user");
Curelation curelation1 = new Curelation();
JSONObject json = new JSONObject();
List<Role> 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
curelation.setType("2");
curelationService.insert(curelation);
}
return "redirect:/Course/teacher";
}
@RequestMapping("update2")
public String update2(HttpServletRequest request,Course course){
User user = (User) request.getSession().getAttribute("user");
Curelation curelation = new Curelation();
curelation.setUserid(user.getId());
curelation.setCourseid(course.getId());
List<Curelation> curelationList = curelationService.queryAll(curelation);
if(curelationList.size() == 0){
curelation.setId(String.valueOf(Math.random()).substring(2, 10));
curelation.setType("1");
curelationService.insert(curelation);
}else{
return json.toJSONString(list);
}
@RequestMapping("/student")
public String QueryAllStudent(HttpServletRequest request,User user){
List<User> 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("/student")
public String student(HttpServletRequest request){
Course course = new Course();
course.setStatus("1");
List<Course> courseList = courseService.queryAll(course);
request.setAttribute("list",courseList);
return "studentChoose";
}
@RequestMapping("/upload")
public String upload(){
return "uploadScore";
}
@RequestMapping("/Export")
public void Export(HttpServletResponse response, User user){
response.setContentType("application/binary;charset=UTF-8");
try {
ServletOutputStream out = response.getOutputStream();
String fileName1 = "学生信息";
public String deletecomment(String ID){
coursecommentService.deleteByPrimaryKey(ID);
return "redirect:/Course/suggeetion";
}
@RequestMapping("queryAll")
public String queryAll(HttpServletRequest request, Course course){
List<Course> list = courseService.queryAll(course);
request.setAttribute("list",list);
return "course";
}
@RequestMapping("/receive")
public String receive(HttpServletRequest request, HttpServletResponse response, MultipartFile file){
try {
//也可以用request获取上传文件
//MultipartFile fileFile = request.getFile("file"); //这里是页面的name属性
//转换成输入流
InputStream is = file.getInputStream();
//得到excel