热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Java项目:垃圾分类管理系统的开发与设计(使用JavaSSM框架、Bootstrap、HTML、jQuery和MySQL数据库)

源码获取:博客首页资源里下载!项目介绍垃圾分类管理系统采用的是BS的结构。系统管理员具有小区管理、垃圾分类信息、垃圾站信息、垃圾运输信息、垃圾信息
源码获取:博客首页 "资源" 里下载!

项目介绍


垃圾分类管理系统采用的是B/S的结构。系统管理员具有小区管理、垃圾分类信息、垃圾站信息、垃圾运输信息、垃圾信息、报修管理,投诉管理等功能。本系统界面简单直观,易于操作和使用,交互性强。


环境需要


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版本;


技术栈


1. 后端:Spring SpringMVC MyBatis
2. 前端:HTML+CSS+Javascript+jQuery+bootstrap


使用说明


1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 将项目中yml配置文件中的数据库配置改为自己的配置

3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

   若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

4. 运行项目,输入localhost:8080/ 登录

5. 账户admin 密码123123

 

 

 

 

 

用户管理控制层:

@Controller("User")
@RequestMapping("/user")
public class UserController {private final Logger logger = LoggerFactory.getLogger(UserController.class);private final ResultMap resultMap;@Autowiredprivate UserService userService;@Autowiredprivate UserRoleService userRoleService;@Autowiredpublic UserController(ResultMap resultMap) {this.resultMap = resultMap;}@RequestMapping(value = "/getMessage", method = RequestMethod.GET)public ResultMap getMessage() {return resultMap.success().message("您拥有用户权限,可以获得该接口的信息!");}@RequestMapping(value = "/editUserPage")public String editUserPage(Long userId, Model model) {model.addAttribute("manageUser", userId);if (null != userId) {User user = userService.selectByPrimaryKey(userId);model.addAttribute("manageUser", user);}return "user/userEdit";}@ResponseBody@RequestMapping("/updateUser")public String updateUser(User user) {return userService.updateUser(user);}
}

垃圾分类控制层: 

@Controller("GarbageTypeController")
@RequestMapping("/admin/type")
public class GarbageTypeController {@Autowiredprivate GarbageTypeService garbageTypeService;private final Logger logger = LoggerFactory.getLogger(this.getClass());/*** 分类列表页面*/@RequestMapping("/typeList")public String fenleiList() {return "sa/typeList";}@RequestMapping("user/typeList")public String typeUserList() {return "sa/typeUserList";}/*** 返回查询数据*/@RequestMapping("/getAllByLimit")@ResponseBodypublic Object getAllByLimit(GarbageType categorization) {return garbageTypeService.getAllByLimit(categorization);}@RequestMapping(value = "/del")@ResponseBody@Transactionalpublic String delUser(Long id) {try {garbageTypeService.deleteById(id);return "SUCCESS";} catch (Exception e) {logger.error("删除异常", e);TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();return "ERROR";}}@RequestMapping(value = "/add")public String addUserPage() {return "sa/typeAdd";}@RequestMapping(value = "/updateOne")public String update(Integer id, Model model) {GarbageType g = garbageTypeService.getById(id);model.addAttribute("gtype", g);return "sa/typeAdd";}@RequestMapping(value = "/doAdd")@ResponseBody@Transactionalpublic String doAdd(GarbageType categorization) {try {categorization.setCreateTime(new Date());garbageTypeService.add(categorization);return "SUCCESS";} catch (Exception e) {logger.error("添加异常", e);TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();return "ERROR";}}@RequestMapping(value = "/update")@ResponseBody@Transactionalpublic String update(GarbageType categorization) {try {garbageTypeService.update(categorization);return "SUCCESS";} catch (Exception e) {logger.error("修改异常", e);TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();return "ERROR";}}
}

后台管理员控制层:

@Controller("Admin")
@RequestMapping("/admin")
public class Adminontroller {@Autowiredprivate PageService pageService;@Autowiredprivate RoleService roleService;@Autowiredprivate PageRoleService pageRoleService;@Autowiredprivate UserRoleService userRoleService;@Autowiredprivate UserService userService;private final Logger logger = LoggerFactory.getLogger(Adminontroller.class);/*** Method name: page
* Description: 跳转到页面设置页面
* * @param model* @return String
*/@RequestMapping("/page")public String page(Model model) {List pageList = pageService.getAllPage();model.addAttribute("pageList", pageList);return "sa/page";}/*** Method name: role
* Description: 跳转到角色设置页面
* * @param model* @return String
*/@RequestMapping("/role")public String role(Model model) {return "sa/role";}/*** Method name: getAllRole
* Description: 获取所有权限
* * @return List
*/@RequestMapping("/getAllRole")@ResponseBodypublic List getAllRole() {return roleService.getAllRole();}/*** Method name: getAllPage
* Description: 获取所有页面
* * @return List
*/@RequestMapping("/getAllPage")@ResponseBodypublic List getAllPage() {return pageService.getAllPage();}/*** Method name: getPageByRole
* Description: 获取某个角色的权限页面
*/@RequestMapping("/getPageByRole")@ResponseBodypublic Object getPageByRole(Integer roleId) {return pageService.getAllPageByRoleId(roleId);}/*** Method name: updatePageById
* Description: 根据页面id更新页面
* * @param page* @return ResultMap
*/@RequestMapping("/updatePageById")@ResponseBodypublic ResultMap updatePageById(Page page) {return pageService.updatePageById(page);}/*** Method name: addPage
* Description: 添加页面
* * @param page* @return Page
*/@RequestMapping("/addPage")@ResponseBodypublic Page addPage(Page page) {return pageService.addPage(page);}/*** Method name: delPageById
* Description: 根据页面id删除页面
* * @param id* @return ResultMap
*/@RequestMapping("/delPageById")@ResponseBodypublic ResultMap delPageById(Integer id) {if (null == id) {return new ResultMap().fail().message("参数错误");}return pageService.delPageById(id);}/*** Method name: addRole
* Description: 增加角色
* * @param name* @return String
*/@RequestMapping("/addRole")@ResponseBodypublic String addRole(String name) {return roleService.addRole(name);}/*** Method name: delManageRole
* Description: 根据角色id删除角色
* * @param id* @return String
*/@RequestMapping("/delRole")@ResponseBodypublic String delRole(int id) {// 删除角色boolean flag1 = roleService.delRoleById(id);// 删除角色_权限表boolean flag2 = pageRoleService.delPageRoleByRoleId(id);// 删除某个角色的所有用户boolean flag3 = userRoleService.delUserRoleByRoleId(id);if (flag1 && flag2 && flag3) {return "SUCCESS";}return "ERROR";}/*** Method name: updateRole
* Description: 根据权限id修改权限信息
* * @param id* @param name* @return String
*/@RequestMapping("/updateRole")@ResponseBodypublic String updateRole(Integer id, String name) {int n = roleService.updateRoleById(id, name);if (n != 0) {return "SUCCESS";}return "ERROR";}/*** Method name: addPageRoleByRoleId
* Description: 增加某个角色的权限页面
* * @param roleId* @param pageIds* @return String
*/@RequestMapping("/addPageRoleByRoleId")@ResponseBodypublic String addPageRoleByRoleId(Integer roleId, Integer[] pageIds) {if (null == roleId) {return "ERROR";}// 先删除老的权限boolean flag1 = pageRoleService.delPageRoleByRoleId(roleId);boolean flag2 = pageRoleService.addPageRoles(roleId, pageIds);if (flag1 && flag2) {return "SUCCESS";}return "ERROR";}/*** Method name: getAllUserByMap
* Description: 根据角色查询下面所有的人员/非角色下所有人员
*/@RequestMapping("/getAllUserByRoleId")@ResponseBodypublic Object getAllUserByRoleId(Integer roleId, String roleNot, Integer page, Integer limit) {if (null == roleNot) {return userService.getAllUserByRoleId(roleId, page, limit);}return userService.getAllUserByNotRoleId(roleId, page, limit);}/*** Method name: delUserRoleByUserIdAndRoleId
* Description: 根据用户id权限id删除用户权限表
* * @param userId* @param roleId* @return ResultMap
*/@RequestMapping("/delUserRoleByUserIdAndRoleId")@ResponseBodypublic ResultMap delUserRoleByUserIdAndRoleId(String userId, Integer roleId) {return userRoleService.delUserRoleByUserIdAndRoleId(userId, roleId);}/*** Method name: selectUserRole
* Description: 跳转到选择用户角色页面
* * @return String
*/@RequestMapping("/selectUserRole")public String selectUserRole() {return "sa/selectUserRole";}/*** Method name: addUserRole
* Description: 增加用户的角色
* * @param roleId* @param userIds* @return String
*/@RequestMapping("/addUserRole")@ResponseBodypublic String addUserRole(Integer roleId, String[] userIds) {return userRoleService.addUserRole(roleId, userIds);}/*** Method name: userAddPage
* Description: 用户添加页面
* * @return String
*/@RequestMapping(value = "/userAddPage")public String userAddPage() {return "sa/userAdd";}/*** Method name: userPage
* Description: 用户管理页面
* * @return String
*/@RequestMapping(value = "/userPage")public String userPage() {return "sa/userList";}/*** Method name: getAllUserByLimit
* Description: 根据条件获取所有用户
* * @param userParameter* @return Object
*/@RequestMapping("/getAllUserByLimit")@ResponseBodypublic Object getAllUserByLimit(UserParameter userParameter) {return userService.getAllUserByLimit(userParameter);}/*** Method name: getAllDelUserByLimit
* Description: 获取所有删除用户
* * @param userParameter* @return Object
*/@RequestMapping("/getAllDelUserByLimit")@ResponseBodypublic Object getAllDelUserByLimit(UserParameter userParameter) {return userService.getAllDelUserByLimit(userParameter);}/*** Method name: delUser
* Description: 批量删除用户
* * @param ids* @return String
*/@RequestMapping(value = "delUser")@ResponseBody@Transactionalpublic String delUser(Long[] ids) {Subject subject = SecurityUtils.getSubject();User user = (User) subject.getPrincipal();try {for (Long id : ids) {if (id.equals(user.getId())) {return "DontOP";}userService.delUserById(id);}return "SUCCESS";} catch (Exception e) {logger.error("根据用户id更新用户异常", e);TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();return "ERROR";}}/*** Method name: addUserPage
* Description: 增加用户界面
* * @return String
*/@RequestMapping(value = "/addUserPage")public String addUserPage(Long userId, Model model) {model.addAttribute("manageUser", userId);if (null != userId) {User user = userService.selectByPrimaryKey(userId);model.addAttribute("manageUser", user);}return "sa/userAdd";}/*** Method name: checkUserId
* Description: 检测用户账号是否存在
* * @param userId* @return User
*/@ResponseBody@RequestMapping("/checkUserId")public User checkUserId(Long userId) {return userService.selectByPrimaryKey(userId);}/*** Method name: addUser
* Description: 用户添加
* * @param user* @return String
*/@ResponseBody@RequestMapping("/addUser")public String addUser(User user) {try {user.setPassword(MD5.md5(user.getPassword()));user.setCreateTime(new Date());userService.addUser(user);User u = userService.getUserByPhoneAndName(user.getPhone(), user.getName());String[] ids = new String[1];ids[0] = u.getId()+"";userRoleService.addUserRole(3, ids);return "SUCCESS";} catch (Exception e) {return "ERR";}}/*** Method name: updateUser
* Description: 更新用户
* * @param user* @return String
*/@ResponseBody@RequestMapping("/updateUser")public String updateUser(User user, Long oldId) {return userService.updateUser(oldId, user);}/*** Method name: delUserPage
* Description: 已删除用户列表
* * @return String
*/@RequestMapping("/delUserPage")public String delUserPage() {return "sa/userDelPage";}}

源码获取:博客首页 "资源" 里下载! 

推荐阅读
author-avatar
多少年都不会变
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有