赞
踩
基于javaweb的学生成绩管理系统(java+springboot+mybatis+layui+html+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+SpringBoot的学生成绩管理系统(java+SpringBoot+Mybatis+layui+HTML+maven+mysql)
功能介绍
SpringBoot学生成绩管理系统。主要分老师与学生两个角色。
其中,教师角色包含以下功能:
教师登录,学生信息管理,成绩管理,查看总成绩等功能。
学生角色包含以下功能:
学生登录,查看我的成绩,查看我的总成绩等功能。
环境需要
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 5.7版本;
技术栈
后端:SpringBoot+Mybatis
前端:Layui+HTML
使用说明
若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包;
系统用户管理控制层:
/**
系统用户
@author yy
*/
@RestController
@RequestMapping(“/sys/user”)
public class SysUserController extends AbstractController {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserRoleService sysUserRoleService;
/**
*/
@RequestMapping(“/list”)
@RequiresPermissions(“sys:user:list”)
public R list(@RequestParam Map<String, Object> params){
PageUtils page = sysUserService.queryPage(params);
return R.ok().put(“page”, page);
/**
*/
@RequestMapping(“/info”)
public R info(){
return R.ok().put(“user”, getUser());
/**
*/
@SysLog(“修改密码”)
@RequestMapping(“/password”)
public R password(String password, String newPassword){
Assert.isBlank(newPassword, “新密码不为能空”);
//原密码
password = ShiroUtils.sha256(password, getUser().getSalt());
//新密码
newPassword = ShiroUtils.sha256(newPassword, getUser().getSalt());
//更新密码
boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword);
if(!flag){
return R.error(“原密码不正确”);
return R.ok();
/**
*/
@RequestMapping(“/info/{userId}”)
@RequiresPermissions(“sys:user:info”)
public R info(@PathVariable(“userId”) Long userId){
SysUserEntity user = sysUserService.getById(userId);
//获取用户所属的角色列表
List roleIdList = sysUserRoleService.queryRoleIdList(userId);
user.setRoleIdList(roleIdList);
return R.ok().put(“user”, user);
/**
*/
@SysLog(“保存用户”)
@RequestMapping(“/save”)
@RequiresPermissions(“sys:user:save”)
public R save(@RequestBody SysUserEntity user){
ValidatorUtils.validateEntity(user, AddGroup.class);
sysUserService.saveUser(user);
return R.ok();
/**
*/
@SysLog(“修改用户”)
@RequestMapping(“/update”)
@RequiresPermissions(“sys:user:update”)
public R update(@RequestBody SysUserEntity user){
ValidatorUtils.validateEntity(user, UpdateGroup.class);
sysUserService.update(user);
return R.ok();
/**
*/
@SysLog(“删除用户”)
@RequestMapping(“/delete”)
@RequiresPermissions(“sys:user:delete”)
public R delete(@RequestBody Long[] userIds){
if(ArrayUtils.contains(userIds, 1L)){
return R.error(“系统管理员不能删除”);
if(ArrayUtils.contains(userIds, getUserId())){
return R.error(“当前用户不能删除”);
sysUserService.removeByIds(Arrays.asList(userIds));
return R.ok();
角色管理控制层:
/**
角色管理
@author yy
*/
@RestController
@RequestMapping(“/sys/role”)
public class SysRoleController extends AbstractController {
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysRoleMenuService sysRoleMenuService;
@Autowired
private SysRoleDeptService sysRoleDeptService;
/**
*/
@RequestMapping(“/list”)
@RequiresPermissions(“sys:role:list”)
public R list(@RequestParam Map<String, Object> params){
PageUtils page = sysRoleService.queryPage(params);
return R.ok().put(“page”, page);
/**
*/
@RequestMapping(“/select”)
@RequiresPermissions(“sys:role:select”)
public R select(){
List list = sysRoleService.list();
return R.ok().put(“list”, list);
/**
*/
@RequestMapping(“/info/{roleId}”)
@RequiresPermissions(“sys:role:info”)
public R info(@PathVariable(“roleId”) Long roleId){
SysRoleEntity role = sysRoleService.getById(roleId);
//查询角色对应的菜单
List menuIdList = sysRoleMenuService.queryMenuIdList(roleId);
role.setMenuIdList(menuIdList);
//查询角色对应的部门
List deptIdList = sysRoleDeptService.queryDeptIdList(new Long[]{roleId});
role.setDeptIdList(deptIdList);
return R.ok().put(“role”, role);
/**
*/
@SysLog(“保存角色”)
@RequestMapping(“/save”)
@RequiresPermissions(“sys:role:save”)
public R save(@RequestBody SysRoleEntity role){
ValidatorUtils.validateEntity(role);
sysRoleService.saveRole(role);
return R.ok();
/**
*/
@SysLog(“修改角色”)
@RequestMapping(“/update”)
@RequiresPermissions(“sys:role:update”)
public R update(@RequestBody SysRoleEntity role){
ValidatorUtils.validateEntity(role);
sysRoleService.update(role);
return R.ok();
/**
*/
@SysLog(“删除角色”)
@RequestMapping(“/delete”)
@RequiresPermissions(“sys:role:delete”)
public R delete(@RequestBody Long[] roleIds){
sysRoleService.deleteBatch(roleIds);
return R.ok();
登录管理控制层:
/**
登录相关
@author yy
*/
@Controller
public class SysLoginController {
@Autowired
private Producer producer;
@RequestMapping(“captcha.jpg”)
public void captcha(HttpServletResponse response)throws IOException {
response.setHeader(“Cache-Control”, “no-store, no-cache”);
response.setContentType(“image/jpeg”);
//生成文字验证码
String text = producer.createText();
//生成图片验证码
BufferedImage image = producer.createImage(text);
//保存到shiro session
ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text);
ServletOutputStream out = response.getOutputStream();
ImageIO.write(image, “jpg”, out);
/**
*/
@ResponseBody
@RequestMapping(value = “/sys/login”, method = RequestMethod.POST)
public R login(String username, String password, String captcha) {
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
if(!captcha.equalsIgnoreCase(kaptcha)){
return R.error(“验证码不正确”);
try{
Subject subject = ShiroUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, password);//md5+Jiayan
subject.login(token);
}catch (UnknownAccountException e) {
return R.error(e.getMessage());
}catch (IncorrectCredentialsException e) {
return R.error(“账号或密码不正确”);
}catch (LockedAccountException e) {
return R.error(“账号已被锁定,请联系管理员”);
}catch (AuthenticationException e) {
return R.error(“账户验证失败”);
return R.ok();
/**
*/
@RequestMapping(value = “logout”, method = RequestMethod.GET)
public String logout() {
ShiroUtils.logout();
return “redirect:login.html”;
系统菜单管理控制层:
/**
系统菜单
@author yy
*/
@RestController
@RequestMapping(“/sys/menu”)
public class SysMenuController extends AbstractController {
@Autowired
private SysMenuService sysMenuService;
/**
*/
@RequestMapping(“/nav”)
public R nav(){
List menuList = sysMenuService.getUserMenuList(getUserId());
return R.ok().put(“menuList”, menuList);
/**
*/
@RequestMapping(“/list”)
@RequiresPermissions(“sys:menu:list”)
public List list(){
List menuList = sysMenuService.list();
for(SysMenuEntity sysMenuEntity : menuList){
SysMenuEntity parentMenuEntity = sysMenuService.getById(sysMenuEntity.getParentId());
if(parentMenuEntity != null){
sysMenuEntity.setParentName(parentMenuEntity.getName());
return menuList;
/**
*/
@RequestMapping(“/select”)
@RequiresPermissions(“sys:menu:select”)
public R select(){
//查询列表数据
List menuList = sysMenuService.queryNotButtonList();
//添加顶级菜单
SysMenuEntity root = new SysMenuEntity();
root.setMenuId(0L);
root.setName(“一级菜单”);
root.setParentId(-1L);
root.setOpen(true);
menuList.add(root);
return R.ok().put(“menuList”, menuList);
/**
*/
@RequestMapping(“/info/{menuId}”)
@RequiresPermissions(“sys:menu:info”)
public R info(@PathVariable(“menuId”) Long menuId){
SysMenuEntity menu = sysMenuService.getById(menuId);
return R.ok().put(“menu”, menu);
/**
*/
@SysLog(“保存菜单”)
@RequestMapping(“/save”)
@RequiresPermissions(“sys:menu:save”)
public R save(@RequestBody SysMenuEntity menu){
//数据校验
verifyForm(menu);
sysMenuService.save(menu);
return R.ok();
/**
*/
@SysLog(“修改菜单”)
@RequestMapping(“/update”)
@RequiresPermissions(“sys:menu:update”)
public R update(@RequestBody SysMenuEntity menu){
//数据校验
verifyForm(menu);
sysMenuService.updateById(menu);
return R.ok();
/**
*/
@SysLog(“删除菜单”)
@RequestMapping(“/delete”)
@RequiresPermissions(“sys:menu:delete”)
public R delete(long menuId){
if(menuId <= 31){
return R.error(“系统菜单,不能删除”);
//判断是否有子菜单或按钮
List menuList = sysMenuService.queryListParentId(menuId);
if(menuList.size() > 0){
return R.error(“请先删除子菜单或按钮”);
sysMenuService.delete(menuId);
return R.ok();
/**
*/
private void verifyForm(SysMenuEntity menu){
if(StringUtils.isBlank(menu.getName())){
throw new RRException(“菜单名称不能为空”);
if(menu.getParentId() == null){
throw new RRException(“上级菜单不能为空”);
//菜单
if(menu.getType() == Constant.MenuType.MENU.getValue()){
if(StringUtils.isBlank(menu.getUrl())){
throw new RRException(“菜单URL不能为空”);
//上级菜单类型
int parentType = Constant.MenuType.CATALOG.getValue();
if(menu.getParentId() != 0){
SysMenuEntity parentMenu = sysMenuService.getById(menu.getParentId());
parentType = parentMenu.getType();
//目录、菜单
if(menu.getType() == Constant.MenuType.CATALOG.getValue() ||
menu.getType() == Constant.MenuType.MENU.getValue()){
if(parentType != Constant.MenuType.CATALOG.getValue()){
throw new RRException(“上级菜单只能为目录类型”);
return ;
//按钮
if(menu.getType() == Constant.MenuType.BUTTON.getValue()){
if(parentType != Constant.MenuType.MENU.getValue()){
throw new RRException(“上级菜单只能为菜单类型”);
return ;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。