老年人评估系统开发记录02(登录注册,和老人信息登记)

登录注册
今天聚焦于项目的登录注册,这两个操作十分基础,曾经写过很多次,没有什么要注意的下面直接给出代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .form-div {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            text-align: center;
        }

        .form-div h1 {
            color: #333;
            margin: 0 0 20px;
        }

        .form-div a {
            color: #007BFF;
            text-decoration: none;
            font-size: 14px;
        }

        .form-div a:hover {
            text-decoration: underline;
        }

        form {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        table {
            width: 100%;
            margin-bottom: 20px;
            border-collapse: collapse;
        }

        table td {
            padding: 10px 0;
            text-align: left;
        }

        table td:first-child {
            width: 30%;
            font-weight: bold;
        }

        table td.input {
            width: 70%;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        input[type="text"]:focus,
        input[type="password"]:focus {
            outline: none;
            border-color: #007BFF;
        }

        .buttons {
            display: flex;
            justify-content: space-between;
            width: 100%;
        }

        input[type="submit"] {
            padding: 10px 20px;
            font-size: 16px;
            color: #fff;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
            width: 100%;
        }

        input[type="submit"]:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="form-div">
    <form action="/Older/LoginServlet" method="post" id="form">
        <h2>欢迎使用老年人能力评估系统</h2>
        <table>
            <tr>
                <td>用户名:</td>
                <td class="input">
                    <input id="UserID" name="UserID" type="text">
                </td>
            </tr>
            <tr>
                <td>密码:</td>
                <td class="input">
                    <input id="Password" name="Password" type="password">
                </td>
            </tr>
        </table>
        <div class="buttons">
            <input type="submit" value="登录">
            <a href="register.html">没有账号?点击注册</a>
        </div>
    </form>
</div>
</body>
</html>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎注册</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .form-div {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            text-align: center;
        }
        .reg-content {
            margin-bottom: 20px;
        }
        .reg-content h1 {
            color: #333;
            margin: 0 0 10px;
        }
        .reg-content a {
            color: #007BFF;
            text-decoration: none;
            font-size: 14px;
        }
        .reg-content a:hover {
            text-decoration: underline;
        }
        table {
            width: 100%;
            margin-bottom: 20px;
            border-collapse: collapse;
        }
        table td {
            padding: 10px 0;
            text-align: left;
        }
        table td:first-child {
            width: 30%;
            font-weight: bold;
        }
        table td.input {
            width: 70%;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }
        input[type="text"]:focus,
        input[type="password"]:focus {
            outline: none;
            border-color: #007BFF;
        }
        .err_msg {
            color: red;
            font-size: 12px;
            display: none;
        }
        .buttons {
            display: flex;
            justify-content: center;
        }
        #reg_btn {
            padding: 10px 20px;
            font-size: 16px;
            color: #fff;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        #reg_btn:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="form-div">
    <div class="reg-content">
        <h1>欢迎注册</h1>
        <a href="login.html">已有帐号?登录</a>
    </div>
    <form id="reg-form" action="/Older/RegisterServlet" method="post">
        <table>
            <tr>
                <td>用户ID</td>
                <td class="input">
                    <input name="userID" type="text" id="userID">
                    <br>
                    <span id="username_err" class="err_msg">用户名不太受欢迎</span>
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td class="input">
                    <input name="password" type="password" id="password">
                    <br>
                    <span id="password_err" class="err_msg">密码格式有误</span>
                </td>
            </tr>
        </table>
        <div class="buttons">
            <input value="注 册" type="submit" id="reg_btn">
        </div>
    </form>
</div>
</body>
</html>
insert into tb_user (UserID, Password) values (#{UserID}, #{Password});
<update id="updatePassword" >
    update tb_user
    <set>
        <if test="Password != null and Password != ''">
            Password = #{Password},
        </if>
    </set>
    where UserID = #{UserID};
</update>

<delete id="deleteByUserID">
    delete from tb_user where UserID = #{UserID}
</delete>

<select id="selectALL" resultType="com.QixunQiu.pojo.User">
    select *
    from tb_user ;
</select>
```
package com.QixunQiu.service;

import com.QixunQiu.mapper.UserMapper;
import com.QixunQiu.pojo.User;
import com.QixunQiu.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public class UserService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
    public User selectUser(String UserID, String Password) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User user = userMapper.select(UserID, Password);
        sqlSession.close();
        return user;
    }

    public void addUser(User user) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        userMapper.addUser(user);
        sqlSession.commit();
        sqlSession.close();
    }
}

信息登记
对于老人首先要记录老人的各项信息,实际上是实现一个对于老人信息的添加功能,一下是代码

        <select id="痴呆" name="痴呆" required>
            <option value="0">无</option>
            <option value="1">轻度</option>
            <option value="2">中度</option>
            <option value="3">重度</option>
        </select>
    </div>

    <!-- 精神疾病 -->
    <div class="表单组">
        <label for="精神疾病">精神疾病:</label>
        <select id="精神疾病" name="精神疾病" required>
            <option value="0">无</option>
            <option value="1">精神分裂症</option>
            <option value="2">双相情感障碍</option>
            <option value="3">偏执性精神障碍</option>
            <option value="4">分裂情感性障碍</option>
            <option value="5">癫痫所致精神障碍</option>
            <option value="6">精神发育迟滞伴发精神障碍</option>
        </select>
    </div>

    <!-- 慢性疾病 -->
    <div class="表单组">
        <label for="慢性疾病">慢性疾病:</label>
        <input type="text" id="慢性疾病" name="慢性疾病" placeholder="例如:高血压,糖尿病">
    </div>

    <!-- 跌倒 -->
    <div class="表单组">
        <label for="跌倒">跌倒:</label>
        <select id="跌倒" name="跌倒" required>
            <option value="0">无</option>
            <option value="1">发生过1次</option>
            <option value="2">发生过2次</option>
            <option value="3">发生过3次及以上</option>
        </select>
    </div>

    <!-- 走失 -->
    <div class="表单组">
        <label for="走失">走失:</label>
        <select id="走失" name="走失" required>
            <option value="0">无</option>
            <option value="1">发生过1次</option>
            <option value="2">发生过2次</option>
            <option value="3">发生过3次及以上</option>
        </select>
    </div>

    <!-- 噎食 -->
    <div class="表单组">
        <label for="噎食">噎食:</label>
        <select id="噎食" name="噎食" required>
            <option value="0">无</option>
            <option value="1">发生过1次</option>
            <option value="2">发生过2次</option>
            <option value="3">发生过3次及以上</option>
        </select>
    </div>

    <!-- 自杀 -->
    <div class="表单组">
        <label for="自杀">自杀:</label>
        <select id="自杀" name="自杀" required>
            <option value="0">无</option>
            <option value="1">发生过1次</option>
            <option value="2">发生过2次</option>
            <option value="3">发生过3次及以上</option>
        </select>
    </div>

    <!-- 其他意外事件 -->
    <div class="表单组">
        <label for="其他意外事件">其他意外事件:</label>
        <input type="text" id="其他意外事件" name="其他意外事件">
    </div>

    <!-- 提交按钮 -->
    <div class="表单组">
        <input type="submit" class="提交按钮" value="提交">
    </div>
</form>
</body>
</html>
package com.QixunQiu.service;

import com.QixunQiu.mapper.OlderMapper;
import com.QixunQiu.pojo.Older;
import com.QixunQiu.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class OlderService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
    public List<Older> selectOlder(String userID) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OlderMapper olderMapper = sqlSession.getMapper(OlderMapper.class);
        List<Older> olders=olderMapper.select(userID);
        sqlSession.close();
        return olders;
    }

    public void addOlder(Older older) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OlderMapper olderMapper = sqlSession.getMapper(OlderMapper.class);
        olderMapper.add(older);
        sqlSession.commit();
        sqlSession.close();
    }

    public Older selectOlderById(String userID) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        OlderMapper olderMapper = sqlSession.getMapper(OlderMapper.class);
        Older older=olderMapper.selectOlder(userID);
        sqlSession.close();
        return older;
    }
}
package com.QixunQiu.pojo;

import java.util.Date;

public class Older {
    private String AssessmentID ;
    private String AssessmentDate ;
    private int AssessmentReason;
    private String userID;

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getAssessmentDate() {
        return AssessmentDate;
    }

    public void setAssessmentDate(String assessmentDate) {
        AssessmentDate = assessmentDate;
    }

    public String getAssessmentID() {
        return AssessmentID;
    }

    public void setAssessmentID(String assessmentID) {
        AssessmentID = assessmentID;
    }

    public int getAssessmentReason() {
        return AssessmentReason;
    }

    public void setAssessmentReason(int assessmentReason) {
        AssessmentReason = assessmentReason;
    }


    // A.2.1 姓名
        private String name;

        // A.2.2 性别 (1: 男, 2: 女)
        private Integer gender;

        // A.2.3 出生日期
        private String birthDate;

        // A.2.4 身份证号
        private String idCard;

        // A.2.5 社保卡号
        private String socialSecurityCard;

        // A.2.6 民族 (1: 汉族, 2: 少数民族)
        private String ethnicity;


        // A.2.7 文化程度 (1: 文盲, 2: 小学, 3: 初中, 4: 高中/技校/中专, 5: 大学专科及以上, 6: 不详)
        private Integer educationLevel;

        // A.2.8 宗教信仰 (0: 无, 1: 有)
        private String religion;


        // A.2.9 婚姻状况 (1: 未婚, 2: 已婚, 3: 丧偶, 4: 离婚, 5: 未说明的婚姻状况)
        private Integer maritalStatus;

        // A.2.10 居住情况 (1: 独居, 2: 与配偶/伴侣居住, 3: 与子女居住, 4: 与父母居住, 5: 与兄弟姐妹居住, 6: 与其他亲属居住, 7: 与非亲属关系的人居住, 8: 养老机构)
        private Integer livingSituation;

        // A.2.11 医疗费用支付方式 (多选, 用逗号分隔)
        private String paymentMethod;

        // A.2.12 经济来源 (多选, 用逗号分隔)
        private String incomeSource;

        // A.2.13.1 痴呆 (0: 无, 1: 轻度, 2: 中度, 3: 重度)
        private Integer dementiaLevel;

        // A.2.13.2 精神疾病 (0: 无, 1: 精神分裂症, 2: 双相情感障碍, 3: 偏执性精神障碍, 4: 分裂情感性障碍, 5: 癫痫所致精神障碍, 6: 精神发育迟滞伴发精神障碍)
        private Integer mentalIllness;

        // A.2.13.3 慢性疾病 (可填写多个)
        private String chronicDiseases;

        // A.2.14.1 跌倒 (0: 无, 1: 发生过1次, 2: 发生过2次, 3: 发生过3次及以上)
        private Integer fallIncidents;

        // A.2.14.2 走失 (0: 无, 1: 发生过1次, 2: 发生过2次, 3: 发生过3次及以上)
        private Integer lostIncidents;

        // A.2.14.3 噎食 (0: 无, 1: 发生过1次, 2: 发生过2次, 3: 发生过3次及以上)
        private Integer chokingIncidents;

        // A.2.14.4 自杀 (0: 无, 1: 发生过1次, 2: 发生过2次, 3: 发生过3次及以上)
        private Integer suicideIncidents;

        // A.2.14.5 其他意外事件
        private String otherIncidents;

    @Override
    public String toString() {
        return "Older{" +
                "AssessmentID='" + AssessmentID + '\'' +
                ", AssessmentDate='" + AssessmentDate + '\'' +
                ", AssessmentReason=" + AssessmentReason +
                ", userID='" + userID + '\'' +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", birthDate=" + birthDate +
                ", idCard='" + idCard + '\'' +
                ", socialSecurityCard='" + socialSecurityCard + '\'' +
                ", ethnicity='" + ethnicity + '\'' +
                ", educationLevel=" + educationLevel +
                ", religion='" + religion + '\'' +
                ", maritalStatus=" + maritalStatus +
                ", livingSituation=" + livingSituation +
                ", paymentMethod='" + paymentMethod + '\'' +
                ", incomeSource='" + incomeSource + '\'' +
                ", dementiaLevel=" + dementiaLevel +
                ", mentalIllness=" + mentalIllness +
                ", chronicDiseases='" + chronicDiseases + '\'' +
                ", fallIncidents=" + fallIncidents +
                ", lostIncidents=" + lostIncidents +
                ", chokingIncidents=" + chokingIncidents +
                ", suicideIncidents=" + suicideIncidents +
                ", otherIncidents='" + otherIncidents + '\'' +
                '}';
    }

    public String getEthnicity() {
        return ethnicity;
    }

    public void setEthnicity(String ethnicity) {
        this.ethnicity = ethnicity;
    }

    public String getReligion() {
        return religion;
    }

    public void setReligion(String religion) {
        this.religion = religion;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(String birthDate) {
        this.birthDate = birthDate;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getSocialSecurityCard() {
        return socialSecurityCard;
    }

    public void setSocialSecurityCard(String socialSecurityCard) {
        this.socialSecurityCard = socialSecurityCard;
    }


    public Integer getEducationLevel() {
        return educationLevel;
    }

    public void setEducationLevel(Integer educationLevel) {
        this.educationLevel = educationLevel;
    }


    public Integer getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(Integer maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    public Integer getLivingSituation() {
        return livingSituation;
    }

    public void setLivingSituation(Integer livingSituation) {
        this.livingSituation = livingSituation;
    }



    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public Integer getDementiaLevel() {
        return dementiaLevel;
    }

    public void setDementiaLevel(Integer dementiaLevel) {
        this.dementiaLevel = dementiaLevel;
    }

    public Integer getMentalIllness() {
        return mentalIllness;
    }

    public void setMentalIllness(Integer mentalIllness) {
        this.mentalIllness = mentalIllness;
    }

    public String getIncomeSource() {
        return incomeSource;
    }

    public void setIncomeSource(String incomeSource) {
        this.incomeSource = incomeSource;
    }

    public Integer getFallIncidents() {
        return fallIncidents;
    }

    public void setFallIncidents(Integer fallIncidents) {
        this.fallIncidents = fallIncidents;
    }

    public Integer getChokingIncidents() {
        return chokingIncidents;
    }

    public void setChokingIncidents(Integer chokingIncidents) {
        this.chokingIncidents = chokingIncidents;
    }

    public String getOtherIncidents() {
        return otherIncidents;
    }

    public void setOtherIncidents(String otherIncidents) {
        this.otherIncidents = otherIncidents;
    }

    public Integer getSuicideIncidents() {
        return suicideIncidents;
    }

    public void setSuicideIncidents(Integer suicideIncidents) {
        this.suicideIncidents = suicideIncidents;
    }

    public Integer getLostIncidents() {
        return lostIncidents;
    }

    public void setLostIncidents(Integer lostIncidents) {
        this.lostIncidents = lostIncidents;
    }

    public String getChronicDiseases() {
        return chronicDiseases;
    }

    public void setChronicDiseases(String chronicDiseases) {
        this.chronicDiseases = chronicDiseases;
    }
}

posted @ 2025-02-18 21:46  元始天尊123  阅读(15)  评论(0)    收藏  举报