案例198基于Springboot的智能家居系统

发布时间:2024-12-14 09:13

创新乐趣案例20:小米的智能家居生态系统 #生活乐趣# #创新乐趣# #创新乐趣案例#

目录

功能描述

系统设计

功能展示

实现代码

为什么选择我?

项目推荐

获取源码

结尾名片获取源码

开发语言:Java

框架:SpringBoot

持久化框架:Mybatis-plus

JDK版本:JDK1.8

服务器:tomcat7\8\9

数据库:mysql 5.7以上

数据库工具:Navicat11以上

开发软件:eclipse/myeclipse/idea

Maven:Maven3.5.4

浏览器:谷歌浏览器\Edge

功能描述

社会和科技的不断进步带来更便利的生活,计算机技术也越来越平民化。二十一世纪是数据时代,各种信息经过统计分析都可以得到想要的结果,所以也可以更好的为人们工作、生活服务。智能家居是家庭的重要组成部分,家具管理、任务管理等都非常重要。把计算机技术和智能家居管理相结合可以更符合智能家居管理的要求,实现智能家居管理的最大价值。

本基于Springboot的智能家居系统采用Java语言和Vue技术,框架采用Springboot,搭配Mysql数据库,运行在Idea里。本基于Springboot的智能家居系统提供管理员、用户两种角色的服务。总的功能个人中心、基础数据管理、家具管理、任务管理和用户管理。本系统可以帮助用户发布任务,帮助管理员管理家具,本系统采用成熟技术开发可以完成智能家居管理的相关工作。

系统设计

系统的功能结构是采用树形图来绘制功能设计。根据分析所得,本系统的功能设计为管理员和用户两部分。管理员为高级角色,可以管理系统里的所有信息,包括用户信息。用户功能为发布任务和管理家具。本基于Springboot的智能家居系统的功能结构设计图如下图3-1所示:  

 

功能展示

用户登录界面起到验证身份的作用,本界面采用图片背景进行设计。在用户登录界面里设置了程序的名称和用户、密码、权限的文本框。在文本框下是登录按钮和用户注册按钮。用户在信息输入完成后可以使用这两个按钮进行相对应的操作。用户登录功能的实现界面如下图4-1所示:

 本功能的作用为修改当前登录用户的登录密码以及信息。本功能可以实现新密码的设置。个人中心管理功能的实现界面如下图4-2所示:

 

 管理员负责用户信息的审核和管理。用户的密码可以通过本功能重置。管理员查询用户信息的功能实现如下图4-3所示:

 管理员可以对家具的信息进行管理、审核。包括增加家具和淘汰家具,管理员查询家具信息的实现界面如下图4-4所示:

 管理员可以查询用户发布的任务指令,并对任务进行修改等必要操作。管理员查询任务功能的实现界面如下图4-5所示:

 管理员可以实现家具类型、区域类型的管理。管理员添加家具类型的实现界面如下图4-6所示:

 用户可以实现家具的查询和家具的新增、修改、删除。家具查询功能实现界面如下图4-7所示:

 用户可以发布任务,填写任务单就可以实现任务的发布。用户发布任务功能的实现界面如下图4-8所示:

 

实现代码

Controller层

package com.controller;

import java.util.Arrays;

import java.util.Calendar;

import java.util.Date;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.PostMapping;

import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;

import com.baomidou.mybatisplus.mapper.EntityWrapper;

import com.entity.TokenEntity;

import com.entity.UserEntity;

import com.service.TokenService;

import com.service.UserService;

import com.utils.CommonUtil;

import com.utils.MD5Util;

import com.utils.MPUtil;

import com.utils.PageUtils;

import com.utils.R;

import com.utils.ValidatorUtils;

@RequestMapping("users")

@RestController

public class UserController{

@Autowired

private UserService userService;

@Autowired

private TokenService tokenService;

@IgnoreAuth

@PostMapping(value = "/login")

public R login(String username, String password, String captcha, HttpServletRequest request) {

UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));

if(user==null || !user.getPassword().equals(password)) {

return R.error("账号或密码不正确");

}

String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());

return R.ok().put("token", token);

}

@IgnoreAuth

@PostMapping(value = "/register")

public R register(@RequestBody UserEntity user){

if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {

return R.error("用户已存在");

}

userService.insert(user);

return R.ok();

}

@GetMapping(value = "logout")

public R logout(HttpServletRequest request) {

request.getSession().invalidate();

return R.ok("退出成功");

}

@IgnoreAuth

@RequestMapping(value = "/resetPass")

public R resetPass(String username, HttpServletRequest request){

UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));

if(user==null) {

return R.error("账号不存在");

}

user.setPassword("123456");

userService.update(user,null);

return R.ok("密码已重置为:123456");

}

@RequestMapping("/page")

public R page(@RequestParam Map<String, Object> params,UserEntity user){

EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();

PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));

return R.ok().put("data", page);

}

@RequestMapping("/list")

public R list( UserEntity user){

EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();

ew.allEq(MPUtil.allEQMapPre( user, "user"));

return R.ok().put("data", userService.selectListView(ew));

}

@RequestMapping("/info/{id}")

public R info(@PathVariable("id") String id){

UserEntity user = userService.selectById(id);

return R.ok().put("data", user);

}

@RequestMapping("/session")

public R getCurrUser(HttpServletRequest request){

Long id = (Long)request.getSession().getAttribute("userId");

UserEntity user = userService.selectById(id);

return R.ok().put("data", user);

}

@PostMapping("/save")

public R save(@RequestBody UserEntity user){

if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {

return R.error("用户已存在");

}

userService.insert(user);

return R.ok();

}

@RequestMapping("/update")

public R update(@RequestBody UserEntity user){

userService.updateById(user);

return R.ok();

}

@RequestMapping("/delete")

public R delete(@RequestBody Long[] ids){

userService.deleteBatchIds(Arrays.asList(ids));

return R.ok();

}

}

Dao层

package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;

import com.baomidou.mybatisplus.mapper.Wrapper;

import com.baomidou.mybatisplus.plugins.pagination.Pagination;

import com.entity.UserEntity;

public interface UserDao extends BaseMapper<UserEntity> {

List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);

List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);

}

Server层

package com.service;

import java.util.List;

import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.Wrapper;

import com.baomidou.mybatisplus.service.IService;

import com.entity.UserEntity;

import com.utils.PageUtils;

public interface UserService extends IService<UserEntity> {

PageUtils queryPage(Map<String, Object> params);

List<UserEntity> selectListView(Wrapper<UserEntity> wrapper);

PageUtils queryPage(Map<String, Object> params,Wrapper<UserEntity> wrapper);

}

package com.service.impl;

import java.util.List;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;

import com.baomidou.mybatisplus.mapper.Wrapper;

import com.baomidou.mybatisplus.plugins.Page;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.dao.UserDao;

import com.entity.UserEntity;

import com.service.UserService;

import com.utils.PageUtils;

import com.utils.Query;

@Service("userService")

public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {

@Override

public PageUtils queryPage(Map<String, Object> params) {

Page<UserEntity> page = this.selectPage(

new Query<UserEntity>(params).getPage(),

new EntityWrapper<UserEntity>()

);

return new PageUtils(page);

}

@Override

public List<UserEntity> selectListView(Wrapper<UserEntity> wrapper) {

return baseMapper.selectListView(wrapper);

}

@Override

public PageUtils queryPage(Map<String, Object> params,

Wrapper<UserEntity> wrapper) {

Page<UserEntity> page =new Query<UserEntity>(params).getPage();

page.setRecords(baseMapper.selectListView(page,wrapper));

PageUtils pageUtil = new PageUtils(page);

return pageUtil;

}

}

权限验证

package com.interceptor;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.HashMap;

import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Component;

import org.springframework.web.method.HandlerMethod;

import org.springframework.web.servlet.HandlerInterceptor;

import com.annotation.IgnoreAuth;

import com.entity.EIException;

import com.entity.TokenEntity;

import com.service.TokenService;

import com.utils.R;

@Component

public class AuthorizationInterceptor implements HandlerInterceptor {

public static final String LOGIN_TOKEN_KEY = "Token";

@Autowired

private TokenService tokenService;

@Override

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");

response.setHeader("Access-Control-Max-Age", "3600");

response.setHeader("Access-Control-Allow-Credentials", "true");

response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");

response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));

IgnoreAuth annotation;

if (handler instanceof HandlerMethod) {

annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);

} else {

return true;

}

String token = request.getHeader(LOGIN_TOKEN_KEY);

if(annotation!=null) {

return true;

}

TokenEntity tokenEntity = null;

if(StringUtils.isNotBlank(token)) {

tokenEntity = tokenService.getTokenEntity(token);

}

if(tokenEntity != null) {

request.getSession().setAttribute("userId", tokenEntity.getUserid());

request.getSession().setAttribute("role", tokenEntity.getRole());

request.getSession().setAttribute("tableName", tokenEntity.getTablename());

request.getSession().setAttribute("username", tokenEntity.getUsername());

return true;

}

PrintWriter writer = null;

response.setCharacterEncoding("UTF-8");

response.setContentType("application/json; charset=utf-8");

try {

writer = response.getWriter();

writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));

} finally {

if(writer != null){

writer.close();

}

}

return false;

}

}

为什么选择我?

选择我作为您的毕业设计系统开发伙伴,是基于以下几个关键理由:

专业经验:我拥有丰富的软件开发经验,特别是在教育技术和信息系统方面。我了解毕业设计流程的复杂性,能够针对性地提供解决方案,确保系统的实用性和高效性。

定制化服务:我明白每个教育机构都有其独特的需求和挑战。我将与您紧密合作,深入了解您的具体要求,从而开发出完全符合您需求的定制化系统。

技术专长:我对最新的编程语言和开发工具有深入的了解,能够运用先进的技术来构建安全、稳定且易于维护的系统。无论是前端用户体验还是后端数据处理,我都能够提供专业的技术支持。

项目管理能力:我具备良好的项目管理技能,能够确保项目按时按质完成。我会制定详细的项目计划,并与您保持密切沟通,确保项目的每个阶段都能满足预期目标。

持续支持与维护:系统开发完成后,我将提供持续的技术支持和维护服务。这包括定期的系统更新、故障排除以及根据用户反馈进行的功能改进。

成本效益:我提供的是高性价比的服务。通过高效的项目管理和合理的资源配置,我能够在保证质量的前提下,为您节省不必要的开支。

综上所述,我的专业技能、定制化服务、技术专长、项目管理能力以及对客户的长期承诺,都是您选择我作为毕业设计系统开发伙伴的有力理由。

项目推荐

题目未定的小伙伴可以看看下面找找灵感

Java Spring Boot框架合集

Java 微信小程序(UNIAPP、云原生)合集

Java Android合集

Java SSM框架合集

Python Djaogo框架合集

获取源码

大家点赞、关注加收藏!下方名片获取源码啦!

网址:案例198基于Springboot的智能家居系统 https://www.yuejiaxmz.com/news/view/472471

相关内容

【计算机毕业设计】198智能家居系统
Springboot基于SpringBoot的宠物门诊系统6f8jy
基于springboot的疫情社区生活服务系统
基于Uniapp与SpringBoot的智能家居环境检测App设计与实现
Springboot基于springboot的校园生活工具租赁系统cftei
基于SpringBoot的线上学习资源智能推荐系统
【开题报告】基于SpringBoot的老年养生系统的设计与实现
【毕业设计】基于Springboot的公益捐赠管理系统的设计与实现
基于SpringBoot和VUE技术的智慧生活商城系统设计与实现
【毕业设计】基于SpringBoot + Vue的校园二手书交易管理系统

随便看看