老年人评估系统开发记录06(其他的功能和页面)

其他的功能和页面
今天对项目进行收尾工作,实现信息提供者信息的提交和展示.页面之间的跳转和其他项目中的代码

package com.QixunQiu.pojo;

public class Social{

    private String assessmentID; // 评估编号(主键)
    private Integer lifeAbility; // 生活能力评分
    private Integer workAbility; // 工作能力评分
    private Integer timeSpaceOrientation; // 时间/空间定向评分
    private Integer personOrientation; // 人物定向评分
    private Integer socialInteractionAbility; // 社会交往能力评分
    private Integer totalScore; // 社会参与总分
    private Integer participationGrade; // 社会参与分级

    // Default constructor
    public Social() {
    }

    // Parameterized constructor
    public Social(String assessmentID, Integer lifeAbility, Integer workAbility,
                            Integer timeSpaceOrientation, Integer personOrientation,
                            Integer socialInteractionAbility, Integer totalScore,
                            Integer participationGrade) {
        this.assessmentID = assessmentID;
        this.lifeAbility = lifeAbility;
        this.workAbility = workAbility;
        this.timeSpaceOrientation = timeSpaceOrientation;
        this.personOrientation = personOrientation;
        this.socialInteractionAbility = socialInteractionAbility;
        this.totalScore = totalScore;
        this.participationGrade = participationGrade;
    }

    // Getters and Setters
    public String getAssessmentID() {
        return assessmentID;
    }

    public void setAssessmentID(String assessmentID) {
        this.assessmentID = assessmentID;
    }

    public Integer getLifeAbility() {
        return lifeAbility;
    }

    public void setLifeAbility(Integer lifeAbility) {
        this.lifeAbility = lifeAbility;
    }

    public Integer getWorkAbility() {
        return workAbility;
    }

    public void setWorkAbility(Integer workAbility) {
        this.workAbility = workAbility;
    }

    public Integer getTimeSpaceOrientation() {
        return timeSpaceOrientation;
    }

    public void setTimeSpaceOrientation(Integer timeSpaceOrientation) {
        this.timeSpaceOrientation = timeSpaceOrientation;
    }

    public Integer getPersonOrientation() {
        return personOrientation;
    }

    public void setPersonOrientation(Integer personOrientation) {
        this.personOrientation = personOrientation;
    }

    public Integer getSocialInteractionAbility() {
        return socialInteractionAbility;
    }

    public void setSocialInteractionAbility(Integer socialInteractionAbility) {
        this.socialInteractionAbility = socialInteractionAbility;
    }

    public Integer getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(Integer totalScore) {
        this.totalScore = totalScore;
    }

    public Integer getParticipationGrade() {
        return participationGrade;
    }

    public void setParticipationGrade(Integer participationGrade) {
        this.participationGrade = participationGrade;
    }

    // toString method for debugging
    @Override
    public String toString() {
        return "SocialAssessment{" +
                "assessmentID='" + assessmentID + '\'' +
                ", lifeAbility=" + lifeAbility +
                ", workAbility=" + workAbility +
                ", timeSpaceOrientation=" + timeSpaceOrientation +
                ", personOrientation=" + personOrientation +
                ", socialInteractionAbility=" + socialInteractionAbility +
                ", totalScore=" + totalScore +
                ", participationGrade=" + participationGrade +
                '}';
    }
}
package com.QixunQiu.pojo;

public class Person {
    private String userID;
    private String olderID;
    private String providerName;
    private Integer relationship;
    private String otherRelationship;
    private String contactName;
    private String contactPhone;

    // Getter 和 Setter 方法
    public String getUserID() {
        return userID;
    }

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

    public String getOlderID() {
        return olderID;
    }

    public void setOlderID(String olderID) {
        this.olderID = olderID;
    }

    public String getProviderName() {
        return providerName;
    }

    public void setProviderName(String providerName) {
        this.providerName = providerName;
    }

    public Integer getRelationship() {
        return relationship;
    }

    public void setRelationship(Integer relationship) {
        this.relationship = relationship;
    }

    public String getOtherRelationship() {
        return otherRelationship;
    }

    public void setOtherRelationship(String otherRelationship) {
        this.otherRelationship = otherRelationship;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    @Override
    public String toString() {
        return "Person{" +
                "userID='" + userID + '\'' +
                ", olderID='" + olderID + '\'' +
                ", providerName='" + providerName + '\'' +
                ", relationship=" + relationship +
                ", otherRelationship='" + otherRelationship + '\'' +
                ", contactName='" + contactName + '\'' +
                ", contactPhone='" + contactPhone + '\'' +
                '}';
    }
}
package com.QixunQiu.service;

import com.QixunQiu.mapper.CommunicationMapper;
import com.QixunQiu.pojo.Communication;
import com.QixunQiu.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class CommunicationService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
    public List<Communication> select(String AssessmentID) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        CommunicationMapper communicationMapper = sqlSession.getMapper(CommunicationMapper.class);
        List<Communication> communicationList=communicationMapper.select(AssessmentID);
        sqlSession.close();
        return communicationList;
    }

    public void add(Communication communication) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        CommunicationMapper communicationMapper = sqlSession.getMapper(CommunicationMapper.class);
        communicationMapper.addCommunication(communication);
        sqlSession.commit();
        sqlSession.close();
    }
}

package com.QixunQiu.web;

import com.QixunQiu.pojo.Communication;
import com.QixunQiu.pojo.Daily;
import com.QixunQiu.pojo.Older;
import com.QixunQiu.pojo.User;
import com.QixunQiu.service.CommunicationService;
import com.QixunQiu.service.OlderService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/selectCommunicationServlet")
public class selectCommunicationServlet extends HttpServlet {
    private OlderService olderService = new OlderService();
    private CommunicationService communicationService = new CommunicationService();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        Older older=olderService.selectOlderById(user.getUserID());
        List<Communication> communicationList=communicationService.select(older.getAssessmentID());
        PrintWriter writer = response.getWriter();
        if(!communicationList.isEmpty()){
            // 登陆成功
            writer.write("登陆成功");
            System.out.println(communicationList);
            session.setAttribute("communicationList", communicationList);
            request.getRequestDispatcher("/communication.jsp").forward(request,response);

        }else {
            // 登陆失败
            writer.write("登陆失败");
            request.getRequestDispatcher("/addCommunication.jsp").forward(request,response);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

package com.QixunQiu.web;

import com.QixunQiu.pojo.Older;
import com.QixunQiu.pojo.Person;
import com.QixunQiu.pojo.User;
import com.QixunQiu.service.PersonService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/selectPersonServlet")
public class selectPersonServlet extends HttpServlet {
    private PersonService personService = new PersonService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        List<Person> persons= personService.selectPerson(user.getUserID());
        PrintWriter writer = response.getWriter();
        if(!persons.isEmpty()){
            // 登陆成功
            writer.write("登陆成功");
            session.setAttribute("persons", persons);
            request.getRequestDispatcher("/person.jsp").forward(request,response);

        }else {
            // 登陆失败
            writer.write("登陆失败");
            request.getRequestDispatcher("/addPerson.jsp").forward(request,response);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.QixunQiu.mapper.DailyMapper">

    <insert id="add" parameterType="com.QixunQiu.pojo.Daily">
        INSERT INTO tb_daily (
            AssessmentID,
            Eating,
            Bathing,
            Grooming,
            Dressing,
            BowelControl,
            BladderControl,
            Toileting,
            BedChairTransfer,
            Walking,
            Stairs,
            TotalScore,
            ActivityLevel
        ) VALUES (
                     #{assessmentID},
                     #{eating},
                     #{bathing},
                     #{grooming},
                     #{dressing},
                     #{bowelControl},
                     #{bladderControl},
                     #{toileting},
                     #{bedChairTransfer},
                     #{walking},
                     #{stairs},
                     #{totalScore},
                     #{activityLevel}
                 )
    </insert>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.QixunQiu.mapper.PersonMapper">

    <insert id="addPerson" parameterType="com.QixunQiu.pojo.Person">
        INSERT INTO tb_person (
            userID,
            OlderID,
            ProviderName,
            Relationship,
            OtherRelationship,
            ContactName,
            ContactPhone
        ) VALUES (
                     #{userID},
                     #{olderID},
                     #{providerName},
                     #{relationship},
                     #{otherRelationship},
                     #{contactName},
                     #{contactPhone}
                 )
    </insert>
</mapper>

posted @   元始天尊123  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示