源码获取:博客首页 “资源” 里下载!

项目介绍 :

Spring Boot + SpringMVC + MyBatis+ Mysql + druid + Thymeleaf +HTML+CSS+JavaScrip+ Layui 开发的社区养老院管理系统

运行环境: 最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。

IDE环境: Eclipse,Myeclipse,IDEA或者Spring Tool Suite都可以
内置功能

管理员角色包含以下功能:

  1. 管理员登录
  2. 用户管理
  3. 床位类型管理
  4. 床位管理
  5. 护工管理
  6. 老人管理
  7. 预约登记管理
  8. 来访登记管理
  9. 健康记录管理
  10. 费用管理
  11. 外出记录管理

护工角色包含以下功能

  1. 护工登录
  2. 床位类型查看
  3. 床位查看
  4. 护工查看
  5. 老人查看
  6. 健康信息上报管理
  7. 费用查看等功能

预览项目

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
用户管理控制层:


/**
 * 用户表(User)表控制层
 *
 * @author 老王
 * @since 2022-03-21 16:02:42
 */
@RestController
@RequestMapping("admin/user")
public class UserController extends ResultController {

    private String prefix = "admin/user";
    /**
     * 服务对象
     */
    @Resource
    private UserService userService;


    /**
     * 到user页面
     */
    @GetMapping("/main")
    public ModelAndView main() {
        return jumpPage(prefix + "/main");
    }


    /**
     * 查询User列表
     *
     * @param user        筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */
    @ResponseBody
    @GetMapping("/data")
    public ResultTable list(User user, PageRequest pageRequest) {
        PageInfo<User> pageInfo = userService.selectUserPage(user, pageRequest);

        return pageTable(pageInfo.getList(), pageInfo.getTotal());
    }

    /**
     * 到新增User页面
     */
    @GetMapping("/add")
    public ModelAndView add() {
        return jumpPage(prefix + "/add");
    }

    /**
     * 新增保存User
     */
    @ResponseBody
    @PostMapping("/save")
    public Result save(@RequestBody User user) {
        User dbUser = userService.selectUserByAccountName(user.getAccountName());
        if (dbUser != null) {
            return failure("添加失败,账号已存在,请重新输入!");
        }
        int result = userService.insertUser(user);
        return decide(result);
    }

    /**
     * 到修改User页面
     */
    @GetMapping("/edit")
    public ModelAndView edit(Integer userId, ModelMap modelMap) {
        User user = userService.selectUserById(userId);
        modelMap.put("user", user);
        return jumpPage(prefix + "/edit");
    }

    /**
     * 修改保存User
     */
    @ResponseBody
    @PutMapping("/update")
    public Result update(@RequestBody User user) {
        User dbUser = userService.selectUserByAccountName(user.getAccountName());
        if (dbUser != null && !dbUser.getUserId().equals(user.getUserId())) {
            return failure("修改失败,账号已存在,请重新输入!");
        }
        int result = userService.updateUser(user);
        return decide(result);
    }

    /**
     * 批量删除User
     */
    @ResponseBody
    @DeleteMapping("/batchRemove")
    public Result batchRemove(Integer[] ids) {
        return decide(userService.deleteUserByIds(ids));
    }

    /**
     * 删除
     */
    @ResponseBody
    @DeleteMapping("/remove/{userId}")
    public Result remove(@PathVariable("userId") Integer userId) {
        return decide(userService.deleteUserById(userId));
    }

}


用户信息主页

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('用户列表')"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <div class="col-sm-12 search-collapse">
            <form id="formId" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="accountName" placeholder="请输入用户名"
                               class="layui-input" lay-required/>
                    </div>
                    <label class="layui-form-label">姓名:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="userName" placeholder="请输入姓名"
                               class="layui-input" lay-required/>
                    </div>
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="type-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="user-table" lay-filter="user-table"></table>
        <script type="text/html" id="type-toolbar">
            <button
                    class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                新增
            </button>
            <button
                    class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
                <i class="layui-icon layui-icon-delete"></i>
                批量删除
            </button>
        </script>
        <script type="text/html" id="type-bar">
            {{#  if(d.userId === 1){ }}
            <button
                    class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
                    class="layui-icon layui-icon-edit"></i>
            </button>
            {{#  } }}
            {{#  if(d.userId != 1){ }}
            <button
                    class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
                    class="layui-icon layui-icon-edit"></i>
            </button>
            <button
                    class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
                    class="layui-icon layui-icon-delete"></i>
            </button>
            {{#  } }}
        </script>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script>
    layui.use(["table", "form", "jquery", "dictionary"], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;

        let prefix = "/admin/user/";

        let cols = [
            [
                {type: "checkbox"},
                {
                    field: "userId",
                    title: "编号"
                },
                {
                    field: "accountName",
                    title: "用户名"
                },
                {
                    field: "userName",
                    title: "姓名"
                },
                {
                    field: "birthdate",
                    title: "出生日期"
                },
                {
                    field: "sex", title: "性别", templet: function (res) {
                        return res.sex === 1 ? "女" : "男";
                    }
                },
                {
                    field: "phone",
                    title: "联系方式"
                },
                {
                    field: "roleType", title: "角色类型", templet: function (res) {
                        return res.sex === 1 ? "护工" : "管理员";
                    }
                },
                {title: "操作", toolbar: "#type-bar", align: "center", width: 130}
            ]
        ];

        table.render({
            elem: "#user-table",
            url: prefix + "data",
            page: true,
            cols: cols,
            skin: "line",
            toolbar: "#type-toolbar",
            defaultToolbar: [{
                layEvent: "refresh",
                icon: "layui-icon-refresh",
            }, "filter", "print", "exports"]
        });

        table.on("tool(user-table)", function (obj) {
            if (obj.event === "remove") {
                window.remove(obj);
            } else if (obj.event === "edit") {
                window.edit(obj);
            }
        });

        table.on("toolbar(user-table)", function (obj) {
            if (obj.event === "add") {
                window.add();
            } else if (obj.event === "refresh") {
                window.refresh();
            } else if (obj.event === "batchRemove") {
                window.batchRemove(obj);
            }
        });

        form.on("submit(type-query)", function (data) {
            table.reload("user-table", {where: data.field});
            return false;
        });

        window.add = function () {
            layer.open({
                type: 2,
                title: "新增用户",
                shade: 0.1,
                area: ["550px", "600px"],
                content: prefix + "add"
            });
        };

        window.edit = function (obj) {
            layer.open({
                type: 2,
                title: "修改用户",
                shade: 0.1,
                area: ["550px", "600px"],
                content: prefix + 'edit?userId=' + obj.data['userId']
            });
        };

        window.remove = function (obj) {
            layer.confirm("确定要删除该用户", {icon: 3, title: "提示"}, function (index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: prefix + "remove/" + obj.data['userId'],
                    dataType: "json",
                    type: "delete",
                    success: function (result) {
                        layer.close(loading);
                        if (result.success) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                obj.del();
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                });
            });
        };

        window.batchRemove = function (obj) {
            let data = table.checkStatus(obj.config.id).data;
            if (data.length === 0) {
                layer.msg("未选中数据", {icon: 3, time: 1000});
                return false;
            }
            let ids = "";
            for (let i = 0; i < data.length; i++) {
                ids += data[i].userId + ",";
            }
            ids = ids.substr(0, ids.length - 1);
            layer.confirm("确定要删除这些用户", {icon: 3, title: "提示"}, function (index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: prefix + "batchRemove",
                    dataType: "json",
                    data: {"ids": ids},
                    type: "delete",
                    success: function (result) {
                        layer.close(loading);
                        if (result.success) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                table.reload("user-table");
                            });
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    }
                });
            });
        };

        window.refresh = function (param) {
            table.reload("user-table", {where: param});
        };
    });
</script>
</body>
</html>

源码获取:博客首页 “资源” 里下载!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐