基于javaweb的SpringBoot课程评价系统(java+springboot+layui+html+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

130023262402

140023262402

150023262402

160023262402

170023262402

180023262402

190023262402

基于javaweb的SpringBoot课程评价系统(java+springboot+layui+html+maven+mysql)

项目介绍

适合刚接触springboot的同学学习一下的,难度不大,前端使用layui框架,后台springboot+mybatis。代码量较少。 角色分为 学生、教师、管理员,学生可修改密码,先选择课程之后对对应课程的教师做出评价,最后计算出总分入库;

管理员角色包含以下功能:登录,管理员管理,教师管理增删改查,课程管理增删改查,教学指标增删改查,学生增删改查,查看评价等功能。 教师角色包含以下功能:登录,课程管理,教学指标管理,学生管理,收到的评价等功能。 学生角色包含以下功能:登录,修改个人信息,开始评分,选择课程进行评价,查看评分,打分等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;

技术栈

  1. 后端:SpringBoot+MyBatis

  2. 前端:layui+html

使用说明
运行项目,输入localhost:8085 登录 5. 管理员账户:admin  密码:123456 教师账户:jiaoshi 密码:123456

学生账户:student 密码:123456

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    @Autowired
private AdminEntityMapper adminEntityMapper;

@PostMapping("/add")
public Integer add(@RequestBody AdminEntity entity) {
return adminEntityMapper.insert(entity);
}

@PostMapping(value = "/delete", consumes = "application/json")
public Integer delete(@RequestBody AdminEntity entity) {
return adminEntityMapper.deleteByPrimaryKey(entity.getUserid());
}

@PostMapping("/update")
public Integer update(@RequestBody AdminEntity entity) {
return adminEntityMapper.updateByPrimaryKey(entity);
}

@RequestMapping("/select")
public Layui select(@RequestParam(required = false) String username,@RequestParam(value = "page")Integer page,
@RequestParam(value = "limit")Integer limit) {
AdminEntityExample example = new AdminEntityExample();
if (!StringUtils.isEmpty(username)){
example.or().andUsernameLike("%"+username+"%");
}
example.getOrderByClause();
Long cou = adminEntityMapper.countByExample(example);
return Layui.data(cou.intValue(), adminEntityMapper.selectByExamplePaging(example, page-1, limit));
}

@RequestMapping("/getAdmin")
public AdminEntity getAdmin(@RequestParam(value="userid")Integer userid) {
return adminEntityMapper.selectByPrimaryKey(userid);
}

}
package com.evaluation.config;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 */
@RestController
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentEntityMapper studentEntityMapper;

@PostMapping("/add")
public Integer add(@RequestBody StudentEntity entity) {
return studentEntityMapper.insert(entity);
}

@PostMapping("/delete")
public Integer delete(@RequestBody StudentEntity entity) {
return studentEntityMapper.deleteByPrimaryKey(entity.getStuId());
}

@PostMapping("/update")
public Integer update(@RequestBody StudentEntity entity) {
return studentEntityMapper.updateByPrimaryKey(entity);
}


@RequestMapping("/select")
public Layui select(@RequestParam(required = false) String stuRealname, @RequestParam(value = "page") Integer page,
@RequestParam(value = "limit") Integer limit) {
StudentEntityExample example = new StudentEntityExample();
if (!StringUtils.isEmpty(stuRealname)){
example.or().andStuRealnameLike("%"+stuRealname+"%");
}
Long cou = studentEntityMapper.countByExample(example);
return Layui.data(cou.intValue(), studentEntityMapper.selectByExamplePaging(example, page - 1, limit));
}

@RequestMapping("/getStudent")
public StudentEntity getAdmin(@RequestParam(value="stuId")Integer stuId) {
return studentEntityMapper.selectByPrimaryKey(stuId);
}
}
package com.evaluation.controller;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
                studentEntity.setLoginName(loginUserDTO.getUsername());
studentEntity.setLoginPw(loginUserDTO.getPassword());
userDTO = studentEntityMapper.updateByPrimaryKey(studentEntity);
break;
default:
break;
}
return userDTO;
}

@RequestMapping("/getLoginUser")
public LoginUserDTO getLoginUser() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpSession session = request.getSession();
String loginType = session.getAttribute("loginUserType").toString();
String loginUserId = session.getAttribute("loginUserId").toString();
UserTypeEnum userTypeEnum = UserTypeEnum.getEventByCode(loginType);
LoginUserDTO userDTO = new LoginUserDTO();
switch (userTypeEnum) {
case ADMIN:
AdminEntity adminEntity = adminEntityMapper.selectByPrimaryKey(Integer.parseInt(loginUserId));
userDTO.setId(adminEntity.getUserid());
userDTO.setUsername(adminEntity.getUsername());
userDTO.setPassword(adminEntity.getUserpw());
break;
case TEACHER:
TeacherEntity teacherEntity = teacherEntityMapper.selectByPrimaryKey(Integer.parseInt(loginUserId));
userDTO.setId(teacherEntity.getTeaId());
userDTO.setUsername(teacherEntity.getLoginName());
userDTO.setPassword(teacherEntity.getLoginPw());
break;
case STUDENT:
StudentEntity studentEntity = studentEntityMapper.selectByPrimaryKey(Integer.parseInt(loginUserId));
userDTO.setId(studentEntity.getStuId());
userDTO.setUsername(studentEntity.getLoginName());
userDTO.setPassword(studentEntity.getLoginPw());
break;
default:
break;
}
System.out.println(JSONObject.toJSONString(userDTO));
return userDTO;
}
}
package com.evaluation.controller;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
        courseTeaEntity.setCourseId(entity.getCourseIds()[i]);
courseTeaEntity.setTeacherId(entity.getTeaId());
teaEntities.add(courseTeaEntity);
}
if (teaEntities.size() > 0) {
courseTeaEntityMapper.insertBatch(teaEntities);
}
return teacherEntityMapper.updateByPrimaryKey(entity);
}

@RequestMapping("/select")
public Layui select(@RequestParam(required = false) String teaRealname, @RequestParam(value = "page") Integer page,
@RequestParam(value = "limit") Integer limit) {
TeacherEntityExample example = new TeacherEntityExample();
if (!StringUtils.isEmpty(teaRealname)) {
example.or().andTeaRealnameLike("%"+teaRealname+"%");
}
Long cou = teacherEntityMapper.countByExample(example);
return Layui.data(cou.intValue(), teacherEntityMapper.selectByExamplePaging(example, page - 1, limit));
}

@RequestMapping("/getTeacher")
public TeacherDTO getAdmin(@RequestParam(value = "teaId") Integer teaId) {
TeacherEntity entity = teacherEntityMapper.selectByPrimaryKey(teaId);
CourseTeaEntityExample example = new CourseTeaEntityExample();
example.or().andTeacherIdEqualTo(entity.getTeaId());
List<CourseTeaEntity> courseTeaEntities = courseTeaEntityMapper.selectByExample(example);
Integer[] arr = new Integer[courseTeaEntities.size()];
for (int i = 0; i < courseTeaEntities.size(); i++) {
arr[i] = courseTeaEntities.get(i).getCourseId();
}
TeacherDTO dto = new TeacherDTO();
dto.setCourseIds(arr);
dto.setLoginName(entity.getLoginName());
dto.setLoginPw(entity.getLoginPw());
dto.setTeaId(entity.getTeaId());
dto.setDel(entity.getDel());
dto.setTeaAge(entity.getTeaAge());
dto.setTeaBianhao(entity.getTeaBianhao());
dto.setTeaRealname(entity.getTeaRealname());
dto.setTeaSex(entity.getTeaSex());
return dto;
}

/**
* 若存在--提示已经评论过
*
* @param teaId
* @return
*/
@RequestMapping("/exit")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

PingjiaxinxiEntity entity = new PingjiaxinxiEntity();
entity.setShijian(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
entity.setTeaId(teacherId);
entity.setZongfen(lastResult);
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpSession session = request.getSession();
String userId = session.getAttribute("loginUserId").toString();
String loginUserType = session.getAttribute("loginUserType").toString();
entity.setStuId(Integer.parseInt(userId));
PingjiaxinxiEntityExample entityExample = new PingjiaxinxiEntityExample();
entityExample.or().andTeaIdEqualTo(teacherId).andStuIdEqualTo(Integer.parseInt(userId));
Long result = pingjiaxinxiEntityMapper.countByExample(entityExample);
System.out.println("评价用户身份:"+loginUserType);
if (result > 0) {
return Result.ofSuccess(loginUserType);
}
pingjiaxinxiEntityMapper.insertSelective(entity);
return Result.ofSuccess(loginUserType);
} catch (Exception e) {
e.printStackTrace();
}
return Result.ofError(5001,"评价失败");
}

@RequestMapping("/listLayui")
public Layui listLayui(@RequestParam(value = "page") Integer page,
@RequestParam(value = "limit") Integer limit) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
HttpSession session = request.getSession();
PingjiaxinxiEntityExample entityExample = new PingjiaxinxiEntityExample();
String loginUserId = session.getAttribute("loginUserId").toString();
String loginUserType = session.getAttribute("loginUserType").toString();
//如果登录用户为a教师 只能看到他自己的评价信息
if (loginUserType.equals(UserTypeEnum.TEACHER.getCode())) {
entityExample.or().andTeaIdEqualTo(Integer.parseInt(loginUserId));
}
Long count = pingjiaxinxiEntityMapper.countByExample(entityExample);
List<PingjiaxinxiEntity> entities = pingjiaxinxiEntityMapper.selectByExamplePaging(entityExample, page, limit);
List<PJDTO> pjdtoList = new ArrayList<>();
entities.forEach(o -> {
PJDTO pjdto = new PJDTO();
pjdto.setId(o.getId());
TeacherEntity teacherEntity = teacherEntityMapper.selectByPrimaryKey(o.getTeaId());
StudentEntity studentEntity = studentEntityMapper.selectByPrimaryKey(o.getStuId());
pjdto.setStudentName(studentEntity == null ? "" : studentEntity.getStuRealname());
pjdto.setTeacherName(teacherEntity == null ? "" : teacherEntity.getTeaRealname());
pjdto.setShijian(o.getShijian());
pjdto.setZongfen(o.getZongfen());
pjdtoList.add(pjdto);
});
return Layui.data(count.intValue(), pjdtoList);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

/**
* @Description:
*/
@RestController
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentEntityMapper studentEntityMapper;

@PostMapping("/add")
public Integer add(@RequestBody StudentEntity entity) {
return studentEntityMapper.insert(entity);
}

@PostMapping("/delete")
public Integer delete(@RequestBody StudentEntity entity) {
return studentEntityMapper.deleteByPrimaryKey(entity.getStuId());
}

@PostMapping("/update")
public Integer update(@RequestBody StudentEntity entity) {
return studentEntityMapper.updateByPrimaryKey(entity);
}


@RequestMapping("/select")
public Layui select(@RequestParam(required = false) String stuRealname, @RequestParam(value = "page") Integer page,
@RequestParam(value = "limit") Integer limit) {
StudentEntityExample example = new StudentEntityExample();
if (!StringUtils.isEmpty(stuRealname)){
example.or().andStuRealnameLike("%"+stuRealname+"%");
}
Long cou = studentEntityMapper.countByExample(example);
return Layui.data(cou.intValue(), studentEntityMapper.selectByExamplePaging(example, page - 1, limit));
}

@RequestMapping("/getStudent")
public StudentEntity getAdmin(@RequestParam(value="stuId")Integer stuId) {
return studentEntityMapper.selectByPrimaryKey(stuId);
}
}
package com.evaluation.controller;


项目链接:
https://javayms.github.io?id=431422322105200kv
https://javayms.pages.dev?id=431422322105200kv