일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Absolute
- AGI
- ai
- AI agents
- AI engineer
- AI researcher
- ajax
- algorithm
- Algorithms
- aliases
- Array 객체
- ASI
- bayes' theorem
- Bit
- Blur
- BOM
- bootstrap
- canva
- challenges
- ChatGPT
- Today
- In Total
A Joyful AI Research Journey🌳😊
[10] 230426 팀 프로젝트 (1) 10일 차 Wed) 할 것 목록 순서 및 코드, *모델 본문
[10] 230426 팀 프로젝트 (1) 10일 차 Wed) 할 것 목록 순서 및 코드, *모델
yjyuwisely 2023. 4. 26. 07:00230426 Wed 83rd class
우선 할 것
1) 데이터베이스 쿼리 적음
Create a MySQL database and tables to store the necessary information.
MySQL (ateam)
- certificate(PatientVO): id, Diagnostic, patientcode, admission_date, discharge_date, disease, opertation, surg_date
- member(MemberVO): id(UUID), email, password, name, residentid, phone, doctor (n/y)
1) 진료확인서: 환자 정보 name, residentid, phone + 상병명 disease
2) 입,퇴원확인서: 환자 정보 name, residentid, phone + 입원 날짜 admission_date, 퇴원 날짜 discharge_date
3) 수술확인서: 환자 정보 name, residentid, phone + 상병명 disease, 수술명 operation, 수술 날짜 surg_date
환자이름 ${member.name} 주민등록번호 ${member.residentid}
병명 ${certificate.disease} 입원 날짜 ${certificate.admission_date} 퇴원 날짜 ${certificate.discharge_date}
수술명 ${certificate.opertation} 수술일자 ${certificate.surg_date}
2) JSP 파일 태그 수정해서 데이터 읽어들인다. [완료]
Write JSP pages to display the data to the patient. You can use JSTL tags to iterate through the data and display it on the web page.
3) 마이바티스 써서 MemberVO랑 PatientVO에 연결
Write the MyBatis configuration file (mybatis-config.xml) and map the MemberVO and PatientVO classes to their respective database tables.
=> 이미 root-context.xml에 있음. 파일 만들 필요 없는 듯
<!-- Mybatis 관련 설정 SessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
</bean>
<mybatis-spring:scan base-package="com.obj.mapper"/>
<context:component-scan base-package="com.obj.service"/>
코드)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<typeAliases>
<typeAlias type="com.obj.vo.MemberVO" alias="MemberVO" />
<typeAlias type="com.obj.vo.PatientVO" alias="PatientVO" />
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://192.168.30.79:3306/ateam?useSSL=false&serverTimezone=Asia/Seoul" />
<property name="username" value="totoro" />
<property name="password" value="1234" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/obj/mapper/MemberMapper.xml" />
<mapper resource="com/obj/mapper/PatientMapper.xml" />
</mappers>
</configuration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
environments : DB 연결 설정, environment id를 구분하여 연결할 DB를 여러 개 구성할 수 도
있음
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driverClassName"
value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl"
value="jdbc:mysql://192.168.30.79:3306/ateam?allowMultiQueries=true"></property>
<property name="username" value="totoro"></property>
<property name="password" value="1234"></property>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/obj/mapper/CertificateMapper.xml" />
</mappers>
</configuration>
4) CertificateMapper.xml 파일 만듦 [완료]
<?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.obj.mapper.CertificateMapper">
<!-- used INNER JOIN to combine data from two tables (patient and certificate)
that share a common field (id). -->
<!-- 진료확인서 -->
<select id="GeneralDown" resultMap="PatientResultMap">
SELECT p.name, p.residentid, c.disease
FROM patient p
INNER JOIN certificate c ON p.id = c.id
WHERE
p.name = #{name} and p.residentid = #{residentid}
AND c.disease = #{disease}
</select>
<!-- 입,퇴원확인서 -->
<select id="InoutDown" resultMap="PatientResultMap">
SELECT p.name, p.residentid,
c.admission_date, c.discharge_date
FROM patient p
INNER JOIN certificate c ON p.id = c.id
WHERE p.name = #{name} and p.residentid = #{residentid}
AND c.admission_date = #{admission_date} and c.discharge_date = #{discharge_date}
</select>
<!-- 수술확인서 -->
<select id="SergDown" resultMap="PatientResultMap">
SELECT p.name, p.residentid, c.disease, c.operation, c.surge_date
FROM patient p
INNER JOIN certificate c ON p.id = c.id
WHERE p.name = #{name} and p.residentid = #{residentid}
AND c.disease = #{disease} and c.operation = #{operation} and c.surge_date = #{surge_date}
</select>
<!-- The resultMap (복잡한 결과 매핑을 간편하게 만들어주기 위해 만들어진 태그)
specifies which columns in the result set
should be mapped to which properties in your Java object. -->
<!-- defined the PatientResultMap, which maps from the name to the surge_date columns
to properties in the PatientVO class. -->
<resultMap id="PatientResultMap"
type="com.obj.model.PatientVO">
<result property="name" column="name" />
<result property="residentid" column="residentid" />
<result property="disease" column="disease" />
<result property="admission_date" column="admission_date" />
<result property="discharge_date" column="discharge_date" />
<result property="operation" column="operation" />
<result property="surge_date" column="surge_date" />
</resultMap>
</mapper>
Write the CertificateMapper.xml file to define the SQL queries to retrieve the necessary data from the database.
<?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.obj.mapper.CertificateMapper">
<select id="getMedicalCertificatesByEmail" resultType="com.obj.model.PatientVO">
SELECT * FROM medical_certificate WHERE email = #{email}
</select>
</mapper>
참고)2023.04.26 - [👩💻to be a Software Engineer🐥/개발 공부 자료] - MyBatis: ResultMap 관련 링크들
https://suhun918.tistory.com/15
5) CertificateMapper.java 메서드 실행
Implement the CertificateMapper interface in CertificateMapper.java to execute the SQL queries defined in CertificateMapper.xml.
package com.obj.mapper;
import java.util.List;
import com.obj.model.PatientVO;
public interface CertificateMapper {
List<PatientVO> getMedicalCertificatesByEmail(String email);
}
6) Write a servlet to handle requests from the JSP pages and call the appropriate methods in the CertificateService or CertificateMapper classes.
- END XD -
Deploy the web application to a server, such as Tomcat or Jetty, and test it to ensure it is working correctly.
기타 팀원의 요청) JS 로그아웃 구현,
https://jobtc.tistory.com/13
로그인, 로그아웃 버튼 크게 [완료]
You can simply retrieve the necessary data using the appropriate DAO or Mapper classes and populate the necessary fields in your JSP or other view technology.
1) CertificateMapper interface that defines the necessary database operations and
2) a corresponding CertificateMapper.xml file that contains the SQL queries to retrieve the data.
You can write a query to retrieve data from the database that matches the selected medical certificate for a specific patient. You may need to join tables to get all the necessary data, depending on how the data is structured in the database.
You can then use the MyBatis framework to execute the queries and map the results to your MemberVO and PatientVO objects.
Once you have the query, you can implement it in your CertificateMapper.xml file. You can then call the method that executes this query from your CertificateMapper.java file.
Finally, you can use the data retrieved to populate the view that displays the medical certificate data to the patient.
On the server-side, create a function that takes the patient and doctor data as parameters and
returns the file for the requested certificate.
Use a web framework like Spring to handle the requests and responses.
the logic to retrieve the patient and doctor data from your MySQL database and
display it on the screen.
Create a new Spring MVC controller that handles the request for the page
that displays the patient and doctor data.
The controller can retrieve the data from the database and pass it to a JSP page,
which can then display the data using HTML and JSP tags.
MySQL DB에서 데이터 불러온다.
MySQL (ateam)
certificate(PatientVO): id, Diagnostic, patientcode, admission_date, discharge_date, disease, opertation, surg_date
member(MemberVO): id(UUID), email, password, residentid, phone, doctor
1) 진료확인서: 환자 정보 name, residentid, phone + 상병명 disease
2) 입,퇴원확인서: 환자 정보 name, residentid, phone + 입원 날짜 admission_date, 퇴원 날짜 discharge_date
3) 수술확인서: 환자 정보 name, residentid, phone + 상병명 disease, 수술명 operation, 수술 날짜 surg_date
각 상세 내역 뜬다.
2) 입,퇴원확인서: 입원 날짜 admission_date, 퇴원 날짜 discharge_date,
1) 진료확인서, 3) 수술확인서: 상병명 disease, 수술명 operation
- member: (id), (email), (password), name, residentid, phone
- certificate: id, Diagnostic, patientcode,
1) CertificateVO.java - Start by defining the data model or value object that represents the medical certificate. This should include all the necessary fields to store the relevant information about each certificate.
CertificateRepository.java - Create the repository interface that will define the methods for accessing and manipulating the certificate data in the database. This can include methods for querying, inserting, updating, and deleting certificates.
MyBatis 사용 가능
2) CertificateService.java - Define the service interface that will provide the business logic for handling certificate-related operations. This can include methods for validating certificate data, generating certificate PDFs, and interacting with the repository.
3) CertificateServiceImpl.java - Implement the service interface by creating a concrete class that provides the actual implementation of the business logic. This can include dependencies on other services, such as a PDF generation service or an email service.
4) CertificateController.java - Create the controller class that will handle incoming requests related to certificates. This can include methods for displaying certificate information, downloading certificates, and uploading new certificates. Use the service layer to perform the actual logic for each method.
CertificateVO.java model
contain the necessary data fields to represent a medical certificate.
represents the model or data layer, which contains the attributes and methods that define the data and how it is manipulated.
CertificateRepository.java model
handle the database operations related to the medical certificates
also part of the model layer, specifically the data access layer, and provides an interface for accessing and manipulating the data stored in a database.
CertificateService.java model
provide the business logic for interacting with the CertificateRepository.
the service layer, which contains the business logic and serves as an intermediary between the controller and the repository. These layers are responsible for processing and transforming data to meet the requirements of the application.
CertificateServiceImpl.java model
handle the HTTP requests from the client-side and serve the appropriate response.
the service layer, which contains the business logic and serves as an intermediary between the controller and the repository. These layers are responsible for processing and transforming data to meet the requirements of the application.
CertificateController.java controller
provide the business logic for interacting with the CertificateRepository.
the controller layer, which handles the user input and interacts with the service layer to process the request and send the response back to the user.
'💖My Bootcamp Projects Logs✨ > Team Project 1️⃣' 카테고리의 다른 글
[12] 230428 팀 프로젝트 (1) 12일 차 Fri) 할 것 리스트 (0) | 2023.04.28 |
---|---|
🌷[7, 9] 230423, 230425 팀 프로젝트 (1) 7, 9일 차) 화면 구현 스크린샷 (0) | 2023.04.27 |
🌷[9] 230425 팀 프로젝트 (1) 9일 차 Tue) 화면 구현(최종): 증명서 다운로드 페이지 3장 및 각각 프린트 할 때 이미지 (0) | 2023.04.25 |
[9] 230425 팀 프로젝트 (1) 9일 차 Tue) 남은 것 2개 리스트 (컨트롤러, JSP 수정) (0) | 2023.04.25 |