Refactor mapper query
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
<mapper namespace="com.yam.app.account.domain.AccountRepository">
|
||||
<update id="update" parameterType="com.yam.app.account.domain.Account">
|
||||
UPDATE ACCOUNT
|
||||
UPDATE account
|
||||
SET email = #{email},
|
||||
email_check_token = #{emailCheckToken},
|
||||
email_check_token_generated_at = #{emailCheckTokenGeneratedAt},
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.account.domain.Account">
|
||||
INSERT
|
||||
INTO ACCOUNT(email, email_check_token, email_check_token_generated_at, email_verified,
|
||||
INTO account(email, email_check_token, email_check_token_generated_at, email_verified,
|
||||
password, withdraw, role, status)
|
||||
VALUES (#{email}, #{emailCheckToken}, #{emailCheckTokenGeneratedAt}, #{emailVerified},
|
||||
#{password}, #{withdraw}, #{role}, #{status})
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
<select id="existsByEmail" parameterType="String" resultType="boolean">
|
||||
SELECT COUNT(email)
|
||||
FROM ACCOUNT
|
||||
FROM account
|
||||
WHERE email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="findByEmail" parameterType="String"
|
||||
resultType="com.yam.app.account.domain.Account">
|
||||
SELECT * FROM ACCOUNT WHERE email = #{email}
|
||||
SELECT * FROM account WHERE email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="findByEmailAndMemberId" resultMap="memberAccount">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.yam.app.article.domain.ArticleRepository">
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.article.domain.Article">
|
||||
INSERT INTO ARTICLE(title, content, image, status, created_at, modified_at, member_id)
|
||||
INSERT INTO article (title, content, image, status, created_at, modified_at, member_id)
|
||||
VALUES (#{title}, #{content}, #{image}, #{status}, #{createdAt}, #{modifiedAt}, #{authorId})
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.yam.app.article.domain.ArticleTagRepository">
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.article.domain.ArticleTag">
|
||||
INSERT INTO ARTICLE_TAG(article_id, tag_id)
|
||||
INSERT INTO article_tag (article_id, tag_id)
|
||||
VALUES (#{articleId}, #{tag.id})
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<mapper namespace="com.yam.app.comment.domain.CommentRepository">
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.comment.domain.Comment">
|
||||
INSERT INTO COMMENT(content, created_at, modified_at, status, article_id, member_id)
|
||||
INSERT INTO comment (content, created_at, modified_at, status, article_id, member_id)
|
||||
VALUES (#{content}, #{createdAt}, #{modifiedAt}, #{status}, #{articleId}, #{memberId})
|
||||
|
||||
<selectKey keyProperty="id" resultType="long" order="AFTER">
|
||||
@@ -14,14 +14,14 @@
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.yam.app.comment.domain.Comment">
|
||||
UPDATE COMMENT
|
||||
UPDATE comment
|
||||
SET content = #{content},
|
||||
modified_at = #{modifiedAt}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="delete" parameterType="com.yam.app.comment.domain.Comment">
|
||||
UPDATE COMMENT
|
||||
UPDATE comment
|
||||
SET status = #{status}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
<select id="findById" parameterType="Long" resultType="com.yam.app.comment.domain.Comment">
|
||||
SELECT *
|
||||
FROM COMMENT
|
||||
FROM comment
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByArticleId" parameterType="Long" resultType="com.yam.app.comment.domain.Comment">
|
||||
SELECT *
|
||||
FROM COMMENT
|
||||
FROM comment
|
||||
WHERE article_id = #{articleId}
|
||||
</select>
|
||||
|
||||
<select id="existsById" parameterType="Long" resultType="boolean">
|
||||
SELECT COUNT(*)
|
||||
FROM COMMENT
|
||||
FROM comment
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.member.domain.Member">
|
||||
INSERT
|
||||
INTO MEMBER(nickname, image, status)
|
||||
INTO member (nickname, image, status)
|
||||
VALUES (#{nickname}, #{image}, #{status})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.yam.app.member.domain.Member">
|
||||
UPDATE MEMBER
|
||||
UPDATE member
|
||||
SET nickname = #{nickname},
|
||||
image = #{image},
|
||||
status = #{status}
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
<insert id="save" parameterType="com.yam.app.article.domain.Tag">
|
||||
INSERT
|
||||
INTO TAG(name)
|
||||
INTO tag (name)
|
||||
VALUES (#{name})
|
||||
</insert>
|
||||
|
||||
<select id="findByName" parameterType="String"
|
||||
resultType="com.yam.app.article.domain.Tag">
|
||||
SELECT * FROM TAG WHERE name = #{name}
|
||||
SELECT * FROM tag WHERE name = #{name}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
create table member
|
||||
(
|
||||
id bigint not null auto_increment,
|
||||
nickname varchar(255) not null,
|
||||
image varchar(255) not null,
|
||||
status varchar(255) not null,
|
||||
primary key (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table account
|
||||
(
|
||||
id bigint not null auto_increment,
|
||||
@@ -13,15 +22,14 @@ create table account
|
||||
withdrawal_at timestamp,
|
||||
member_id bigint,
|
||||
status varchar(255) not null,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (member_id) references member (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table member
|
||||
create table tag
|
||||
(
|
||||
id bigint not null auto_increment,
|
||||
nickname varchar(255) not null,
|
||||
image varchar(255) not null,
|
||||
status varchar(255) not null,
|
||||
id bigint not null auto_increment,
|
||||
name varchar(255) not null,
|
||||
primary key (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
@@ -35,7 +43,8 @@ create table article
|
||||
status varchar(255) not null,
|
||||
title varchar(255) not null,
|
||||
member_id bigint,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (member_id) references member (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table article_likes
|
||||
@@ -43,7 +52,9 @@ create table article_likes
|
||||
id bigint not null auto_increment,
|
||||
article_id bigint,
|
||||
member_id bigint,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (member_id) references member (id),
|
||||
foreign key (article_id) references article (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table article_tag
|
||||
@@ -51,7 +62,9 @@ create table article_tag
|
||||
id bigint not null auto_increment,
|
||||
article_id bigint not null,
|
||||
tag_id bigint not null,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (article_id) references article (id),
|
||||
foreign key (tag_id) references tag (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table comment
|
||||
@@ -63,7 +76,9 @@ create table comment
|
||||
status varchar(255),
|
||||
article_id bigint,
|
||||
member_id bigint,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (member_id) references member (id),
|
||||
foreign key (article_id) references article (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table comment_likes
|
||||
@@ -71,39 +86,14 @@ create table comment_likes
|
||||
id bigint not null auto_increment,
|
||||
comment_id bigint,
|
||||
member_id bigint,
|
||||
primary key (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
create table tag
|
||||
(
|
||||
id bigint not null auto_increment,
|
||||
name varchar(255) not null,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
foreign key (member_id) references member (id),
|
||||
foreign key (comment_id) references comment (id)
|
||||
) engine=InnoDB;
|
||||
|
||||
alter table account
|
||||
add constraint UK_q0uja26qgu1atulenwup9rxyr unique (email);
|
||||
alter table account
|
||||
add constraint FKr5j0huynd7nsv1s7e9vb8qvwo foreign key (member_id) references member;
|
||||
alter table tag
|
||||
add constraint UK_1wdpsed5kna2y38hnbgrnhi5b unique (name);
|
||||
alter table article
|
||||
add constraint UK_571gx7oqo5xpmgocegaidlcu9 unique (title);
|
||||
alter table article
|
||||
add constraint FK6l9vkfd5ixw8o8kph5rj1k7gu foreign key (member_id) references member;
|
||||
alter table article_likes
|
||||
add constraint FK1wt0ww82gfxkuxw3ghxmp55xy foreign key (article_id) references article;
|
||||
alter table article_likes
|
||||
add constraint FKkipxs7p8nrjd4537f3k8rexh5 foreign key (member_id) references member;
|
||||
alter table article_tag
|
||||
add constraint FKenqeees0y8hkm7x1p1ittuuye foreign key (article_id) references article;
|
||||
alter table article_tag
|
||||
add constraint FKesqp7s9jj2wumlnhssbme5ule foreign key (tag_id) references tag;
|
||||
alter table comment
|
||||
add constraint FK5yx0uphgjc6ik6hb82kkw501y foreign key (article_id) references article;
|
||||
alter table comment
|
||||
add constraint FKmrrrpi513ssu63i2783jyiv9m foreign key (member_id) references member;
|
||||
alter table comment_likes
|
||||
add constraint FKd0epu3dcjc57pwe7lt5jgfqsi foreign key (comment_id) references comment;
|
||||
alter table comment_likes
|
||||
add constraint FK7mxs5jtimpj71miv2r0fp6r8p foreign key (member_id) references member;
|
||||
|
||||
Reference in New Issue
Block a user