Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: entity field, table column 대소문자변환 #87

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Gameresult {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long GameresultId;
private Long gameresultId;

private int runningTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ public interface GameresultRepository extends JpaRepository<Gameresult, Long> {
/*
member의 모든 게임 결과 조회
*/
@Query("select gr from Gameresult gr inner join fetch MemberGameresult mg on gr.GameresultId = mg.gameresult.GameresultId " +
"inner join fetch Member m on mg.member.loginId = m.loginId where m.loginId = :loginId")
List<Gameresult> findGameresultsByMemberId(@Param("loginId")String loginId);
@Query("select mg.gameresult from MemberGameresult mg " +
"join fetch mg.gameresult gr " +
"join fetch mg.member m " +
"where m.loginId = :loginId")
List<Gameresult> findGameresultsByMemberId(@Param("loginId") String loginId);

/*
member의 특정한 게임 결과 조회
*/
@Query("select gr from Gameresult gr inner join fetch MemberGameresult mg on gr.GameresultId = mg.gameresult.GameresultId " +
"inner join fetch Member m on mg.member.loginId = m.loginId where m.loginId = :loginId and gr.GameresultId = :gameresultId")
Gameresult findGameresultByMemberIdAndGameresultId(@Param("loginId")String loginId, @Param("gameresultId")Long gameresultId);
@Query("select gr from MemberGameresult mg " +
"join mg.gameresult gr " +
"join mg.member m " +
"where m.loginId = :loginId and gr.gameresultId = :gameresultId")
Gameresult findGameresultByMemberIdAndGameresultId(@Param("loginId") String loginId, @Param("gameresultId") Long gameresultId);
}
6 changes: 3 additions & 3 deletions algofi-mysql/init/create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CREATE TABLE member_chatroom (

/* gameresult table 생성 */
CREATE TABLE gameresult (
game_result_id INT(11) AUTO_INCREMENT PRIMARY KEY,
gameresult_id INT(11) AUTO_INCREMENT PRIMARY KEY,
running_time VARCHAR(100),
host_code_content VARCHAR(5500),
guest_code_content VARCHAR(5500),
Expand All @@ -97,10 +97,10 @@ CREATE TABLE gameresult (
/* member_gameresult table 생성 */
CREATE TABLE member_gameresult (
member_gameresult_id INT AUTO_INCREMENT PRIMARY KEY,
game_result_id INT NOT NULL,
gameresult_id INT NOT NULL,
member_id INT NOT NULL,
game_over_type VARCHAR(10) NOT NULL,
FOREIGN KEY(game_result_id) REFERENCES gameresult(game_result_id),
FOREIGN KEY(gameresult_id) REFERENCES gameresult(gameresult_id),
FOREIGN KEY(member_id) REFERENCES member(member_id)
) character set utf8mb4 collate utf8mb4_general_ci;

Expand Down
8 changes: 4 additions & 4 deletions algofi-mysql/init/insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ INSERT INTO chatroom(chatroom_id, chatroom_name) VALUES('global','GLOBAL');
-- INSERT INTO member_chatroom(chatroom_id, member_id) VALUES (1,1);

-- insert gameresult
-- INSERT INTO gameresult(running_time, member_code_content, other_member_code_content, algorithmproblem_id, chatroom_id)
-- VALUES('20:30', 'code1' , 'code2', 1 , 1);
-- INSERT INTO gameresult(running_time, host_code_content, guest_code_content, algorithmproblem_id, chatroom_id, guest_id, host_id, host_code_language, guest_code_language,game_over_type)
-- VALUES('20:30', 'code1' , 'code2', 1 , 'global', 'guest','host','java','java','WIN');

-- insert member_gameresult
-- INSERT INTO member_gameresult(game_result_id, member_id) VALUES (1, 1);
-- INSERT INTO member_gameresult(gameresult_id, member_id,game_over_type) VALUES (1, 1,'WIN');

-- insert testcase
INSERT INTO testcase(test_input, test_output, algorithmproblem_id)
Expand Down Expand Up @@ -202,4 +202,4 @@ VALUES
-- VALUES('20:30', 'code1' , 'code2', 1 , 1);
--
-- insert member_gameresult
-- INSERT INTO member_gameresult(game_result_id, member_id) VALUES (1, 1);
-- INSERT INTO member_gameresult(gameresult_id, member_id) VALUES (1, 1);