Java项目:垃圾回收管理系统(计算机毕业设计)

作者主页:Java毕设网

 简介: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. 后端:SpringBoot

2. 前端:Thymeleaf+HTML+CSS+jQuery

四、使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8085/ 登录,端口必须是8085

五、运行截图


六、相关代码

用户管理控制器

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private Producer producer;
    @Autowired
    private IUserService userService;

    @GetMapping("/captcha.jpg")
    public void captcha(HttpServletRequest request, HttpServletResponse response )
            throws IOException {
        response.setHeader("Cache-Control", "no-store, no-cache");
        response.setContentType("image/jpeg");
        //生成文字验证码
        String text = producer.createText();
        System.out.println(text);
        //生成图片验证码
        BufferedImage image = producer.createImage(text);
        HttpSession session = request.getSession();
        session.setAttribute(Constants.KAPTCHA_SESSION_KEY,text);

        session.setMaxInactiveInterval(60);
        ServletOutputStream out = response.getOutputStream();
        ImageIO.write(image, "jpg", out);
        IOUtils.closeQuietly(out);
    }


    @RequestMapping("/register")
    public Result register(@RequestBody RequestRegisterVo registerVo) throws IOException {
        //System.out.println(registerVo);
       // String avatarUrl = userService.avatarUpload(registerVo.getAvatarFile());
        //用户数据的校验
        if(ObjectUtils.isNotEmpty(userService.queryByUsername(registerVo.getUsername()))){
            System.out.println(registerVo.getUsername());
            return  Result.getFailure().setMsg("用户名已存在!!!");
        }
        if(ObjectUtils.isNotEmpty(userService.queryByTel(registerVo.getTel()))){
            return  Result.getFailure().setMsg("用户名已存在!!!");
        }
        if(VoUtilsTool.checkObjFieldIsNull(registerVo)){
            return Result.getFailure().setMsg("输入数据为空!!!");
        }
        if(registerVo.getPassword().trim().toCharArray().length < 8){
            return  Result.getFailure().setMsg("密码位数必须大于8!!!");
        }
        if(!PhoneFormatCheckUtils.isPhoneLegal(registerVo.getTel())){
            return  Result.getFailure().setMsg("手机号格式正确!!!");
        }

        //用户数据拷贝
        User user = new User();
        BeanUtils.copyProperties(registerVo,user);
        user.setPassword(DigestUtil.md5Hex(registerVo.getPassword()));
        user.setId(IdUtil.simpleUUID());
        user.setAvatarUrl("\\goodsImg\\avatar.jpg");
        //存入数据库中
        if(userService.saveOrUpdate(user)){
            return Result.getSuccess().setMsg("注册成功!!!");
        }else{
            return  Result.getFailure().setMsg("注册失败!!!");
        }
    }

    @RequestMapping("/login")
    public Result login(HttpServletRequest request, @RequestBody RequestLoginVo loginRequestVo){
        //System.out.println(loginRequestVo);
        HttpSession session = request.getSession();
        String trueCaptcha = (String) session.getAttribute(Constants.KAPTCHA_SESSION_KEY);
        if(!trueCaptcha.equalsIgnoreCase(loginRequestVo.getCaptcha())){
            return Result.getFailure().setMsg(StringConst.CAPTCHA_ERROR);
        }
        User user;
        if(ObjectUtils.isEmpty(userService.queryByUsername(loginRequestVo.getUsernameOrTel()))){
             user = userService.queryByTel(loginRequestVo.getUsernameOrTel());
        }else{
            user = userService.queryByUsername(loginRequestVo.getUsernameOrTel());
        }
        if(ObjectUtils.isEmpty(user) || !DigestUtil.md5Hex(loginRequestVo.getPassword()).
                equals(user.getPassword())){
            return Result.getFailure().setMsg(StringConst.LOGIN_ERROR);
        }
        Map<String,Object> result = new HashMap<>();
        result.put("userId",user.getId());
        result.put("userType",user.getType());

        return Result.getSuccess().setData(result);
    }

    @GetMapping("/getUserById/{userId}")
    public Result getUserById(@PathVariable String userId){
        return Result.getSuccess().setData(userService.getUserById(userId));
    }
    @DeleteMapping("/deleteByIds")
    public Result delete(@RequestBody RequestUserDeleteVo deleteVo){
        if(VoUtilsTool.checkObjFieldIsNull(deleteVo)){
            return Result.getFailure().setMsg(StringConst.DELETE_SELECT_ERROR);
        }
        if(userService.removeByIds(deleteVo.getStringIds())){
            return  Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
        }else{
            return  Result.getFailure().setMsg(StringConst.DELETE_ERROR);
        }
    }
    @PostMapping("/list/{id}")
    public Result list(@RequestBody RequestUserListVo userListVo, @PathVariable String id){
        int type = userService.getById(id).getType();
        if(type== 0 || (type == 1 && userListVo.getType() == 1)){
            return Result.getFailure().setMsg("权限不足!!");
        }
        IPage<ResponseUserListVo> listVoIPage = userService.userList(userListVo,type);
        return Result.getSuccess().setData(listVoIPage);
    }

    @GetMapping("/updateByType/{userId}")
    public Result updateByType(@PathVariable String userId){
        if(userService.updateByType(userService.getById(userId))){
            return Result.getSuccess().setMsg("操作成功");
        }else{
            return Result.getFailure().setMsg("操作失败");
        }
    }

    @PostMapping("/update")
    public Result update(@RequestBody RequestUpdateUserVo requestUpdateUserVo){
        User user = userService.getById(requestUpdateUserVo.getId());
        BeanUtils.copyProperties(requestUpdateUserVo,user);
        if(userService.saveOrUpdate(user)){
            return Result.getSuccess().setMsg("修改成功");
        }else{
            return Result.getFailure().setMsg("修改失败");
        }
    }

    @PostMapping("/changePwd")
    public Result changePwd(@RequestBody RequestChangePwdVo requestChangePwdVo){
        User user = userService.getById(requestChangePwdVo.getId());
        if(!user.getPassword().equals(DigestUtil.md5Hex(requestChangePwdVo.getOldPassword()))){
            return Result.getFailure().setMsg("原密码错误");
        }
        if(requestChangePwdVo.getNewPassword().trim().toCharArray().length < 8){
            return  Result.getFailure().setMsg("密码位数必须大于8!!!");
        }
        user.setPassword(DigestUtil.md5Hex(requestChangePwdVo.getNewPassword()));
        if(userService.saveOrUpdate(user)){
            return Result.getSuccess().setMsg("修改成功");
        }else{
            return Result.getFailure().setMsg("修改失败");
        }
    }


    /**上传地址*/
    @Value("${file.upload.path}")
    private String uploadPath;
    /**
     * 上传图片
     * @param file
     */
    @RequestMapping("/upload")
    public Result upload(@RequestParam(value = "file") MultipartFile file,
                         @RequestParam(value = "userId") String id) {
        // 获取上传文件名
        String filename = file.getOriginalFilename();
        // 定义上传文件保存路径
        String path = uploadPath+"goodsImg/";
        // 新建文件
        File filepath = new File(path, filename);
        // 判断路径是否存在,如果不存在就创建一个
        if (!filepath.getParentFile().exists()) {
            filepath.getParentFile().mkdirs();
        }
        try {
            file.transferTo(new File(path + File.separator + filename));
        } catch (IOException e) {
            e.printStackTrace();
        }
        User user = userService.getById(id);
        user.setAvatarUrl("goodsImg/"+filename);
        userService.updateById(user);
        Map<String,String> img = new HashMap<>();
        img.put("src","goodsImg/"+filename);
        return Result.getSuccess().setData(img);
    }

    @GetMapping("/manage/{id}")
    public Result manage(@PathVariable String id){

        User user = userService.getById(id);

        if(user.getType() == 0){
            user.setType(1);
        }else if(user.getType() == 1){
            user.setType(0);
        }
        userService.updateById(user);

        return Result.getSuccess().setMsg("操作成功!!!");
    }

    @GetMapping("/resetPwd/{id}")
    public Result resetPwd(@PathVariable String id){
        User user = userService.getById(id);

        user.setPassword(DigestUtil.md5Hex("12345678"));

        userService.updateById(user);

        return Result.getSuccess().setMsg("操作成功!!!");
    }
}

前端管理控制器

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    INoticeService noticeService;

    @PostMapping("/saveOrUpdateNotice")
    public Result saveOrUpdateNotice(@RequestBody RequestSaveOrUpdateNoticeVo saveOrUpdateNoticeVo){
        if(ObjectUtils.isEmpty(saveOrUpdateNoticeVo.getTitle())){
            return Result.getFailure().setMsg(StringConst.NOTICE_IS_NULL);
        }
        String result = null;
        Notice notice;
        if(ObjectUtils.isEmpty(saveOrUpdateNoticeVo.getId())){
            notice = new Notice();
            BeanUtils.copyProperties(saveOrUpdateNoticeVo,notice);
            result = "添加";
        }else{
            notice = noticeService.getById(saveOrUpdateNoticeVo.getId());
            BeanUtils.copyProperties(saveOrUpdateNoticeVo,notice);
            result = "修改";
        }
        if(!noticeService.saveOrUpdate(notice)){
            return  Result.getFailure().setMsg(result +"失败了。");
        }
        return Result.getSuccess().setMsg(result + "成功啦!");
    }

    @DeleteMapping("/deleteByIds")
    public Result delete(@RequestBody RequestDeleteVo deleteVo){
        if(VoUtilsTool.checkObjFieldIsNull(deleteVo)){
            return Result.getFailure().setMsg(StringConst.DELETE_SELECT_ERROR);

        }
        if(noticeService.removeByIds(deleteVo.getIntegerIds())){
            return  Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
        }else{
            return  Result.getFailure().setMsg(StringConst.DELETE_ERROR);
        }
    }

    @PostMapping("/list")
    public Result noticeList(@RequestBody RequestNoticeListVo noticeListVo){
        IPage<Notice> listVoIPage = noticeService.noticeList(noticeListVo);
        return Result.getSuccess().setData(listVoIPage);
    }

    @GetMapping("/getById/{id}")
    public Result getById( @PathVariable Integer id){
        return Result.getSuccess().setData(noticeService.getById(id));
    }

}

七、如果也想学习本系统,下面领取。关注并回复:092sb

  • 19
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值