Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

[10] 230426 ํŒ€ ํ”„๋กœ์ ํŠธ (1) 10์ผ ์ฐจ Wed) ํ•  ๊ฒƒ ๋ชฉ๋ก ์ˆœ์„œ ๋ฐ ์ฝ”๋“œ, *๋ชจ๋ธ ๋ณธ๋ฌธ

๐Ÿ’–My Bootcamp Projects Logsโœจ/Team Project 1๏ธโƒฃ

[10] 230426 ํŒ€ ํ”„๋กœ์ ํŠธ (1) 10์ผ ์ฐจ Wed) ํ•  ๊ฒƒ ๋ชฉ๋ก ์ˆœ์„œ ๋ฐ ์ฝ”๋“œ, *๋ชจ๋ธ

yjyuwisely 2023. 4. 26. 07:00

230426 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_datediseaseopertationsurg_date
- member(MemberVO): id(UUID), email, password, nameresidentidphone, 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&amp;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>
 

[Mybatis] ์ดˆ๊ธฐ ์„ค์ • ๋ฐ xml ํŒŒ์ผ ์„ค์ •

Mybatis ์ดˆ๊ธฐ ์„ค์ • ๋ฐ xml ํŒŒ์ผ ์„ค์ •

velog.io

https://spring.tistory.com/3

 

mybatis-config.xml - ๋งˆ์ด๋ฐ”ํ‹ฐ์Šค ์ „์ฒด ์„ค์ •์ •๋ณด ์ž‘์„ฑํ•˜๊ธฐ

Java Resources ์•ˆ์— resouces ์†Œ์Šคํด๋” ์ƒ์„ฑ ํ›„ ๊ทธ ์•ˆ์— xmlํŒŒ์ผ ์ƒ์„ฑ environments : DB์— ์—ฐ๊ฒฐํ•  ์„ค์ •์— ๋Œ€ํ•œ ์ •๋ณด ์„ ์–ธ : ์—ฌ๋Ÿฌ๊ฐœ์˜ environment ์ค‘ ๊ธฐ๋ณธ์œผ๋กœ ์—ฐ๊ฒฐํ•  ์ •๋ณด๋ฅผ ์„ค์ • ์—ฌ๋Ÿฌ๊ฐœ์˜ environment๋ฅผ ์ง‘์–ด ๋„ฃ

spring.tistory.com


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 ๊ด€๋ จ ๋งํฌ๋“ค

 

[MyBatis] ๋‘ํ…Œ์ด๋ธ” ์ •๋ณด๋ฅผ ํ•œ๊ฐœ์˜ ๋ชจ๋ธ๋กœ! Join ์ฟผ๋ฆฌ๋กœ ๋ฐ›๊ธฐ

ํ…Œ์ด๋ธ”์— ๋งค์นญ๋˜๋Š” ๊ฐ๊ฐ์˜ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์—ˆ์ง€๋งŒ, ํ…Œ์ด๋ธ” ๊ตฌ์กฐ์™€ ๋กœ์ง ์ฒ˜๋ฆฌ์— ํ•„์š”ํ•œ ๊ตฌ์กฐ๋Š” ๋‹ค๋ฅด๋‹ค. ๋‘ ํ…Œ์ด๋ธ”์— ํ•ด๋‹นํ•˜๋Š” ๋‘ ํด๋ž˜์Šค ์ค‘,ํ•œ ํด๋ž˜์Šค๊ฐ€ ๋‹ค๋ฅธ ํด๋ž˜์Šค๋ฅผ ์ธ์ž๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐJOIN

ssodang.tistory.com

https://suhun918.tistory.com/15

 

Mybatis - Resultmap์„ ์‚ฌ์šฉํ•ด์„œ VO ์—ฌ๋Ÿฌ๊ฐ€์ง€๋ฅผ join์ฟผ๋ฆฌ ์‚ฌ์šฉํ•˜์—ฌ ๋งคํ•‘

AdminVO package net.araise.practice.vo; import java.sql.Timestamp; import lombok.Data; @Data public class AdminVO { private String adminId; //๊ด€๋ฆฌ์žID private String adminPwd;//๊ด€๋ฆฌ์žPW private String adminLv;//๊ด€๋ฆฌ์žLV private String useYn; //

suhun918.tistory.com


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 ๋กœ๊ทธ์•„์›ƒ ๊ตฌํ˜„,

2023.01.18 - [๐ŸŒณK-Digital Revision 2023โœจ/JavaScript] - [16] 230118 Ch. 10 ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ DOM๊ณผ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ, ์ž…๋ ฅ ๊ฒ€์ฆ: 1. ๋ฌธ์„œ ๊ฐ์ฒด ๋ชจ๋ธ(DOM), 2. HTML ์š”์†Œ ์ฐพ๊ธฐ, 3. HTML ๋ณ€๊ฒฝํ•˜๊ธฐ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 16์ผ]

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_datediseaseopertationsurg_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), nameresidentidphone
- certificate: idDiagnosticpatientcode


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.


728x90
๋ฐ˜์‘ํ˜•
Comments