【计算机毕业设计】智慧养老平台

智慧养老平台设计与实现
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本智慧养老平台就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此智慧养老平台利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了老人基础数据的管理,家人管理,机构社区人员管理,服务管理,留言管理,公告信息的发布等功能。智慧养老平台的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
Java SSM智慧养老平台,后端基于SSM框架进行开发设计,前端页面效果通过使用JSP进行编码实现,主要实现了老人、家人、机构社区人员跟管理员角色,将实现服务记录管理、老人管理等功能。在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

package com.controller;


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.StringUtil;
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.DictionaryEntity;

import com.service.DictionaryService;
import com.entity.view.DictionaryView;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 字典表
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/dictionary")
public class DictionaryController {
    private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);

    @Autowired
    private DictionaryService dictionaryService;


    @Autowired
    private TokenService tokenService;



    //级联表service


    /**
    * 后端列表
    */
    @RequestMapping("/page")
    @IgnoreAuth
    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.isNotEmpty(role) && "老人".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        }
        params.put("orderBy","id");
        PageUtils page = dictionaryService.queryPage(params);

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

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

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
        Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
            .eq("dic_code", dictionary.getDicCode())
            .eq("code_index", dictionary.getCodeIndex())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
        if(dictionaryEntity==null){
            dictionary.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      dictionary.set
        //  }
            dictionaryService.insert(dictionary);
            //如果字典表新增数据的话,把数据再重新查出,放入监听器中
            List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
            ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
            Map<String, Map<Integer,String>> map = new HashMap<>();
            for(DictionaryEntity d :dictionaryEntities){
                Map<Integer, String> m = map.get(d.getDicCode());
                if(m ==null || m.isEmpty()){
                    m = new HashMap<>();
                }
                m.put(d.getCodeIndex(),d.getIndexName());
                map.put(d.getDicCode(),m);
            }
            servletContext.setAttribute("dictionaryMap",map);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
        //根据字段查询是否有相同数据
        Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
            .notIn("id",dictionary.getId())
            .eq("dic_code", dictionary.getDicCode())
            .eq("code_index", dictionary.getCodeIndex())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
        if(dictionaryEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      dictionary.set
            //  }
            dictionaryService.updateById(dictionary);//根据id更新
            //如果字典表修改数据的话,把数据再重新查出,放入监听器中
            List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
            ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
            Map<String, Map<Integer,String>> map = new HashMap<>();
            for(DictionaryEntity d :dictionaryEntities){
                Map<Integer, String> m = map.get(d.getDicCode());
                if(m ==null || m.isEmpty()){
                    m = new HashMap<>();
                }
                m.put(d.getCodeIndex(),d.getIndexName());
                map.put(d.getDicCode(),m);
            }
            servletContext.setAttribute("dictionaryMap",map);
            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());
        dictionaryService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }






}


package com.controller;


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.StringUtil;
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.JigoushequEntity;

import com.service.JigoushequService;
import com.entity.view.JigoushequView;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 机构社区人员
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/jigoushequ")
public class JigoushequController {
    private static final Logger logger = LoggerFactory.getLogger(JigoushequController.class);

    @Autowired
    private JigoushequService jigoushequService;


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



    //级联表service


    /**
    * 后端列表
    */
    @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.isNotEmpty(role) && "老人".equals(role)){
//            params.put("yonghuId",request.getSession().getAttribute("userId"));
//        }
        params.put("orderBy","id");
        PageUtils page = jigoushequService.queryPage(params);

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

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

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody JigoushequEntity jigoushequ, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,jigoushequ:{}",this.getClass().getName(),jigoushequ.toString());
        Wrapper<JigoushequEntity> queryWrapper = new EntityWrapper<JigoushequEntity>()
            .eq("username", jigoushequ.getUsername())
            .or()
            .eq("jigoushequ_phone", jigoushequ.getJigoushequPhone())
            .or()
            .eq("jigoushequ_id_number", jigoushequ.getJigoushequIdNumber())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        JigoushequEntity jigoushequEntity = jigoushequService.selectOne(queryWrapper);
        if(jigoushequEntity==null){
            jigoushequ.setCreateTime(new Date());
            jigoushequ.setPassword("123456");
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      jigoushequ.set
        //  }
            jigoushequService.insert(jigoushequ);
            return R.ok();
        }else {
            return R.error(511,"账户或者身份证号或者手机号已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody JigoushequEntity jigoushequ, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,jigoushequ:{}",this.getClass().getName(),jigoushequ.toString());
        //根据字段查询是否有相同数据
        Wrapper<JigoushequEntity> queryWrapper = new EntityWrapper<JigoushequEntity>()
            .notIn("id",jigoushequ.getId())
            .andNew()
            .eq("username", jigoushequ.getUsername())
            .or()
            .eq("jigoushequ_phone", jigoushequ.getJigoushequPhone())
            .or()
            .eq("jigoushequ_id_number", jigoushequ.getJigoushequIdNumber())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        JigoushequEntity jigoushequEntity = jigoushequService.selectOne(queryWrapper);
        if("".equals(jigoushequ.getJigoushequPhoto()) || "null".equals(jigoushequ.getJigoushequPhoto())){
                jigoushequ.setJigoushequPhoto(null);
        }
        if(jigoushequEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      jigoushequ.set
            //  }
            jigoushequService.updateById(jigoushequ);//根据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());
        jigoushequService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }

    /**
    * 登录
    */
    @IgnoreAuth
    @RequestMapping(value = "/login")
    public R login(String username, String password, String captcha, HttpServletRequest request) {
        JigoushequEntity jigoushequ = jigoushequService.selectOne(new EntityWrapper<JigoushequEntity>().eq("username", username));
        if(jigoushequ==null || !jigoushequ.getPassword().equals(password)) {
            return R.error("账号或密码不正确");
        }
        //  // 获取监听器中的字典表
        // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        // Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
        // Map<Integer, String> role_types = dictionaryMap.get("role_types");
        // role_types.get(yonghu.getRoleTypes());
        String token = tokenService.generateToken(jigoushequ.getId(),username, "jigoushequ", "机构社区人员");
        R r = R.ok();
        r.put("token", token);
        r.put("role","机构社区人员");
        r.put("username",jigoushequ.getJigoushequName());
        r.put("tableName","jigoushequ");
        r.put("userId",jigoushequ.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody JigoushequEntity jigoushequ){
    //    	ValidatorUtils.validateEntity(user);
        if(jigoushequService.selectOne(new EntityWrapper<JigoushequEntity>().eq("username", jigoushequ.getUsername()).orNew().eq("jigoushequ_phone",jigoushequ.getJigoushequPhone()).orNew().eq("jigoushequ_id_number",jigoushequ.getJigoushequIdNumber())) !=null) {
            return R.error("账户已存在或手机号或身份证号已经被使用");
        }
        jigoushequ.setCreateTime(new Date());
        jigoushequService.insert(jigoushequ);
        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id){
        JigoushequEntity jigoushequ = new JigoushequEntity();
        jigoushequ.setPassword("123456");
        jigoushequ.setId(id);
        jigoushequService.updateById(jigoushequ);
        return R.ok();
    }

    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrJigoushequ(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        JigoushequEntity jigoushequ = jigoushequService.selectById(id);
        return R.ok().put("data", jigoushequ);
    }


    /**
    * 退出
    */
    @GetMapping(value = "logout")
    public R logout(HttpServletRequest request) {
        request.getSession().invalidate();
        return R.ok("退出成功");
    }






}


package com.controller;


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.StringUtil;
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.YuleEntity;

import com.service.YuleService;
import com.entity.view.YuleView;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 娱乐活动
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/yule")
public class YuleController {
    private static final Logger logger = LoggerFactory.getLogger(YuleController.class);

    @Autowired
    private YuleService yuleService;


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



    //级联表service


    /**
    * 后端列表
    */
    @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.isNotEmpty(role) && "老人".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        }
        params.put("orderBy","id");
        PageUtils page = yuleService.queryPage(params);

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

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

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody YuleEntity yule, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,yule:{}",this.getClass().getName(),yule.toString());
        Wrapper<YuleEntity> queryWrapper = new EntityWrapper<YuleEntity>()
            .eq("yule_name", yule.getYuleName())
            .eq("yule_types", yule.getYuleTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YuleEntity yuleEntity = yuleService.selectOne(queryWrapper);
        if(yuleEntity==null){
            yule.setInsertTime(new Date());
            yule.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      yule.set
        //  }
            yuleService.insert(yule);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody YuleEntity yule, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,yule:{}",this.getClass().getName(),yule.toString());
        //根据字段查询是否有相同数据
        Wrapper<YuleEntity> queryWrapper = new EntityWrapper<YuleEntity>()
            .notIn("id",yule.getId())
            .andNew()
            .eq("yule_name", yule.getYuleName())
            .eq("yule_types", yule.getYuleTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YuleEntity yuleEntity = yuleService.selectOne(queryWrapper);
        if(yuleEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      yule.set
            //  }
            yuleService.updateById(yule);//根据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());
        yuleService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }






}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JAVA编码选手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值