失物招领平台|基于Springboot+Vue实现失物招领系统

作者简介:Java、前端、Python开发多年,做过高程,项目经理,架构师

主要内容:Java项目开发、Python项目开发、大学数据和AI项目开发、单片机项目设计、面试技术整理、最新技术分享

收藏点赞不迷路  关注作者有好处

文末获得源码

 项目编号:BS-XX-194

一,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

开发技术:Springboot+Vue

二,项目简介

目前高校对于信息化系统的应用和普及,己相当普遍,各种有助于教学的线上教学管理平台,有助于教务管理的教务管理系统等等都己被开发和应用起来,通过这些系统的应用和集成,有效的帮助高校实现数字化校园和智慧化校园的建设。本次课题主要实现一款校内的失物招领系统平台,帮助师生快速的找到自己丢失的物品,帮助丢失的物品快速的找到自己的主人,它有效的解决了传统线下黑板报式的失物招领方式,通过互联网的快速传播和信息浏览的方便性,提升了失物招领的效率。

在经过对目前相关失物招领业务流程进行调查研究后,本次毕业设计采用B/S架构设计开发了一款线上失物招领系统,技术上采用SpringBoot框架集成其它框架技术进行开发,数据库采用Mysql5.7进行数据管理,前端采用Vue框架结合ElementUI组件来实现页面布局和人机交互。实现了一款功能完整,界面友好的失物招领系统。

前端用户操作用例:

管理员操作用例

前端用户主要实现的功能具体描述如下。

(1)注册登陆:这是提供的最基本的功能模块,用户只有注册为失物招领系统的用户,才可以登陆进行定餐操作。

(2)公告浏览:可以在线查看系统平台发布的公告详情信息。

(3)在线交流:为师生提供一个在线交流的平台。

(4)失物招领:可以查看平台发布的招领信息,也可以在线发布自己捡拾的物品让失主认领。

(5)物品挂失:可在线查看别人挂失的物品,也可在线发布自己的寻物启示。

(6)宣传视频:可以在线查看平台发布的一些公益性的宣传视频。

(7)个人中心:可以管理个人的基本信息。

后台管理员功能介绍描述如下。

(1)管理员管理:对于线上订餐来讲,餐品是本系统的核心业务数据,系统平台提供的后台管理模块,可以实现对餐品的添加和管理操作功能。

(2)用户管理:对于在失物招领系统中注册的用户信息,后台管理员可以在线进行管理,对其进行删除或修改。

(3)公告管理:主要完成对失物招领系统中发布的公告信息进行管理。

(4)论坛管理:主要管理系统发布的交流贴子信息。

(5)失物招领管理:主要完成对于前端发布的失物招领信息的管理操作。

(6)物品挂失管理:主要完成对于系统展示的挂失物品的编辑和管理操作。

(7)宣传视频管理:完成对前端展示的宣传视频的管理操作。

(8)轮播图管理:完成对前端展示的广告轮播图片的替换。

三,系统展示

用户信息管理

失物招领管理

失物信息

统计信息

挂失管理

公告查看

失物查看

四,核心代码展示


package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 失物招领
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/shiwuzhaoling")
public class ShiwuzhaolingController {
    private static final Logger logger = LoggerFactory.getLogger(ShiwuzhaolingController.class);

    @Autowired
    private ShiwuzhaolingService shiwuzhaolingService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service
    @Autowired
    private YonghuService yonghuService;



    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = shiwuzhaolingService.queryPage(params);

        //字典表数据转换
        List<ShiwuzhaolingView> list =(List<ShiwuzhaolingView>)page.getList();
        for(ShiwuzhaolingView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ShiwuzhaolingEntity shiwuzhaoling = shiwuzhaolingService.selectById(id);
        if(shiwuzhaoling !=null){
            //entity转view
            ShiwuzhaolingView view = new ShiwuzhaolingView();
            BeanUtils.copyProperties( shiwuzhaoling , view );//把实体数据重构到view中

                //级联表
                YonghuEntity yonghu = yonghuService.selectById(shiwuzhaoling.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody ShiwuzhaolingEntity shiwuzhaoling, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,shiwuzhaoling:{}",this.getClass().getName(),shiwuzhaoling.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        else if("用户".equals(role))
            shiwuzhaoling.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<ShiwuzhaolingEntity> queryWrapper = new EntityWrapper<ShiwuzhaolingEntity>()
            .eq("shiwuzhaoling_uuid_number", shiwuzhaoling.getShiwuzhaolingUuidNumber())
            .eq("shiwuzhaoling_name", shiwuzhaoling.getShiwuzhaolingName())
            .eq("shiwuzhaoling_types", shiwuzhaoling.getShiwuzhaolingTypes())
            .eq("status_types", shiwuzhaoling.getStatusTypes())
            .eq("yonghu_id", shiwuzhaoling.getYonghuId())
            .eq("shiwuzhaoling_dizhi", shiwuzhaoling.getShiwuzhaolingDizhi())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ShiwuzhaolingEntity shiwuzhaolingEntity = shiwuzhaolingService.selectOne(queryWrapper);
        if(shiwuzhaolingEntity==null){
            shiwuzhaoling.setCreateTime(new Date());
            shiwuzhaolingService.insert(shiwuzhaoling);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody ShiwuzhaolingEntity shiwuzhaoling, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,shiwuzhaoling:{}",this.getClass().getName(),shiwuzhaoling.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(StringUtil.isEmpty(role))
//            return R.error(511,"权限为空");
//        else if("用户".equals(role))
//            shiwuzhaoling.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        //根据字段查询是否有相同数据
        Wrapper<ShiwuzhaolingEntity> queryWrapper = new EntityWrapper<ShiwuzhaolingEntity>()
            .notIn("id",shiwuzhaoling.getId())
            .andNew()
            .eq("shiwuzhaoling_uuid_number", shiwuzhaoling.getShiwuzhaolingUuidNumber())
            .eq("shiwuzhaoling_name", shiwuzhaoling.getShiwuzhaolingName())
            .eq("shiwuzhaoling_types", shiwuzhaoling.getShiwuzhaolingTypes())
            .eq("status_types", shiwuzhaoling.getStatusTypes())
            .eq("yonghu_id", shiwuzhaoling.getYonghuId())
            .eq("shiwuzhaoling_dizhi", shiwuzhaoling.getShiwuzhaolingDizhi())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ShiwuzhaolingEntity shiwuzhaolingEntity = shiwuzhaolingService.selectOne(queryWrapper);
        if("".equals(shiwuzhaoling.getShiwuzhaolingPhoto()) || "null".equals(shiwuzhaoling.getShiwuzhaolingPhoto())){
                shiwuzhaoling.setShiwuzhaolingPhoto(null);
        }
        if(shiwuzhaolingEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      shiwuzhaoling.set
            //  }
            shiwuzhaolingService.updateById(shiwuzhaoling);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        shiwuzhaolingService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<ShiwuzhaolingEntity> shiwuzhaolingList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            ShiwuzhaolingEntity shiwuzhaolingEntity = new ShiwuzhaolingEntity();
//                            shiwuzhaolingEntity.setShiwuzhaolingUuidNumber(data.get(0));                    //失物编号 要改的
//                            shiwuzhaolingEntity.setShiwuzhaolingName(data.get(0));                    //物品名称 要改的
//                            shiwuzhaolingEntity.setShiwuzhaolingTypes(Integer.valueOf(data.get(0)));   //物品类型 要改的
//                            shiwuzhaolingEntity.setStatusTypes(Integer.valueOf(data.get(0)));   //物品状态 要改的
//                            shiwuzhaolingEntity.setYonghuId(Integer.valueOf(data.get(0)));   //用户 要改的
//                            shiwuzhaolingEntity.setShiwuzhaolingPhoto("");//照片
//                            shiwuzhaolingEntity.setShiwuzhaolingTime(new Date(data.get(0)));          //拾遗时间 要改的
//                            shiwuzhaolingEntity.setShiwuzhaolingDizhi(data.get(0));                    //拾遗地址 要改的
//                            shiwuzhaolingEntity.setShiwuzhaolingContent("");//照片
//                            shiwuzhaolingEntity.setCreateTime(date);//时间
                            shiwuzhaolingList.add(shiwuzhaolingEntity);


                            //把要查询是否重复的字段放入map中
                                //失物编号
                                if(seachFields.containsKey("shiwuzhaolingUuidNumber")){
                                    List<String> shiwuzhaolingUuidNumber = seachFields.get("shiwuzhaolingUuidNumber");
                                    shiwuzhaolingUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> shiwuzhaolingUuidNumber = new ArrayList<>();
                                    shiwuzhaolingUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("shiwuzhaolingUuidNumber",shiwuzhaolingUuidNumber);
                                }
                        }

                        //查询是否重复
                         //失物编号
                        List<ShiwuzhaolingEntity> shiwuzhaolingEntities_shiwuzhaolingUuidNumber = shiwuzhaolingService.selectList(new EntityWrapper<ShiwuzhaolingEntity>().in("shiwuzhaoling_uuid_number", seachFields.get("shiwuzhaolingUuidNumber")));
                        if(shiwuzhaolingEntities_shiwuzhaolingUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(ShiwuzhaolingEntity s:shiwuzhaolingEntities_shiwuzhaolingUuidNumber){
                                repeatFields.add(s.getShiwuzhaolingUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [失物编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        shiwuzhaolingService.insertBatch(shiwuzhaolingList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }





    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = shiwuzhaolingService.queryPage(params);

        //字典表数据转换
        List<ShiwuzhaolingView> list =(List<ShiwuzhaolingView>)page.getList();
        for(ShiwuzhaolingView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ShiwuzhaolingEntity shiwuzhaoling = shiwuzhaolingService.selectById(id);
            if(shiwuzhaoling !=null){


                //entity转view
                ShiwuzhaolingView view = new ShiwuzhaolingView();
                BeanUtils.copyProperties( shiwuzhaoling , view );//把实体数据重构到view中

                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(shiwuzhaoling.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody ShiwuzhaolingEntity shiwuzhaoling, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,shiwuzhaoling:{}",this.getClass().getName(),shiwuzhaoling.toString());
        Wrapper<ShiwuzhaolingEntity> queryWrapper = new EntityWrapper<ShiwuzhaolingEntity>()
            .eq("shiwuzhaoling_uuid_number", shiwuzhaoling.getShiwuzhaolingUuidNumber())
            .eq("shiwuzhaoling_name", shiwuzhaoling.getShiwuzhaolingName())
            .eq("shiwuzhaoling_types", shiwuzhaoling.getShiwuzhaolingTypes())
            .eq("status_types", shiwuzhaoling.getStatusTypes())
            .eq("yonghu_id", shiwuzhaoling.getYonghuId())
            .eq("shiwuzhaoling_dizhi", shiwuzhaoling.getShiwuzhaolingDizhi())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ShiwuzhaolingEntity shiwuzhaolingEntity = shiwuzhaolingService.selectOne(queryWrapper);
        if(shiwuzhaolingEntity==null){
            shiwuzhaoling.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      shiwuzhaoling.set
        //  }
        shiwuzhaolingService.insert(shiwuzhaoling);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}

五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

 

 

猜你喜欢

转载自blog.csdn.net/whirlwind526/article/details/133513471