基于javaweb+mysql的springboot智能垃圾分类系统(java+springboot+vue+maven+mysql)
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot智能垃圾分类系统(java+springboot+vue+maven+mysql)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
model.addAttribute("logTotal",operaterLogService.total());
model.addAttribute("dataTotal",databaseBakService.total());
model.addAttribute("onlineUserTotal", HttpSessionS.onlineUserCount);
model.addAttribute("associationTotal",associationService.count(Association.TEAM_AUDIT_SUCCESS));
model.addAttribute("activitesTotal",activitiesService.count(Activities.ACTIVITIES_AUDIT_SUCCESS));
model.addAttribute("styleTotal",styleService.count(Style.STYLE_AUDIT_SUCCESS));
model.addAttribute("studentTotal",studentService.count());
return "admin/system/index";
@ResponseBody
@RequestMapping(value = "/login",method = RequestMethod.POST)
public Result<Boolean> login(HttpServletRequest request,User user, String cpacha){
Map<String,String>ret=new HashMap<String,String>();
//没有ID 传个0进去 0不是Long类型 所以加个0l L
if(userService.isExistUsername(user.getUsername(),0l)){
return Result.error(CodeMsg.ADMIN_USER_NAME_EXIST);
//到这说明一切符合条件进行数据库新增
if(userService.save(user)==null){
return Result.error(CodeMsg.ADMIN_USER_ADD_ERROR);
operaterLogService.add("添加用户,用户名:"+user.getUsername());
return Result.success(true);
/**
* 用户编辑页面
* @param model
* @param id
return Result.error(CodeMsg.ADMIN_USER_ROLE_STATUS_ERROR);
//检查用户有哪些权限
if(byUsername.getRole().getAuthorities()==null ||byUsername.getRole().getAuthorities().size()==0){
return Result.error(CodeMsg.ADMIN_USER_ROLE_AUTHORITES_EMPTY);
//检查一切符合 可以登录
request.getSession().setAttribute(SessionConstant.SESSION_USER_LOGIN_KEY,byUsername);
//销毁session中的验证码
request.getSession().setAttribute("admin_login",null);
//将登录日志写入日志库
OperaterLog operaterLog=new OperaterLog();
operaterLog.setOperator(user.getUsername());
operaterLog.setContent("用户["+user.getUsername()+"]与["+ StringUtil.getFormatterDate(new Date(),"yyyy-MM-dd HH:mm:ss")+"]登录系统");
//调用方法
String code = redisTemplate.opsForValue().get(phone);
if(!StringUtils.isEmpty(code)){
return Result.error(CodeMsg.ADMIN_PHONE_SMS_EXIST);
//生成验证码并存储到redis中
code = UUID.randomUUID().toString().substring(0, 4);
HashMap<String, Object> param = new HashMap<>();
param.put("code",code);
boolean isSend = smsService.send(phone, "", param);
if(isSend){
redisTemplate.opsForValue().set(phone,code,5, TimeUnit.SECONDS);
return Result.success(true);
if(user.getRole()==null ||user.getRole().getId()==null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
if(user.getId()==null||user.getId().longValue()<=0){
return Result.error(CodeMsg.ADMIN_USER_NO_EXIST);
//判断数据库user表有没有这个用户名
if(userService.isExistUsername(user.getUsername(),user.getId().longValue())){
return Result.error(CodeMsg.ADMIN_USER_NAME_EXIST);
//将提交的用户信息指定字段复制到已存在的user对象中
User findbyId = userService.find(user.getId());
//把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
BeanUtils.copyProperties(user,findbyId,"id","createTime","updateTime");
model.addAttribute("logTotal",operaterLogService.total());
model.addAttribute("dataTotal",databaseBakService.total());
model.addAttribute("onlineUserTotal", HttpSessionS.onlineUserCount);
model.addAttribute("associationTotal",associationService.count(Association.TEAM_AUDIT_SUCCESS));
model.addAttribute("activitesTotal",activitiesService.count(Activities.ACTIVITIES_AUDIT_SUCCESS));
model.addAttribute("styleTotal",styleService.count(Style.STYLE_AUDIT_SUCCESS));
model.addAttribute("studentTotal",studentService.count());
return "admin/system/index";
@ResponseBody
@RequestMapping(value = "/login",method = RequestMethod.POST)
@RequestMapping(value = "/update_userInfo",method = RequestMethod.POST)
public String updateUserInfo(User user){
User loginedUser = SessionUtil.getLoginedUser();
loginedUser.setHeadPic(user.getHeadPic());
loginedUser.setEmail(user.getEmail());
loginedUser.setMobile(user.getMobile());
//首先保存到数据库
userService.save(loginedUser);
//更新session里的值
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY,loginedUser);
return "redirect:update_userInfo";
@RequestMapping(value = "/update_pwd",method = RequestMethod.GET)
* @param model
* @return
*/
@RequestMapping("/list")
public String list(Model model, User user, PageBean<User> pageBean){
model.addAttribute("usernmae",user.getUsername());
model.addAttribute("pageBean",userService.findList(user,pageBean));
model.addAttribute("title","用户列表");
return "admin/user/list";
/**
* 用户添加页面
* @param model
* @param
return Result.error(validate);
//表示实体信息合法,开始验证验证码是否为空、
if(StringUtils.isEmpty(cpacha)){
return Result.error(CodeMsg.CPACHA_EMPTY);
//说明验证码不为空,从session里获取验证码
Object attribute = request.getSession().getAttribute("admin_login");
if(attribute==null){
return Result.error(CodeMsg.SESSION_EXPIRED);
//表示session未失效,进一步判断用户填写的验证码是否正确
if(!cpacha.equalsIgnoreCase(attribute.toString())){
return Result.error(CodeMsg.CPACHA_ERROR);
//表示验证码正确,开始查询数据库,检验密码是否正确
User byUsername = userService.findByUsername(user.getUsername());
userService.save(loginedUser);
//更新session
//更新session里的值
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY,loginedUser);
return Result.success(true);
/**
* 日志管理页面
* @param model
* @param operaterLog
* @param pageBean
* @return
*/
model.addAttribute("usernmae",user.getUsername());
model.addAttribute("pageBean",userService.findList(user,pageBean));
model.addAttribute("title","用户列表");
return "admin/user/list";
/**
* 用户添加页面
* @param model
* @param
* @return
*/
@RequestMapping(value = "/add",method = RequestMethod.GET)
* @return
*/
@RequestMapping(value = "/delete_operator_log",method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(String ids){
if(!StringUtils.isEmpty(ids)){
String[] splitIds = ids.split(",");
for(String id:splitIds){
operaterLogService.delete(Long.valueOf(id));
return Result.success(true);
/**
public String index(Model model){
model.addAttribute("siteName",siteConfig.getSiteName());
model.addAttribute("siteUrl",siteConfig.getSiteUrl());
return "admin/system/login";
//登录成功后主页
@RequestMapping(value = "/index")
public String indext(Model model){
model.addAttribute("operatorLogs",operaterLogService.findLastLog(10));
model.addAttribute("userTotal",userService.total());
model.addAttribute("logTotal",operaterLogService.total());
model.addAttribute("dataTotal",databaseBakService.total());
model.addAttribute("onlineUserTotal", HttpSessionS.onlineUserCount);
model.addAttribute("associationTotal",associationService.count(Association.TEAM_AUDIT_SUCCESS));
User byUsername = userService.findByUsername(user.getUsername());
if(byUsername==null){
return Result.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);
//表示用户存在 进一步对比密码是否正确
if(!byUsername.getPassword().equals(user.getPassword())){
return Result.error(CodeMsg.ADMIN_PASSWORD_NO_ERROR);
//表示密码正确,将登录信息放入session中 并判断状态是否可用
if(byUsername.getStatus()!=byUsername.ADMIN_USER_STATUS_ENABLE){
return Result.error(CodeMsg.ADMIN_USER_STATUS_ERROR);
//检查用户是否有角色 状态是否被冻结
if(byUsername.getRole()==null||byUsername.getRole().getStatus()!= Role.ADMIN_ROLE_STATUS_ENABLE){
* @param oldPwd
* @param newPwd
* @return
*/
@ResponseBody
@RequestMapping(value = "/update_pwd",method = RequestMethod.POST)
public Result<Boolean> updatePwd(@RequestParam(name = "oldPwd",required = true) String oldPwd,
@RequestParam(name = "newPwd",required = true)String newPwd){
User loginedUser = SessionUtil.getLoginedUser();
if(!loginedUser.getPassword().equals(oldPwd)){
return Result.error(CodeMsg.ADMIN_USER_PASSWORD_OLD_ERROR);
if(StringUtils.isEmpty(newPwd)){
return Result.error(CodeMsg.ADMIN_USER_PASSWORD_NEW_ERROR);
return Result.success(true);
@ResponseBody
@RequestMapping(value = "/send",method = RequestMethod.POST)
public Result<Boolean> code(@RequestParam(name ="phoneName")String phone){
//调用方法
String code = redisTemplate.opsForValue().get(phone);
if(!StringUtils.isEmpty(code)){
return Result.error(CodeMsg.ADMIN_PHONE_SMS_EXIST);
//生成验证码并存储到redis中
code = UUID.randomUUID().toString().substring(0, 4);
HashMap<String, Object> param = new HashMap<>();
param.put("code",code);
boolean isSend = smsService.send(phone, "", param);
public String indext(Model model){
model.addAttribute("operatorLogs",operaterLogService.findLastLog(10));
model.addAttribute("userTotal",userService.total());
model.addAttribute("logTotal",operaterLogService.total());
model.addAttribute("dataTotal",databaseBakService.total());
model.addAttribute("onlineUserTotal", HttpSessionS.onlineUserCount);
model.addAttribute("associationTotal",associationService.count(Association.TEAM_AUDIT_SUCCESS));
model.addAttribute("activitesTotal",activitiesService.count(Activities.ACTIVITIES_AUDIT_SUCCESS));
model.addAttribute("styleTotal",styleService.count(Style.STYLE_AUDIT_SUCCESS));
model.addAttribute("studentTotal",studentService.count());
return "admin/system/index";
@ResponseBody
@RequestMapping(value = "/login",method = RequestMethod.POST)