摘要
本文旨在设计并实现一个基于Java SpringBoot和Vue技术的社区网格化管理服务平台。该平台主要包括用户功能和管理员功能两大部分,用户功能涵盖单位管理、问卷调查、论坛讨论、公告查看等;管理员功能则包括单位管理、基础数据维护、帖子和公告类型管理、人口状况管理等。通过前后端分离架构,利用SpringBoot框架在后端提供API接口,前端使用Vue.js进行数据交互,实现社区信息的数字化和智能化管理,提升社区管理效率和服务质量。
功能介绍
管理员和普通用户两种用户角色;
管理员:个人中心、管理员管理、基础数据管理、论坛管理、公告管理、意见征集管理、商业门店管理、单位管理、用户管理、问卷调查管理、试题管理、调查记录管理、轮播图管理等;
普通用户:个人中心、首页、论坛交流、问卷调查、意见征集、商业门店、单位、公告信息等。
技术介绍
后端:Java语言的Spring Boot框架、MySQL数据库、Maven依赖管理等;
前端:Vue、element-ui、axios等。
部分代码展示
public class DanweiController {private static final Logger logger = LoggerFactory.getLogger(DanweiController.class);private static final String TABLE_NAME = "danwei";@Autowiredprivate DanweiService danweiService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate ExampaperService exampaperService;//问卷调查@Autowiredprivate ExampapertopicService exampapertopicService;//问卷调查选题@Autowiredprivate ExamquestionService examquestionService;//试题表@Autowiredprivate ExamrecordService examrecordService;//调查记录表@Autowiredprivate ExamredetailsService examredetailsService;//答题详情表@Autowiredprivate ExamrewrongquestionService examrewrongquestionService;//错题表@Autowiredprivate ForumService forumService;//论坛@Autowiredprivate GonggaoService gonggaoService;//公告@Autowiredprivate LiuyanService liuyanService;//意见征集@Autowiredprivate ShangyemendianService shangyemendianService;//商业门店@Autowiredprivate YonghuService yonghuService;//用户@Autowiredprivate UsersService usersService;//管理员/*** 后端列表*/@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(false)return R.error(511,"永不会进入");else if("用户".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = danweiService.queryPage(params);//字典表数据转换List<DanweiView> list =(List<DanweiView>)page.getList();for(DanweiView 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);DanweiEntity danwei = danweiService.selectById(id);if(danwei !=null){//entity转viewDanweiView view = new DanweiView();BeanUtils.copyProperties( danwei , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody DanweiEntity danwei, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,danwei:{}",this.getClass().getName(),danwei.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<DanweiEntity> queryWrapper = new EntityWrapper<DanweiEntity>().eq("danwei_name", danwei.getDanweiName()).eq("danwei_address", danwei.getDanweiAddress()).eq("danwei_types", danwei.getDanweiTypes());logger.info("sql语句:"+queryWrapper.getSqlSegment());DanweiEntity danweiEntity = danweiService.selectOne(queryWrapper);if(danweiEntity==null){danwei.setCreateTime(new Date());danweiService.insert(danwei);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody DanweiEntity danwei, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,danwei:{}",this.getClass().getName(),danwei.toString());DanweiEntity oldDanweiEntity = danweiService.selectById(danwei.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");if("".equals(danwei.getDanweiPhoto()) || "null".equals(danwei.getDanweiPhoto())){danwei.setDanweiPhoto(null);}danweiService.updateById(danwei);//根据id更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<DanweiEntity> oldDanweiList =danweiService.selectBatchIds(Arrays.asList(ids));//要删除的数据danweiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 批量上传*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");try {List<DanweiEntity> danweiList = 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){//循环DanweiEntity danweiEntity = new DanweiEntity();danweiList.add(danweiEntity);//把要查询是否重复的字段放入map中//单位编号if(seachFields.containsKey("danweiUuidNumber")){List<String> danweiUuidNumber = seachFields.get("danweiUuidNumber");danweiUuidNumber.add(data.get(0));//要改的}else{List<String> danweiUuidNumber = new ArrayList<>();danweiUuidNumber.add(data.get(0));//要改的seachFields.put("danweiUuidNumber",danweiUuidNumber);}}//查询是否重复//单位编号List<DanweiEntity> danweiEntities_danweiUuidNumber = danweiService.selectList(new EntityWrapper<DanweiEntity>().in("danwei_uuid_number", seachFields.get("danweiUuidNumber")));if(danweiEntities_danweiUuidNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(DanweiEntity s:danweiEntities_danweiUuidNumber){repeatFields.add(s.getDanweiUuidNumber());}return R.error(511,"数据库的该表中的 [单位编号] 字段已经存在 存在数据为:"+repeatFields.toString());}danweiService.insertBatch(danweiList);return R.ok();}}}}catch (Exception e){e.printStackTrace();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));CommonUtil.checkMap(params);PageUtils page = danweiService.queryPage(params);//字典表数据转换List<DanweiView> list =(List<DanweiView>)page.getList();for(DanweiView 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);DanweiEntity danwei = danweiService.selectById(id);if(danwei !=null){//entity转viewDanweiView view = new DanweiView();BeanUtils.copyProperties( danwei , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody DanweiEntity danwei, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,danwei:{}",this.getClass().getName(),danwei.toString());Wrapper<DanweiEntity> queryWrapper = new EntityWrapper<DanweiEntity>().eq("danwei_name", danwei.getDanweiName()).eq("danwei_uuid_number", danwei.getDanweiUuidNumber()).eq("danwei_address", danwei.getDanweiAddress()).eq("danwei_types", danwei.getDanweiTypes())
// .notIn("danwei_types", new Integer[]{102});logger.info("sql语句:"+queryWrapper.getSqlSegment());DanweiEntity danweiEntity = danweiService.selectOne(queryWrapper);if(danweiEntity==null){danwei.setCreateTime(new Date());danweiService.insert(danwei);return R.ok();}else {return R.error(511,"表中有相同数据");}}}
演示视频
Java SpringBoot和Vue社区服务网格化管理系统