基于javaweb+mysql的springboot学生学科竞赛管理系统设计和实现(java+springboot+ssm+maven+html)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot学生学科竞赛管理系统设计和实现(java+springboot+ssm+maven+html)
主要技术、spring、 springmvc、 springboot、 mybatis 、 jquery 、 layUI、md5 、bootstarp.js tomcat、、拦截器等项目 主要功能:登录、用户、菜单管理、角色管理、权限管理、立项申请、报名、结、经费管理、审核、统计等
用户登录:输入账号密码和验证码登录登录、登陆后根据用户权限显示不同菜单、角色灵活控制。
管理后主要功能模块:用户管理、角色管理、承菜管理、权限管理、竞赛报名管理、经费申请和审核管理、项目结题管理、立项申请管理等具体功能
用户管理:用户列表的显示、数据的添加以及删除修改等操作。
角色管理:通过给用户绑定角色、角色控制菜单灵活显示菜单权限功能。用户可以新建多角色
菜单管理:
系统日志监控:aop切面编程实现日志记录操作
业务模块功能;
立项申请:
立项审核:
活动经费预算申请:
立项申请个人赛以及团队赛报名管理:录入报名相关信息字段
项目结题管理:
项目完成之后选择项目进行资金使用统计结题:录入金额
项目结题统计:
代码结构:idea、eclipse直接导入就可运行
//请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
sysLog.setMethod(className + "." + methodName + "()");
//请求的参数
Object[] args = joinPoint.getArgs();
try{
String params = new Gson().toJson(args[0]);
sysLog.setParams(params);
}catch (Exception e){
}
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
//用户名
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
sysLog.setUsername(username);
sysLog.setTime(time);
sysLog.setCreateDate(new Date());
//保存系统日志
sysLogService.save(sysLog);
}
}
/**
* .
*
*
*
*
*/
@RestController
@RequestMapping("/sys/personal")
public class PersonalController extends AbstractController {
@Autowired
private PersonalService personalService;
@Autowired
private ClosingService closingService;
@RequestMapping("/list")
public R list(Map<String, Object> params) {
PageUtils page = personalService.queryPage(params);
return R.ok().put("page", page);
}
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
Personal personal = personalService.getById(id);
return R.ok().put("personal", personal);
}
@RequestMapping("/save")
public R save(@RequestBody Personal personal) {
personalService.save(personal);
Closing closing = new Closing();
closing.setBid(personal.getId());
closing.setJtType("个人赛");
closing.setStartTime(new Date());
closing.setTitle(personal.getTitle());
closingService.save(closing);
return R.ok();
//目录、菜单
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 ;
}
}
}
/**
* .
*
*
*
*
*/
/**
* XSS过滤处理
*
*/
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
/**
PageUtils page = sysConfigService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 配置信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("sys:config:info")
@ResponseBody
public R info(@PathVariable("id") Long id){
SysConfigEntity config = sysConfigService.getById(id);
return R.ok().put("config", config);
}
/**
* 保存配置
*/
@SysLog("保存配置")
@RequestMapping("/save")
@RequiresPermissions("sys:config:save")
public R save(@RequestBody SysConfigEntity config){
ValidatorUtils.validateEntity(config);
sysConfigService.saveConfig(config);
return R.ok();
}
/**
* 修改配置
*/
@SysLog("修改配置")
@RequestMapping("/update")
@RequiresPermissions("sys:config:update")
public R update(@RequestBody SysConfigEntity config){
ValidatorUtils.validateEntity(config);
sysConfigService.update(config);
/**
* 系统日志,切面处理类
*
*/
@Aspect
@Component
public class SysLogAspect {
@Autowired
private SysLogService sysLogService;
@Pointcut("@annotation(io.renren.common.annotation.SysLog)")
public void logPointCut() {
}
@Around("logPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
long beginTime = System.currentTimeMillis();
//执行方法
Object result = point.proceed();
//执行时长(毫秒)
long time = System.currentTimeMillis() - beginTime;
//保存日志
saveSysLog(point, time);
return result;
}
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
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<SysMenuEntity> 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("上级菜单不能为空");
}
return result;
}
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
SysLog syslog = method.getAnnotation(SysLog.class);
if(syslog != null){
//注解上的描述
sysLog.setOperation(syslog.value());
}
//请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
sysLog.setMethod(className + "." + methodName + "()");
//请求的参数
Object[] args = joinPoint.getArgs();
try{
String params = new Gson().toJson(args[0]);
sysLog.setParams(params);
}catch (Exception e){
}
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
//用户名
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
sysLog.setUsername(username);
sysLog.setTime(time);
sysLog.setCreateDate(new Date());
/**
* 系统配置信息
*
*/
@RestController
@RequestMapping("/sys/config")
public class SysConfigController extends AbstractController {
@Autowired
private SysConfigService sysConfigService;
/**
* 所有配置列表
*/
@RequestMapping("/list")
@RequiresPermissions("sys:config:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = sysConfigService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 配置信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("sys:config:info")
@ResponseBody
public R info(@PathVariable("id") Long id){
SysConfigEntity config = sysConfigService.getById(id);
return R.ok().put("config", config);
}
/**
* 保存配置
*/
@SysLog("保存配置")
// cityService.updateById(city);
//
// return R.ok();
// }
//
// /**
// * 删除
// */
// @RequestMapping("/delete")
// @RequiresPermissions("sys:city:delete")
// public R delete(@RequestBody Long[] ids){
// cityService.removeByIds(Arrays.asList(ids));
//
// return R.ok();
// }
//
//}
@RestController
@RequestMapping("sys/dict")
public class SysDictController {
@Autowired
private SysDictService sysDictService;
@RequestMapping("/list")
@RequiresPermissions("sys:dict:list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = sysDictService.queryPage(params);
return R.ok().put("page", page);
}
@RequestMapping("/info/{id}")
@RequiresPermissions("sys:dict:info")
public R info(@PathVariable("id") Long id) {
SysDictEntity dict = sysDictService.getById(id);
return R.ok().put("dict", dict);
}
@RequestMapping("/save")
public R save(@RequestBody SysDictEntity dict) {
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("sys:dept:update")
public R update(@RequestBody SysDeptEntity dept){
sysDeptService.updateById(dept);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("sys:dept:delete")
public R delete(long deptId){
//判断是否有子部门
List<Long> deptList = sysDeptService.queryDetpIdList(deptId);
if(deptList.size() > 0){
return R.error("请先删除子部门");
}
sysDeptService.removeById(deptId);
return R.ok();
}
}
/**
* .
*
*
*
*
*/
*
*/
/**
* IP地址
*
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
/**
* 获取IP地址
*
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} catch (Exception e) {
logger.error("IPUtils ERROR ", e);
}
// //使用代理,则获取第一个IP地址
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
}
@RequestMapping("/test")
public R test2() {
List<SysDictEntity> list = sysDictService.list();
return R.ok().put("mapList", list);
}
@RequestMapping("/cshi")
public R cshi(@RequestParam("name") String name) {
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("id", 12);
map.put("name", "xxx街道");
Map<String, Object> map2 = new HashMap<>();
map2.put("id", 12);
map2.put("name", "xxx街道2");
list.add(map);
list.add(map2);
return R.ok().put("list", list);
}
@RequestMapping("/update")
@RequiresPermissions("sys:dict:update")
public R update(@RequestBody SysDictEntity dict) {
//校验类型
ValidatorUtils.validateEntity(dict);
sysDictService.updateById(dict);
return R.ok();
}
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
sysDictService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
return R.ok().put("menuList", menuList);
}
/**
* 所有菜单列表
*/
@RequestMapping("/list")
@RequiresPermissions("sys:menu:list")
public List<SysMenuEntity> list(){
List<SysMenuEntity> 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<SysMenuEntity> 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")
expenditure.setTotal(expenditure.getZhuche()+expenditure.getRate()+expenditure.getTrain()+expenditure.getGuidance()
+expenditure.getBonus()+expenditure.getOther()+expenditure.getHaocai());
expenditureService.save(expenditure);
return R.ok();
}
@RequestMapping("/update")
public R update(@RequestBody Expenditure expenditure){
if(expenditure.getId() == null){
save(expenditure);
}else{
expenditureService.updateById(expenditure);
}
return R.ok();
}
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
expenditureService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
@RestController
@RequestMapping("/sys/apply")
public class ApplyController extends AbstractController {
@Autowired
private ApplyService applyService;
@RequestMapping("/list")
public R list(Map<String, Object> params) {
PageUtils page = applyService.queryPage(params);
return R.ok().put("page", page);
}
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
Apply apply = applyService.getById(id);
continue;
}
if(parentId > sysDeptEntity.getParentId().longValue()){
parentId = sysDeptEntity.getParentId();
}
}
deptId = parentId;
}
return R.ok().put("deptId", deptId);
}
/**
* 信息
*/
@RequestMapping("/info/{deptId}")
@RequiresPermissions("sys:dept:info")
public R info(@PathVariable("deptId") Long deptId){
SysDeptEntity dept = sysDeptService.getById(deptId);
return R.ok().put("dept", dept);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("sys:dept:save")
public R save(@RequestBody SysDeptEntity dept){
sysDeptService.save(dept);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("sys:dept:update")
public R update(@RequestBody SysDeptEntity dept){
sysDeptService.updateById(dept);
sysLog.setTime(time);
sysLog.setCreateDate(new Date());
//保存系统日志
sysLogService.save(sysLog);
}
}
/**
* .
*
*
*
*
*/
/**
* 登录相关
*
*/
@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");
*/
@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<SysRoleEntity> 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<Long> menuIdList = sysRoleMenuService.queryMenuIdList(roleId);
role.setMenuIdList(menuIdList);