基于javaweb+mysql的springboot课程排课系统(java+springboot+vue+maven+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot课程排课系统(java+springboot+vue+maven+mysql)
项目介绍
课程排课系统,该系统分两种角色:管理员与普通用户;
主要功能包括: 排课管理、教师管理、教室管理、课程管理、菜单管理、角色管理、用户管理;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 8.0版本;
技术栈 1.java+SpringBoot+VUE+maven+Mysql
//构造查询条件
QueryWrapper<Course> query = new QueryWrapper<>();
if(StringUtils.isNotEmpty(courseParam.getCourseName())){
query.lambda().like(Course::getCourseName,courseParam.getCourseName());
}
if(StringUtils.isNotEmpty(courseParam.getCourseType())){
query.lambda().eq(Course::getCourseType,courseParam.getCourseType());
}
//查询
IPage<Course> list = courseService.page(page, query);
return CommonResult.success("查询成功",list);
}
}
@RestController
@RequestMapping("/api/role")
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private RoleMenuService roleMenuService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody Role role){
boolean save = roleService.save(role);
if(save){
return CommonResult.success("新增成功");
}
return CommonResult.error("新增失败!");
}
//新增
@PutMapping
}
//查询列表
@GetMapping("/list")
public CommonResult< IPage<Role>> getList(ListParm listParm){
IPage<Role> list = roleService.getList(listParm);
return CommonResult.success("查询成功",list);
}
//查询分配权限回显
@GetMapping("/getAssingShow")
public CommonResult<AssignVo> getAssingShow(AssignParm parm){
AssignVo vo = roleService.getAssignShow(parm);
return CommonResult.success("查询成功",vo);
}
//分配权限保存
@PostMapping("/assignSave")
public CommonResult<String> assignSave(@RequestBody SaveAssign saveAssign){
roleMenuService.assignSve(saveAssign);
return CommonResult.success("分配权限成功!");
}
}
@RestController
@RequestMapping("/api/menu")
public class MenuController {
@Autowired
private MenuService menuService;
/**
*/
@RestController
@RequestMapping("/api/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@PostMapping
public CommonResult<String> add(@RequestBody Teacher teacher){
boolean save = teacherService.save(teacher);
if(save){
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
@PutMapping
public CommonResult<String> edit(@RequestBody Teacher teacher){
boolean save = teacherService.updateById(teacher);
if(save){
return CommonResult.success("编辑成功!");
}
return CommonResult.error("编辑失败!");
}
@DeleteMapping("/{teacherId}")
public CommonResult<String> delete(@PathVariable("teacherId") Long teacherId){
boolean b = teacherService.removeById(teacherId);
if(b){
return CommonResult.success("删除成功!");
}
return CommonResult.error("删除失败!");
}
@GetMapping("/list")
public CommonResult<IPage<Teacher>> getList(TeacherParam param){
//删除
@DeleteMapping("/{roleId}")
public CommonResult<String> delete(@PathVariable("roleId") Long roleId){
boolean save = roleService.removeById(roleId);
if(save){
return CommonResult.success("删除成功");
}
return CommonResult.error("删除失败!");
}
//查询列表
@GetMapping("/list")
public CommonResult< IPage<Role>> getList(ListParm listParm){
IPage<Role> list = roleService.getList(listParm);
return CommonResult.success("查询成功",list);
}
//查询分配权限回显
@GetMapping("/getAssingShow")
public CommonResult<AssignVo> getAssingShow(AssignParm parm){
AssignVo vo = roleService.getAssignShow(parm);
return CommonResult.success("查询成功",vo);
}
//分配权限保存
@PostMapping("/assignSave")
public CommonResult<String> assignSave(@RequestBody SaveAssign saveAssign){
roleMenuService.assignSve(saveAssign);
return CommonResult.success("分配权限成功!");
}
}
@RestController
@RequestMapping("/api/menu")
/**
* 删除
* @param courseId
* @return
*/
@DeleteMapping("/{courseId}")
public CommonResult<String> delete(@PathVariable("courseId") Long courseId){
boolean save = courseService.removeById(courseId);
if(save){
return CommonResult.success("删除成功!");
}
return CommonResult.error("删除失败!");
}
/**
* 查询列表
* @param courseParam
* @return
*/
@GetMapping("/list")
public CommonResult<IPage<Course>> getList(CourseParam courseParam){
//构造分页对象
IPage<Course> page = new Page<>();
page.setCurrent(courseParam.getCurrentPage());
page.setSize(courseParam.getPageSize());
//构造查询条件
QueryWrapper<Course> query = new QueryWrapper<>();
if(StringUtils.isNotEmpty(courseParam.getCourseName())){
query.lambda().like(Course::getCourseName,courseParam.getCourseName());
}
if(StringUtils.isNotEmpty(courseParam.getCourseType())){
query.lambda().eq(Course::getCourseType,courseParam.getCourseType());
}
//查询
IPage<Course> list = courseService.page(page, query);
return CommonResult.success("查询成功",list);
}
}
//查询分配权限回显
@GetMapping("/getAssingShow")
public CommonResult<AssignVo> getAssingShow(AssignParm parm){
AssignVo vo = roleService.getAssignShow(parm);
return CommonResult.success("查询成功",vo);
}
//分配权限保存
@PostMapping("/assignSave")
public CommonResult<String> assignSave(@RequestBody SaveAssign saveAssign){
roleMenuService.assignSve(saveAssign);
return CommonResult.success("分配权限成功!");
}
}
@RestController
@RequestMapping("/api/menu")
public class MenuController {
@Autowired
private MenuService menuService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody Menu menu) {
menu.setCreateTime(new Date());
menu.setUpdateTime(new Date());
boolean save = menuService.save(menu);
if (save) {
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
//编辑
@PutMapping
public CommonResult<String> edit(@RequestBody Menu menu) {
menu.setUpdateTime(new Date());
boolean save = menuService.updateById(menu);
if (save) {
public CommonResult<String> delete(@PathVariable("roomId") Long roomId){
boolean b = classRoomService.removeById(roomId);
if(b){
return CommonResult.success("删除成功!");
}
return CommonResult.error("删除失败!");
}
@GetMapping("/list")
public CommonResult<IPage<ClassRoom>> getList(ListParam listParam){
IPage<ClassRoom> list = classRoomService.getList(listParam);
return CommonResult.success("查询成功",list);
}
}
/**
*/
@RestController
@RequestMapping("/api/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@PostMapping
public CommonResult<String> add(@RequestBody Teacher teacher){
boolean save = teacherService.save(teacher);
if(save){
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
@PutMapping
public CommonResult<String> edit(@RequestBody Teacher teacher){
query.lambda().eq(Course::getCourseType,courseParam.getCourseType());
}
//查询
IPage<Course> list = courseService.page(page, query);
return CommonResult.success("查询成功",list);
}
}
@RestController
@RequestMapping("/api/role")
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private RoleMenuService roleMenuService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody Role role){
boolean save = roleService.save(role);
if(save){
return CommonResult.success("新增成功");
}
return CommonResult.error("新增失败!");
}
//新增
@PutMapping
public CommonResult<String> edit(@RequestBody Role role){
boolean save = roleService.updateById(role);
if(save){
return CommonResult.success("编辑成功");
}
return CommonResult.error("编辑失败!");
}
//删除
@RestController
@RequestMapping("/api/role")
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private RoleMenuService roleMenuService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody Role role){
boolean save = roleService.save(role);
if(save){
return CommonResult.success("新增成功");
}
return CommonResult.error("新增失败!");
}
//新增
@PutMapping
public CommonResult<String> edit(@RequestBody Role role){
boolean save = roleService.updateById(role);
if(save){
return CommonResult.success("编辑成功");
}
return CommonResult.error("编辑失败!");
}
@RestController
@RequestMapping("/api/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private UserRoleService userRoleService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody User user) {
//根据用户名查询
QueryWrapper<User> query = new QueryWrapper<>();
query.lambda().eq(User::getUsername,user.getUsername());
//user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
User one = userService.getOne(query);
if(one != null){
return CommonResult.error("账户被占用!");
}
userService.addUser(user);
boolean save = teacherService.updateById(teacher);
if(save){
return CommonResult.success("编辑成功!");
}
return CommonResult.error("编辑失败!");
}
@DeleteMapping("/{teacherId}")
public CommonResult<String> delete(@PathVariable("teacherId") Long teacherId){
boolean b = teacherService.removeById(teacherId);
if(b){
return CommonResult.success("删除成功!");
}
return CommonResult.error("删除失败!");
}
@GetMapping("/list")
public CommonResult<IPage<Teacher>> getList(TeacherParam param){
IPage<Teacher> list = teacherService.getList(param);
return CommonResult.success("查询成功",list);
}
}
@ControllerAdvice
public class GlobalExceptionHandler {
/**
* 自定义业务异常拦截
* BusinessException
*/
@ExceptionHandler(BusinessException.class)
@ResponseBody
public CommonResult bussinessexception(BusinessException e) {
return CommonResult.error(e.getCode(),e.getMessage(),e.getMessage());
}
/**
public CommonResult<String> delete(@PathVariable("userId") Long userId) {
userService.deletUser(userId);
return CommonResult.success("删除成功!");
}
//列表查询
@GetMapping("/list")
public CommonResult<IPage<User>> getList(PageParm parm) {
IPage<User> list = userService.getUserList(parm);
return CommonResult.success("查询成功", list);
}
//角色列表查询
@GetMapping("/role")
public CommonResult<List<SelectOption>> getRole() {
List<Role> list = roleService.list();
List<SelectOption> selectOptions = new ArrayList<>();
Optional.ofNullable(list).orElse(new ArrayList<>())
.stream()
.forEach(item -> {
SelectOption option = new SelectOption();
option.setValue(item.getRoleId());
option.setLabel(item.getRoleName());
selectOptions.add(option);
});
return CommonResult.success("查询成功", selectOptions);
}
//根据id查询用户信息
@GetMapping("/getUser")
public CommonResult<User> getUserById(Long userId){
User user = userService.getById(userId);
//查角色id
QueryWrapper<UserRole> query = new QueryWrapper<>();
query.lambda().eq(UserRole::getUserId,userId);
UserRole one = userRoleService.getOne(query);
user.setRoleId(one.getRoleId());
return CommonResult.success("查询成功",user);
}
}
@RestController
@RequestMapping("/api/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private UserRoleService userRoleService;
//新增
@PostMapping
public CommonResult<String> add(@RequestBody User user) {
//根据用户名查询
QueryWrapper<User> query = new QueryWrapper<>();
query.lambda().eq(User::getUsername,user.getUsername());
//user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
User one = userService.getOne(query);
if(one != null){
return CommonResult.error("账户被占用!");
}
userService.addUser(user);
return CommonResult.success("新增成功!");
}
//编辑
@PutMapping
public CommonResult<String> edit(@RequestBody User user) {
//根据用户名查询
QueryWrapper<User> query = new QueryWrapper<>();
query.lambda().eq(User::getUsername,user.getUsername());
User one = userService.getOne(query);
if(one != null && !Objects.equals(one.getUserId(), user.getUserId())){
return CommonResult.error("账户被占用!");
}
return CommonResult.success("查询成功",list);
}
}
/**
*/
@RestController
@RequestMapping("/api/teacher")
public class TeacherController {
@Autowired
private TeacherService teacherService;
@PostMapping
public CommonResult<String> add(@RequestBody Teacher teacher){
boolean save = teacherService.save(teacher);
if(save){
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
@PutMapping
public CommonResult<String> edit(@RequestBody Teacher teacher){
boolean save = teacherService.updateById(teacher);
if(save){
return CommonResult.success("编辑成功!");
}
return CommonResult.error("编辑失败!");
}
/**
* 新增课程
* @param course
* @return
*/
@PostMapping
public CommonResult<String> add(@RequestBody Course course) {
course.setCourseTime(new Date());
boolean save = courseService.save(course);
if(save){
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
/**
* 编辑课程
* @param course
* @return
*/
@PutMapping
public CommonResult<String> edit(@RequestBody Course course) {
course.setCourseTime(new Date());
boolean save = courseService.updateById(course);
if(save){
return CommonResult.success("编辑成功!");
}
return CommonResult.error("编辑失败!");
}
/**
* 删除
* @param courseId
* @return
*/
@DeleteMapping("/{courseId}")
public CommonResult<String> delete(@PathVariable("courseId") Long courseId){
boolean save = courseService.removeById(courseId);
if(save){
return CommonResult.success("删除成功!");
//列表
@GetMapping("/list")
public CommonResult<List<Menu>> getList(){
List<Menu> list = menuService.getList();
return CommonResult.success("查询成功",list);
}
//上级菜单树数据
@GetMapping("/parent")
public CommonResult< List<Menu>> getParentList(){
List<Menu> list = menuService.parentList();
return CommonResult.success("查询成功",list);
}
}
/**
*/
@RestController
@RequestMapping("/api/classroom")
public class ClassRoomController {
@Autowired
private ClassRoomService classRoomService;
@PostMapping
public CommonResult<String> add(@RequestBody ClassRoom classRoom){
boolean save = classRoomService.save(classRoom);
if(save){
return CommonResult.success("新增成功!");
}
return CommonResult.error("新增失败!");
}
@PutMapping
public CommonResult<String> edit(@RequestBody ClassRoom classRoom){
@RestController
@RequestMapping("/api/login")
public class LoginController {
@Autowired
private JwtUtils jwtUtils;
@Autowired
private UserService userService;
@Autowired
private MenuService menuService;
@PostMapping("/login")
public CommonResult<LoginResult> login(@RequestBody LoginParm loginParm) {
if (StringUtils.isEmpty(loginParm.getUsername()) || StringUtils.isEmpty(loginParm.getPassword())) {
return CommonResult.error("用户名或密码不能为空!");
}
//查询用户
QueryWrapper<User> query = new QueryWrapper<>();
//query.lambda().eq(User::getUsername, loginParm.getUsername()).eq(User::getPassword,DigestUtils.md5DigestAsHex(loginParm.getPassword().getBytes()));
query.lambda().eq(User::getUsername, loginParm.getUsername()).eq(User::getPassword,loginParm.getPassword());
User user = userService.getOne(query);
if (user == null) {
return CommonResult.error("用户名或密码错误!");
*/
@PutMapping
public CommonResult<String> edit(@RequestBody Course course) {
course.setCourseTime(new Date());
boolean save = courseService.updateById(course);
if(save){
return CommonResult.success("编辑成功!");
}
return CommonResult.error("编辑失败!");
}
/**
* 删除
* @param courseId
* @return
*/
@DeleteMapping("/{courseId}")
public CommonResult<String> delete(@PathVariable("courseId") Long courseId){
boolean save = courseService.removeById(courseId);
if(save){
return CommonResult.success("删除成功!");
}
return CommonResult.error("删除失败!");
}
/**
* 查询列表
* @param courseParam
* @return
*/
@GetMapping("/list")
public CommonResult<IPage<Course>> getList(CourseParam courseParam){
//构造分页对象
IPage<Course> page = new Page<>();
page.setCurrent(courseParam.getCurrentPage());
page.setSize(courseParam.getPageSize());
//构造查询条件
QueryWrapper<Course> query = new QueryWrapper<>();
if(StringUtils.isNotEmpty(courseParam.getCourseName())){
query.lambda().like(Course::getCourseName,courseParam.getCourseName());
}
if(StringUtils.isNotEmpty(courseParam.getCourseType())){
query.lambda().eq(Course::getCourseType,courseParam.getCourseType());
}
//查询
IPage<Course> list = courseService.page(page, query);
return CommonResult.success("查询成功",list);
}
}