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: change comment user id to seller id #41

Merged
merged 1 commit into from
Jan 22, 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 @@ -12,14 +12,14 @@
public class Comment {
private String id;
private String body;
private String userId;
private String sellerId;
private String itemId;
private DateTime createdAt;

public Comment(String body, String userId, String itemId) {
public Comment(String body, String sellerId, String itemId) {
this.id = UUID.randomUUID().toString();
this.body = body;
this.userId = userId;
this.sellerId = sellerId;
this.itemId = itemId;
this.createdAt = new DateTime();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public static boolean canWriteItem(User user, Item item) {
}

public static boolean canWriteComment(User user, Item item, Comment comment) {
return user.getId().equals(item.getSellerId()) || user.getId().equals(comment.getUserId());
return user.getId().equals(item.getSellerId()) || user.getId().equals(comment.getSellerId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ create table comments (
id varchar(255) primary key,
body text,
item_id varchar(255),
user_id varchar(255),
seller_id varchar(255),
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.spring.infrastructure.mybatis.mapper.CommentMapper">
<insert id="insert">
insert into comments(id, body, user_id, item_id, created_at, updated_at)
insert into comments(id, body, seller_id, item_id, created_at, updated_at)
values (
#{comment.id},
#{comment.body},
#{comment.userId},
#{comment.sellerId},
#{comment.itemId},
#{comment.createdAt},
#{comment.createdAt}
Expand All @@ -19,7 +19,7 @@
select
id commentId,
body commentBody,
user_id commentUserId,
seller_id commentSellerId,
item_id commentItemId,
created_at commentCreatedAt
from comments
Expand All @@ -28,7 +28,7 @@
<resultMap id="comment" type="io.spring.core.comment.Comment">
<id column="commentId" property="id"/>
<result column="commentBody" property="body"/>
<result column="commentUserId" property="userId"/>
<result column="commentSellerId" property="sellerId"/>
<result column="commentItemId" property="itemId"/>
<result column="commentCreatedAt" property="createdAt"/>
</resultMap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<include refid="io.spring.infrastructure.mybatis.readservice.ItemReadService.profileColumns"/>
from comments C
left join users U
on C.user_id = U.id
on C.seller_id = U.id
</sql>

<select id="findById" resultMap="transfer.data.commentData">
Expand Down
Loading