shm11C3 / what-do-you-need-backend

MIT License
0 stars 0 forks source link

リアクション機能の追加 #100

Open shm11C3 opened 1 year ago

shm11C3 commented 1 year ago

テーブルの追加

erDiagram

users ||--o{ reactions: ""

users ||--o{ posts: ""

reactions }o--|| posts: ""

users ||--o{ comments: ""

comments }o--|| posts: ""

users ||--o{ comments: ""

comments ||--o{ reactions: ""

users ||--o{ comments: ""

comments }o--|| comments: ""

users {
  string auth_id
  string name
  string username
  integer country_id
  string profile_img_uri
  integer delete_flg
  timestamp created_at
  timestamp updated_at
}

posts {
  string ulid
  string auth_id
  string category_uuid
  string title
  string content
  integer is_draft
  integer is_publish
  integer is_edited
  integer is_deleted
  timestamp created_at
  timestamp updated_at
}

reactions {
  string ulid
  string user_auth_id
  string post_ulid
  string reaction_type
}

comments {
  string ulid
  string user_auth_id
  string post_ulid
  string comment
  timestamp updated_at
}

エンドポイント

ReactionController.php

AddReactionRequest.php

POST:/reactionで使用

DeleteReactionRequest.php

DELETE:/reactionで使用

AddCommentRequest.php

POST:/commentで使用

UpdateCommentRequest.php

PUT:/comment で使用

DeleteCommentRequest.php

DELETE:/comment で使用

Reaction.php

shm11C3 commented 1 year ago

中間テーブルを用いてポリモーフィック関連を回避したい

erDiagram

posts_reactions }o--|| posts: ""
posts_reactions }o--|| reactions: ""

comments ||--o{ comments_reactions: ""
reactions ||--o{ comments_reactions: ""

posts_comments }o--|| posts: ""
posts_comments }o--|| comments: ""

users {
  string auth_id
  string name
  string username
  integer country_id
  string profile_img_uri
  integer delete_flg
  timestamp created_at
  timestamp updated_at
}

posts {
  string ulid
  string auth_id
  string category_uuid
  string title
  string content
  integer is_draft
  integer is_publish
  integer is_edited
  integer is_deleted
  timestamp created_at
  timestamp updated_at
}

posts_reactions {
  string post_ulid
  string reaction_ulid
}

comments_reactions {
  string reaction_ulid
  string comment_ulid
}

posts_comments {
  string post_ulid
  string comment_ulid
}

reactions {
  string ulid
  string user_auth_id
  string reaction_type
}

comments {
  string ulid
  string user_auth_id
  string post_ulid
  string comment
  timestamp updated_at
}
shm11C3 commented 1 year ago