作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目为后台管理系统;
管理员角色包含以下功能:
管理员登录,学生管理,课程管理,课堂表现管理,成绩信息管理,作业管理,出勤信息管理,归宿情况管理,宿舍卫生管理等功能。
环境需要
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.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jquery+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ssm_xueyeyujing_sys 登录
运行截图
代码相关
出勤控制器
package com.learn.controller;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.learn.entity.ChuqinEntity;
import com.learn.service.ChuqinService;
import com.learn.utils.PageUtils;
import com.learn.utils.Query;
import com.learn.utils.R;
/**
* 出勤信息
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2020-04-01 16:42:55
*/
@RestController
@RequestMapping("chuqin")
public class ChuqinController extends AbstractController {
@Autowired
private ChuqinService chuqinService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
if (super.getUserId() > 1)
params.put("user", super.getUserId());
//查询列表数据
Query query = new Query(params);
List<ChuqinEntity> chuqinList = chuqinService.queryList(query);
int total = chuqinService.queryTotal(query);
PageUtils pageUtil = new PageUtils(chuqinList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 列表
*/
@RequestMapping("/list2")
public R list2(@RequestParam Map<String, Object> params){
Query query = new Query(params);
List<ChuqinEntity> chuqinList = chuqinService.queryList(query);
return R.ok().put("list", chuqinList );
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ChuqinEntity chuqin = chuqinService.queryObject(id);
return R.ok().put("chuqin", chuqin);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody ChuqinEntity chuqin){
if (chuqin.getUser() == null)
chuqin.setUser(super.getUserId());
chuqinService.save(chuqin);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ChuqinEntity chuqin){
chuqinService.update(chuqin);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
chuqinService.deleteBatch(ids);
return R.ok();
}
}
课程控制器
package com.learn.controller;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.learn.entity.CourseEntity;
import com.learn.service.CourseService;
import com.learn.utils.PageUtils;
import com.learn.utils.Query;
import com.learn.utils.R;
/**
* 课程信息
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2020-04-01 16:42:55
*/
@RestController
@RequestMapping("course")
public class CourseController extends AbstractController {
@Autowired
private CourseService courseService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
//查询列表数据
Query query = new Query(params);
List<CourseEntity> courseList = courseService.queryList(query);
int total = courseService.queryTotal(query);
PageUtils pageUtil = new PageUtils(courseList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 列表
*/
@RequestMapping("/list2")
public R list2(@RequestParam Map<String, Object> params){
Query query = new Query(params);
List<CourseEntity> courseList = courseService.queryList(query);
return R.ok().put("list", courseList );
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
CourseEntity course = courseService.queryObject(id);
return R.ok().put("course", course);
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody CourseEntity course){
courseService.save(course);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody CourseEntity course){
courseService.update(course);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
courseService.deleteBatch(ids);
return R.ok();
}
}
登录控制器
package com.learn.controller;
import com.learn.entity.SysUserEntity;
import com.learn.service.SysUserService;
import com.learn.utils.R;
import com.learn.utils.ShiroUtils;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
/**
* 登录相关
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2018年11月10日 下午1:15:31
*/
@Controller
public class SysLoginController {
@Autowired
private Producer producer;
@Autowired
private SysUserService sysUserService;
@RequestMapping("captcha.jpg")
public void captcha(HttpServletResponse response) throws ServletException, 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) throws IOException {
// String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
// if(!captcha.equalsIgnoreCase(kaptcha)){
// return R.error("验证码不正确");
// }
try {
Subject subject = ShiroUtils.getSubject();
//sha256加密
password = new Sha256Hash(password).toHex();
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
subject.login(token);
} catch (UnknownAccountException e) {
return R.error(e.getMessage());
} catch (IncorrectCredentialsException e) {
return R.error(e.getMessage());
} catch (LockedAccountException e) {
return R.error(e.getMessage());
} catch (AuthenticationException e) {
return R.error("账户验证失败");
}
return R.ok();
}
/**
*/
@ResponseBody
@RequestMapping(value = "/sys/reg", method = RequestMethod.POST)
public R reg(String username, String password, String captcha) throws IOException {
// String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
// if(!captcha.equalsIgnoreCase(kaptcha)){
// return R.error("验证码不正确");
// }
//sha256加密
SysUserEntity user = new SysUserEntity();
user.setUsername(username);
user.setPassword(password);
user.setStatus(1);
List<Long> roles = new ArrayList<>();
roles.add(1L);
user.setRoleIdList(roles);
this.sysUserService.save(user);
return R.ok();
}
/**
* 退出
*/
@RequestMapping(value = "logout", method = RequestMethod.GET)
public String logout() {
ShiroUtils.logout();
return "redirect:login.html";
}
}
用户控制器
package com.learn.controller;
import com.learn.entity.SysUserEntity;
import com.learn.service.SysUserRoleService;
import com.learn.service.SysUserService;
import com.learn.utils.PageUtils;
import com.learn.utils.Query;
import com.learn.utils.R;
import com.learn.utils.ShiroUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 系统用户
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2018年10月31日 上午10:40:10
*/
@RestController
@RequestMapping("/sys/user")
public class SysUserController extends AbstractController {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserRoleService sysUserRoleService;
/**
* 所有用户列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<SysUserEntity> userList = sysUserService.queryList(query);
int total = sysUserService.queryTotal(query);
PageUtils pageUtil = new PageUtils(userList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
@RequestMapping("/list2")
public R list2(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<SysUserEntity> userList = sysUserService.queryList(query);
return R.ok().put("list", userList);
}
/**
* 获取登录的用户信息
*/
@RequestMapping("/info")
public R info() {
return R.ok().put("user", this.sysUserService.queryObject(getUser().getUserId()));
}
/**
* 修改登录用户密码
*/
@RequestMapping("/password")
public R password(String password, String newPassword) {
//sha256加密
password = new Sha256Hash(password).toHex();
//sha256加密
newPassword = new Sha256Hash(newPassword).toHex();
//更新密码
int count = sysUserService.updatePassword(getUserId(), password, newPassword);
if (count == 0) {
return R.error("原密码不正确");
}
//退出
ShiroUtils.logout();
return R.ok();
}
@RequestMapping("/updateInfo")
public R updateInfo(@RequestBody SysUserEntity user) {
this.sysUserService.update(user);
return R.ok();
}
/**
* 用户信息
*/
@RequestMapping("/info/{userId}")
public R info(@PathVariable("userId") Long userId) {
SysUserEntity user = sysUserService.queryObject(userId);
//获取用户所属的角色列表
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(userId);
user.setRoleIdList(roleIdList);
return R.ok().put("user", user);
}
/**
* 保存用户
*/
@RequestMapping("/save")
public R save(@RequestBody SysUserEntity user) {
user.setCreateUserId(getUserId());
sysUserService.save(user);
return R.ok();
}
/**
* 修改用户
*/
@RequestMapping("/update")
public R update(@RequestBody SysUserEntity user) {
user.setCreateUserId(getUserId());
sysUserService.update(user);
return R.ok();
}
/**
* 删除用户
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] userIds) {
if (ArrayUtils.contains(userIds, 1L) || ArrayUtils.contains(userIds, -1L)) {
return R.error("系统管理员不能删除");
}
if (ArrayUtils.contains(userIds, getUserId())) {
return R.error("当前用户不能删除");
}
sysUserService.deleteBatch(userIds);
return R.ok();
}
}
如果也想学习本系统,下面领取。关注并回复:156ssm
本文含有隐藏内容,请 开通VIP 后查看