基于springboot养老院管理系统源码

本文介绍了基于SpringBoot和Mybatis开发的养老院管理系统,涉及超级管理员和用户的不同功能,如账号管理、健康档案管理等,并展示了SorttypeController中关键操作的实现,包括分页查询和数据CRUD操作。

基于springboot的养老院管理系统326,本系统为后台管理系统,分为三个角色,分别是超级管理员、管理员、用户。

超级管理员、管理员的功能如下:
登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理; 其中超级管理员可进行管理员账号管理;

用户的功能如下:
登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准

开发工具:idea (eclipse) 环境:jdk1.8  mysql5.7

后端:springboot+Mybatis

2.前端:HTML+thymeleaf+Javascript+css

 

package com.module.controller;

import com.github.pagehelper.Page;
import com.module.mapper.SorttypeMapper;
import com.module.pojo.Sorttype;
import com.module.util.ResultUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 页面请求控制  分类管理
 */
@Controller
public class SorttypeController {
    @Autowired
    SorttypeMapper sorttypeMapper;


    /**
     * 跳转到列表页面
     *
     * @return
     */
    @RequestMapping("manage/sorttypeList")
    public String sorttypeList() {
        return "manage/sorttype/sorttypeList";
    }

    /**
     * 跳转到添加页面
     *
     * @return
     */
    @RequestMapping("manage/addSorttype")
    public String addSorttype(Model model) {
        return "manage/sorttype/saveSorttype";
    }

    /**
     * 跳转到修改页面
     *
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("manage/editSorttype")
    public String editSorttype(Integer id, Model model) {
        Sorttype sorttype = sorttypeMapper.selectSorttypeById(id);
        model.addAttribute("sorttype", sorttype);
        return "manage/sorttype/saveSorttype";
    }

    /**
     * 查看详情页面
     *
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("manage/sorttypeInfo")
    public String sorttypeInfo(Integer id, Model model) {
        Sorttype sorttype = sorttypeMapper.selectSorttypeById(id);
        model.addAttribute("sorttype", sorttype);
        return "manage/sorttype/sorttypeInfo";
    }


    /**
     * 分页查询
     *
     * @param page  默认第一页
     * @param limit 默认每页显示10条
     * @return
     */
    @RequestMapping("manage/querySorttypeList")
    @ResponseBody
    public ResultUtil getCarouseList(Integer page, Integer limit, String keyword) {
        if (null == page) { //默认第一页
            page = 1;
        }
        if (null == limit) { //默认每页10条
            limit = 10;
        }
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(keyword)) {
            map.put("keyword", keyword);
        }
        Page pageHelper = PageHelper.startPage(page, limit, true);
        pageHelper.setOrderBy(" id desc ");
        List<Sorttype> list = sorttypeMapper.selectAll(map);
        PageInfo<Sorttype> pageInfo = new PageInfo<Sorttype>(list);  //使用mybatis分页插件
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(0);  //设置返回状态0为成功
        resultUtil.setCount(pageInfo.getTotal());  //获取总记录数目 类似count(*)
        resultUtil.setData(pageInfo.getList());    //获取当前查询出来的集合
        return resultUtil;
    }

    /**
     * 插入记录
     */
    @RequestMapping("manage/saveSorttype")
    @ResponseBody
    public ResultUtil saveSorttype(Sorttype sorttype, HttpSession session) {
        Date nowTime = new Date();
        sorttype.setCreatetime(nowTime);
        try {
            sorttypeMapper.insertSorttype(sorttype);
            return ResultUtil.ok("添加分类成功");
        } catch (Exception e) {
            return ResultUtil.error("添加分类出错,稍后再试!");
        }
    }

    /**
     * 更新记录
     */
    @RequestMapping("manage/updateSorttype")
    @ResponseBody
    public ResultUtil updateSorttype(Sorttype sorttype, HttpSession session) {
        Date nowTime = new Date();
        sorttype.setCreatetime(nowTime);
        try {
            sorttypeMapper.updateSorttype(sorttype);
            return ResultUtil.ok("修改分类成功");
        } catch (Exception e) {
            return ResultUtil.error("修改分类出错,稍后再试!");
        }
    }


    /**
     * 根据ID删除
     *
     * @param id
     * @return
     */
    @RequestMapping("manage/deleteSorttype")
    @ResponseBody
    public ResultUtil deleteSorttypeById(Integer id) {
        try {
            sorttypeMapper.deleteSorttypeById(id);
            return ResultUtil.ok("删除分类成功");
        } catch (Exception e) {
            return ResultUtil.error("删除分类出错,稍后再试!");
        }
    }

    /**
     * 根据ID批量删除
     *
     * @param idsStr
     * @return
     */
    @RequestMapping("manage/deletesSorttype")
    @ResponseBody
    public ResultUtil deletesSorttype(String idsStr) {
        try {
            if (!StringUtils.isBlank(idsStr)) {
                String[] ids = idsStr.split(",");
                for (String id : ids) {
                    sorttypeMapper.deleteSorttypeById(Integer.parseInt(id));
                }
            }
            return ResultUtil.ok("批量删除分类成功");
        } catch (Exception e) {
            return ResultUtil.error("删除分类出错,稍后再试!");
        }
    }


}

 

 

评论 12
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值