电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術文章
文章詳情頁

基于springboot+vue實現垃圾分類管理系統

瀏覽:103日期:2023-02-24 17:39:02

本文實例為大家分享了springboot+vue實現垃圾分類管理系統的具體代碼,供大家參考,具體內容如下

一、項目概述

1.項目內容

本項目利用IDEA,Visual Studio Code 開發工具,借助Mysql,Navicat for MySQL 工具,實現了一個基于springboot+vue的垃圾分類管理系統。系統為兩種類型的用戶提供服務,用戶和管理員。

2.實現功能

(1)登陸功能

通過和數據庫建立聯系后,數據庫內的用戶和管理員可在登錄頁面輸入賬號和密碼登陸網頁。

(2)數據的增、查、改、刪功能

① 垃圾的增、查、改、刪

② 管理員的增、查、改、刪

③ 用戶的增、查、改、刪

(3)通過餅狀圖,柱狀圖可顯示用戶的性別比例,入庫垃圾的數量信息,用戶總數,管理員總數,入庫垃圾數量,查詢次數等。

二、具體實現

1.前端登陸界面

<template> <div class='login-wrap'> <div class='ms-title'>垃圾分類信息管理系統</div> <div class='ms-login'> <el-form :model='ruleForm' :rules='rules' ref='ruleForm'><el-form-item prop='username'> <el-input v-model='ruleForm.username' placeholder='用戶名'></el-input></el-form-item><el-form-item prop='password'> <el-input type='password' v-model='ruleForm.password' placeholder='密碼'></el-input></el-form-item><div class='login-btn'> <el-button type='primary' @click='submitForm'>登錄</el-button></div> </el-form> </div> </div></template><script>import {mixin} from '../mixins/index';import {getLoginStatus} from '../api/index';export default { mixins:[mixin], data: function(){ return { ruleForm:{username: 'admin',password: '123' }, rules:{username:[ {required:true,message:'請輸入用戶名',trigger:'blur'}],password:[ {required:true,message:'請輸入密碼',trigger:'blur'}] } }; }, methods:{ submitForm(){ let params = new URLSearchParams(); params.append('name',this.ruleForm.username); params.append('password',this.ruleForm.password); getLoginStatus(params).then((res) =>{ if(res.code == 1){ this.$router.push('/Info'); this.notify('登錄成功','success'); }else{ this.notify('登錄失敗','error'); }}); } }}</script>

2.增刪改查實現

(1)管理員信息增刪改查:

/** * 添加管理員 **/ @RequestMapping(value = '/add',method = RequestMethod.POST) public Object addAdminGuanli(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String name = request.getParameter('name').trim();String username = request.getParameter('username').trim();String password = request.getParameter('password').trim();String pic = request.getParameter('pic').trim();String location = request.getParameter('location').trim();String introduction = request.getParameter('introduction').trim();//保存到管理員的對象中AdminGuanli adminGuanli = new AdminGuanli();adminGuanli.setName(name);adminGuanli.setUsername(username);adminGuanli.setPassword(password);adminGuanli.setPic(pic);adminGuanli.setLocation(location);adminGuanli.setIntroduction(introduction);boolean flag = AdminGuanliService.insert(adminGuanli);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'添加成功'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'添加失敗');return jsonObject; } /** * 修改管理員 **/ @RequestMapping(value ='/update',method = RequestMethod.POST) public Object updateAdminGuanli(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String id = request.getParameter('id').trim();String name = request.getParameter('name').trim();String username = request.getParameter('username').trim();String password = request.getParameter('password').trim();String location = request.getParameter('location').trim();String introduction = request.getParameter('introduction').trim();//保存到管理員的對象中AdminGuanli adminGuanli = new AdminGuanli();adminGuanli.setId(Integer.parseInt(id));adminGuanli.setName(name);adminGuanli.setUsername(username);adminGuanli.setPassword(password);adminGuanli.setLocation(location);adminGuanli.setIntroduction(introduction);boolean flag = AdminGuanliService.update(adminGuanli);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'修改成功'); System.out.println('11111111111111111'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'修改失敗');return jsonObject; } /** * 刪除管理員 **/ @RequestMapping(value ='/delete',method = RequestMethod.GET) public Object deleteAdminGuanli(HttpServletRequest request){String id = request.getParameter('id').trim();boolean flag = AdminGuanliService.delete(Integer.parseInt(id));return flag; } /** * 查詢管理員 **/ @RequestMapping(value ='/selectByPrimaryKey',method = RequestMethod.GET) public Object selectByPrimaryKey(HttpServletRequest request){String id = request.getParameter('id').trim();return AdminGuanliService.selectByPrimaryKey(Integer.parseInt(id)); } @RequestMapping(value ='/allAdminGuanli',method = RequestMethod.GET) public Object allAdminGuanli(HttpServletRequest request){return AdminGuanliService.allAdminGuanli(); } @RequestMapping(value ='/AdminGuanliOfName',method = RequestMethod.GET) public Object AdminGuanliOfName(HttpServletRequest request){String name = request.getParameter('name').trim();return AdminGuanliService.AdminGuanliOfName('%'+name+'#'); } /** * 更新管理員圖片 **/ @RequestMapping(value ='/updateAdminPic',method = RequestMethod.POST) public Object updateAdminPic(@RequestParam('file') MultipartFile avatorFile, @RequestParam('id')int id){JSONObject jsonObject = new JSONObject();if(avatorFile.isEmpty()){ jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'文件上傳失敗'); return jsonObject;}//文件名=當前時間到毫秒+原來文件名String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();//文件路徑String filePath = System.getProperty('user.dir')+System.getProperty('file.separator')+'img'+System.getProperty('file.separator')+'AdminPic';//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(file1.exists()){ file1.mkdir();}//實際文件路徑File dest = new File(filePath+System.getProperty('file.separator')+fileName);//存儲到數據庫的相對文件地址String storeAvatorPath = '/img/AdminPic/'+fileName;try { avatorFile.transferTo(dest); AdminGuanli adminGuanli = new AdminGuanli(); adminGuanli.setId(id); adminGuanli.setPic(storeAvatorPath); boolean flag = AdminGuanliService.update(adminGuanli); if(flag){jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,'上傳成功');jsonObject.put('pic',storeAvatorPath);return jsonObject; } jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'修改失敗'); return jsonObject;} catch (IOException e) { jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'修改失敗'+e.getMessage());}finally { return jsonObject;} }}

(2)垃圾信息增刪改查

/** * 添加垃圾信息 **/ @RequestMapping(value='/add',method= RequestMethod.POST) public Object addGarbage(HttpServletRequest request){JSONObject jsonObject=new JSONObject();String name=request.getParameter('name').trim();String type=request.getParameter('type').trim();String introduction=request.getParameter('introduction').trim();//保存到垃圾信息的對象當中Garbage garbage=new Garbage();garbage.setName(name);garbage.setType(type);garbage.setIntroduction(introduction);boolean flag=GarbageService.insert(garbage);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'添加成功'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'添加失敗');return jsonObject; } /** * 修改垃圾信息 **/ @RequestMapping(value = '/update',method = RequestMethod.POST) public Object updateGarbage(HttpServletRequest request){JSONObject jsonObject=new JSONObject();String id=request.getParameter('id').trim();String name=request.getParameter('name').trim();String type=request.getParameter('type').trim();String introduction=request.getParameter('introduction');//保存到垃圾信息的對象中去Garbage garbage=new Garbage();garbage.setId(Integer.parseInt(id));garbage.setName(name);garbage.setType(type);garbage.setIntroduction(introduction);boolean flag=GarbageService.update(garbage);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'修改成功'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'修改失敗');return jsonObject; }/** * 刪除垃圾信息 **/ @RequestMapping(value = '/delete',method = RequestMethod.GET) public Object deleteGarbage(HttpServletRequest request){String id=request.getParameter('id').trim();boolean flag=GarbageService.delete(Integer.parseInt(id));return flag; }/** * 查詢垃圾信息 **/ @RequestMapping(value = '/allGarbage',method = RequestMethod.GET) public Object allGarbage(HttpServletRequest request){return GarbageService.allGarbage(); }}

(3)用戶信息增刪改查

/** * 添加用戶 **/ @RequestMapping(value = '/add',method = RequestMethod.POST) public Object addUser(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String name = request.getParameter('name').trim();String username = request.getParameter('username').trim();String password = request.getParameter('password').trim();String sex = request.getParameter('sex').trim();String pic = request.getParameter('pic').trim();String birth = request.getParameter('birth').trim();String location = request.getParameter('location').trim();String contact = request.getParameter('contact').trim();DateFormat dateFormat = new SimpleDateFormat('yyyy-MM-dd');Date birthDate = new Date();try { birthDate = dateFormat.parse(birth);} catch (ParseException e) { e.printStackTrace();}System.out.println(name);//保存到用戶的對象中User user=new User();user.setName(name);user.setUsername(username);user.setPassword(password);user.setSex(new Byte(sex));user.setPic(pic);user.setBirth(birthDate);user.setLocation(location);user.setContact(contact);boolean flag = UserService.insert(user);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'添加成功'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'添加失敗');return jsonObject; }/** * 修改用戶 **/ @RequestMapping(value ='/update',method = RequestMethod.POST) public Object updateUser(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String id = request.getParameter('id').trim();String name = request.getParameter('name').trim();String username = request.getParameter('username').trim();String password = request.getParameter('password').trim();String sex = request.getParameter('sex').trim();String pic = request.getParameter('pic').trim();String birth = request.getParameter('birth').trim();String location = request.getParameter('location').trim();String contact = request.getParameter('contact').trim();DateFormat dateFormat = new SimpleDateFormat('yyyy-MM-dd');Date birthDate = new Date();try { birthDate = dateFormat.parse(birth);} catch (ParseException e) { e.printStackTrace();}//保存到用戶的對象中User user=new User();user.setId(Integer.parseInt(id));user.setName(name);user.setPassword(password);user.setSex(new Byte(sex));user.setPic(pic);user.setBirth(birthDate);user.setLocation(location);user.setContact(contact);boolean flag = UserService.update(user);if(flag){ jsonObject.put(Consts.CODE,1); jsonObject.put(Consts.MSG,'修改成功'); System.out.println('11111111111111111'); return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,'修改失敗');return jsonObject; }/** * 刪除用戶 **/ @RequestMapping(value ='/delete',method = RequestMethod.GET) public Object deleteUser(HttpServletRequest request){String id = request.getParameter('id').trim();boolean flag = UserService.delete(Integer.parseInt(id));return flag; }/** * 查詢用戶 **/ @RequestMapping(value ='/selectByPrimaryKey',method = RequestMethod.GET) public Object selectByPrimaryKey(HttpServletRequest request){String id = request.getParameter('id').trim();return UserService.selectByPrimaryKey(Integer.parseInt(id)); } @RequestMapping(value ='/allUser',method = RequestMethod.GET) public Object allUser(HttpServletRequest request){return UserService.allUser(); } @RequestMapping(value ='/UserOfName',method = RequestMethod.GET) public Object UserOfName(HttpServletRequest request){String name = request.getParameter('name').trim();return UserService.userOfName('%'+name+'#'); }/** * 更新用戶圖片 **/ @RequestMapping(value ='/updateUserPic',method = RequestMethod.POST) public Object updateUserPic(@RequestParam('file') MultipartFile avatorFile, @RequestParam('id')int id){JSONObject jsonObject = new JSONObject();if(avatorFile.isEmpty()){ jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'文件上傳失敗'); return jsonObject;}//文件名=當前時間到毫秒+原來文件名String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();//文件路徑String filePath = System.getProperty('user.dir')+System.getProperty('file.separator')+'img'+System.getProperty('file.separator')+'userPic';//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(file1.exists()){ file1.mkdir();}//實際文件路徑File dest = new File(filePath+System.getProperty('file.separator')+fileName);//存儲到數據庫的相對文件地址String storeAvatorPath = '/img/userPic/'+fileName;try { avatorFile.transferTo(dest); User user = new User(); user.setId(id); user.setPic(storeAvatorPath); boolean flag = UserService.update(user); if(flag){jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,'上傳成功');jsonObject.put('pic',storeAvatorPath);return jsonObject; } jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'修改失敗'); return jsonObject;} catch (IOException e) { jsonObject.put(Consts.CODE,0); jsonObject.put(Consts.MSG,'修改失敗'+e.getMessage());}finally { return jsonObject;} }}

3.解決跨域問題

public class WebMvcConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) {registry.addMapping('/**').allowCredentials(true) /*訪問是否需要驗證*/.allowedOriginPatterns('*').allowedMethods('*'); }}三、功能演示

1.跟隨前端網址訪問網頁

基于springboot+vue實現垃圾分類管理系統

2.登陸主頁

基于springboot+vue實現垃圾分類管理系統

3.查看垃圾信息

基于springboot+vue實現垃圾分類管理系統

4.用戶管理頁面

基于springboot+vue實現垃圾分類管理系統

5.管理員管理頁面

基于springboot+vue實現垃圾分類管理系統

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | 智能风向风速仪,风速告警仪,数字温湿仪,综合气象仪(气象五要素)-上海风云气象仪器有限公司 | 压力喷雾干燥机,喷雾干燥设备,柱塞隔膜泵-无锡市闻华干燥设备有限公司 | 洗地机-全自动/手推式洗地机-扫地车厂家_扬子清洁设备 | 一点车讯-汽车网站,每天一点最新车讯! | 板式换网器_柱式换网器_自动换网器-郑州海科熔体泵有限公司 | 求是网 - 思想建党 理论强党 | 热镀锌槽钢|角钢|工字钢|圆钢|H型钢|扁钢|花纹板-天津千百顺钢铁贸易有限公司 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 六自由度平台_六自由度运动平台_三自由度摇摆台—南京全控科技 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 北京京云律师事务所 | 海外仓系统|国际货代系统|退货换标系统|WMS仓储系统|海豚云 | 药品仓库用除湿机-变电站用防爆空调-油漆房用防爆空调-杭州特奥环保科技有限公司 | 透平油真空滤油机-变压器油板框滤油机-滤油车-华之源过滤设备 | 超声波焊接机_超音波熔接机_超声波塑焊机十大品牌_塑料超声波焊接设备厂家 | 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | 聚合氯化铝厂家-聚合氯化铝铁价格-河南洁康环保科技 | 国产液相色谱仪-超高效液相色谱仪厂家-上海伍丰科学仪器有限公司 | 大行程影像测量仪-探针型影像测量仪-增强型影像测量仪|首丰百科 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 【电子厂招聘_普工招工网_工厂招聘信息平台】-工立方打工网 | 乙炔气体报警装置|固定式氯化氢检测仪|河南驰诚电气百科 | 北京开源多邦科技发展有限公司官网 | 2025世界机器人大会_IC China_半导体展_集成电路博览会_智能制造展览网 | 冷热冲击试验箱_温度冲击试验箱价格_冷热冲击箱排名_林频厂家 | 马尔表面粗糙度仪-MAHR-T500Hommel-Mitutoyo粗糙度仪-笃挚仪器 | ZHZ8耐压测试仪-上海胜绪电气有限公司 | 合肥制氮机_合肥空压机厂家_安徽真空泵-凯圣精机 | 硬度计_影像测量仪_维氏硬度计_佛山市精测计量仪器设备有限公司厂家 | 综合管廊模具_生态,阶梯护坡模具_检查井模具制造-致宏模具厂家 | 铸钢件厂家-铸钢齿轮-减速机厂家-淄博凯振机械有限公司 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 江苏全风,高压风机,全风环保风机,全风环形高压风机,防爆高压风机厂家-江苏全风环保科技有限公司(官网) | 路斯特伺服驱动器维修,伦茨伺服驱动器维修|万骏自动化百科 | 岩棉板|岩棉复合板|聚氨酯夹芯板|岩棉夹芯板|彩钢夹芯板-江苏恒海钢结构 | 标准光源箱|对色灯箱|色差仪|光泽度仪|涂层测厚仪_HRC大品牌生产厂家 | 餐饮小吃技术培训-火锅串串香培训「何小胖培训」_成都点石成金[官网] | 3d可视化建模_三维展示_产品3d互动数字营销_三维动画制作_3D虚拟商城 【商迪3D】三维展示服务商 广东健伦体育发展有限公司-体育工程配套及销售运动器材的体育用品服务商 | 土壤水分自动监测站-SM150便携式土壤水分仪-铭奥仪器 | 定硫仪,量热仪,工业分析仪,马弗炉,煤炭化验设备厂家,煤质化验仪器,焦炭化验设备鹤壁大德煤质工业分析仪,氟氯测定仪 | 高考志愿规划师_高考规划师_高考培训师_高报师_升学规划师_高考志愿规划师培训认证机构「向阳生涯」 |