From e1787423e81ac004004544141fa92ef6b8f88eb2 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:02:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=88=86=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E3=82=92=E3=83=9B=E3=83=BC=E3=83=A0=E3=82=BF=E3=82=A4=E3=83=A0?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=B3=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rRegisterHomeTimelineApplicationService.kt | 14 ++++++++ .../src/main/resources/application.yml | 12 +++---- .../resources/db/migration/V1__Init_DB.sql | 34 +++++++++++++++++-- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt index 5394e998..6119370b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt @@ -4,6 +4,10 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.model.timeline.* +import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship +import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipId +import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipRepository +import dev.usbharu.hideout.core.domain.model.timelinerelationship.Visible import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService @@ -15,6 +19,7 @@ class UserRegisterHomeTimelineApplicationService( private val userDetailRepository: UserDetailRepository, private val timelineRepository: TimelineRepository, private val idGenerateService: IdGenerateService, transaction: Transaction, + private val timelineRelationshipRepository: TimelineRelationshipRepository ) : AbstractApplicationService(transaction, logger) { override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) { @@ -31,6 +36,15 @@ class UserRegisterHomeTimelineApplicationService( timelineRepository.save(timeline) userDetail.homeTimelineId = timeline.id + val timelineRelationship = TimelineRelationship( + TimelineRelationshipId(idGenerateService.generateId()), + timeline.id, + userDetail.actorId, + Visible.DIRECT + ) + + timelineRelationshipRepository.save(timelineRelationship) + userDetailRepository.save(userDetail) } diff --git a/hideout-core/src/main/resources/application.yml b/hideout-core/src/main/resources/application.yml index c4bcecdd..371565d4 100644 --- a/hideout-core/src/main/resources/application.yml +++ b/hideout-core/src/main/resources/application.yml @@ -20,6 +20,12 @@ hideout: spring: + data: + mongodb: + auto-index-creation: true + host: localhost + port: 27017 + database: hideout jmx: enabled: false jackson: @@ -31,12 +37,6 @@ spring: url: "jdbc:postgresql:hideout" username: "postgres" password: "password" - data: - mongodb: - auto-index-creation: true - host: localhost - port: 27017 - database: hideout servlet: multipart: max-file-size: 40MB diff --git a/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql b/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql index e7330e1b..dd9dfa5c 100644 --- a/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql +++ b/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql @@ -81,7 +81,7 @@ create table timelines ); create table if not exists user_details ( - id bigserial primary key, + id bigint primary key, actor_id bigint not null unique, password varchar(255) not null, auto_accept_followee_follow_request boolean not null, @@ -286,4 +286,34 @@ create table if not exists actor_instance_relationships PRIMARY KEY (actor_id, instance_id), constraint fk_actor_instance_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete cascade on update cascade, constraint fk_actor_instance_relationships_instance_id__id foreign key (instance_id) references instance (id) on delete cascade on update cascade -); \ No newline at end of file +); + +create table if not exists timeline_relationships +( + id bigint primary key, + timeline_id bigint not null, + actor_id bigint not null, + visible varchar(100) not null, + constraint fk_timeline_relationships_timeline_id__id foreign key (timeline_id) references timelines (id) on delete cascade on update cascade, + constraint fk_timeline_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete cascade on update cascade + +); + +create table if not exists filters +( + id bigint primary key, + user_id bigint not null, + name varchar(255) not null, + context varchar(500) not null, + action varchar(255) not null, + constraint fk_filters_user_id__id foreign key (user_id) references user_details (id) on delete cascade on update cascade +); + +create table if not exists filter_keywords +( + id bigint primary key, + filter_id bigint not null, + keyword varchar(1000) not null, + mode varchar(100) not null, + constraint fk_filter_keywords_filter_id__id foreign key (filter_id) references filters (id) on delete cascade on update cascade +) \ No newline at end of file