From a291ea56d03d55b975bee31ac6e0905bbbce426f Mon Sep 17 00:00:00 2001 From: seon0025 Date: Wed, 21 Feb 2024 17:29:33 +0900 Subject: [PATCH 001/183] =?UTF-8?q?=F0=9F=92=9A=20cloudtype=20cd=20branch?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms_backend_cloudtype_develop_cd.yml | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/sms_backend_cloudtype_develop_cd.yml diff --git a/.github/workflows/sms_backend_cloudtype_develop_cd.yml b/.github/workflows/sms_backend_cloudtype_develop_cd.yml new file mode 100644 index 00000000..ab2fd646 --- /dev/null +++ b/.github/workflows/sms_backend_cloudtype_develop_cd.yml @@ -0,0 +1,105 @@ +name: Deploy to cloudtype +on: + push: + branches: + - develop +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: SMS-Backend-CD Discord Notification + uses: sarisia/actions-status-discord@v1 + if: ${{ success() }} + with: + title: ℹ️ SMS-Backend-CD 시작! ℹ️ + webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} + color: 00FF00 + + - name: Checkout + uses: actions/checkout@v2 + - name: Connect deploy key + uses: cloudtype-github-actions/connect@v1 + with: + token: ${{ secrets.CLOUDTYPE_TOKEN }} + ghtoken: ${{ secrets.GHP_TOKEN }} + - name: Deploy + uses: cloudtype-github-actions/deploy@v1 + with: + token: ${{ secrets.CLOUDTYPE_TOKEN }} + project: seungwon/movie + stage: main + yaml: > + name: sms-backend + + app: java@11 + + options: + ports: 8080 + includes: sms-infrastructure + env: + - name: AWS_ACCESS_KEY + value: ${{ secrets.AWS_ACCESS_KEY }} + - name: AWS_REGION_STATIC + value: ${{ secrets.AWS_REGION_STATIC }} + - name: AWS_SECRET_KEY + value: ${{ secrets.AWS_SECRET_KEY }} + - name: DB_DRIVER + value: ${{ secrets.DB_DRIVER }} + - name: DB_PASSWORD + value: ${{ secrets.DB_PASSWORD }} + - name: DB_URL + value: ${{ secrets.DB_URL }} + - name: DB_USERNAME + value: ${{ secrets.DB_USERNAME }} + - name: GAUTH_CLIENT_ID + value: ${{ secrets.GAUTH_CLIENT_ID }} + - name: GAUTH_CLIENT_SECRET + value: ${{ secrets.GAUTH_CLIENT_SECRET }} + - name: GAUTH_REDIRECT_URI + value: ${{ secrets.GAUTH_REDIRECT_URI }} + - name: JWT_ACCESS_SECRET + value: ${{ secrets.JWT_ACCESS_SECRET }} + - name: JWT_REFRESH_SECRET + value: ${{ secrets.JWT_REFRESH_SECRET }} + - name: REDIS_HOST + value: ${{ secrets.REDIS_HOST }} + - name: REDIS_PORT + value: ${{ secrets.REDIS_PORT }} + - name: S3_BUCKET + value: ${{ secrets.S3_BUCKET }} + - name: S3_LOG_BUCKET + value: ${{ secrets.S3_LOG_BUCKET }} + - name: SECURITY_SECRET_KEY + value: ${{ secrets.SECURITY_SECRET_KEY }} + start: java -jar sms-infrastructure/build/libs/sms-infrastructure-0.0.1-SNAPSHOT.jar + context: + git: + url: git@github.com:${{ github.repository }}.git + ref: ${{ github.ref }} + preset: kotlin + + - name: SMS-Backend-CD Discord Notification + uses: sarisia/actions-status-discord@v1 + if: ${{ success() }} + with: + title: ✅ SMS-Backend-CD 성공! ✅ + webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} + status: ${{ job.status }} + image: ${{ secrets.CD_SUCCESS_IMAGE }} + description: 영역전개 CD 성공 + color: 00FF00 + username: SMS CD 봇 + url: https://github.com/GSM-MSG/SMS-BackEnd + + - name: SMS-Backend-CD Discord Notification + uses: sarisia/actions-status-discord@v1 + if: ${{ failure() }} + with: + title: ❗️ SMS-Backend-CD 실패! ❗️ + webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} + status: ${{ job.status }} + image: ${{ secrets.CD_FAIL_IMAGE }} + description: 무례하긴, 실패다. + color: FF0000 + username: SMS CD 봇 + url: https://github.com/GSM-MSG/SMS-BackEnd \ No newline at end of file From c232444e4480c0e50cc2f21ee4d9eb7450d400de Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 22 Feb 2024 19:57:35 +0900 Subject: [PATCH 002/183] =?UTF-8?q?=F0=9F=92=9A=20cloudtype=20cd=20branch?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_cloudtype_develop_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sms_backend_cloudtype_develop_cd.yml b/.github/workflows/sms_backend_cloudtype_develop_cd.yml index ab2fd646..40aac2b7 100644 --- a/.github/workflows/sms_backend_cloudtype_develop_cd.yml +++ b/.github/workflows/sms_backend_cloudtype_develop_cd.yml @@ -2,7 +2,7 @@ name: Deploy to cloudtype on: push: branches: - - develop + - 'feature/cloudtype' jobs: deploy: runs-on: ubuntu-latest From 9b126f49f44999dc2324b215200c6d9b88d4357f Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 22 Feb 2024 20:17:19 +0900 Subject: [PATCH 003/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20latest=20tag=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_develop_cd.yml | 138 +++++++++---------- .github/workflows/sms_backend_master_cd.yml | 2 +- docker-compose.yml | 4 +- scripts/pullDocker.sh | 2 +- scripts/server_start.sh | 2 +- 5 files changed, 72 insertions(+), 76 deletions(-) diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index ab2fd646..f8874013 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -1,88 +1,84 @@ -name: Deploy to cloudtype +name: Deploy to Develop server + on: - push: - branches: - - develop + push: + branches: ?? + - feature/261-develop-server + - develop jobs: - deploy: - runs-on: ubuntu-latest - steps: + CD: + name: CD + runs-on: ubuntu-latest + environment: production + + steps: - name: SMS-Backend-CD Discord Notification uses: sarisia/actions-status-discord@v1 if: ${{ success() }} with: - title: ℹ️ SMS-Backend-CD 시작! ℹ️ + title: ℹ️ SMS-Backend-Develop-CD 시작! ℹ️ webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} color: 00FF00 - + - name: Checkout - uses: actions/checkout@v2 - - name: Connect deploy key - uses: cloudtype-github-actions/connect@v1 + uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 with: - token: ${{ secrets.CLOUDTYPE_TOKEN }} - ghtoken: ${{ secrets.GHP_TOKEN }} - - name: Deploy - uses: cloudtype-github-actions/deploy@v1 + java-version: '11' + distribution: 'temurin' + cache: gradle + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Create application.yml + run: | + touch ./sms-infrastructure/src/main/resources/application.yml + echo "${{ secrets.SMS_BACKEND_ENV }}" > ./sms-infrastructure/src/main/resources/application.yml + shell: bash + + - name: Run build with Gradle wrapper + run: ./gradlew clean build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 with: - token: ${{ secrets.CLOUDTYPE_TOKEN }} - project: seungwon/movie - stage: main - yaml: > - name: sms-backend - - app: java@11 - - options: - ports: 8080 - includes: sms-infrastructure - env: - - name: AWS_ACCESS_KEY - value: ${{ secrets.AWS_ACCESS_KEY }} - - name: AWS_REGION_STATIC - value: ${{ secrets.AWS_REGION_STATIC }} - - name: AWS_SECRET_KEY - value: ${{ secrets.AWS_SECRET_KEY }} - - name: DB_DRIVER - value: ${{ secrets.DB_DRIVER }} - - name: DB_PASSWORD - value: ${{ secrets.DB_PASSWORD }} - - name: DB_URL - value: ${{ secrets.DB_URL }} - - name: DB_USERNAME - value: ${{ secrets.DB_USERNAME }} - - name: GAUTH_CLIENT_ID - value: ${{ secrets.GAUTH_CLIENT_ID }} - - name: GAUTH_CLIENT_SECRET - value: ${{ secrets.GAUTH_CLIENT_SECRET }} - - name: GAUTH_REDIRECT_URI - value: ${{ secrets.GAUTH_REDIRECT_URI }} - - name: JWT_ACCESS_SECRET - value: ${{ secrets.JWT_ACCESS_SECRET }} - - name: JWT_REFRESH_SECRET - value: ${{ secrets.JWT_REFRESH_SECRET }} - - name: REDIS_HOST - value: ${{ secrets.REDIS_HOST }} - - name: REDIS_PORT - value: ${{ secrets.REDIS_PORT }} - - name: S3_BUCKET - value: ${{ secrets.S3_BUCKET }} - - name: S3_LOG_BUCKET - value: ${{ secrets.S3_LOG_BUCKET }} - - name: SECURITY_SECRET_KEY - value: ${{ secrets.SECURITY_SECRET_KEY }} - start: java -jar sms-infrastructure/build/libs/sms-infrastructure-0.0.1-SNAPSHOT.jar - context: - git: - url: git@github.com:${{ github.repository }}.git - ref: ${{ github.ref }} - preset: kotlin + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ secrets.Develop_IMAGE_TAG }} + run: | + docker build -t ${{ secrets.ECR_REPOSITORY }} . + docker tag ${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG ${{ secrets.REPO_URL }}:$IMAGE_TAG + docker push ${{ secrets.REPO_URL }}:$IMAGE_TAG + - name : CodeDeploy Create Deployment + run: | + aws deploy create-deployment \ + --application-name codedeploy-develop-server \ + --deployment-group-name codedeploy-group \ + --deployment-config-name CodeDeployDefault.OneAtATime \ + --github-location repository=${{ github.repository }},commitId=${{ github.sha }} + - name: SMS-Backend-CD Discord Notification uses: sarisia/actions-status-discord@v1 if: ${{ success() }} with: - title: ✅ SMS-Backend-CD 성공! ✅ + title: ✅ SMS-Backend-Develop-CD 성공! ✅ webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} status: ${{ job.status }} image: ${{ secrets.CD_SUCCESS_IMAGE }} @@ -90,12 +86,12 @@ jobs: color: 00FF00 username: SMS CD 봇 url: https://github.com/GSM-MSG/SMS-BackEnd - + - name: SMS-Backend-CD Discord Notification uses: sarisia/actions-status-discord@v1 if: ${{ failure() }} with: - title: ❗️ SMS-Backend-CD 실패! ❗️ + title: ❗️ SMS-Backend-Develop-CD 실패! ❗️ webhook: ${{ secrets.SMS_DISCORD_WEBHOOK }} status: ${{ job.status }} image: ${{ secrets.CD_FAIL_IMAGE }} diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index 423a20ac..6779447f 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -57,7 +57,7 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: latest + IMAGE_TAG: ${{ secrets.IMAGE_TAG }} run: | docker build -t ${{ secrets.ECR_REPOSITORY }} . docker tag ${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG ${{ secrets.REPO_URL }}:$IMAGE_TAG diff --git a/docker-compose.yml b/docker-compose.yml index 5f21f07a..42112248 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" services: blue: - image : ${REPO_URL}/${ECR_REPOSITORY}:latest + image : ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} ports: - 8080:8080 networks: @@ -15,7 +15,7 @@ services: awslogs-stream: "backend-start-logs" green: - image : ${REPO_URL}/${ECR_REPOSITORY}:latest + image : ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} ports: - 8090:8080 networks: diff --git a/scripts/pullDocker.sh b/scripts/pullDocker.sh index 7253561a..380d7226 100644 --- a/scripts/pullDocker.sh +++ b/scripts/pullDocker.sh @@ -2,4 +2,4 @@ aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${REPO_URL} -docker pull ${REPO_URL}/${ECR_REPOSITORY}:latest +docker pull ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} diff --git a/scripts/server_start.sh b/scripts/server_start.sh index 4ab17aa3..15251799 100644 --- a/scripts/server_start.sh +++ b/scripts/server_start.sh @@ -2,7 +2,7 @@ aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${REPO_URL} -docker pull ${REPO_URL}/${ECR_REPOSITORY}:latest +docker pull ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} docker pull ${NGINX_URl} docker compose up -d redis From d7986cd53e0adf67475b9d263e8c6f94589e626d Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 06:53:43 +0900 Subject: [PATCH 004/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20=EC=83=81=ED=83=9C=20enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/authentication/model/ActivityStatus.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/ActivityStatus.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/ActivityStatus.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/ActivityStatus.kt new file mode 100644 index 00000000..1546a57d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/ActivityStatus.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.model + +enum class ActivityStatus(description: String) { + APPROVED("승인됨"), + REJECTED("반려됨"), + REQUESTED("요청됨"), + PENDING("대기중") +} \ No newline at end of file From 9e7a6a4db1fa7b318f15c5b408856eb8435f709c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 07:10:52 +0900 Subject: [PATCH 005/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20=ED=9E=88=EC=8A=A4=ED=86=A0=EB=A6=AC=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/AuthenticationHistoryJpaEntity.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt new file mode 100644 index 00000000..f8d2192a --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt @@ -0,0 +1,26 @@ +package team.msg.sms.persistence.authentication.entity + +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.persistence.BaseIdEntity +import team.msg.sms.persistence.teacher.entity.TeacherJpaEntity +import javax.persistence.* + +@Entity +@Table(name = "authentication_history") +class AuthenticationHistoryJpaEntity ( + override val id: Long, + + @Column + val reason: String, + + @Enumerated(EnumType.STRING) + val activityStatus: ActivityStatus, + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "teacher_id", nullable = true) + val teacher: TeacherJpaEntity?, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "authentication_id") + val authentication: AuthenticationJpaEntity +) : BaseIdEntity() \ No newline at end of file From 9c58b210823ce9593adfddab7594b96b79182258 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 07:11:19 +0900 Subject: [PATCH 006/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/AuthenticationJpaEntity.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationJpaEntity.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationJpaEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationJpaEntity.kt new file mode 100644 index 00000000..99e6a8be --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationJpaEntity.kt @@ -0,0 +1,36 @@ +package team.msg.sms.persistence.authentication.entity + +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.persistence.BaseUuidEntity +import team.msg.sms.persistence.student.entity.StudentJpaEntity +import java.util.UUID +import javax.persistence.* + +@Entity +@Table(name = "authentication") +class AuthenticationJpaEntity ( + override val id: UUID, + + @Column + val title: String, + + @Column + val content: String, + + @ElementCollection + @CollectionTable( + name = "ActivityImages", + joinColumns = [JoinColumn(name = "authentication_id")] + ) + val activityImages: List, + + @Column + val score: Int, + + @Enumerated(EnumType.STRING) + val activityStatus: ActivityStatus, + + @ManyToOne + @JoinColumn(name = "student_id") + val student: StudentJpaEntity +) : BaseUuidEntity(id) \ No newline at end of file From 50ef3f7ed1db6ff30fe6eca4d06fdfc44428b49f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 07:13:59 +0900 Subject: [PATCH 007/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/AuthenticationJpaRepository.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt new file mode 100644 index 00000000..d2541351 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt @@ -0,0 +1,7 @@ +package team.msg.sms.persistence.authentication.repository + +import org.springframework.data.jpa.repository.JpaRepository +import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity +import java.util.* + +interface AuthenticationJpaRepository : JpaRepository \ No newline at end of file From b53e49ea0fd6c217a8923ac4739872b04dc58bd4 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 07:14:12 +0900 Subject: [PATCH 008/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20history=20repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/AuthenticationHistoryJpaRepository.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt new file mode 100644 index 00000000..96648a9a --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -0,0 +1,5 @@ +package team.msg.sms.persistence.authentication.repository + +import org.springframework.data.jpa.repository.JpaRepository + +interface AuthenticationHistoryJpaRepository : JpaRepository \ No newline at end of file From 606909783f5ff39268e6eae8558250c42b1f110c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 23 Feb 2024 07:32:06 +0900 Subject: [PATCH 009/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20history=20domain=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/AuthenticationHistory.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt new file mode 100644 index 00000000..0a689e30 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt @@ -0,0 +1,16 @@ +package team.msg.sms.domain.authentication.model + +import team.msg.sms.common.annotation.Aggregate +import java.time.LocalDate +import java.util.* + +@Aggregate +class AuthenticationHistory ( + val id: Long, + val reason: String, + val activityImages: List = mutableListOf(), + val activityStatus: ActivityStatus = ActivityStatus.PENDING, + val teacherId: UUID? = null, + val authenticationId: UUID, + val createdAt: LocalDate +) \ No newline at end of file From 7094a5fd83cd1d2af3c3867cdfc97c15615182ed Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 29 Feb 2024 19:12:44 +0900 Subject: [PATCH 010/183] =?UTF-8?q?=F0=9F=94=A8=20tag=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20if=EB=AC=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/server_start.sh | 66 +++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/scripts/server_start.sh b/scripts/server_start.sh index 15251799..ed989cfd 100644 --- a/scripts/server_start.sh +++ b/scripts/server_start.sh @@ -2,36 +2,44 @@ aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${REPO_URL} -docker pull ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} -docker pull ${NGINX_URl} -docker compose up -d redis -EXIST_BLUE=$(docker compose ps blue | grep Up) +if [ ${IMAGE_TAG} == "production" ]; then + docker pull ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} + docker pull ${NGINX_URl} + + docker compose up -d redis + + EXIST_BLUE=$(docker compose ps blue | grep Up) + + if [ -z "$EXIST_BLUE" ]; then + echo "blue up" + docker compose up -d blue + BEFORE_COMPOSE_COLOR="green" + AFTER_COMPOSE_COLOR="blue" + sleep 5 + docker compose rm -svf nginx + docker compose up -d nginx + else + echo "green up" + docker compose up -d green + BEFORE_COMPOSE_COLOR="blue" + AFTER_COMPOSE_COLOR="green" + sleep 5 + docker compose rm -svf nginx + docker compose up -d nginx + docker exec nginx sed -i "s|server blue:8080|server green:8090|" /etc/nginx/conf.d/default.conf + fi + + sleep 10 + + EXIST_AFTER=$(docker compose ps ${AFTER_COMPOSE_COLOR}| grep Up) + if [ -n "$EXIST_AFTER" ]; then + docker compose rm -svf ${BEFORE_COMPOSE_COLOR} + echo "$BEFORE_COMPOSE_COLOR down" + fi + -if [ -z "$EXIST_BLUE" ]; then - echo "blue up" - docker compose up -d blue - BEFORE_COMPOSE_COLOR="green" - AFTER_COMPOSE_COLOR="blue" - sleep 5 - docker compose rm -svf nginx - docker compose up -d nginx else - echo "green up" - docker compose up -d green - BEFORE_COMPOSE_COLOR="blue" - AFTER_COMPOSE_COLOR="green" - sleep 5 - docker compose rm -svf nginx - docker compose up -d nginx - docker exec nginx sed -i "s|server blue:8080|server green:8090|" /etc/nginx/conf.d/default.conf -fi - -sleep 10 - -EXIST_AFTER=$(docker compose ps ${AFTER_COMPOSE_COLOR}| grep Up) -if [ -n "$EXIST_AFTER" ]; then - docker compose rm -svf ${BEFORE_COMPOSE_COLOR} - echo "$BEFORE_COMPOSE_COLOR down" -fi + docker-compose -f docker-compose-develop.yml up -d +fi \ No newline at end of file From ad4e295211ca8bbf518a34ddc5f931fe37418439 Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 29 Feb 2024 19:14:09 +0900 Subject: [PATCH 011/183] =?UTF-8?q?=F0=9F=92=9A=20develop=20server?= =?UTF-8?q?=EC=9A=A9=20image=20tag=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_develop_cd.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index f8874013..d75a0f28 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -2,9 +2,10 @@ name: Deploy to Develop server on: push: - branches: ?? - - feature/261-develop-server + branches: - develop + - feature/261-develop-server + jobs: CD: name: CD @@ -37,6 +38,8 @@ jobs: run: chmod +x gradlew - name: Create application.yml + env: + IMAGE_TAG: ${{ secrets.DEVELOP_IMAGE_TAG }} run: | touch ./sms-infrastructure/src/main/resources/application.yml echo "${{ secrets.SMS_BACKEND_ENV }}" > ./sms-infrastructure/src/main/resources/application.yml @@ -60,7 +63,7 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ secrets.Develop_IMAGE_TAG }} + IMAGE_TAG: ${{ secrets.DEVELOP_IMAGE_TAG }} run: | docker build -t ${{ secrets.ECR_REPOSITORY }} . docker tag ${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG ${{ secrets.REPO_URL }}:$IMAGE_TAG From 5abd87ba4c8982c40d801b93bfe131b55bbd5d4a Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 29 Feb 2024 19:15:34 +0900 Subject: [PATCH 012/183] =?UTF-8?q?=F0=9F=91=B7=20develop=20server?= =?UTF-8?q?=EC=9A=A9=20docker-compose=ED=8C=8C=EC=9D=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appspec.yml | 3 +++ docker-compose-develop.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docker-compose-develop.yml diff --git a/appspec.yml b/appspec.yml index eed91b6c..b94d796c 100644 --- a/appspec.yml +++ b/appspec.yml @@ -5,6 +5,9 @@ files: - source: /docker-compose.yml destination: /home/ubuntu/ overwrite: yes + - source: /docker-compose-develop.yml + destination: /home/ubuntu/ + overwrite: yes file_exists_behavior: OVERWRITE diff --git a/docker-compose-develop.yml b/docker-compose-develop.yml new file mode 100644 index 00000000..9ba1aef1 --- /dev/null +++ b/docker-compose-develop.yml @@ -0,0 +1,36 @@ +version: "3.7" + +services: + develop: + image : ${REPO_URL}/${ECR_REPOSITORY}:${IMAGE_TAG} + ports: + - 8080:8080 + networks: + - backend + logging: + driver: awslogs + options: + awslogs-group: "sms-develop-server-logs" + awslogs-region: "ap-northeast-2" + awslogs-stream: "backend-start-logs" + + redis: + image : redis:alpine + ports: + - 6379:6379 + networks: + - backend + + nginx: + image : ${NGINX_URL} + ports: + - 80:80 + networks: + - backend + + + + +networks: + backend: + driver: bridge From bf53525fe791c8fbbdd743c63f24dea6534231a8 Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 29 Feb 2024 19:31:33 +0900 Subject: [PATCH 013/183] =?UTF-8?q?=F0=9F=92=9A=20image=20tag=EA=B0=92=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_develop_cd.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index d75a0f28..d8d91cc7 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -63,11 +63,10 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ secrets.DEVELOP_IMAGE_TAG }} run: | docker build -t ${{ secrets.ECR_REPOSITORY }} . - docker tag ${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG ${{ secrets.REPO_URL }}:$IMAGE_TAG - docker push ${{ secrets.REPO_URL }}:$IMAGE_TAG + docker tag ${{ secrets.ECR_REPOSITORY }}:${{ secrets.DEVELOP_IMAGE_TAG }} ${{ secrets.REPO_URL }}:${{ secrets.DEVELOP_IMAGE_TAG }} + docker push ${{ secrets.REPO_URL }}:${{ secrets.DEVELOP_IMAGE_TAG }} - name : CodeDeploy Create Deployment run: | From dbd74b868c7bb7601207bfede7b3e4255046372c Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 29 Feb 2024 19:55:20 +0900 Subject: [PATCH 014/183] =?UTF-8?q?=F0=9F=92=9A=20docker=20build=20tag=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_develop_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index d8d91cc7..bc44ee8c 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -64,7 +64,7 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | - docker build -t ${{ secrets.ECR_REPOSITORY }} . + docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.DEVELOP_IMAGE_TAG }} . docker tag ${{ secrets.ECR_REPOSITORY }}:${{ secrets.DEVELOP_IMAGE_TAG }} ${{ secrets.REPO_URL }}:${{ secrets.DEVELOP_IMAGE_TAG }} docker push ${{ secrets.REPO_URL }}:${{ secrets.DEVELOP_IMAGE_TAG }} From dcb550aca0f490d6e94439464c4ecd836037028e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 08:39:57 +0900 Subject: [PATCH 015/183] =?UTF-8?q?:sparkles:=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A0=9C=20domain=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/authentication/model/Authentication.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt new file mode 100644 index 00000000..e41271e4 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt @@ -0,0 +1,15 @@ +package team.msg.sms.domain.authentication.model + +import team.msg.sms.common.annotation.Aggregate +import java.util.* + +@Aggregate +class Authentication ( + val id: UUID, + val title: String, + val content: String, + val activityImages: List = mutableListOf(), + val score: Int = 0, + val activityStatus: ActivityStatus = ActivityStatus.PENDING, + val studentId: UUID +) \ No newline at end of file From 207ec171b9f5bc38e0c4a9e8d3a88f6d69337521 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 10:11:27 +0900 Subject: [PATCH 016/183] :sparkles: create authentication domain data --- .../dto/req/CreateAuthenticationRequestData.kt | 7 +++++++ .../dto/res/CreateAuthenticationResponseData.kt | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationRequestData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationRequestData.kt new file mode 100644 index 00000000..d7c180c9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationRequestData.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.req + +data class CreateAuthenticationRequestData ( + val title: String, + val content: String, + val activityImages: List +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationResponseData.kt new file mode 100644 index 00000000..58ae832f --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationResponseData.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.util.UUID + +data class CreateAuthenticationResponseData( + val id: UUID +) From af06fd928b4dc710d06ef97a183e7db916cef157 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 10:11:55 +0900 Subject: [PATCH 017/183] :sparkles: create authentication web data --- .../req/CreateAuthenticationWebRequest.kt | 24 +++++++++++++++++++ .../res/CreateAuthenticationWebResponse.kt | 7 ++++++ 2 files changed, 31 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt new file mode 100644 index 00000000..89d1a0fc --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt @@ -0,0 +1,24 @@ +package team.msg.sms.domain.authentication.req + +import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationRequestData +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size + +data class CreateAuthenticationWebRequest ( + @field:NotBlank + val title: String, + + @field:NotBlank + val content: String, + + @field:NotNull + @field:Size(max = 4) + val activityImages: List +) { + fun toData() = CreateAuthenticationRequestData( + title = title, + content = content, + activityImages = activityImages + ) +} \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt new file mode 100644 index 00000000..caa6f24e --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.res + +import java.util.UUID + +data class CreateAuthenticationWebResponse ( + val id: UUID +) \ No newline at end of file From 9a3a9707c8c85ce2d767d1f6255fff59864189bc Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 10:12:20 +0900 Subject: [PATCH 018/183] :sparkles: create authentication web endpoint --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index b862cfc6..acc48ad2 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -69,6 +69,8 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET,"/authentication").hasAuthority(STUDENT) + .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() From 194d01776e3503e53ac47a3a059076eb02d3d39f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 18:04:38 +0900 Subject: [PATCH 019/183] :sparkles: authentication port --- .../domain/authentication/spi/AuthenticationHistoryPort.kt | 3 +++ .../sms/domain/authentication/spi/AuthenticationPort.kt | 3 +++ .../authentication/spi/CommandAuthenticationHistoryPort.kt | 7 +++++++ .../domain/authentication/spi/CommandAuthenticationPort.kt | 7 +++++++ 4 files changed, 20 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt new file mode 100644 index 00000000..1b6ef56e --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt @@ -0,0 +1,3 @@ +package team.msg.sms.domain.authentication.spi + +interface AuthenticationHistoryPort : CommandAuthenticationHistoryPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt new file mode 100644 index 00000000..06d965e2 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt @@ -0,0 +1,3 @@ +package team.msg.sms.domain.authentication.spi + +interface AuthenticationPort : CommandAuthenticationPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt new file mode 100644 index 00000000..a3cdab7b --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.spi + +import team.msg.sms.domain.authentication.model.AuthenticationHistory + +interface CommandAuthenticationHistoryPort { + fun save(authenticationHistory: AuthenticationHistory): AuthenticationHistory +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt new file mode 100644 index 00000000..a32b98b9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.spi + +import team.msg.sms.domain.authentication.model.Authentication + +interface CommandAuthenticationPort { + fun save(authentication: Authentication): Authentication +} \ No newline at end of file From 9a983c735722d0408945cd131b54059d670d43d6 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 18:20:41 +0900 Subject: [PATCH 020/183] =?UTF-8?q?:bug:=20@Repository=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/AuthenticationHistoryJpaRepository.kt | 2 ++ .../authentication/repository/AuthenticationJpaRepository.kt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index 96648a9a..db7bc9ce 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -1,5 +1,7 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository +@Repository interface AuthenticationHistoryJpaRepository : JpaRepository \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt index d2541351..80ba09d2 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt @@ -1,7 +1,9 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity import java.util.* +@Repository interface AuthenticationJpaRepository : JpaRepository \ No newline at end of file From 0b63e9fd62e30c576e3fa43a6ee3c54d643a8485 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 18:58:59 +0900 Subject: [PATCH 021/183] =?UTF-8?q?:bug:=20=EB=A7=A4=EA=B0=9C=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spi/CommandAuthenticationHistoryPort.kt | 10 +++++++++- .../authentication/spi/CommandAuthenticationPort.kt | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt index a3cdab7b..d6a07826 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt @@ -1,7 +1,15 @@ package team.msg.sms.domain.authentication.spi +import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User interface CommandAuthenticationHistoryPort { - fun save(authenticationHistory: AuthenticationHistory): AuthenticationHistory + fun save( + authenticationHistory: AuthenticationHistory, + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt index a32b98b9..fbb7fbf2 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt @@ -1,7 +1,13 @@ package team.msg.sms.domain.authentication.spi import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User interface CommandAuthenticationPort { - fun save(authentication: Authentication): Authentication + fun save( + authentication: Authentication, + student: Student, + user: User + ): Authentication } \ No newline at end of file From 43ca9677b879d4970a8276688bc388a054ef63b0 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 19:56:51 +0900 Subject: [PATCH 022/183] :recycle: authtication history domain model --- .../domain/authentication/model/AuthenticationHistory.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt index 0a689e30..39e541ec 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt @@ -6,11 +6,10 @@ import java.util.* @Aggregate class AuthenticationHistory ( - val id: Long, + val id: Long = 0, val reason: String, - val activityImages: List = mutableListOf(), - val activityStatus: ActivityStatus = ActivityStatus.PENDING, + val activityStatus: ActivityStatus, val teacherId: UUID? = null, val authenticationId: UUID, - val createdAt: LocalDate + val createdAt: LocalDate = LocalDate.now() ) \ No newline at end of file From 48354004e87f7d3005db4cdf8ff066a6a0ac9bdf Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 19:57:17 +0900 Subject: [PATCH 023/183] :sparkles: authtication mapper --- .../mapper/AuthenticationHistoryMapper.kt | 25 +++++++++++++++++++ .../mapper/AuthenticationMapper.kt | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt new file mode 100644 index 00000000..f5841314 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt @@ -0,0 +1,25 @@ +package team.msg.sms.persistence.authentication.mapper + +import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.persistence.authentication.entity.AuthenticationHistoryJpaEntity +import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity +import team.msg.sms.persistence.teacher.entity.TeacherJpaEntity + +fun AuthenticationHistory.toEntity( + authentication: AuthenticationJpaEntity, + teacher: TeacherJpaEntity? = null +) = AuthenticationHistoryJpaEntity( + id = id, + reason = reason, + activityStatus = activityStatus, + teacher = teacher, + authentication = authentication +) + +fun AuthenticationHistoryJpaEntity.toDomain() = AuthenticationHistory( + id = id, + reason = reason, + activityStatus = activityStatus, + teacherId = teacher?.id, + authenticationId = authentication.id +) \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt new file mode 100644 index 00000000..a5cdd158 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt @@ -0,0 +1,25 @@ +package team.msg.sms.persistence.authentication.mapper + +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity +import team.msg.sms.persistence.student.entity.StudentJpaEntity + +fun Authentication.toEntity(student: StudentJpaEntity) = AuthenticationJpaEntity( + id = id, + title = title, + content = content, + activityImages = activityImages, + score = score, + activityStatus = activityStatus, + student = student, +) + +fun AuthenticationJpaEntity.toDomain() = Authentication( + id = id, + title = title, + content = content, + activityImages = activityImages, + score = score, + activityStatus = activityStatus, + studentId = student.id +) \ No newline at end of file From 2af49e353cdd910abfe493c9e6c4254d9884053e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:07:35 +0900 Subject: [PATCH 024/183] =?UTF-8?q?:bug:=20=ED=83=80=EC=9E=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/AuthenticationHistoryJpaRepository.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index db7bc9ce..c6727120 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -2,6 +2,7 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository +import team.msg.sms.persistence.authentication.entity.AuthenticationHistoryJpaEntity @Repository -interface AuthenticationHistoryJpaRepository : JpaRepository \ No newline at end of file +interface AuthenticationHistoryJpaRepository : JpaRepository \ No newline at end of file From 0b4ace2a74c37cbe844448a543d9f218bcfb2ccd Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:08:56 +0900 Subject: [PATCH 025/183] =?UTF-8?q?:sparkles:=20authentication=20port=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...AuthenticationHistoryPersistenceAdapter.kt | 26 +++++++++++++++++++ .../AuthenticationPersistenceAdapter.kt | 25 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt new file mode 100644 index 00000000..5a04bb26 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt @@ -0,0 +1,26 @@ +package team.msg.sms.persistence.authentication + +import org.springframework.stereotype.Component +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.domain.authentication.spi.AuthenticationHistoryPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User +import team.msg.sms.persistence.authentication.mapper.toDomain +import team.msg.sms.persistence.authentication.mapper.toEntity +import team.msg.sms.persistence.authentication.repository.AuthenticationHistoryJpaRepository +import team.msg.sms.persistence.student.mapper.toEntity +import team.msg.sms.persistence.user.mapper.toEntity + +@Component +class AuthenticationHistoryPersistenceAdapter( + private val authenticationHistoryJpaRepository: AuthenticationHistoryJpaRepository +) : AuthenticationHistoryPort { + override fun save( + authenticationHistory: AuthenticationHistory, + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory = + authenticationHistoryJpaRepository.save(authenticationHistory.toEntity(authentication.toEntity(student.toEntity(user.toEntity())))).toDomain() +} \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt new file mode 100644 index 00000000..08184d52 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -0,0 +1,25 @@ +package team.msg.sms.persistence.authentication + +import org.springframework.stereotype.Component +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.spi.AuthenticationPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User +import team.msg.sms.persistence.authentication.mapper.toDomain +import team.msg.sms.persistence.authentication.mapper.toEntity +import team.msg.sms.persistence.authentication.repository.AuthenticationJpaRepository +import team.msg.sms.persistence.student.mapper.toEntity +import team.msg.sms.persistence.user.mapper.toEntity + +@Component +class AuthenticationPersistenceAdapter( + private val authenticationJpaRepository: AuthenticationJpaRepository +) : AuthenticationPort { + override fun save( + authentication: Authentication, + student: Student, + user: User + ): Authentication = + authenticationJpaRepository.save(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() + +} \ No newline at end of file From 8cbb8e7c0b4f3159addf4db4016ea19513e9f724 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:43:10 +0900 Subject: [PATCH 026/183] :sparkles: authentication history event --- .../event/AuthenticationHistoryEvent.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/event/AuthenticationHistoryEvent.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/event/AuthenticationHistoryEvent.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/event/AuthenticationHistoryEvent.kt new file mode 100644 index 00000000..7adfb07a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/event/AuthenticationHistoryEvent.kt @@ -0,0 +1,14 @@ +package team.msg.sms.domain.authentication.event + +import team.msg.sms.domain.authentication.model.Authentication +import java.util.UUID + +/** + * 인증제 히스토리를 저장하는 event입니다. + * 인증제 활동이 저장되거나 변경될 때 발행됩니다. + */ +data class AuthenticationHistoryEvent ( + val authentication: Authentication, + val reason: String, + val teacherId: UUID? = null +) \ No newline at end of file From 12f3b1db37b7d664e6096f678496f4e35aae98c8 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:43:33 +0900 Subject: [PATCH 027/183] :sparkles: authentication event handler --- .../handler/AuthenticationEventHandler.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt new file mode 100644 index 00000000..d7638eb1 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt @@ -0,0 +1,37 @@ +package team.msg.sms.domain.authentication.handler + +import org.springframework.stereotype.Component +import org.springframework.transaction.event.TransactionPhase +import org.springframework.transaction.event.TransactionalEventListener +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.domain.authentication.spi.AuthenticationHistoryPort +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService + +@Component +class AuthenticationEventHandler( + private val authenticationHistoryPort: AuthenticationHistoryPort, + private val studentService: StudentService, + private val userService: UserService +) { + + /** + * authentication history event가 발행되면 히스토리를 저장하는 핸들러입니다. + * @param authentication history event + */ + @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) + fun authenticationHistoryHandler(event: AuthenticationHistoryEvent) { + val authentication = event.authentication + val student = studentService.getStudentByUuid(authentication.studentId) + val studentUser = userService.getUserById(student.userId) + val history = AuthenticationHistory( + reason = event.reason, + activityStatus = authentication.activityStatus, + teacherId = event.teacherId, + authenticationId = authentication.id + ) + + authenticationHistoryPort.save(history, authentication, student, studentUser) + } +} \ No newline at end of file From 4359562e46a5fcb42b608b50dc7cf8cd52934959 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:45:25 +0900 Subject: [PATCH 028/183] :sparkles: authentication service --- .../service/AuthenticationService.kt | 5 +++++ .../service/CommandAuthenticationService.kt | 13 +++++++++++++ .../impl/CommandAuthenticationServiceImpl.kt | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt new file mode 100644 index 00000000..0aea4b7e --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.service + +class AuthenticationService( + commandAuthenticationService: CommandAuthenticationService +) : CommandAuthenticationService by commandAuthenticationService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt new file mode 100644 index 00000000..c01c6cb0 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User + +interface CommandAuthenticationService { + fun save( + authentication: Authentication, + student: Student, + user: User + ): Authentication +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt new file mode 100644 index 00000000..739f79ba --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt @@ -0,0 +1,19 @@ +package team.msg.sms.domain.authentication.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.CommandAuthenticationService +import team.msg.sms.domain.authentication.spi.AuthenticationPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User + +@Service +class CommandAuthenticationServiceImpl( + private val authenticationPort: AuthenticationPort +) : CommandAuthenticationService { + override fun save( + authentication: Authentication, + student: Student, + user: User + ) = authenticationPort.save(authentication, student, user) +} \ No newline at end of file From a1212357ceed296b95007dda1a64d13ac186026e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:47:12 +0900 Subject: [PATCH 029/183] :sparkles: authentication web adapter --- .../AuthenticationWebAdapter.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt new file mode 100644 index 00000000..f808dfe5 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -0,0 +1,28 @@ +package team.msg.sms.domain.authentication + +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData +import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest +import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse +import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase +import javax.validation.Valid + +@RestController +@RequestMapping("/authentication") +class AuthenticationWebAdapter( + private val createAuthenticationUseCase: CreateAuthenticationUseCase +) { + @PostMapping + fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = + createAuthenticationUseCase.execute(request.toData()) + .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } + + private fun CreateAuthenticationResponseData.toResponse() = CreateAuthenticationWebResponse( + id = id + ) +} \ No newline at end of file From b0e217f8c3c8ba5f817129a91b7a255d1b8b8bbb Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:47:30 +0900 Subject: [PATCH 030/183] :sparkles: create authentication usecase --- .../usecase/CreateAuthenticationUseCase.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/CreateAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/CreateAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/CreateAuthenticationUseCase.kt new file mode 100644 index 00000000..06457d1d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/CreateAuthenticationUseCase.kt @@ -0,0 +1,44 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class CreateAuthenticationUseCase( + private val studentService: StudentService, + private val userService: UserService, + private val authenticationService: AuthenticationService, + private val applicationEventPublisher: ApplicationEventPublisher +) { + @Transactional(rollbackFor = [Exception::class]) + fun execute(createData: CreateAuthenticationRequestData): CreateAuthenticationResponseData { + val user = userService.getCurrentUser() + val student = studentService.getStudentByUser(user) + + val authentication = Authentication( + id = UUID.randomUUID(), + title = createData.title, + content = createData.content, + activityImages = createData.activityImages, + studentId = student.id + ).let { authenticationService.save(it, student, user) } + + AuthenticationHistoryEvent( + authentication = authentication, + reason = "활동이 저장되었습니다." + ).let { applicationEventPublisher.publishEvent(it) } + + return CreateAuthenticationResponseData( + id = authentication.id + ) + } +} \ No newline at end of file From 9f09244515cc202afcb57aaa37708fea6ae4986d Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 20:57:38 +0900 Subject: [PATCH 031/183] =?UTF-8?q?:bug:=20@Service=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/service/AuthenticationService.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt index 0aea4b7e..3b490141 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -1,5 +1,8 @@ package team.msg.sms.domain.authentication.service +import team.msg.sms.common.annotation.Service + +@Service class AuthenticationService( commandAuthenticationService: CommandAuthenticationService ) : CommandAuthenticationService by commandAuthenticationService \ No newline at end of file From 85e8d0b010f21c21ee47b1018666843107a602b7 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 22:49:30 +0900 Subject: [PATCH 032/183] =?UTF-8?q?:recycle:=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/handler/AuthenticationEventHandler.kt | 8 +++++++- .../msg/sms/domain/student/service/GetStudentService.kt | 2 +- .../domain/student/service/impl/GetStudentServiceImpl.kt | 4 ++-- .../team/msg/sms/domain/student/spi/QueryStudentPort.kt | 2 +- .../sms/persistence/student/StudentPersistenceAdapter.kt | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt index d7638eb1..40436611 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt @@ -22,9 +22,13 @@ class AuthenticationEventHandler( */ @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) fun authenticationHistoryHandler(event: AuthenticationHistoryEvent) { + println(1) val authentication = event.authentication - val student = studentService.getStudentByUuid(authentication.studentId) + println(2) + val student = studentService.getStudentByUserId(authentication.studentId) + println(3) val studentUser = userService.getUserById(student.userId) + println(4) val history = AuthenticationHistory( reason = event.reason, activityStatus = authentication.activityStatus, @@ -32,6 +36,8 @@ class AuthenticationEventHandler( authenticationId = authentication.id ) + println(5) authenticationHistoryPort.save(history, authentication, student, studentUser) + println(6) } } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt index bcfb4c49..8341a520 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt @@ -18,7 +18,7 @@ interface GetStudentService { fun getStudentUserInfoByUuid(uuid: String): Student.StudentWithUserInfo - fun getStudentByUuid(uuid: UUID): Student + fun getStudentByUserId(uuid: UUID): Student fun getStudentByUser(user: User): Student diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt index 95eea3f5..af8da51e 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt @@ -45,11 +45,11 @@ class GetStudentServiceImpl( } } - override fun getStudentByUuid(uuid: UUID): Student = + override fun getStudentByUserId(uuid: UUID): Student = studentPort.queryStudentByUserId(uuid) override fun getStudentUserInfoByUuid(uuid: String): Student.StudentWithUserInfo = - studentPort.queryStudentById(UUID.fromString(uuid)) ?: throw StudentNotFoundException + studentPort.queryStudentWithUserInfoById(UUID.fromString(uuid)) ?: throw StudentNotFoundException override fun getStudentByUser(user: User): Student = studentPort.queryStudentByUser(user) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt index 4de9bb19..ebe47680 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt @@ -5,7 +5,7 @@ import team.msg.sms.domain.user.model.User import java.util.UUID interface QueryStudentPort { - fun queryStudentById(uuid: UUID): Student.StudentWithUserInfo? + fun queryStudentWithUserInfoById(uuid: UUID): Student.StudentWithUserInfo? fun queryStudentsWithPage(page: Int, size: Int): Student.StudentWithPageInfo fun queryStudentByUserId(userId: UUID): Student fun queryStudentUserInfoByUserId(userId: UUID): Student.StudentWithUserInfo? diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt index 4856db96..709e1f19 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt @@ -29,7 +29,7 @@ class StudentPersistenceAdapter( override fun deleteById(studentId: UUID) = studentJpaRepository.deleteById(studentId) - override fun queryStudentById(uuid: UUID): Student.StudentWithUserInfo? = + override fun queryStudentWithUserInfoById(uuid: UUID): Student.StudentWithUserInfo? = studentJpaRepository.findByIdOrNull(uuid)?.toDomainWithUserInfo() override fun existsStudentById(uuid: UUID): Boolean = From 7924ae5c9b310a43e38379a45298fad48e8911d2 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 22:57:45 +0900 Subject: [PATCH 033/183] :sparkles: query student by id --- .../team/msg/sms/domain/student/service/GetStudentService.kt | 2 ++ .../sms/domain/student/service/impl/GetStudentServiceImpl.kt | 3 +++ .../kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt | 1 + .../msg/sms/persistence/student/StudentPersistenceAdapter.kt | 3 +++ 4 files changed, 9 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt index 8341a520..f0841661 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentService.kt @@ -18,6 +18,8 @@ interface GetStudentService { fun getStudentUserInfoByUuid(uuid: String): Student.StudentWithUserInfo + fun getStudentById(uuid: UUID): Student + fun getStudentByUserId(uuid: UUID): Student fun getStudentByUser(user: User): Student diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt index af8da51e..b4aa5ea8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentServiceImpl.kt @@ -51,6 +51,9 @@ class GetStudentServiceImpl( override fun getStudentUserInfoByUuid(uuid: String): Student.StudentWithUserInfo = studentPort.queryStudentWithUserInfoById(UUID.fromString(uuid)) ?: throw StudentNotFoundException + override fun getStudentById(uuid: UUID): Student = + studentPort.queryStudentById(uuid) ?: throw StudentNotFoundException + override fun getStudentByUser(user: User): Student = studentPort.queryStudentByUser(user) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt index ebe47680..2c6bee3b 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentPort.kt @@ -6,6 +6,7 @@ import java.util.UUID interface QueryStudentPort { fun queryStudentWithUserInfoById(uuid: UUID): Student.StudentWithUserInfo? + fun queryStudentById(uuid: UUID): Student? fun queryStudentsWithPage(page: Int, size: Int): Student.StudentWithPageInfo fun queryStudentByUserId(userId: UUID): Student fun queryStudentUserInfoByUserId(userId: UUID): Student.StudentWithUserInfo? diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt index 709e1f19..084be40f 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentPersistenceAdapter.kt @@ -32,6 +32,9 @@ class StudentPersistenceAdapter( override fun queryStudentWithUserInfoById(uuid: UUID): Student.StudentWithUserInfo? = studentJpaRepository.findByIdOrNull(uuid)?.toDomainWithUserInfo() + override fun queryStudentById(uuid: UUID): Student? = + studentJpaRepository.findByIdOrNull(uuid)?.toDomain() + override fun existsStudentById(uuid: UUID): Boolean = studentJpaRepository.existsById(uuid) From 60c94b0978b47c2858f176e2d4bab72f8f2c1f78 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 23:04:46 +0900 Subject: [PATCH 034/183] :bug: query student by user id -> query student by id --- .../authentication/handler/AuthenticationEventHandler.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt index 40436611..4586ff5f 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/handler/AuthenticationEventHandler.kt @@ -22,13 +22,10 @@ class AuthenticationEventHandler( */ @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) fun authenticationHistoryHandler(event: AuthenticationHistoryEvent) { - println(1) val authentication = event.authentication - println(2) - val student = studentService.getStudentByUserId(authentication.studentId) - println(3) + val student = studentService.getStudentById(authentication.studentId) val studentUser = userService.getUserById(student.userId) - println(4) + val history = AuthenticationHistory( reason = event.reason, activityStatus = authentication.activityStatus, @@ -36,8 +33,6 @@ class AuthenticationEventHandler( authenticationId = authentication.id ) - println(5) authenticationHistoryPort.save(history, authentication, student, studentUser) - println(6) } } \ No newline at end of file From 9c6d162d27f57536e86d52289e8d36d791eeb3d1 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 4 Mar 2024 23:11:15 +0900 Subject: [PATCH 035/183] :bug: GET -> POST --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index acc48ad2..71bbe697 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -69,7 +69,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) - .antMatchers(HttpMethod.GET,"/authentication").hasAuthority(STUDENT) + .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() From 8debf9c611e8f676f0913447969e401b5df2c91c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 08:26:23 +0900 Subject: [PATCH 036/183] :sparkles: query authentication details endpoint --- .../msg/sms/global/security/SecurityConfig.kt | 1 + .../AuthenticationWebAdapter.kt | 39 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 71bbe697..3cc45cec 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -70,6 +70,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) + .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index f808dfe5..af957792 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -2,27 +2,56 @@ package team.msg.sms.domain.authentication import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController +import org.springframework.web.bind.annotation.* +import team.msg.sms.common.exception.InvalidUuidException import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse +import team.msg.sms.domain.authentication.res.QueryAuthenticationDetailsWebResponse import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase +import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase +import java.util.* import javax.validation.Valid @RestController @RequestMapping("/authentication") class AuthenticationWebAdapter( - private val createAuthenticationUseCase: CreateAuthenticationUseCase + private val createAuthenticationUseCase: CreateAuthenticationUseCase, + private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = createAuthenticationUseCase.execute(request.toData()) .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } + @GetMapping("/{uuid}") + fun queryAuthenticationDetails(@PathVariable uuid: String): ResponseEntity { + if (!isValidUUID(uuid)) throw InvalidUuidException + return queryAuthenticationDetailsUseCase.execute(uuid) + .let { ResponseEntity.ok(it.toResponse()) } + } + private fun CreateAuthenticationResponseData.toResponse() = CreateAuthenticationWebResponse( id = id ) + + private fun QueryAuthenticationDetailsResponseData.toResponse() = QueryAuthenticationDetailsWebResponse( + id = id, + title = title, + content = content, + activityImages = activityImages, + lastModifiedDate = lastModifiedDate, + score = score, + activityStatus = activityStatus + ) + + private fun isValidUUID(uuid: String): Boolean { + return try { + UUID.fromString(uuid) + true + } catch (ex: IllegalArgumentException) { + false + } + } } \ No newline at end of file From 53392c98c639f77d408d98ef50a886ec65ca2096 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 08:26:42 +0900 Subject: [PATCH 037/183] :sparkles: query authentication details response data --- .../res/QueryAuthenticationDetailsResponseData.kt | 15 +++++++++++++++ .../res/QueryAuthenticationDetailsWebResponse.kt | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsResponseData.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsResponseData.kt new file mode 100644 index 00000000..bb0a3c00 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsResponseData.kt @@ -0,0 +1,15 @@ +package team.msg.sms.domain.authentication.dto.res + +import team.msg.sms.domain.authentication.model.ActivityStatus +import java.time.LocalDate +import java.util.UUID + +data class QueryAuthenticationDetailsResponseData ( + val id: UUID, + val title: String, + val content: String, + val activityImages: List, + val lastModifiedDate: LocalDate, + val score: Int, + val activityStatus: ActivityStatus +) \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt new file mode 100644 index 00000000..62cd2000 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt @@ -0,0 +1,15 @@ +package team.msg.sms.domain.authentication.res + +import team.msg.sms.domain.authentication.model.ActivityStatus +import java.time.LocalDate +import java.util.* + +data class QueryAuthenticationDetailsWebResponse( + val id: UUID, + val title: String, + val content: String, + val activityImages: List, + val lastModifiedDate: LocalDate, + val score: Int, + val activityStatus: ActivityStatus +) From 2ccc1afff7fded626d3f10a130b4dd9c0241022e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:09:02 +0900 Subject: [PATCH 038/183] :sparkles: get authentication service --- .../service/AuthenticationService.kt | 6 ++++-- .../service/GetAuthenticationService.kt | 8 ++++++++ .../service/impl/GetAuthenticationServiceImpl.kt | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt index 3b490141..e11febe4 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -4,5 +4,7 @@ import team.msg.sms.common.annotation.Service @Service class AuthenticationService( - commandAuthenticationService: CommandAuthenticationService -) : CommandAuthenticationService by commandAuthenticationService \ No newline at end of file + commandAuthenticationService: CommandAuthenticationService, + getAuthenticationService: GetAuthenticationService +) : CommandAuthenticationService by commandAuthenticationService, + GetAuthenticationService by getAuthenticationService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt new file mode 100644 index 00000000..c969cd95 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.domain.authentication.model.Authentication +import java.util.UUID + +interface GetAuthenticationService { + fun getAuthenticationByUuid(uuid: UUID): Authentication +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt new file mode 100644 index 00000000..2b9fcf4a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt @@ -0,0 +1,15 @@ +package team.msg.sms.domain.authentication.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.GetAuthenticationService +import team.msg.sms.domain.authentication.spi.QueryAuthenticationPort +import java.util.UUID + +@Service +class GetAuthenticationServiceImpl( + private val queryAuthenticationPort: QueryAuthenticationPort +) : GetAuthenticationService { + override fun getAuthenticationByUuid(uuid: UUID): Authentication = + queryAuthenticationPort.queryAuthenticationByUuid(uuid) +} \ No newline at end of file From 758e4338b9b829ad7dc83c23c9ed9147657a8076 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:09:21 +0900 Subject: [PATCH 039/183] :sparkles: get authentication history service --- .../service/AuthenticationHistoryService.kt | 8 ++++++ .../GetAuthenticationHistoryService.kt | 9 ++++++ .../GetAuthenticationHistoryServiceImpl.kt | 16 +++++++++++ .../QueryAuthenticationDetailsUseCase.kt | 28 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt new file mode 100644 index 00000000..d94f2dd9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.common.annotation.Service + +@Service +class AuthenticationHistoryService( + getAuthenticationHistoryService: GetAuthenticationHistoryService +) : GetAuthenticationHistoryService by getAuthenticationHistoryService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt new file mode 100644 index 00000000..3e0f654e --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt @@ -0,0 +1,9 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.model.AuthenticationHistory +import java.util.UUID + +interface GetAuthenticationHistoryService { + fun getLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt new file mode 100644 index 00000000..40afb378 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt @@ -0,0 +1,16 @@ +package team.msg.sms.domain.authentication.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.domain.authentication.service.GetAuthenticationHistoryService +import team.msg.sms.domain.authentication.spi.QueryAuthenticationHistoryPort + +@Service +class GetAuthenticationHistoryServiceImpl( + private val queryAuthenticationHistoryPort: QueryAuthenticationHistoryPort +) : GetAuthenticationHistoryService{ + override fun getLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory = + queryAuthenticationHistoryPort.queryLatestAuthenticationHistory(authentication) + +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt new file mode 100644 index 00000000..e403ca6d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt @@ -0,0 +1,28 @@ +package team.msg.sms.domain.authentication.usecase + +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData +import team.msg.sms.domain.authentication.service.GetAuthenticationHistoryService +import team.msg.sms.domain.authentication.spi.QueryAuthenticationPort +import java.util.* + +@UseCase +class QueryAuthenticationDetailsUseCase( + private val getAuthenticationPort: QueryAuthenticationPort, + private val getAuthenticationHistoryService: GetAuthenticationHistoryService +) { + fun execute(uuid: String): QueryAuthenticationDetailsResponseData { + val authentication = getAuthenticationPort.queryAuthenticationByUuid(UUID.fromString(uuid)) + val history = getAuthenticationHistoryService.getLatestAuthenticationHistory(authentication) + + return QueryAuthenticationDetailsResponseData( + id = authentication.id, + title = authentication.title, + content = authentication.title, + activityImages = authentication.activityImages, + lastModifiedDate = history.createdAt, + score = authentication.score, + activityStatus = authentication.activityStatus + ) + } +} \ No newline at end of file From b4cc2844869668a00b289f39c1070c341d4a91ed Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:10:10 +0900 Subject: [PATCH 040/183] :sparkles: query Authentication port --- .../authentication/spi/AuthenticationHistoryPort.kt | 2 +- .../sms/domain/authentication/spi/AuthenticationPort.kt | 2 +- .../authentication/spi/QueryAuthenticationHistoryPort.kt | 8 ++++++++ .../domain/authentication/spi/QueryAuthenticationPort.kt | 8 ++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt index 1b6ef56e..24840016 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationHistoryPort.kt @@ -1,3 +1,3 @@ package team.msg.sms.domain.authentication.spi -interface AuthenticationHistoryPort : CommandAuthenticationHistoryPort \ No newline at end of file +interface AuthenticationHistoryPort : CommandAuthenticationHistoryPort, QueryAuthenticationHistoryPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt index 06d965e2..c35a3746 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt @@ -1,3 +1,3 @@ package team.msg.sms.domain.authentication.spi -interface AuthenticationPort : CommandAuthenticationPort \ No newline at end of file +interface AuthenticationPort : CommandAuthenticationPort, QueryAuthenticationPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt new file mode 100644 index 00000000..a688aa08 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.spi + +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.model.AuthenticationHistory + +interface QueryAuthenticationHistoryPort { + fun queryLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt new file mode 100644 index 00000000..b44a9019 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.spi + +import team.msg.sms.domain.authentication.model.Authentication +import java.util.UUID + +interface QueryAuthenticationPort { + fun queryAuthenticationByUuid(uuid: UUID): Authentication +} \ No newline at end of file From 7bf84695290d58077b5338ba38330b747914d21e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:41:01 +0900 Subject: [PATCH 041/183] :sparkles: Authentication not found --- .../AuthenticationNotFoundException.kt | 8 ++++++++ .../exception/error/AuthenticationErrorCode.kt | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AuthenticationNotFoundException.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AuthenticationNotFoundException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AuthenticationNotFoundException.kt new file mode 100644 index 00000000..b5788c9d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AuthenticationNotFoundException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object AuthenticationNotFoundException : SmsException( + AuthenticationErrorCode.AUTHENTICATION_NOT_FOUND +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt new file mode 100644 index 00000000..a399c66d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -0,0 +1,17 @@ +package team.msg.sms.domain.authentication.exception.error + +import team.msg.sms.common.error.ErrorProperty +import team.msg.sms.common.error.ErrorStatus + +enum class AuthenticationErrorCode( + private val status: Int, + private val message: String +) : ErrorProperty { + AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다.") + ; + + override fun status(): Int = status + + override fun message(): String = message + +} \ No newline at end of file From 2d0c5796da56a136a4a3a612fba45d46e708cdca Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:42:14 +0900 Subject: [PATCH 042/183] =?UTF-8?q?:sparkles:=20Authentication=20null=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9=20=EB=B0=8F=20=EC=98=88=EC=99=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GetAuthenticationServiceImpl.kt | 3 ++- .../sms/domain/authentication/spi/QueryAuthenticationPort.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt index 2b9fcf4a..4d865f55 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt @@ -1,6 +1,7 @@ package team.msg.sms.domain.authentication.service.impl import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.exception.AuthenticationNotFoundException import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.GetAuthenticationService import team.msg.sms.domain.authentication.spi.QueryAuthenticationPort @@ -11,5 +12,5 @@ class GetAuthenticationServiceImpl( private val queryAuthenticationPort: QueryAuthenticationPort ) : GetAuthenticationService { override fun getAuthenticationByUuid(uuid: UUID): Authentication = - queryAuthenticationPort.queryAuthenticationByUuid(uuid) + queryAuthenticationPort.queryAuthenticationByUuid(uuid) ?: throw AuthenticationNotFoundException } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt index b44a9019..a6b72abb 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt @@ -4,5 +4,5 @@ import team.msg.sms.domain.authentication.model.Authentication import java.util.UUID interface QueryAuthenticationPort { - fun queryAuthenticationByUuid(uuid: UUID): Authentication + fun queryAuthenticationByUuid(uuid: UUID): Authentication? } \ No newline at end of file From 91bda90aa9931921f63cba53c815eed89bce5f8a Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 09:44:03 +0900 Subject: [PATCH 043/183] :sparkles: find by id --- .../authentication/AuthenticationPersistenceAdapter.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt index 08184d52..a92acafc 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -1,5 +1,6 @@ package team.msg.sms.persistence.authentication +import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Component import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.spi.AuthenticationPort @@ -10,6 +11,7 @@ import team.msg.sms.persistence.authentication.mapper.toEntity import team.msg.sms.persistence.authentication.repository.AuthenticationJpaRepository import team.msg.sms.persistence.student.mapper.toEntity import team.msg.sms.persistence.user.mapper.toEntity +import java.util.* @Component class AuthenticationPersistenceAdapter( @@ -22,4 +24,7 @@ class AuthenticationPersistenceAdapter( ): Authentication = authenticationJpaRepository.save(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() + override fun queryAuthenticationByUuid(uuid: UUID): Authentication? = + authenticationJpaRepository.findByIdOrNull(uuid)?.toDomain() + } \ No newline at end of file From 44f478a909fef3a9c145110528af00835e65be28 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 11:12:46 +0900 Subject: [PATCH 044/183] :recycle: date format --- .../kotlin/team/msg/sms/global/config/JacksonConfiguration.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt index 0b91fe33..9a81da39 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt @@ -1,5 +1,6 @@ package team.msg.sms.global.config +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -12,4 +13,5 @@ class JacksonConfiguration { fun jackson2ObjectMapperBuilder(): Jackson2ObjectMapperBuilder = Jackson2ObjectMapperBuilder() .serializers(LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))) + .serializers(LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-d"))) } \ No newline at end of file From 3ea292754e83be1aa670f49c7b259939847bae7f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 11:16:01 +0900 Subject: [PATCH 045/183] =?UTF-8?q?:sparkles:=20=EC=B5=9C=EA=B7=BC=20?= =?UTF-8?q?=ED=9E=88=EC=8A=A4=ED=86=A0=EB=A6=AC=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/AuthenticationHistory.kt | 4 ++-- .../GetAuthenticationHistoryService.kt | 9 +++++++-- .../GetAuthenticationHistoryServiceImpl.kt | 10 ++++++++-- .../spi/QueryAuthenticationHistoryPort.kt | 8 +++++++- .../QueryAuthenticationDetailsUseCase.kt | 20 ++++++++++++------- ...AuthenticationHistoryPersistenceAdapter.kt | 7 +++++++ .../entity/AuthenticationHistoryJpaEntity.kt | 7 ++++++- .../mapper/AuthenticationHistoryMapper.kt | 6 ++++-- .../AuthenticationHistoryJpaRepository.kt | 5 ++++- 9 files changed, 58 insertions(+), 18 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt index 39e541ec..da276a05 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/AuthenticationHistory.kt @@ -1,7 +1,7 @@ package team.msg.sms.domain.authentication.model import team.msg.sms.common.annotation.Aggregate -import java.time.LocalDate +import java.time.LocalDateTime import java.util.* @Aggregate @@ -11,5 +11,5 @@ class AuthenticationHistory ( val activityStatus: ActivityStatus, val teacherId: UUID? = null, val authenticationId: UUID, - val createdAt: LocalDate = LocalDate.now() + val createdAt: LocalDateTime = LocalDateTime.now() ) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt index 3e0f654e..d5935129 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt @@ -2,8 +2,13 @@ package team.msg.sms.domain.authentication.service import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.model.AuthenticationHistory -import java.util.UUID +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User interface GetAuthenticationHistoryService { - fun getLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory + fun getLatestAuthenticationHistory( + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt index 40afb378..58f9706d 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt @@ -5,12 +5,18 @@ import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.model.AuthenticationHistory import team.msg.sms.domain.authentication.service.GetAuthenticationHistoryService import team.msg.sms.domain.authentication.spi.QueryAuthenticationHistoryPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User @Service class GetAuthenticationHistoryServiceImpl( private val queryAuthenticationHistoryPort: QueryAuthenticationHistoryPort ) : GetAuthenticationHistoryService{ - override fun getLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory = - queryAuthenticationHistoryPort.queryLatestAuthenticationHistory(authentication) + override fun getLatestAuthenticationHistory( + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory = + queryAuthenticationHistoryPort.queryLatestAuthenticationHistory(authentication, student, user) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt index a688aa08..69cede04 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt @@ -2,7 +2,13 @@ package team.msg.sms.domain.authentication.spi import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.model.AuthenticationHistory +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User interface QueryAuthenticationHistoryPort { - fun queryLatestAuthenticationHistory(authentication: Authentication): AuthenticationHistory + fun queryLatestAuthenticationHistory( + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt index e403ca6d..7a41b165 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt @@ -2,25 +2,31 @@ package team.msg.sms.domain.authentication.usecase import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData -import team.msg.sms.domain.authentication.service.GetAuthenticationHistoryService -import team.msg.sms.domain.authentication.spi.QueryAuthenticationPort +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService import java.util.* @UseCase class QueryAuthenticationDetailsUseCase( - private val getAuthenticationPort: QueryAuthenticationPort, - private val getAuthenticationHistoryService: GetAuthenticationHistoryService + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val studentService: StudentService, + private val userService: UserService ) { fun execute(uuid: String): QueryAuthenticationDetailsResponseData { - val authentication = getAuthenticationPort.queryAuthenticationByUuid(UUID.fromString(uuid)) - val history = getAuthenticationHistoryService.getLatestAuthenticationHistory(authentication) + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) + val history = authenticationHistoryService.getLatestAuthenticationHistory(authentication, student, user) return QueryAuthenticationDetailsResponseData( id = authentication.id, title = authentication.title, content = authentication.title, activityImages = authentication.activityImages, - lastModifiedDate = history.createdAt, + lastModifiedDate = history.createdAt.toLocalDate(), score = authentication.score, activityStatus = authentication.activityStatus ) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt index 5a04bb26..853280b5 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt @@ -23,4 +23,11 @@ class AuthenticationHistoryPersistenceAdapter( user: User ): AuthenticationHistory = authenticationHistoryJpaRepository.save(authenticationHistory.toEntity(authentication.toEntity(student.toEntity(user.toEntity())))).toDomain() + + override fun queryLatestAuthenticationHistory( + authentication: Authentication, + student: Student, + user: User + ): AuthenticationHistory = + authenticationHistoryJpaRepository.findByAuthenticationOrderByCreatedAtDesc(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt index f8d2192a..4b352f8f 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/entity/AuthenticationHistoryJpaEntity.kt @@ -1,8 +1,10 @@ package team.msg.sms.persistence.authentication.entity +import org.springframework.data.annotation.CreatedDate import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.persistence.BaseIdEntity import team.msg.sms.persistence.teacher.entity.TeacherJpaEntity +import java.time.LocalDateTime import javax.persistence.* @Entity @@ -22,5 +24,8 @@ class AuthenticationHistoryJpaEntity ( @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "authentication_id") - val authentication: AuthenticationJpaEntity + val authentication: AuthenticationJpaEntity, + + @CreatedDate + val createdAt: LocalDateTime ) : BaseIdEntity() \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt index f5841314..004e8543 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationHistoryMapper.kt @@ -13,7 +13,8 @@ fun AuthenticationHistory.toEntity( reason = reason, activityStatus = activityStatus, teacher = teacher, - authentication = authentication + authentication = authentication, + createdAt = createdAt ) fun AuthenticationHistoryJpaEntity.toDomain() = AuthenticationHistory( @@ -21,5 +22,6 @@ fun AuthenticationHistoryJpaEntity.toDomain() = AuthenticationHistory( reason = reason, activityStatus = activityStatus, teacherId = teacher?.id, - authenticationId = authentication.id + authenticationId = authentication.id, + createdAt = createdAt ) \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index c6727120..b53b5e0f 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -3,6 +3,9 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository import team.msg.sms.persistence.authentication.entity.AuthenticationHistoryJpaEntity +import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity @Repository -interface AuthenticationHistoryJpaRepository : JpaRepository \ No newline at end of file +interface AuthenticationHistoryJpaRepository : JpaRepository { + fun findByAuthenticationOrderByCreatedAtDesc(authentication: AuthenticationJpaEntity): AuthenticationHistoryJpaEntity +} \ No newline at end of file From def5d72dddc1d4caacea1a76ba185418aaa8d12f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 15:49:15 +0900 Subject: [PATCH 046/183] =?UTF-8?q?:bug:=20=ED=8A=B8=EB=9E=9C=EC=9E=AD?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/usecase/QueryAuthenticationDetailsUseCase.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt index 7a41b165..c8a374fc 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationDetailsUseCase.kt @@ -1,5 +1,6 @@ package team.msg.sms.domain.authentication.usecase +import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData import team.msg.sms.domain.authentication.service.AuthenticationHistoryService @@ -15,6 +16,7 @@ class QueryAuthenticationDetailsUseCase( private val studentService: StudentService, private val userService: UserService ) { + @Transactional(readOnly = true) fun execute(uuid: String): QueryAuthenticationDetailsResponseData { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) From c7e735aba2ceab38e0ec5040ba64fe602c685d94 Mon Sep 17 00:00:00 2001 From: seon0025 Date: Tue, 5 Mar 2024 16:08:15 +0900 Subject: [PATCH 047/183] =?UTF-8?q?=F0=9F=92=9A=20Develop=20cd=EC=9D=98=20?= =?UTF-8?q?branch=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_develop_cd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index bc44ee8c..4e8fdb1c 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -4,7 +4,6 @@ on: push: branches: - develop - - feature/261-develop-server jobs: CD: From 751215f016b2c9158dd5b78baee70bc2fb97a7cd Mon Sep 17 00:00:00 2001 From: seon0025 Date: Tue, 5 Mar 2024 16:08:49 +0900 Subject: [PATCH 048/183] =?UTF-8?q?=F0=9F=92=9A=20Master=20cd=EC=9D=98=20b?= =?UTF-8?q?ranch=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_master_cd.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index 6779447f..cbfe2fbe 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -57,11 +57,10 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ secrets.IMAGE_TAG }} run: | - docker build -t ${{ secrets.ECR_REPOSITORY }} . - docker tag ${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG ${{ secrets.REPO_URL }}:$IMAGE_TAG - docker push ${{ secrets.REPO_URL }}:$IMAGE_TAG + docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}. + docker tag ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} ${{ secrets.REPO_URL }}:${{ secrets.IMAGE_TAG }} + docker push ${{ secrets.REPO_URL }}:${{ secrets.IMAGE_TAG }} - name : CodeDeploy Create Deployment run: | From 739cdba24e84cdf79ccb688f49aca9d98078e3b2 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 16:10:44 +0900 Subject: [PATCH 049/183] :sparkles: request authentication data --- .../dto/res/RequestAuthenticationResponseData.kt | 7 +++++++ .../authentication/res/RequestAuthenticationWebResponse.kt | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationResponseData.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationResponseData.kt new file mode 100644 index 00000000..749c1153 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationResponseData.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.util.* + +data class RequestAuthenticationResponseData( + val id: UUID +) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt new file mode 100644 index 00000000..d4027de3 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.res + +import java.util.UUID + +data class RequestAuthenticationWebResponse( + val id: UUID +) From fad256113c351b4dff1fbf128d308774dd1536e7 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 16:11:03 +0900 Subject: [PATCH 050/183] :sparkles: request authentication usecase --- .../usecase/RequestAuthenticationUseCase.kt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt new file mode 100644 index 00000000..ac084a04 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt @@ -0,0 +1,49 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class RequestAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val studentService: StudentService, + private val userService: UserService, + private val applicationEventPublisher: ApplicationEventPublisher +) { + @Transactional(rollbackFor = [Exception::class]) + fun execute(uuid: String): RequestAuthenticationResponseData { + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + .run { + Authentication( + id = id, + title = title, + content = content, + activityImages = activityImages, + studentId = studentId, + score = score, + activityStatus = ActivityStatus.REQUESTED + ) + } + + AuthenticationHistoryEvent( + authentication = authentication, + reason = "활동이 채점요청되었습니다." + ).let { applicationEventPublisher.publishEvent(it) } + + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) + + return RequestAuthenticationResponseData( + id = authenticationService.save(authentication, student, user).id + ) + } +} \ No newline at end of file From f601ad30ad8350611aa216171dc2030475a3077f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 16:11:48 +0900 Subject: [PATCH 051/183] :sparkles: request authentication endpoint --- .../msg/sms/global/security/SecurityConfig.kt | 1 + .../authentication/AuthenticationWebAdapter.kt | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 3cc45cec..716d390e 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -71,6 +71,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) + .antMatchers(HttpMethod.PATCH,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index af957792..ec9fe8c0 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -6,11 +6,14 @@ import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData +import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse import team.msg.sms.domain.authentication.res.QueryAuthenticationDetailsWebResponse +import team.msg.sms.domain.authentication.res.RequestAuthenticationWebResponse import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase +import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase import java.util.* import javax.validation.Valid @@ -18,7 +21,8 @@ import javax.validation.Valid @RequestMapping("/authentication") class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, - private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase + private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, + private val requestAuthenticationUseCase: RequestAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -32,6 +36,13 @@ class AuthenticationWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @PatchMapping("/{uuid}") + fun requestAuthenticationDetails(@PathVariable uuid: String): ResponseEntity { + if (!isValidUUID(uuid)) throw InvalidUuidException + return requestAuthenticationUseCase.execute(uuid) + .let { ResponseEntity.ok(it.toResponse()) } + } + private fun CreateAuthenticationResponseData.toResponse() = CreateAuthenticationWebResponse( id = id ) @@ -46,6 +57,10 @@ class AuthenticationWebAdapter( activityStatus = activityStatus ) + private fun RequestAuthenticationResponseData.toResponse() = RequestAuthenticationWebResponse( + id = id + ) + private fun isValidUUID(uuid: String): Boolean { return try { UUID.fromString(uuid) From dad78d5d9c0f351b7b236fd237175e47cbe455a6 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 5 Mar 2024 20:00:09 +0900 Subject: [PATCH 052/183] =?UTF-8?q?:sparkles:=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/UnsuitableActivityStatusException.kt | 8 ++++++++ .../exception/error/AuthenticationErrorCode.kt | 3 ++- .../usecase/RequestAuthenticationUseCase.kt | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/UnsuitableActivityStatusException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/UnsuitableActivityStatusException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/UnsuitableActivityStatusException.kt new file mode 100644 index 00000000..5a8b055f --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/UnsuitableActivityStatusException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object UnsuitableActivityStatusException : SmsException( + AuthenticationErrorCode.UNSUITABLE_ACTIVITY_STATUS +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt index a399c66d..b062f0f3 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -7,7 +7,8 @@ enum class AuthenticationErrorCode( private val status: Int, private val message: String ) : ErrorProperty { - AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다.") + AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다."), + UNSUITABLE_ACTIVITY_STATUS(ErrorStatus.CONFLICT, "요청을 처리하기에 적합하지 않은 인증제 활동 상태입니다.") ; override fun status(): Int = status diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt index ac084a04..2327ceb2 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RequestAuthenticationUseCase.kt @@ -5,6 +5,7 @@ import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.exception.UnsuitableActivityStatusException import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.AuthenticationService @@ -22,6 +23,7 @@ class RequestAuthenticationUseCase( @Transactional(rollbackFor = [Exception::class]) fun execute(uuid: String): RequestAuthenticationResponseData { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + .isSuitableActivityStatus() .run { Authentication( id = id, @@ -46,4 +48,8 @@ class RequestAuthenticationUseCase( id = authenticationService.save(authentication, student, user).id ) } + + private fun Authentication.isSuitableActivityStatus() = + if (activityStatus == ActivityStatus.PENDING || activityStatus == ActivityStatus.REJECTED) this + else throw UnsuitableActivityStatusException } \ No newline at end of file From d0d40beae01c0ae06cde45739e543ecf9ee8b65d Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 20:11:59 +0900 Subject: [PATCH 053/183] =?UTF-8?q?=E2=9C=A8=20delete=20authentication=20s?= =?UTF-8?q?ecurity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 3cc45cec..7f37fb06 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -71,6 +71,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) + .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() From 25bbf33db8d29c8e0ae04ca0f9c9e611c188795b Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 20:26:42 +0900 Subject: [PATCH 054/183] =?UTF-8?q?=E2=9C=A8=20delete=20authentication=20p?= =?UTF-8?q?ort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/spi/AuthenticationPort.kt | 2 +- .../domain/authentication/spi/DeleteAuthenticationPort.kt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt index c35a3746..c94327f3 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt @@ -1,3 +1,3 @@ package team.msg.sms.domain.authentication.spi -interface AuthenticationPort : CommandAuthenticationPort, QueryAuthenticationPort \ No newline at end of file +interface AuthenticationPort : CommandAuthenticationPort, QueryAuthenticationPort, DeleteAuthenticationPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt new file mode 100644 index 00000000..24e6cfc5 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.spi + +import team.msg.sms.domain.authentication.model.Authentication +import java.util.UUID + +interface DeleteAuthenticationPort { + fun deleteAuthenticationByUuid(uuid: UUID) +} \ No newline at end of file From b5799153a31bbae83b49deb792f14149d2987686 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 20:30:00 +0900 Subject: [PATCH 055/183] =?UTF-8?q?=E2=9C=A8=20=20delete=20authentication?= =?UTF-8?q?=20usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/DeleteAuthenticationUseCase.kt | 22 +++++++++++++++++++ .../AuthenticationPersistenceAdapter.kt | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt new file mode 100644 index 00000000..ed4a80a0 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -0,0 +1,22 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class DeleteAuthenticationUseCase( + private val studentService: StudentService +) { + fun execute(uuid: UUID) { + studentService.deleteByUuid(uuid) + } +} \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt index a92acafc..0aa523f4 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -27,4 +27,7 @@ class AuthenticationPersistenceAdapter( override fun queryAuthenticationByUuid(uuid: UUID): Authentication? = authenticationJpaRepository.findByIdOrNull(uuid)?.toDomain() + override fun deleteAuthenticationByUuid(uuid: UUID) { + authenticationJpaRepository.deleteById(uuid) + } } \ No newline at end of file From f700fc856451c5ba6df4ff3ccdcde9f68e129b9d Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 20:41:37 +0900 Subject: [PATCH 056/183] =?UTF-8?q?=E2=9C=A8=20=20delete=20authentication?= =?UTF-8?q?=20web=20adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationWebAdapter.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index af957792..b3c0f16a 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -10,21 +10,31 @@ import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse import team.msg.sms.domain.authentication.res.QueryAuthenticationDetailsWebResponse import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase +import team.msg.sms.domain.authentication.usecase.DeleteAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase import java.util.* import javax.validation.Valid +import javax.validation.constraints.Null @RestController @RequestMapping("/authentication") class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, - private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase + private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, + private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = createAuthenticationUseCase.execute(request.toData()) .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } + @DeleteMapping("/{uuid}") + fun deleteAuthentication(@PathVariable uuid: String) { + if(!isValidUUID(uuid)) throw InvalidUuidException + return deleteAuthenticationUseCase.execute(UUID.fromString(uuid)) + .let { ResponseEntity.ok() } + } + @GetMapping("/{uuid}") fun queryAuthenticationDetails(@PathVariable uuid: String): ResponseEntity { if (!isValidUUID(uuid)) throw InvalidUuidException From 79b21da58d0fd82eb0d6a4f94dadf890234eeb06 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 20:59:21 +0900 Subject: [PATCH 057/183] =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/authentication/AuthenticationWebAdapter.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 7fb36e96..e333fd9c 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -17,14 +17,13 @@ import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseC import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase import java.util.* import javax.validation.Valid -import javax.validation.constraints.Null @RestController @RequestMapping("/authentication") class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, - private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase + private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase, private val requestAuthenticationUseCase: RequestAuthenticationUseCase ) { @PostMapping From 72970b4e238116d6f54e777bf6db866206b02e97 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 21:23:12 +0900 Subject: [PATCH 058/183] NOT_FOUND -> NO_CONTENT --- .../msg/sms/domain/authentication/AuthenticationWebAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index e333fd9c..9fb45f45 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -35,7 +35,7 @@ class AuthenticationWebAdapter( fun deleteAuthentication(@PathVariable uuid: String) { if(!isValidUUID(uuid)) throw InvalidUuidException return deleteAuthenticationUseCase.execute(UUID.fromString(uuid)) - .let { ResponseEntity.ok() } + .let { ResponseEntity.noContent() } } @GetMapping("/{uuid}") From 4301f9781871e30e9286e6e2d9b7becf6177b3b0 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 21:24:00 +0900 Subject: [PATCH 059/183] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EC=A0=90=EC=88=98?= =?UTF-8?q?=EA=B0=80=20=EB=B6=80=EC=97=AC=EB=90=98=EC=96=B4=20=EC=9E=88?= =?UTF-8?q?=EC=9D=84=20=EA=B2=BD=EC=9A=B0=EC=9D=98=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AlreadyAwardedScoreException.kt | 8 ++++++++ .../exception/error/AuthenticationErrorCode.kt | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt new file mode 100644 index 00000000..05cc9602 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object AlreadyAwardedScoreException : SmsException( + AuthenticationErrorCode.ALREADY_AWARDED_SCORE +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt index b062f0f3..1629828b 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -8,7 +8,8 @@ enum class AuthenticationErrorCode( private val message: String ) : ErrorProperty { AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다."), - UNSUITABLE_ACTIVITY_STATUS(ErrorStatus.CONFLICT, "요청을 처리하기에 적합하지 않은 인증제 활동 상태입니다.") + UNSUITABLE_ACTIVITY_STATUS(ErrorStatus.CONFLICT, "요청을 처리하기에 적합하지 않은 인증제 활동 상태입니다."), + ALREADY_AWARDED_SCORE(ErrorStatus.CONFLICT, "활동에 이미 점수가 부여된 상태입니다."), ; override fun status(): Int = status From b456cad1ffaa394b5c2d80cadcbd53f18ed3a03e Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 21:43:51 +0900 Subject: [PATCH 060/183] =?UTF-8?q?=EC=9D=BC=EA=B4=80=EC=84=B1=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD=20UUID=20->=20String?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/usecase/DeleteAuthenticationUseCase.kt | 4 ++-- .../msg/sms/domain/authentication/AuthenticationWebAdapter.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt index ed4a80a0..ad3a1f15 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -16,7 +16,7 @@ import java.util.* class DeleteAuthenticationUseCase( private val studentService: StudentService ) { - fun execute(uuid: UUID) { - studentService.deleteByUuid(uuid) + fun execute(uuid: String) { + studentService.deleteByUuid(UUID.fromString(uuid)) } } \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 9fb45f45..33e22e04 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -34,7 +34,7 @@ class AuthenticationWebAdapter( @DeleteMapping("/{uuid}") fun deleteAuthentication(@PathVariable uuid: String) { if(!isValidUUID(uuid)) throw InvalidUuidException - return deleteAuthenticationUseCase.execute(UUID.fromString(uuid)) + return deleteAuthenticationUseCase.execute(uuid) .let { ResponseEntity.noContent() } } From 78e6e74b349febb7d447b5372c13502158d000a5 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 5 Mar 2024 23:28:29 +0900 Subject: [PATCH 061/183] =?UTF-8?q?=EC=8A=B9=EC=9D=B8=EB=90=9C=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=EC=9D=80OC=20=EC=A7=80=EC=9A=B8=20=EC=88=98=20?= =?UTF-8?q?=EC=97=86=EA=B2=8C=20=EB=B3=80=EA=B2=BD=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AuthenticationService.kt | 6 ++++-- .../service/DeleteAuthenticationService.kt | 7 +++++++ .../usecase/DeleteAuthenticationUseCase.kt | 20 ++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/DeleteAuthenticationService.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt index e11febe4..ddaf6528 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class AuthenticationService( commandAuthenticationService: CommandAuthenticationService, - getAuthenticationService: GetAuthenticationService + getAuthenticationService: GetAuthenticationService, + deleteAuthenticationService: DeleteAuthenticationService ) : CommandAuthenticationService by commandAuthenticationService, - GetAuthenticationService by getAuthenticationService \ No newline at end of file + GetAuthenticationService by getAuthenticationService, + DeleteAuthenticationService by deleteAuthenticationService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/DeleteAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/DeleteAuthenticationService.kt new file mode 100644 index 00000000..53bb1275 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/DeleteAuthenticationService.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.service + +import java.util.UUID + +interface DeleteAuthenticationService { + fun deleteAuthenticationByUuid(uuid: UUID) +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt index ad3a1f15..191d17fc 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -1,22 +1,24 @@ package team.msg.sms.domain.authentication.usecase -import org.springframework.context.ApplicationEventPublisher -import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase -import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationRequestData -import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData -import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent -import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.exception.AlreadyAwardedScoreException +import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService -import team.msg.sms.domain.user.service.UserService -import java.util.* +import java.util.UUID @UseCase class DeleteAuthenticationUseCase( + private val authenticationService: AuthenticationService, private val studentService: StudentService ) { fun execute(uuid: String) { - studentService.deleteByUuid(UUID.fromString(uuid)) + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + val student = studentService.currentStudent() + + if(authentication.activityStatus == ActivityStatus.APPROVED || + authentication.studentId != student.id) throw AlreadyAwardedScoreException + + authenticationService.deleteAuthenticationByUuid(UUID.fromString(uuid)) } } \ No newline at end of file From 405e2b2fed59a7e378eead0eb8b350dd713573ae Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 6 Mar 2024 08:01:54 +0900 Subject: [PATCH 062/183] =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=ED=8F=AC=ED=8A=B8=20commandPort=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/service/AuthenticationService.kt | 4 +--- .../service/CommandAuthenticationService.kt | 2 ++ .../sms/domain/authentication/spi/AuthenticationPort.kt | 2 +- .../authentication/spi/CommandAuthenticationPort.kt | 3 +++ .../domain/authentication/spi/DeleteAuthenticationPort.kt | 8 -------- 5 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt index ddaf6528..95b08030 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -6,7 +6,5 @@ import team.msg.sms.common.annotation.Service class AuthenticationService( commandAuthenticationService: CommandAuthenticationService, getAuthenticationService: GetAuthenticationService, - deleteAuthenticationService: DeleteAuthenticationService ) : CommandAuthenticationService by commandAuthenticationService, - GetAuthenticationService by getAuthenticationService, - DeleteAuthenticationService by deleteAuthenticationService \ No newline at end of file + GetAuthenticationService by getAuthenticationService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt index c01c6cb0..f24ba220 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt @@ -10,4 +10,6 @@ interface CommandAuthenticationService { student: Student, user: User ): Authentication + + fun deleteAuthenticationByUuid(uuid: String) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt index c94327f3..c35a3746 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/AuthenticationPort.kt @@ -1,3 +1,3 @@ package team.msg.sms.domain.authentication.spi -interface AuthenticationPort : CommandAuthenticationPort, QueryAuthenticationPort, DeleteAuthenticationPort \ No newline at end of file +interface AuthenticationPort : CommandAuthenticationPort, QueryAuthenticationPort \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt index fbb7fbf2..da89dd69 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt @@ -3,6 +3,7 @@ package team.msg.sms.domain.authentication.spi import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User +import java.util.* interface CommandAuthenticationPort { fun save( @@ -10,4 +11,6 @@ interface CommandAuthenticationPort { student: Student, user: User ): Authentication + + fun deleteAuthenticationByUuid(uuid: UUID) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt deleted file mode 100644 index 24e6cfc5..00000000 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/DeleteAuthenticationPort.kt +++ /dev/null @@ -1,8 +0,0 @@ -package team.msg.sms.domain.authentication.spi - -import team.msg.sms.domain.authentication.model.Authentication -import java.util.UUID - -interface DeleteAuthenticationPort { - fun deleteAuthenticationByUuid(uuid: UUID) -} \ No newline at end of file From c7d74290a5ffc4d234b46282f84b42b71dbf0105 Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 6 Mar 2024 08:06:09 +0900 Subject: [PATCH 063/183] =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CommandAuthenticationServiceImpl.kt | 3 +++ .../authentication/usecase/DeleteAuthenticationUseCase.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt index 739f79ba..dff165cc 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt @@ -6,6 +6,7 @@ import team.msg.sms.domain.authentication.service.CommandAuthenticationService import team.msg.sms.domain.authentication.spi.AuthenticationPort import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User +import java.util.UUID @Service class CommandAuthenticationServiceImpl( @@ -16,4 +17,6 @@ class CommandAuthenticationServiceImpl( student: Student, user: User ) = authenticationPort.save(authentication, student, user) + + override fun deleteAuthenticationByUuid(uuid: String) = authenticationPort.deleteAuthenticationByUuid(UUID.fromString(uuid)) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt index 191d17fc..e619e745 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -19,6 +19,6 @@ class DeleteAuthenticationUseCase( if(authentication.activityStatus == ActivityStatus.APPROVED || authentication.studentId != student.id) throw AlreadyAwardedScoreException - authenticationService.deleteAuthenticationByUuid(UUID.fromString(uuid)) + authenticationService.deleteAuthenticationByUuid(uuid) } } \ No newline at end of file From 90ad76fb2cd8f08d609b9fad5ac6d2900cf7bdda Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 6 Mar 2024 08:12:54 +0900 Subject: [PATCH 064/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Exception=EC=9D=84?= =?UTF-8?q?=20=EC=A7=81=EA=B4=80=EC=A0=81=EC=9D=B8=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Exception.kt => AlreadyApprovedAuthenticationException.kt} | 2 +- .../authentication/usecase/DeleteAuthenticationUseCase.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/{AlreadyAwardedScoreException.kt => AlreadyApprovedAuthenticationException.kt} (79%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyApprovedAuthenticationException.kt similarity index 79% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyApprovedAuthenticationException.kt index 05cc9602..90ed436d 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyAwardedScoreException.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyApprovedAuthenticationException.kt @@ -3,6 +3,6 @@ package team.msg.sms.domain.authentication.exception import team.msg.sms.common.error.SmsException import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode -object AlreadyAwardedScoreException : SmsException( +object AlreadyApprovedAuthenticationException : SmsException( AuthenticationErrorCode.ALREADY_AWARDED_SCORE ) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt index e619e745..8b0d0bfc 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -1,7 +1,7 @@ package team.msg.sms.domain.authentication.usecase import team.msg.sms.common.annotation.UseCase -import team.msg.sms.domain.authentication.exception.AlreadyAwardedScoreException +import team.msg.sms.domain.authentication.exception.AlreadyApprovedAuthenticationException import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService @@ -17,7 +17,7 @@ class DeleteAuthenticationUseCase( val student = studentService.currentStudent() if(authentication.activityStatus == ActivityStatus.APPROVED || - authentication.studentId != student.id) throw AlreadyAwardedScoreException + authentication.studentId != student.id) throw AlreadyApprovedAuthenticationException authenticationService.deleteAuthenticationByUuid(uuid) } From 7050ff0afc684b17edc4fba2c8ec3841682dacda Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 19:49:04 +0900 Subject: [PATCH 065/183] =?UTF-8?q?:bug:=20=EC=B5=9C=EA=B7=BC=20=EA=B0=92?= =?UTF-8?q?=20=ED=95=98=EB=82=98=EB=A7=8C=20=EB=B6=88=EB=9F=AC=EC=98=A4?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationHistoryPersistenceAdapter.kt | 2 +- .../repository/AuthenticationHistoryJpaRepository.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt index 853280b5..d28542ad 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt @@ -29,5 +29,5 @@ class AuthenticationHistoryPersistenceAdapter( student: Student, user: User ): AuthenticationHistory = - authenticationHistoryJpaRepository.findByAuthenticationOrderByCreatedAtDesc(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() + authenticationHistoryJpaRepository.findFirstByAuthenticationOrderByCreatedAtDesc(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index b53b5e0f..a41c9cbb 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -7,5 +7,5 @@ import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity @Repository interface AuthenticationHistoryJpaRepository : JpaRepository { - fun findByAuthenticationOrderByCreatedAtDesc(authentication: AuthenticationJpaEntity): AuthenticationHistoryJpaEntity + fun findFirstByAuthenticationOrderByCreatedAtDesc(authentication: AuthenticationJpaEntity): AuthenticationHistoryJpaEntity } \ No newline at end of file From b679ab6b3ff1664786b1c33bae1956616c420968 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 19:53:42 +0900 Subject: [PATCH 066/183] =?UTF-8?q?:recycle:=20=EB=94=94=EB=A0=89=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/AuthenticationWebAdapter.kt | 8 ++++---- .../{ => dto}/req/CreateAuthenticationWebRequest.kt | 3 +-- .../{ => dto}/res/CreateAuthenticationWebResponse.kt | 2 +- .../res/QueryAuthenticationDetailsWebResponse.kt | 2 +- .../{ => dto}/res/RequestAuthenticationWebResponse.kt | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/{ => dto}/req/CreateAuthenticationWebRequest.kt (79%) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/{ => dto}/res/CreateAuthenticationWebResponse.kt (63%) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/{ => dto}/res/QueryAuthenticationDetailsWebResponse.kt (87%) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/{ => dto}/res/RequestAuthenticationWebResponse.kt (63%) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index ec9fe8c0..371a8475 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -7,10 +7,10 @@ import team.msg.sms.common.exception.InvalidUuidException import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData -import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest -import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse -import team.msg.sms.domain.authentication.res.QueryAuthenticationDetailsWebResponse -import team.msg.sms.domain.authentication.res.RequestAuthenticationWebResponse +import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationWebRequest +import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationWebResponse +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsWebResponse +import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationWebResponse import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationWebRequest.kt similarity index 79% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationWebRequest.kt index 89d1a0fc..e43bcd36 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/req/CreateAuthenticationWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/CreateAuthenticationWebRequest.kt @@ -1,6 +1,5 @@ -package team.msg.sms.domain.authentication.req +package team.msg.sms.domain.authentication.dto.req -import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationRequestData import javax.validation.constraints.NotBlank import javax.validation.constraints.NotNull import javax.validation.constraints.Size diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationWebResponse.kt similarity index 63% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationWebResponse.kt index caa6f24e..7ef7a889 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/CreateAuthenticationWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/CreateAuthenticationWebResponse.kt @@ -1,4 +1,4 @@ -package team.msg.sms.domain.authentication.res +package team.msg.sms.domain.authentication.dto.res import java.util.UUID diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsWebResponse.kt similarity index 87% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsWebResponse.kt index 62cd2000..9dbd83e4 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationDetailsWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationDetailsWebResponse.kt @@ -1,4 +1,4 @@ -package team.msg.sms.domain.authentication.res +package team.msg.sms.domain.authentication.dto.res import team.msg.sms.domain.authentication.model.ActivityStatus import java.time.LocalDate diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationWebResponse.kt similarity index 63% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationWebResponse.kt index d4027de3..7fafbbd3 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/RequestAuthenticationWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestAuthenticationWebResponse.kt @@ -1,4 +1,4 @@ -package team.msg.sms.domain.authentication.res +package team.msg.sms.domain.authentication.dto.res import java.util.UUID From 5b1ca89a3ab306cbfae9c61cac4850ce1a89f77e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 20:11:17 +0900 Subject: [PATCH 067/183] :sparkles: filter request data --- ...dRequestAuthenticationFilterRequestData.kt | 11 ++++++++++ ...ndRequestAuthenticationFilterWebRequest.kt | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt new file mode 100644 index 00000000..61f58aff --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt @@ -0,0 +1,11 @@ +package team.msg.sms.domain.authentication.dto.req + +import team.msg.sms.domain.student.model.Department + +data class FindRequestAuthenticationFilterRequestData( + val grade: List?, + val classNum: List?, + val department: List?, + val stuNumSort: String?, + val requestTimeSort: String? +) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt new file mode 100644 index 00000000..c03caf92 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt @@ -0,0 +1,20 @@ +package team.msg.sms.domain.authentication.dto.req + +import org.springframework.web.bind.annotation.RequestParam +import team.msg.sms.domain.student.model.Department + +data class FindRequestAuthenticationFilterWebRequest( + @RequestParam("grade", required = false) val grade: List?, + @RequestParam("classNum", required = false) val classNum: List?, + @RequestParam("department", required = false) val department: List?, + @RequestParam("stuNumSort", required = false) val stuNumSort: String?, + @RequestParam("requestTimeSort", required = false) val requestTimeSort: String? +) { + fun toData() = FindRequestAuthenticationFilterRequestData( + grade = grade, + classNum = classNum, + department = department, + stuNumSort = stuNumSort, + requestTimeSort = requestTimeSort + ) +} From 50399fd5c40774a6e5871aabd8d0d2c8c0555ce3 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 20:19:13 +0900 Subject: [PATCH 068/183] =?UTF-8?q?:pencil2:=20data=20class=20=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ata.kt => FindRequestedAuthenticationFilterRequestData.kt} | 2 +- ...uest.kt => FindRequestedAuthenticationFilterWebRequest.kt} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/{FindRequestAuthenticationFilterRequestData.kt => FindRequestedAuthenticationFilterRequestData.kt} (82%) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/{FindRequestAuthenticationFilterWebRequest.kt => FindRequestedAuthenticationFilterWebRequest.kt} (85%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt similarity index 82% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt index 61f58aff..a5d7b5aa 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt @@ -2,7 +2,7 @@ package team.msg.sms.domain.authentication.dto.req import team.msg.sms.domain.student.model.Department -data class FindRequestAuthenticationFilterRequestData( +data class FindRequestedAuthenticationFilterRequestData( val grade: List?, val classNum: List?, val department: List?, diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt similarity index 85% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt index c03caf92..7b64b99a 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestAuthenticationFilterWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt @@ -3,14 +3,14 @@ package team.msg.sms.domain.authentication.dto.req import org.springframework.web.bind.annotation.RequestParam import team.msg.sms.domain.student.model.Department -data class FindRequestAuthenticationFilterWebRequest( +data class FindRequestedAuthenticationFilterWebRequest( @RequestParam("grade", required = false) val grade: List?, @RequestParam("classNum", required = false) val classNum: List?, @RequestParam("department", required = false) val department: List?, @RequestParam("stuNumSort", required = false) val stuNumSort: String?, @RequestParam("requestTimeSort", required = false) val requestTimeSort: String? ) { - fun toData() = FindRequestAuthenticationFilterRequestData( + fun toData() = FindRequestedAuthenticationFilterRequestData( grade = grade, classNum = classNum, department = department, From d9bb5fac3d08136a0fef1822a3d801d9c0528805 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 20:31:01 +0900 Subject: [PATCH 069/183] :sparkles: response data class --- .../res/QueryRequestedAuthenticaionResponseData.kt | 13 +++++++++++++ .../res/QueryRequestedAuthenticationWebResponse.kt | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt new file mode 100644 index 00000000..e37813d3 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.dto.res + +import team.msg.sms.domain.student.model.Department +import java.time.LocalDate +import java.util.* + +data class QueryRequestedAuthenticaionResponseData ( + val id: UUID, + val requestTime: LocalDate, + val stuNum: String, + val department: Department, + val title: String +) \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt new file mode 100644 index 00000000..9dfac577 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.dto.res + +import team.msg.sms.domain.student.model.Department +import java.time.LocalDate +import java.util.* + +data class QueryRequestedAuthenticationWebResponse( + val id: UUID, + val requestTime: LocalDate, + val stuNum: String, + val department: Department, + val title: String +) \ No newline at end of file From 7f6fc43402a2a9b24b2b79cfbb62a4822341b5f1 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 20:39:58 +0900 Subject: [PATCH 070/183] =?UTF-8?q?:pencil2:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ponseData.kt => QueryRequestedAuthenticationResponseData.kt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/{QueryRequestedAuthenticaionResponseData.kt => QueryRequestedAuthenticationResponseData.kt} (83%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt similarity index 83% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt index e37813d3..02a7e042 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticaionResponseData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt @@ -4,7 +4,7 @@ import team.msg.sms.domain.student.model.Department import java.time.LocalDate import java.util.* -data class QueryRequestedAuthenticaionResponseData ( +data class QueryRequestedAuthenticationResponseData ( val id: UUID, val requestTime: LocalDate, val stuNum: String, From 64b94ab3b5b5848450ed03eec41b1c75da4aebf4 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 21:00:30 +0900 Subject: [PATCH 071/183] =?UTF-8?q?:bug:=20=EB=B9=A0=EC=A0=B8=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=ED=94=84=EB=A1=9C=ED=8D=BC=ED=8B=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/QueryRequestedAuthenticationResponseData.kt | 1 + .../dto/res/QueryRequestedAuthenticationWebResponse.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt index 02a7e042..359065e5 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt @@ -8,6 +8,7 @@ data class QueryRequestedAuthenticationResponseData ( val id: UUID, val requestTime: LocalDate, val stuNum: String, + val name: String, val department: Department, val title: String ) \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt index 9dfac577..248f0313 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt @@ -8,6 +8,7 @@ data class QueryRequestedAuthenticationWebResponse( val id: UUID, val requestTime: LocalDate, val stuNum: String, + val name: String, val department: Department, val title: String ) \ No newline at end of file From 5dc4b7a7da4e200c7dfc0b9660c7cee71f3143d3 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 6 Mar 2024 23:21:06 +0900 Subject: [PATCH 072/183] :sparkles: query requested authentication endpoint --- .../msg/sms/global/security/SecurityConfig.kt | 1 + .../AuthenticationWebAdapter.kt | 30 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 716d390e..ce432785 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -72,6 +72,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.PATCH,"/authentication/{uuid}").hasAuthority(STUDENT) + .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAnyAuthority(PRINCIPAL, DEPUTY_PRINCIPAL, DIRECTOR, HOMEROOM) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 371a8475..e4050ad2 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -4,15 +4,12 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException -import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData -import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData -import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationWebRequest -import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationWebResponse -import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsWebResponse -import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationWebResponse +import team.msg.sms.domain.authentication.dto.req.FindRequestedAuthenticationFilterWebRequest +import team.msg.sms.domain.authentication.dto.res.* import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase +import team.msg.sms.domain.authentication.usecase.QueryRequestedAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase import java.util.* import javax.validation.Valid @@ -22,7 +19,8 @@ import javax.validation.Valid class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, - private val requestAuthenticationUseCase: RequestAuthenticationUseCase + private val requestAuthenticationUseCase: RequestAuthenticationUseCase, + private val queryRequestedAuthenticationUseCase: QueryRequestedAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -43,6 +41,15 @@ class AuthenticationWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @GetMapping("/teacher") + fun queryRequestedAuthentication( + @RequestParam(name = "page") page: Int, + @RequestParam(name = "size") size: Int, + filterRequestData: FindRequestedAuthenticationFilterWebRequest + ): ResponseEntity = + queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) + .let { ResponseEntity.ok(it.toResponse()) } + private fun CreateAuthenticationResponseData.toResponse() = CreateAuthenticationWebResponse( id = id ) @@ -61,6 +68,15 @@ class AuthenticationWebAdapter( id = id ) + private fun QueryRequestedAuthenticationResponseData.toResponse() = QueryRequestedAuthenticationWebResponse( + id = id, + requestTime = requestTime, + stuNum = stuNum, + name = name, + department = department, + title = title + ) + private fun isValidUUID(uuid: String): Boolean { return try { UUID.fromString(uuid) From ba2f7c45093f23c8a6ea6892a1e5794474705ba4 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 7 Mar 2024 14:45:39 +0900 Subject: [PATCH 073/183] :sparkles: query requested authentication --- .../authentication/model/Authentication.kt | 13 +++++++++- .../service/GetAuthenticationService.kt | 1 + .../impl/GetAuthenticationServiceImpl.kt | 3 +++ .../spi/QueryAuthenticationPort.kt | 1 + .../AuthenticationPersistenceAdapter.kt | 26 ++++++++++++++++++- .../mapper/AuthenticationMapper.kt | 10 +++++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt index e41271e4..7b1908db 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt @@ -1,6 +1,8 @@ package team.msg.sms.domain.authentication.model import team.msg.sms.common.annotation.Aggregate +import team.msg.sms.domain.student.model.Department +import java.time.LocalDateTime import java.util.* @Aggregate @@ -12,4 +14,13 @@ class Authentication ( val score: Int = 0, val activityStatus: ActivityStatus = ActivityStatus.PENDING, val studentId: UUID -) \ No newline at end of file +) { + class AuthenticationWithStudentInfoAndRequestedTime ( + val id: UUID, + val title: String, + val requestedTime: LocalDateTime, + val stuNum: String, + val name: String, + val department: Department, + ) +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt index c969cd95..d99e56fe 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt @@ -5,4 +5,5 @@ import java.util.UUID interface GetAuthenticationService { fun getAuthenticationByUuid(uuid: UUID): Authentication + fun getRequestedAuthentications(): List } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt index 4d865f55..08751d28 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt @@ -13,4 +13,7 @@ class GetAuthenticationServiceImpl( ) : GetAuthenticationService { override fun getAuthenticationByUuid(uuid: UUID): Authentication = queryAuthenticationPort.queryAuthenticationByUuid(uuid) ?: throw AuthenticationNotFoundException + + override fun getRequestedAuthentications(): List = + queryAuthenticationPort.queryRequestedAuthentications() } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt index a6b72abb..b9ce0129 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt @@ -5,4 +5,5 @@ import java.util.UUID interface QueryAuthenticationPort { fun queryAuthenticationByUuid(uuid: UUID): Authentication? + fun queryRequestedAuthentications(): List } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt index a92acafc..a016e8a4 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -1,21 +1,27 @@ package team.msg.sms.persistence.authentication +import com.querydsl.jpa.impl.JPAQueryFactory import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Component +import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.spi.AuthenticationPort import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User import team.msg.sms.persistence.authentication.mapper.toDomain +import team.msg.sms.persistence.authentication.mapper.toDomainWithUserInfoAndRequestedTime import team.msg.sms.persistence.authentication.mapper.toEntity import team.msg.sms.persistence.authentication.repository.AuthenticationJpaRepository import team.msg.sms.persistence.student.mapper.toEntity import team.msg.sms.persistence.user.mapper.toEntity import java.util.* +import team.msg.sms.persistence.authentication.entity.QAuthenticationHistoryJpaEntity.authenticationHistoryJpaEntity as history +import team.msg.sms.persistence.authentication.entity.QAuthenticationJpaEntity.authenticationJpaEntity as authentication @Component class AuthenticationPersistenceAdapter( - private val authenticationJpaRepository: AuthenticationJpaRepository + private val authenticationJpaRepository: AuthenticationJpaRepository, + private val queryFactory: JPAQueryFactory ) : AuthenticationPort { override fun save( authentication: Authentication, @@ -27,4 +33,22 @@ class AuthenticationPersistenceAdapter( override fun queryAuthenticationByUuid(uuid: UUID): Authentication? = authenticationJpaRepository.findByIdOrNull(uuid)?.toDomain() + override fun queryRequestedAuthentications(): List = + queryFactory.select(authentication, history) + .from(authentication) + .leftJoin(history).on(authentication.eq(history.authentication)) + .where( + authentication.activityStatus.eq(ActivityStatus.REQUESTED), + history.createdAt.eq(queryLastedAuthentication()) + ) + .fetch() + .map { + it[authentication]!!.toDomainWithUserInfoAndRequestedTime(it[history]!!.createdAt) + } + + private fun queryLastedAuthentication() = + queryFactory + .select(history.createdAt.max()) + .from(history) + .where(history.authentication.eq(authentication)) } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt index a5cdd158..25501d8d 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/mapper/AuthenticationMapper.kt @@ -3,6 +3,7 @@ package team.msg.sms.persistence.authentication.mapper import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity import team.msg.sms.persistence.student.entity.StudentJpaEntity +import java.time.LocalDateTime fun Authentication.toEntity(student: StudentJpaEntity) = AuthenticationJpaEntity( id = id, @@ -22,4 +23,13 @@ fun AuthenticationJpaEntity.toDomain() = Authentication( score = score, activityStatus = activityStatus, studentId = student.id +) + +fun AuthenticationJpaEntity.toDomainWithUserInfoAndRequestedTime(requestedTime: LocalDateTime) = Authentication.AuthenticationWithStudentInfoAndRequestedTime( + id = id, + title = title, + requestedTime = requestedTime, + stuNum = student.user.stuNum, + name = student.user.name, + department = student.department ) \ No newline at end of file From 4ec40cdcd999df85cd5f5a87309c479333b99475 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 7 Mar 2024 14:51:47 +0900 Subject: [PATCH 074/183] =?UTF-8?q?:pencil2:=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dAuthenticationFilterRequestData.kt => FilterRequestData.kt} | 2 +- .../dto/req/FindRequestedAuthenticationFilterWebRequest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/{FindRequestedAuthenticationFilterRequestData.kt => FilterRequestData.kt} (82%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt similarity index 82% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt index a5d7b5aa..b0812575 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt @@ -2,7 +2,7 @@ package team.msg.sms.domain.authentication.dto.req import team.msg.sms.domain.student.model.Department -data class FindRequestedAuthenticationFilterRequestData( +data class FilterRequestData( val grade: List?, val classNum: List?, val department: List?, diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt index 7b64b99a..d39464ab 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt @@ -10,7 +10,7 @@ data class FindRequestedAuthenticationFilterWebRequest( @RequestParam("stuNumSort", required = false) val stuNumSort: String?, @RequestParam("requestTimeSort", required = false) val requestTimeSort: String? ) { - fun toData() = FindRequestedAuthenticationFilterRequestData( + fun toData() = FilterRequestData( grade = grade, classNum = classNum, department = department, From 816cc5b9d64991243e328497fce3642305b45bac Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 7 Mar 2024 15:07:50 +0900 Subject: [PATCH 075/183] =?UTF-8?q?:pencil2:=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/{FilterRequestData.kt => FiltersRequestData.kt} | 2 +- .../msg/sms/domain/authentication/AuthenticationWebAdapter.kt | 4 ++-- ...est.kt => FindRequestedAuthenticationFiltersWebRequest.kt} | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/{FilterRequestData.kt => FiltersRequestData.kt} (89%) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/{FindRequestedAuthenticationFilterWebRequest.kt => FindRequestedAuthenticationFiltersWebRequest.kt} (88%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FiltersRequestData.kt similarity index 89% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FiltersRequestData.kt index b0812575..3efae484 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FilterRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FiltersRequestData.kt @@ -2,7 +2,7 @@ package team.msg.sms.domain.authentication.dto.req import team.msg.sms.domain.student.model.Department -data class FilterRequestData( +data class FiltersRequestData( val grade: List?, val classNum: List?, val department: List?, diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index e4050ad2..8a739078 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -5,7 +5,7 @@ import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationWebRequest -import team.msg.sms.domain.authentication.dto.req.FindRequestedAuthenticationFilterWebRequest +import team.msg.sms.domain.authentication.dto.req.FindRequestedAuthenticationFiltersWebRequest import team.msg.sms.domain.authentication.dto.res.* import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase @@ -45,7 +45,7 @@ class AuthenticationWebAdapter( fun queryRequestedAuthentication( @RequestParam(name = "page") page: Int, @RequestParam(name = "size") size: Int, - filterRequestData: FindRequestedAuthenticationFilterWebRequest + filterRequestData: FindRequestedAuthenticationFiltersWebRequest ): ResponseEntity = queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) .let { ResponseEntity.ok(it.toResponse()) } diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFiltersWebRequest.kt similarity index 88% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFiltersWebRequest.kt index d39464ab..ddc7b001 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFilterWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/FindRequestedAuthenticationFiltersWebRequest.kt @@ -3,14 +3,14 @@ package team.msg.sms.domain.authentication.dto.req import org.springframework.web.bind.annotation.RequestParam import team.msg.sms.domain.student.model.Department -data class FindRequestedAuthenticationFilterWebRequest( +data class FindRequestedAuthenticationFiltersWebRequest( @RequestParam("grade", required = false) val grade: List?, @RequestParam("classNum", required = false) val classNum: List?, @RequestParam("department", required = false) val department: List?, @RequestParam("stuNumSort", required = false) val stuNumSort: String?, @RequestParam("requestTimeSort", required = false) val requestTimeSort: String? ) { - fun toData() = FilterRequestData( + fun toData() = FiltersRequestData( grade = grade, classNum = classNum, department = department, From 97366dc643499c10aad6bee1fe0f9e59168066a1 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 7 Mar 2024 15:33:52 +0900 Subject: [PATCH 076/183] =?UTF-8?q?=F0=9F=90=9B=20Authentication=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=8B=9C=EC=97=90=20=EC=97=B0=EA=B4=80=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=EC=9D=B8=20AuthenticationTable?= =?UTF-8?q?=EB=8F=84=20=EC=A0=9C=EA=B1=B0=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AuthenticationHistoryService.kt | 6 ++++-- .../CommandAuthenticationHistoryService.kt | 13 ++++++++++++ ...CommandAuthenticationHistoryServiceImpl.kt | 21 +++++++++++++++++++ .../GetAuthenticationHistoryServiceImpl.kt | 1 - .../spi/CommandAuthenticationHistoryPort.kt | 2 ++ .../usecase/DeleteAuthenticationUseCase.kt | 12 ++++++++--- .../src/main/resources/application.yml | 2 +- ...AuthenticationHistoryPersistenceAdapter.kt | 4 ++++ .../AuthenticationHistoryJpaRepository.kt | 3 +++ 9 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationHistoryService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationHistoryServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt index d94f2dd9..452e7728 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationHistoryService.kt @@ -4,5 +4,7 @@ import team.msg.sms.common.annotation.Service @Service class AuthenticationHistoryService( - getAuthenticationHistoryService: GetAuthenticationHistoryService -) : GetAuthenticationHistoryService by getAuthenticationHistoryService \ No newline at end of file + getAuthenticationHistoryService: GetAuthenticationHistoryService, + commandAuthenticationHistoryService: CommandAuthenticationHistoryService +) : GetAuthenticationHistoryService by getAuthenticationHistoryService, + CommandAuthenticationHistoryService by commandAuthenticationHistoryService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationHistoryService.kt new file mode 100644 index 00000000..55f38def --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationHistoryService.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User + +interface CommandAuthenticationHistoryService { + fun deleteAuthenticationHistoryByAuthentication( + authentication: Authentication, + student: Student, + user: User + ) +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationHistoryServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationHistoryServiceImpl.kt new file mode 100644 index 00000000..7084dad9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationHistoryServiceImpl.kt @@ -0,0 +1,21 @@ +package team.msg.sms.domain.authentication.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.CommandAuthenticationHistoryService +import team.msg.sms.domain.authentication.spi.CommandAuthenticationHistoryPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User + +@Service +class CommandAuthenticationHistoryServiceImpl( + private val commandAuthenticationHistoryPort: CommandAuthenticationHistoryPort +) : CommandAuthenticationHistoryService { + override fun deleteAuthenticationHistoryByAuthentication( + authentication: Authentication, + student: Student, + user: User + ) { + commandAuthenticationHistoryPort.deleteAuthenticationHistory(authentication, student, user) + } +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt index 58f9706d..4d16b789 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt @@ -18,5 +18,4 @@ class GetAuthenticationHistoryServiceImpl( user: User ): AuthenticationHistory = queryAuthenticationHistoryPort.queryLatestAuthenticationHistory(authentication, student, user) - } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt index d6a07826..67353ecf 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationHistoryPort.kt @@ -12,4 +12,6 @@ interface CommandAuthenticationHistoryPort { student: Student, user: User ): AuthenticationHistory + + fun deleteAuthenticationHistory(authentication: Authentication, student: Student, user: User) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt index 8b0d0bfc..dad77174 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/DeleteAuthenticationUseCase.kt @@ -3,22 +3,28 @@ package team.msg.sms.domain.authentication.usecase import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.authentication.exception.AlreadyApprovedAuthenticationException import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService import java.util.UUID @UseCase class DeleteAuthenticationUseCase( - private val authenticationService: AuthenticationService, - private val studentService: StudentService + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val studentService: StudentService, + private val userService: UserService ) { fun execute(uuid: String) { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) - val student = studentService.currentStudent() + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) if(authentication.activityStatus == ActivityStatus.APPROVED || authentication.studentId != student.id) throw AlreadyApprovedAuthenticationException + authenticationHistoryService.deleteAuthenticationHistoryByAuthentication(authentication, student, user) authenticationService.deleteAuthenticationByUuid(uuid) } } \ No newline at end of file diff --git a/sms-infrastructure/src/main/resources/application.yml b/sms-infrastructure/src/main/resources/application.yml index 47ba52f1..256884b6 100644 --- a/sms-infrastructure/src/main/resources/application.yml +++ b/sms-infrastructure/src/main/resources/application.yml @@ -53,4 +53,4 @@ logging: com: amazonaws: util: - EC2MetadataUtils: error + EC2MetadataUtils: error \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt index 853280b5..689c092b 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt @@ -24,6 +24,10 @@ class AuthenticationHistoryPersistenceAdapter( ): AuthenticationHistory = authenticationHistoryJpaRepository.save(authenticationHistory.toEntity(authentication.toEntity(student.toEntity(user.toEntity())))).toDomain() + override fun deleteAuthenticationHistory(authentication: Authentication, student: Student, user: User) = + authenticationHistoryJpaRepository.deleteAuthenticationHistoryJpaEntityByAuthentication(authentication.toEntity(student.toEntity(user.toEntity()))) + + override fun queryLatestAuthenticationHistory( authentication: Authentication, student: Student, diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index b53b5e0f..e835336a 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -2,10 +2,13 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository +import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.persistence.authentication.entity.AuthenticationHistoryJpaEntity import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity @Repository interface AuthenticationHistoryJpaRepository : JpaRepository { fun findByAuthenticationOrderByCreatedAtDesc(authentication: AuthenticationJpaEntity): AuthenticationHistoryJpaEntity + + fun deleteAuthenticationHistoryJpaEntityByAuthentication(authentication: AuthenticationJpaEntity) } \ No newline at end of file From 5ba89291424880452b904c528da5a8062009d9b5 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 7 Mar 2024 15:46:34 +0900 Subject: [PATCH 077/183] :sparkles: filter service --- .../service/AuthenticationService.kt | 6 +- .../service/FilterAuthenticationService.kt | 18 ++++++ .../impl/FilterAuthenticationServiceImpl.kt | 58 +++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/FilterAuthenticationService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt index e11febe4..a3d4fe4b 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/AuthenticationService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class AuthenticationService( commandAuthenticationService: CommandAuthenticationService, - getAuthenticationService: GetAuthenticationService + getAuthenticationService: GetAuthenticationService, + filterAuthenticationService: FilterAuthenticationService ) : CommandAuthenticationService by commandAuthenticationService, - GetAuthenticationService by getAuthenticationService \ No newline at end of file + GetAuthenticationService by getAuthenticationService, + FilterAuthenticationService by filterAuthenticationService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/FilterAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/FilterAuthenticationService.kt new file mode 100644 index 00000000..514f2d38 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/FilterAuthenticationService.kt @@ -0,0 +1,18 @@ +package team.msg.sms.domain.authentication.service + +import team.msg.sms.domain.authentication.dto.req.FiltersRequestData +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.teacher.model.HomeroomTeacher + +interface FilterAuthenticationService { + fun filterAuthenticationsForTeacher( + authentications: List, + filters: FiltersRequestData + ): List + + fun filterAuthenticationsForHomeroomTeacher( + authentications: List, + filters: FiltersRequestData, + homeroomTeacher: HomeroomTeacher + ): List +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt new file mode 100644 index 00000000..ef32209a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt @@ -0,0 +1,58 @@ +package team.msg.sms.domain.authentication.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.dto.req.FiltersRequestData +import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithStudentInfoAndRequestedTime +import team.msg.sms.domain.authentication.service.FilterAuthenticationService +import team.msg.sms.domain.teacher.model.HomeroomTeacher + +@Service +class FilterAuthenticationServiceImpl : FilterAuthenticationService { + override fun filterAuthenticationsForTeacher( + authentications: List, + filters: FiltersRequestData + ) : List { + var filteredAuthentication = authentications + + filters.grade?.let { grade -> + if (filters.grade.isNotEmpty()) + filteredAuthentication = filteredAuthentication.filter { authentication -> + authentication.stuNum.substring(0, 1).toInt() in grade + } + } + + filters.classNum?.let { classNum -> + if (filters.classNum.isNotEmpty()) + filteredAuthentication = filteredAuthentication.filter { authentication -> + authentication.stuNum.substring(1, 2).toInt() in classNum + } + } + + filters.department?.let { departments -> + if (filters.department.isNotEmpty()) + filteredAuthentication = filteredAuthentication.filter { authentication -> + authentication.department in departments + } + } + + return filteredAuthentication + } + + override fun filterAuthenticationsForHomeroomTeacher( + authentications: List, + filters: FiltersRequestData, + homeroomTeacher: HomeroomTeacher + ) : List { + var filteredAuthentication = authentications + + filteredAuthentication = filteredAuthentication.filter { authentication -> + authentication.stuNum.substring(0, 1).toInt() == homeroomTeacher.grade + } + + filteredAuthentication = filteredAuthentication.filter { authentication -> + authentication.stuNum.substring(1, 2).toInt() == homeroomTeacher.classNum + } + + return filteredAuthentication + } +} \ No newline at end of file From fce5f31de262d8b318f1f5d03a5df5a789e2abed Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 7 Mar 2024 17:36:01 +0900 Subject: [PATCH 078/183] =?UTF-8?q?=F0=9F=94=A5=20=ED=99=9C=EB=8F=99=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20API=20OK=20->=20NO=5FCONTENT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/AuthenticationWebAdapter.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 33e22e04..3af0b441 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -17,6 +17,7 @@ import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseC import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase import java.util.* import javax.validation.Valid +import javax.validation.constraints.Null @RestController @RequestMapping("/authentication") @@ -32,10 +33,10 @@ class AuthenticationWebAdapter( .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } @DeleteMapping("/{uuid}") - fun deleteAuthentication(@PathVariable uuid: String) { + fun deleteAuthentication(@PathVariable uuid: String): ResponseEntity { if(!isValidUUID(uuid)) throw InvalidUuidException - return deleteAuthenticationUseCase.execute(uuid) - .let { ResponseEntity.noContent() } + deleteAuthenticationUseCase.execute(uuid) + return ResponseEntity.noContent().build() } @GetMapping("/{uuid}") From ac2f221ffdde41fae215d962a83f9dbcd01fb762 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 7 Mar 2024 18:12:19 +0900 Subject: [PATCH 079/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=ED=99=9C=EB=8F=99?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20API=20ResponseEntity=20Void=20->=20Unit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/authentication/AuthenticationWebAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 3af0b441..143184d6 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -33,7 +33,7 @@ class AuthenticationWebAdapter( .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } @DeleteMapping("/{uuid}") - fun deleteAuthentication(@PathVariable uuid: String): ResponseEntity { + fun deleteAuthentication(@PathVariable uuid: String): ResponseEntity { if(!isValidUUID(uuid)) throw InvalidUuidException deleteAuthenticationUseCase.execute(uuid) return ResponseEntity.noContent().build() From 18ee3ffa717b9e862987a4b79abf17c2b132606b Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 8 Mar 2024 09:31:37 +0900 Subject: [PATCH 080/183] :sparkles: homeroom teacher not found --- .../teacher/exception/HomeroomTeacherNotFoundException.kt | 8 ++++++++ .../domain/teacher/exception/error/TeacherErrorCode.kt | 1 + 2 files changed, 9 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/HomeroomTeacherNotFoundException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/HomeroomTeacherNotFoundException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/HomeroomTeacherNotFoundException.kt new file mode 100644 index 00000000..627a86e8 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/HomeroomTeacherNotFoundException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.teacher.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.teacher.exception.error.TeacherErrorCode + +object HomeroomTeacherNotFoundException : SmsException( + TeacherErrorCode.HOMEROOM_TEACHER_NOT_FOUNT +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/error/TeacherErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/error/TeacherErrorCode.kt index 501b6fb8..1da8c87f 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/error/TeacherErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/exception/error/TeacherErrorCode.kt @@ -10,6 +10,7 @@ enum class TeacherErrorCode( TEACHER_ALREADY(ErrorStatus.CONFLICT, "선생님 정보가 존재하는 유저입니다."), HOMEROOM_TEACHER_ALREADY(ErrorStatus.CONFLICT, "동일 정보의 담임선생님이 존재합니다."), + HOMEROOM_TEACHER_NOT_FOUNT(ErrorStatus.NOT_FOUND, "담임 선생님이 존재하지 않습니다.") ; override fun status(): Int = status From b3f860c9276b8f6efd22f430b1619b9d096c3646 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 8 Mar 2024 09:33:27 +0900 Subject: [PATCH 081/183] :sparkles: find homeroom teacher by user id --- .../service/GetHomeroomTeacherService.kt | 8 ++++++++ .../teacher/service/HomeroomTeacherService.kt | 6 ++++-- .../impl/GetHomeroomTeacherServiceImpl.kt | 16 ++++++++++++++++ .../teacher/spi/QueryHomeroomTeacherPort.kt | 4 ++++ .../HomeroomTeacherPersistenceAdapter.kt | 17 +++++++++++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt new file mode 100644 index 00000000..2ee21449 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.teacher.service + +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import java.util.UUID + +interface GetHomeroomTeacherService { + fun getHomeroomTeacherByUserId (userId: UUID): HomeroomTeacher +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt index 24316aef..84ed740e 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class HomeroomTeacherService ( checkHomeroomTeacherService: CheckHomeroomTeacherService, - commandHomeroomTeacherService: CommandHomeroomTeacherService + commandHomeroomTeacherService: CommandHomeroomTeacherService, + getHomeroomTeacherService: GetHomeroomTeacherService ) : CheckHomeroomTeacherService by checkHomeroomTeacherService, - CommandHomeroomTeacherService by commandHomeroomTeacherService \ No newline at end of file + CommandHomeroomTeacherService by commandHomeroomTeacherService, + GetHomeroomTeacherService by getHomeroomTeacherService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt new file mode 100644 index 00000000..415629e4 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt @@ -0,0 +1,16 @@ +package team.msg.sms.domain.teacher.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.teacher.exception.HomeroomTeacherNotFoundException +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import team.msg.sms.domain.teacher.service.GetHomeroomTeacherService +import team.msg.sms.domain.teacher.spi.HomeroomTeacherPort +import java.util.* + +@Service +class GetHomeroomTeacherServiceImpl( + private val homeroomTeacherPort: HomeroomTeacherPort +) : GetHomeroomTeacherService { + override fun getHomeroomTeacherByUserId(userId: UUID): HomeroomTeacher = + homeroomTeacherPort.queryHomeroomTeacherByUserId(userId) ?: throw HomeroomTeacherNotFoundException +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt index 0a3db192..06ef7206 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt @@ -1,5 +1,9 @@ package team.msg.sms.domain.teacher.spi +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import java.util.UUID + interface QueryHomeroomTeacherPort { fun existsHomeroomTeacherByGradeAndClassNum(grade: Int, classNum: Int): Boolean + fun queryHomeroomTeacherByUserId(userId: UUID): HomeroomTeacher? } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt index a2a89b63..d0644e0d 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt @@ -1,22 +1,35 @@ package team.msg.sms.persistence.teacher +import com.querydsl.jpa.impl.JPAQueryFactory import org.springframework.stereotype.Component import team.msg.sms.domain.teacher.model.HomeroomTeacher import team.msg.sms.domain.teacher.model.Teacher import team.msg.sms.domain.teacher.spi.HomeroomTeacherPort import team.msg.sms.domain.user.model.User +import team.msg.sms.persistence.teacher.entity.QTeacherJpaEntity.teacherJpaEntity as teacher +import team.msg.sms.persistence.teacher.entity.QHomeroomTeacherJpaEntity.homeroomTeacherJpaEntity as homeroomTeacher +import team.msg.sms.persistence.user.entity.QUserJpaEntity.userJpaEntity as user import team.msg.sms.persistence.teacher.mapper.toDomain import team.msg.sms.persistence.teacher.mapper.toEntity import team.msg.sms.persistence.teacher.repository.HomeroomTeacherJpaRepository import team.msg.sms.persistence.user.mapper.toEntity +import java.util.UUID @Component -class HomeroomTeacherPersistenceAdapter( - private val homeroomTeacherJpaRepository: HomeroomTeacherJpaRepository +class HomeroomTeacherPersistxenceAdapter( + private val homeroomTeacherJpaRepository: HomeroomTeacherJpaRepository, + private val queryFactory: JPAQueryFactory ) : HomeroomTeacherPort { override fun existsHomeroomTeacherByGradeAndClassNum(grade: Int, classNum: Int): Boolean = homeroomTeacherJpaRepository.existsByGradeAndClassNum(grade, classNum) + override fun queryHomeroomTeacherByUserId(userId: UUID): HomeroomTeacher? = + queryFactory.selectFrom(homeroomTeacher) + .innerJoin(homeroomTeacher.teacher, teacher) + .innerJoin(teacher.user, user) + .where(user.id.eq(userId)) + .fetchOne()?.toDomain() + override fun saveHomeroomTeacher(homeroomTeacher: HomeroomTeacher, teacher: Teacher, user: User): HomeroomTeacher = homeroomTeacherJpaRepository.save(homeroomTeacher.toEntity(teacher.toEntity(user.toEntity()))).toDomain() } \ No newline at end of file From bbe3d3e9bb7d4e1f23572f70ec94e08de2f49817 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 8 Mar 2024 14:13:05 +0900 Subject: [PATCH 082/183] :recycle: web data --- ...yRequestedAuthenticationListResponseData.kt | 9 +++++++++ .../res/RequestedAuthenticationResponseData.kt | 4 ++-- .../authentication/model/Authentication.kt | 8 ++++++++ .../authentication/AuthenticationWebAdapter.kt | 18 +++++++++++++----- ...ryRequestedAuthenticationListWebResponse.kt | 9 +++++++++ .../res/RequestedAuthenticationWebResponse.kt | 4 ++-- 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListResponseData.kt rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt => sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationResponseData.kt (76%) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListWebResponse.kt rename sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt => sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationWebResponse.kt (75%) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListResponseData.kt new file mode 100644 index 00000000..77dabad4 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListResponseData.kt @@ -0,0 +1,9 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryRequestedAuthenticationListResponseData ( + val content: List, + val page: Int, + val contentSize: Int, + val totalSize: Long, + val last: Boolean +) \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationResponseData.kt similarity index 76% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt rename to sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationResponseData.kt index 248f0313..7c34953f 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationWebResponse.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationResponseData.kt @@ -4,9 +4,9 @@ import team.msg.sms.domain.student.model.Department import java.time.LocalDate import java.util.* -data class QueryRequestedAuthenticationWebResponse( +data class RequestedAuthenticationResponseData ( val id: UUID, - val requestTime: LocalDate, + val requestedTime: LocalDate, val stuNum: String, val name: String, val department: Department, diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt index 7b1908db..96351aff 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/model/Authentication.kt @@ -23,4 +23,12 @@ class Authentication ( val name: String, val department: Department, ) + + class AuthenticationWithPageInfo( + val authentications: List, + val page: Int, + val contentSize: Int, + val totalSize: Long, + val last: Boolean + ) } \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 8a739078..6388aa31 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -46,7 +46,7 @@ class AuthenticationWebAdapter( @RequestParam(name = "page") page: Int, @RequestParam(name = "size") size: Int, filterRequestData: FindRequestedAuthenticationFiltersWebRequest - ): ResponseEntity = + ): ResponseEntity = queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) .let { ResponseEntity.ok(it.toResponse()) } @@ -68,13 +68,21 @@ class AuthenticationWebAdapter( id = id ) - private fun QueryRequestedAuthenticationResponseData.toResponse() = QueryRequestedAuthenticationWebResponse( + private fun QueryRequestedAuthenticationListResponseData.toResponse() = QueryRequestedAuthenticationListWebResponse( + content = content.map { it.toResponse() }, + page = page, + contentSize = contentSize, + totalSize = totalSize, + last = last + ) + + private fun RequestedAuthenticationResponseData.toResponse() = RequestedAuthenticationWebResponse( id = id, - requestTime = requestTime, + requestedTime = requestedTime, + title = title, stuNum = stuNum, name = name, - department = department, - title = title + department = department ) private fun isValidUUID(uuid: String): Boolean { diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListWebResponse.kt new file mode 100644 index 00000000..4382e6fb --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationListWebResponse.kt @@ -0,0 +1,9 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryRequestedAuthenticationListWebResponse ( + val content: List, + val page: Int, + val contentSize: Int, + val totalSize: Long, + val last: Boolean +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationWebResponse.kt similarity index 75% rename from sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationWebResponse.kt index 359065e5..e3ab64a8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationResponseData.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestedAuthenticationWebResponse.kt @@ -4,9 +4,9 @@ import team.msg.sms.domain.student.model.Department import java.time.LocalDate import java.util.* -data class QueryRequestedAuthenticationResponseData ( +data class RequestedAuthenticationWebResponse( val id: UUID, - val requestTime: LocalDate, + val requestedTime: LocalDate, val stuNum: String, val name: String, val department: Department, From c25b2c20cf33ac4158c1f1847560ba1688063b8e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 8 Mar 2024 14:13:35 +0900 Subject: [PATCH 083/183] :recycle: query request authentication usecase --- .../QueryRequestedAuthenticationUseCase.kt | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt new file mode 100644 index 00000000..beb86206 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt @@ -0,0 +1,77 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role +import team.msg.sms.domain.authentication.dto.req.FiltersRequestData +import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationListResponseData +import team.msg.sms.domain.authentication.dto.res.RequestedAuthenticationResponseData +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.user.service.UserService +import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithPageInfo as AuthenticationWithPageInfo +import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithStudentInfoAndRequestedTime as AuthenticationWithStudentInfoAndRequestedTime + +@UseCase +class QueryRequestedAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val homeroomTeacherService: HomeroomTeacherService, + private val userService: UserService +) { + @Transactional(readOnly = true) + fun execute( + page: Int, size: Int, + filterRequestData: FiltersRequestData + ): QueryRequestedAuthenticationListResponseData { + val user = userService.getCurrentUser() + val authentications = authenticationService.getRequestedAuthentications() + + val filteredAuthentications = if(user.roles.contains(Role.ROLE_HOMEROOM)){ + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(user.id) + authenticationService.filterAuthenticationsForHomeroomTeacher(authentications, filterRequestData, homeroomTeacher) + } else { + authenticationService.filterAuthenticationsForTeacher(authentications, filterRequestData) + } + + val authenticationPage = filteredAuthentications.toDomainPageWithUserInfo(page, size) + + return QueryRequestedAuthenticationListResponseData( + content = authenticationPage.authentications.toRequestedAuthenticationResponseData(), + page = authenticationPage.page, + contentSize = authenticationPage.contentSize, + totalSize = authenticationPage.totalSize, + last = authenticationPage.last + ) + } + + private fun List.toDomainPageWithUserInfo(page: Int, size: Int): AuthenticationWithPageInfo { + val startIndex = (page - 1) * size + val endIndex = (startIndex + size).coerceAtMost(this.size) + val content = if (startIndex <= endIndex) this.subList(startIndex, endIndex) else emptyList() + + val totalPages = (this.size + size - 1) / size + val isLast = page >= totalPages + + return AuthenticationWithPageInfo( + authentications = content, + page = page, + contentSize = content.size, + totalSize = this.size.toLong(), + last = isLast + ) + } + + fun List.toRequestedAuthenticationResponseData(): List = + map { + RequestedAuthenticationResponseData( + id = it.id, + requestedTime = it.requestedTime.toLocalDate(), + title = it.title, + stuNum = it.stuNum, + name = it.name, + department = it.department + ) + } + + +} \ No newline at end of file From 9ed16bad992b19abb6243a9c4bc5b4bbc75277d2 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:39:59 +0900 Subject: [PATCH 084/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Persistence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationHistoryPersistenceAdapter.kt | 8 ++++++++ .../repository/AuthenticationHistoryJpaRepository.kt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt index 689c092b..9b2174cf 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationHistoryPersistenceAdapter.kt @@ -34,4 +34,12 @@ class AuthenticationHistoryPersistenceAdapter( user: User ): AuthenticationHistory = authenticationHistoryJpaRepository.findByAuthenticationOrderByCreatedAtDesc(authentication.toEntity(student.toEntity(user.toEntity()))).toDomain() + + override fun queryAuthenticationHistories( + authentication: Authentication, + student: Student, + user: User + ): List = + authenticationHistoryJpaRepository.findByAuthentication(authentication.toEntity(student.toEntity(user.toEntity()))) + .map {historyJpaEntity -> historyJpaEntity.toDomain() } } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt index e835336a..5eae4d6c 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationHistoryJpaRepository.kt @@ -11,4 +11,6 @@ interface AuthenticationHistoryJpaRepository : JpaRepository } \ No newline at end of file From 52b1d6f46b764e4843c095887805e31f36e0e18a Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:40:51 +0900 Subject: [PATCH 085/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20ResponseData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/QueryAuthenticationHistoriesResponseData.kt | 5 +++++ .../dto/res/QueryAuthenticationHistoryResponseData.kt | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoriesResponseData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoriesResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoriesResponseData.kt new file mode 100644 index 00000000..0f34bae3 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoriesResponseData.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryAuthenticationHistoriesResponseData ( + val histories: List +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt new file mode 100644 index 00000000..526fa094 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt @@ -0,0 +1,10 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryAuthenticationHistoryResponseData ( + val authenticationId: String, + val teacherName: String, + val gradedDate: String, + val score: Int, + val activityStatus: String, + val reason: String, +) \ No newline at end of file From fd4a64f1fec63872c9e37bb7d7bf3ef8022fb536 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:41:51 +0900 Subject: [PATCH 086/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20UseCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryAuthenticationHistoriesUseCase.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt new file mode 100644 index 00000000..8fdafa46 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -0,0 +1,41 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoriesResponseData +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoryResponseData +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class QueryAuthenticationHistoriesUseCase( + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val studentService: StudentService, + private val userService: UserService +) { + @Transactional(readOnly = true) + fun execute(uuid: String): QueryAuthenticationHistoriesResponseData { + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) + val histories = authenticationHistoryService.getAuthenticationHistories(authentication, student, user) + + return QueryAuthenticationHistoriesResponseData( + histories.map { history -> + QueryAuthenticationHistoryResponseData( + authenticationId = history.authenticationId.toString(), + teacherName = "나임", + gradedDate = history.createdAt.toString(), + score = authentication.score, + activityStatus = history.activityStatus.name, + reason = history.reason + ) + } + ) + } +} \ No newline at end of file From 0775769ab0ead10866e1fc2288e592b46d9cc9f4 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:42:33 +0900 Subject: [PATCH 087/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/spi/QueryAuthenticationHistoryPort.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt index 69cede04..b0dfc441 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationHistoryPort.kt @@ -11,4 +11,10 @@ interface QueryAuthenticationHistoryPort { student: Student, user: User ): AuthenticationHistory + + fun queryAuthenticationHistories( + authentication: Authentication, + student: Student, + user: User + ): List } \ No newline at end of file From 725b11106c6637d0e174645fa3200f09711ac400 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:42:55 +0900 Subject: [PATCH 088/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/GetAuthenticationHistoryService.kt | 6 ++++++ .../service/impl/GetAuthenticationHistoryServiceImpl.kt | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt index d5935129..bf92ee8c 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationHistoryService.kt @@ -11,4 +11,10 @@ interface GetAuthenticationHistoryService { student: Student, user: User ): AuthenticationHistory + + fun getAuthenticationHistories( + authentication: Authentication, + student: Student, + user: User + ): List } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt index 4d16b789..4177dc8d 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationHistoryServiceImpl.kt @@ -18,4 +18,11 @@ class GetAuthenticationHistoryServiceImpl( user: User ): AuthenticationHistory = queryAuthenticationHistoryPort.queryLatestAuthenticationHistory(authentication, student, user) + + override fun getAuthenticationHistories( + authentication: Authentication, + student: Student, + user: User + ): List = + queryAuthenticationHistoryPort.queryAuthenticationHistories(authentication, student, user) } \ No newline at end of file From 64027d127b8ff575b1f4439ecbe82b13159479bf Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:44:05 +0900 Subject: [PATCH 089/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20get=20authenticati?= =?UTF-8?q?on=20histories=20Teacher=20Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/teacher/service/GetTeacherService.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt new file mode 100644 index 00000000..45cfcdb3 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.teacher.service + +import team.msg.sms.domain.teacher.model.Teacher +import java.util.UUID + +interface GetTeacherService{ + fun findTeacherByUuid(uuid: UUID?): Teacher +} \ No newline at end of file From f9fce5ac76aae460d11de4423cb805fe475c269e Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 13:44:27 +0900 Subject: [PATCH 090/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Presentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationWebAdapter.kt | 25 ++++++++++++------- ...QueryAuthenticationHistoriesWebResponse.kt | 7 ++++++ 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationHistoriesWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 143184d6..283e7f5f 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -4,20 +4,15 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException -import team.msg.sms.domain.authentication.dto.res.CreateAuthenticationResponseData -import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData -import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData +import team.msg.sms.domain.authentication.dto.res.* import team.msg.sms.domain.authentication.req.CreateAuthenticationWebRequest import team.msg.sms.domain.authentication.res.CreateAuthenticationWebResponse import team.msg.sms.domain.authentication.res.QueryAuthenticationDetailsWebResponse +import team.msg.sms.domain.authentication.res.QueryAuthenticationHistoriesWebResponse import team.msg.sms.domain.authentication.res.RequestAuthenticationWebResponse -import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase -import team.msg.sms.domain.authentication.usecase.DeleteAuthenticationUseCase -import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase -import team.msg.sms.domain.authentication.usecase.RequestAuthenticationUseCase +import team.msg.sms.domain.authentication.usecase.* import java.util.* import javax.validation.Valid -import javax.validation.constraints.Null @RestController @RequestMapping("/authentication") @@ -25,7 +20,8 @@ class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase, - private val requestAuthenticationUseCase: RequestAuthenticationUseCase + private val requestAuthenticationUseCase: RequestAuthenticationUseCase, + private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -46,6 +42,13 @@ class AuthenticationWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @GetMapping("/{uuid}/history") + fun queryAuthenticationHistories(@PathVariable uuid: String): ResponseEntity { + if(!isValidUUID(uuid)) throw InvalidUuidException + return queryAuthenticationHistoriesUseCase.execute(uuid) + .let { ResponseEntity.ok(it.toResponse()) } + } + @PatchMapping("/{uuid}") fun requestAuthenticationDetails(@PathVariable uuid: String): ResponseEntity { if (!isValidUUID(uuid)) throw InvalidUuidException @@ -57,6 +60,10 @@ class AuthenticationWebAdapter( id = id ) + private fun QueryAuthenticationHistoriesResponseData.toResponse() = QueryAuthenticationHistoriesWebResponse( + histories = histories + ) + private fun QueryAuthenticationDetailsResponseData.toResponse() = QueryAuthenticationDetailsWebResponse( id = id, title = title, diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationHistoriesWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationHistoriesWebResponse.kt new file mode 100644 index 00000000..c6524925 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/res/QueryAuthenticationHistoriesWebResponse.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.res + +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoryResponseData + +data class QueryAuthenticationHistoriesWebResponse( + val histories: List +) \ No newline at end of file From 1a22f0ad90ddf8eddfe3b6843ef4cb5e50005862 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 14:41:22 +0900 Subject: [PATCH 091/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=EC=9D=98=20=EB=82=A0=EC=A7=9C=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EC=84=A0=EC=83=9D?= =?UTF-8?q?=EB=8B=98=20=EC=9D=B4=EB=A6=84=20String=20->=20String=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/QueryAuthenticationHistoryResponseData.kt | 2 +- .../usecase/QueryAuthenticationHistoriesUseCase.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt index 526fa094..f8ba34b7 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt @@ -2,7 +2,7 @@ package team.msg.sms.domain.authentication.dto.res data class QueryAuthenticationHistoryResponseData ( val authenticationId: String, - val teacherName: String, + val teacherName: String?, val gradedDate: String, val score: Int, val activityStatus: String, diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index 8fdafa46..adb2b948 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -2,13 +2,13 @@ package team.msg.sms.domain.authentication.usecase import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase -import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoriesResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoryResponseData import team.msg.sms.domain.authentication.service.AuthenticationHistoryService import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService import team.msg.sms.domain.user.service.UserService +import java.time.format.DateTimeFormatter import java.util.* @UseCase @@ -16,7 +16,7 @@ class QueryAuthenticationHistoriesUseCase( private val authenticationService: AuthenticationService, private val authenticationHistoryService: AuthenticationHistoryService, private val studentService: StudentService, - private val userService: UserService + private val userService: UserService, ) { @Transactional(readOnly = true) fun execute(uuid: String): QueryAuthenticationHistoriesResponseData { @@ -27,10 +27,14 @@ class QueryAuthenticationHistoriesUseCase( return QueryAuthenticationHistoriesResponseData( histories.map { history -> + val teacherName = if (history.teacherId != null) { + userService.getUserById(history.teacherId).name + } else null + QueryAuthenticationHistoryResponseData( authenticationId = history.authenticationId.toString(), - teacherName = "나임", - gradedDate = history.createdAt.toString(), + teacherName = teacherName, + gradedDate = history.createdAt.format(DateTimeFormatter.ofPattern("YYYY-MM-dd")), score = authentication.score, activityStatus = history.activityStatus.name, reason = history.reason From 081012f0ecb682cb8576723a50a96b5e161963b6 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 10 Mar 2024 15:24:25 +0900 Subject: [PATCH 092/183] =?UTF-8?q?=E2=99=BB=EF=B8=8Fget=20authentication?= =?UTF-8?q?=20histories=20=EC=97=91=EC=84=B8=EC=8A=A4=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=9C=20=EC=97=AD=ED=95=A0=EC=9D=98=20=EB=B2=94=EC=9C=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/PermissionRoleDeniedException.kt | 8 ++++++++ .../exception/error/AuthenticationErrorCode.kt | 1 + .../usecase/QueryAuthenticationHistoriesUseCase.kt | 7 +++++++ .../kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 4 files changed, 17 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/PermissionRoleDeniedException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/PermissionRoleDeniedException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/PermissionRoleDeniedException.kt new file mode 100644 index 00000000..8d86c56c --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/PermissionRoleDeniedException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object PermissionRoleDeniedException : SmsException( + AuthenticationErrorCode.PERMISSION_ROLE_DENIED +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt index 1629828b..ddc24069 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -10,6 +10,7 @@ enum class AuthenticationErrorCode( AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다."), UNSUITABLE_ACTIVITY_STATUS(ErrorStatus.CONFLICT, "요청을 처리하기에 적합하지 않은 인증제 활동 상태입니다."), ALREADY_AWARDED_SCORE(ErrorStatus.CONFLICT, "활동에 이미 점수가 부여된 상태입니다."), + PERMISSION_ROLE_DENIED(ErrorStatus.FORBIDDEN, "학생이거나 교장, 교감, 부장, 담임 선생님만 조회할 수 있습니다.") ; override fun status(): Int = status diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index adb2b948..5f4a1fe1 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -2,11 +2,14 @@ package team.msg.sms.domain.authentication.usecase import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoriesResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoryResponseData +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException import team.msg.sms.domain.authentication.service.AuthenticationHistoryService import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.TeacherService import team.msg.sms.domain.user.service.UserService import java.time.format.DateTimeFormatter import java.util.* @@ -20,11 +23,15 @@ class QueryAuthenticationHistoriesUseCase( ) { @Transactional(readOnly = true) fun execute(uuid: String): QueryAuthenticationHistoriesResponseData { + val allowedRole = arrayOf(Role.ROLE_STUDENT, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL, Role.ROLE_DIRECTOR, Role.ROLE_HOMEROOM) + if (userService.getCurrentUser().roles.none { it in allowedRole}) throw PermissionRoleDeniedException + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) val user = userService.getUserById(student.userId) val histories = authenticationHistoryService.getAuthenticationHistories(authentication, student, user) + return QueryAuthenticationHistoriesResponseData( histories.map { history -> val teacherName = if (history.teacherId != null) { diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index e428bda4..a28105c6 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -69,6 +69,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER ) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) From b52caa38d15eb11fc74081f3e43f5782b72a0be4 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 12:16:26 +0900 Subject: [PATCH 093/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20DTO=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20Jackson=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/QueryAuthenticationHistoryResponseData.kt | 7 +++++-- .../usecase/QueryAuthenticationHistoriesUseCase.kt | 4 ++-- .../team/msg/sms/global/config/JacksonConfiguration.kt | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt index f8ba34b7..fc0e222a 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryAuthenticationHistoryResponseData.kt @@ -1,10 +1,13 @@ package team.msg.sms.domain.authentication.dto.res +import team.msg.sms.domain.authentication.model.ActivityStatus +import java.time.LocalDate + data class QueryAuthenticationHistoryResponseData ( val authenticationId: String, val teacherName: String?, - val gradedDate: String, + val gradedDate: LocalDate, val score: Int, - val activityStatus: String, + val activityStatus: ActivityStatus, val reason: String, ) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index 5f4a1fe1..56e3c6c6 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -41,9 +41,9 @@ class QueryAuthenticationHistoriesUseCase( QueryAuthenticationHistoryResponseData( authenticationId = history.authenticationId.toString(), teacherName = teacherName, - gradedDate = history.createdAt.format(DateTimeFormatter.ofPattern("YYYY-MM-dd")), + gradedDate = history.createdAt.toLocalDate(), score = authentication.score, - activityStatus = history.activityStatus.name, + activityStatus = history.activityStatus, reason = history.reason ) } diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt index 9a81da39..74bd7535 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/config/JacksonConfiguration.kt @@ -13,5 +13,5 @@ class JacksonConfiguration { fun jackson2ObjectMapperBuilder(): Jackson2ObjectMapperBuilder = Jackson2ObjectMapperBuilder() .serializers(LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))) - .serializers(LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-d"))) + .serializers(LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) } \ No newline at end of file From 9a2ecd45f5261d9913a148e14a363fcaa74a38df Mon Sep 17 00:00:00 2001 From: Donghak Kim Date: Mon, 11 Mar 2024 12:19:39 +0900 Subject: [PATCH 094/183] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=EA=B4=84=ED=98=B8?= =?UTF-8?q?=20=EC=82=AC=EC=9D=B4=EC=97=90=20=EB=9B=B0=EC=96=B4=EC=93=B0?= =?UTF-8?q?=EA=B8=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 노현주 <106813267+ani2689@users.noreply.github.com> --- .../usecase/QueryAuthenticationHistoriesUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index 56e3c6c6..973c82fe 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -24,7 +24,7 @@ class QueryAuthenticationHistoriesUseCase( @Transactional(readOnly = true) fun execute(uuid: String): QueryAuthenticationHistoriesResponseData { val allowedRole = arrayOf(Role.ROLE_STUDENT, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL, Role.ROLE_DIRECTOR, Role.ROLE_HOMEROOM) - if (userService.getCurrentUser().roles.none { it in allowedRole}) throw PermissionRoleDeniedException + if (userService.getCurrentUser().roles.none { it in allowedRole }) throw PermissionRoleDeniedException val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) From a6f1c6d907518991612ca231509551f4ab3f8b31 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 14:27:16 +0900 Subject: [PATCH 095/183] =?UTF-8?q?=E2=9C=A8=20=20get=20authentication=20h?= =?UTF-8?q?istories=20Exception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/InvalidGradeClassException.kt | 8 ++++++++ .../authentication/exception/OnlyAccessMyselfException.kt | 8 ++++++++ .../exception/error/AuthenticationErrorCode.kt | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/InvalidGradeClassException.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/OnlyAccessMyselfException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/InvalidGradeClassException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/InvalidGradeClassException.kt new file mode 100644 index 00000000..05460a46 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/InvalidGradeClassException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object InvalidGradeClassException : SmsException( + AuthenticationErrorCode.INVALID_GRADE_CLASS +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/OnlyAccessMyselfException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/OnlyAccessMyselfException.kt new file mode 100644 index 00000000..830aab9f --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/OnlyAccessMyselfException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object OnlyAccessMyselfException : SmsException( + AuthenticationErrorCode.ONLY_ACCESS_MYSELF +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt index ddc24069..b617d4f8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -10,7 +10,9 @@ enum class AuthenticationErrorCode( AUTHENTICATION_NOT_FOUND(ErrorStatus.NOT_FOUND, "인증제 활동을 찾을 수 없습니다."), UNSUITABLE_ACTIVITY_STATUS(ErrorStatus.CONFLICT, "요청을 처리하기에 적합하지 않은 인증제 활동 상태입니다."), ALREADY_AWARDED_SCORE(ErrorStatus.CONFLICT, "활동에 이미 점수가 부여된 상태입니다."), - PERMISSION_ROLE_DENIED(ErrorStatus.FORBIDDEN, "학생이거나 교장, 교감, 부장, 담임 선생님만 조회할 수 있습니다.") + PERMISSION_ROLE_DENIED(ErrorStatus.FORBIDDEN, "학생이거나 교장, 교감, 부장, 담임 선생님만 조회할 수 있습니다."), + ONLY_ACCESS_MYSELF(ErrorStatus.FORBIDDEN, "자기 자신만 조회할 수 있습니다."), + INVALID_GRADE_CLASS(ErrorStatus.FORBIDDEN, "담임 선생님만 조회할 수 있습니다.") ; override fun status(): Int = status From 7540cf12beae4ea627bcc21986c2c9c43df85377 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 14:28:54 +0900 Subject: [PATCH 096/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EC=9D=98=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryAuthenticationHistoriesUseCase.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index 56e3c6c6..bf07f11c 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -5,13 +5,16 @@ import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoriesResponseData import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationHistoryResponseData +import team.msg.sms.domain.authentication.exception.InvalidGradeClassException +import team.msg.sms.domain.authentication.exception.OnlyAccessMyselfException import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException +import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.AuthenticationHistoryService import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService import team.msg.sms.domain.teacher.service.TeacherService import team.msg.sms.domain.user.service.UserService -import java.time.format.DateTimeFormatter import java.util.* @UseCase @@ -20,17 +23,29 @@ class QueryAuthenticationHistoriesUseCase( private val authenticationHistoryService: AuthenticationHistoryService, private val studentService: StudentService, private val userService: UserService, + private val teacherService: TeacherService, + private val homeroomTeacherService: HomeroomTeacherService ) { @Transactional(readOnly = true) fun execute(uuid: String): QueryAuthenticationHistoriesResponseData { - val allowedRole = arrayOf(Role.ROLE_STUDENT, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL, Role.ROLE_DIRECTOR, Role.ROLE_HOMEROOM) - if (userService.getCurrentUser().roles.none { it in allowedRole}) throw PermissionRoleDeniedException - val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) val user = userService.getUserById(student.userId) val histories = authenticationHistoryService.getAuthenticationHistories(authentication, student, user) + val currentUser = userService.getCurrentUser() + + val allowedRole = arrayOf(Role.ROLE_STUDENT, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL, Role.ROLE_DIRECTOR, Role.ROLE_HOMEROOM) + if (currentUser.roles.none { it in allowedRole }) throw PermissionRoleDeniedException + + when{ + currentUser.roles.contains(Role.ROLE_STUDENT) -> if(currentUser.id != user.id) throw OnlyAccessMyselfException + currentUser.roles.contains(Role.ROLE_HOMEROOM) -> { + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByTeacher(teacherService.getTeacherByUser(currentUser)) + if("${homeroomTeacher.grade}${homeroomTeacher.classNum}" != user.stuNum.substring(0, 1)) + throw InvalidGradeClassException + } + } return QueryAuthenticationHistoriesResponseData( histories.map { history -> From e00009c393a5df1f443e79934cf3191c42197f27 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 14:31:54 +0900 Subject: [PATCH 097/183] =?UTF-8?q?=E2=9C=A8=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=EC=9D=84=20=EC=9C=84=ED=95=9C=20Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/service/GetHomeroomTeacherService.kt | 9 +++++++++ .../msg/sms/domain/teacher/service/GetTeacherService.kt | 6 ++++-- .../sms/domain/teacher/service/HomeroomTeacherService.kt | 6 ++++-- .../msg/sms/domain/teacher/service/TeacherService.kt | 6 ++++-- 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt new file mode 100644 index 00000000..25682f87 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt @@ -0,0 +1,9 @@ +package team.msg.sms.domain.teacher.service + +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.user.model.User + +interface GetHomeroomTeacherService { + fun getHomeroomTeacherByTeacher(teacher: Teacher): HomeroomTeacher +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt index 45cfcdb3..31d8e6f3 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetTeacherService.kt @@ -1,8 +1,10 @@ package team.msg.sms.domain.teacher.service +import team.msg.sms.domain.teacher.model.HomeroomTeacher import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.user.model.User import java.util.UUID -interface GetTeacherService{ - fun findTeacherByUuid(uuid: UUID?): Teacher +interface GetTeacherService { + fun getTeacherByUser(user: User): Teacher } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt index 24316aef..5e4f6c28 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/HomeroomTeacherService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class HomeroomTeacherService ( checkHomeroomTeacherService: CheckHomeroomTeacherService, - commandHomeroomTeacherService: CommandHomeroomTeacherService + commandHomeroomTeacherService: CommandHomeroomTeacherService, + getHomeroomTeacherService: GetHomeroomTeacherService ) : CheckHomeroomTeacherService by checkHomeroomTeacherService, - CommandHomeroomTeacherService by commandHomeroomTeacherService \ No newline at end of file + CommandHomeroomTeacherService by commandHomeroomTeacherService, + GetHomeroomTeacherService by getHomeroomTeacherService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/TeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/TeacherService.kt index 79489a5a..07a99e41 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/TeacherService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/TeacherService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class TeacherService ( checkTeacherService: CheckTeacherService, - commandTeacherService: CommandTeacherService + commandTeacherService: CommandTeacherService, + getTeacherService: GetTeacherService ) : CheckTeacherService by checkTeacherService, - CommandTeacherService by commandTeacherService \ No newline at end of file + CommandTeacherService by commandTeacherService, + GetTeacherService by getTeacherService \ No newline at end of file From 6280be042f43461968d96fe0f33da6119b7a8b78 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 16:04:31 +0900 Subject: [PATCH 098/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Persistence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/teacher/HomeroomTeacherPersistenceAdapter.kt | 4 ++++ .../teacher/repository/HomeroomTeacherJpaRepository.kt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt index a2a89b63..0ae71069 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/HomeroomTeacherPersistenceAdapter.kt @@ -17,6 +17,10 @@ class HomeroomTeacherPersistenceAdapter( override fun existsHomeroomTeacherByGradeAndClassNum(grade: Int, classNum: Int): Boolean = homeroomTeacherJpaRepository.existsByGradeAndClassNum(grade, classNum) + override fun findHomeroomTeacherByTeacher(teacher: Teacher, user: User): HomeroomTeacher { + return homeroomTeacherJpaRepository.findByTeacher(teacher.toEntity(user.toEntity())).toDomain() + } + override fun saveHomeroomTeacher(homeroomTeacher: HomeroomTeacher, teacher: Teacher, user: User): HomeroomTeacher = homeroomTeacherJpaRepository.save(homeroomTeacher.toEntity(teacher.toEntity(user.toEntity()))).toDomain() } \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/HomeroomTeacherJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/HomeroomTeacherJpaRepository.kt index c637ccb7..5c467c28 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/HomeroomTeacherJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/HomeroomTeacherJpaRepository.kt @@ -2,9 +2,13 @@ package team.msg.sms.persistence.teacher.repository import org.springframework.data.repository.CrudRepository import org.springframework.stereotype.Repository +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import team.msg.sms.domain.teacher.model.Teacher import team.msg.sms.persistence.teacher.entity.HomeroomTeacherJpaEntity +import team.msg.sms.persistence.teacher.entity.TeacherJpaEntity @Repository interface HomeroomTeacherJpaRepository : CrudRepository { fun existsByGradeAndClassNum(grade: Int, classNum: Int): Boolean + fun findByTeacher(teacherJpaEntity: TeacherJpaEntity): HomeroomTeacherJpaEntity } \ No newline at end of file From 7bc9c46b786e28350645ef522d0c932259d4216c Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 16:06:00 +0900 Subject: [PATCH 099/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Persistence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/persistence/teacher/TeacherPersistenceAdapter.kt | 4 ++++ .../persistence/teacher/repository/TeacherJpaRepository.kt | 3 +++ 2 files changed, 7 insertions(+) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/TeacherPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/TeacherPersistenceAdapter.kt index 01370a82..7f44d471 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/TeacherPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/TeacherPersistenceAdapter.kt @@ -20,6 +20,10 @@ class TeacherPersistenceAdapter( override fun existsTeacherByUser(user: User) = teacherJpaRepository.existsByUser(user.toEntity()) + override fun findTeacherByUser(user: User): Teacher { + return teacherJpaRepository.findByUser(user).toDomain() + } + override fun saveTeacher(teacher: Teacher, user: User) = teacherJpaRepository.save(teacher.toEntity(user.toEntity())).toDomain() diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/TeacherJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/TeacherJpaRepository.kt index 08b87189..a8c6e840 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/TeacherJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/teacher/repository/TeacherJpaRepository.kt @@ -2,6 +2,8 @@ package team.msg.sms.persistence.teacher.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository +import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.user.model.User import team.msg.sms.persistence.teacher.entity.TeacherJpaEntity import team.msg.sms.persistence.user.entity.UserJpaEntity import java.util.* @@ -9,4 +11,5 @@ import java.util.* @Repository interface TeacherJpaRepository : JpaRepository{ fun existsByUser(user: UserJpaEntity): Boolean + fun findByUser(user: User): TeacherJpaEntity } \ No newline at end of file From ffac71d9e7720dd58cf2afd708d80cbcfe044a72 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 16:06:12 +0900 Subject: [PATCH 100/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/GetHomeroomTeacherService.kt | 2 +- .../impl/GetHomeroomTeacherServiceImpl.kt | 18 ++++++++++++++++++ .../service/impl/GetTeacherServiceImpl.kt | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetTeacherServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt index 25682f87..177b9163 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/GetHomeroomTeacherService.kt @@ -5,5 +5,5 @@ import team.msg.sms.domain.teacher.model.Teacher import team.msg.sms.domain.user.model.User interface GetHomeroomTeacherService { - fun getHomeroomTeacherByTeacher(teacher: Teacher): HomeroomTeacher + fun getHomeroomTeacherByTeacher(teacher: Teacher, user: User): HomeroomTeacher } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt new file mode 100644 index 00000000..0de93760 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetHomeroomTeacherServiceImpl.kt @@ -0,0 +1,18 @@ +package team.msg.sms.domain.teacher.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.teacher.service.GetHomeroomTeacherService +import team.msg.sms.domain.teacher.spi.HomeroomTeacherPort +import team.msg.sms.domain.user.model.User + +@Service +class GetHomeroomTeacherServiceImpl( + private val homeroomTeacherPort: HomeroomTeacherPort +) : GetHomeroomTeacherService { + + override fun getHomeroomTeacherByTeacher(teacher: Teacher, user: User): HomeroomTeacher { + return homeroomTeacherPort.findHomeroomTeacherByTeacher(teacher, user) + } +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetTeacherServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetTeacherServiceImpl.kt new file mode 100644 index 00000000..e52606fe --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/service/impl/GetTeacherServiceImpl.kt @@ -0,0 +1,16 @@ +package team.msg.sms.domain.teacher.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.teacher.service.GetTeacherService +import team.msg.sms.domain.teacher.spi.TeacherPort +import team.msg.sms.domain.user.model.User + +@Service +class GetTeacherServiceImpl( + private val teacherPort: TeacherPort +) : GetTeacherService { + override fun getTeacherByUser(user: User): Teacher { + return teacherPort.findTeacherByUser(user) + } +} \ No newline at end of file From 14e1dc7beeadf1ae542bb52932e525a77f62a22d Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 16:06:24 +0900 Subject: [PATCH 101/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt | 6 ++++++ .../team/msg/sms/domain/teacher/spi/QueryTeacherPort.kt | 2 ++ 2 files changed, 8 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt index 0a3db192..4e59607e 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryHomeroomTeacherPort.kt @@ -1,5 +1,11 @@ package team.msg.sms.domain.teacher.spi +import team.msg.sms.domain.teacher.model.HomeroomTeacher +import team.msg.sms.domain.teacher.model.Teacher +import team.msg.sms.domain.user.model.User + interface QueryHomeroomTeacherPort { fun existsHomeroomTeacherByGradeAndClassNum(grade: Int, classNum: Int): Boolean + + fun findHomeroomTeacherByTeacher(teacher: Teacher, user: User): HomeroomTeacher } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryTeacherPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryTeacherPort.kt index 29f67879..07d85437 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryTeacherPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/teacher/spi/QueryTeacherPort.kt @@ -1,9 +1,11 @@ package team.msg.sms.domain.teacher.spi +import team.msg.sms.domain.teacher.model.Teacher import team.msg.sms.domain.user.model.User import java.util.* interface QueryTeacherPort { fun existsTeacherById(uuid: UUID): Boolean fun existsTeacherByUser(user: User): Boolean + fun findTeacherByUser(user: User): Teacher } \ No newline at end of file From 3642eb519e0e63eae522da53642cb61a9daf9a5c Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 11 Mar 2024 16:06:30 +0900 Subject: [PATCH 102/183] =?UTF-8?q?=E2=9C=A8=20get=20authentication=20hist?= =?UTF-8?q?ories=20Usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/QueryAuthenticationHistoriesUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt index 45d24815..eff654c7 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryAuthenticationHistoriesUseCase.kt @@ -40,7 +40,7 @@ class QueryAuthenticationHistoriesUseCase( when{ Role.ROLE_STUDENT in currentUser.roles -> if(currentUser.id != user.id) throw OnlyAccessMyselfException Role.ROLE_HOMEROOM in currentUser.roles -> { - val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByTeacher(teacherService.getTeacherByUser(currentUser)) + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByTeacher(teacherService.getTeacherByUser(currentUser), currentUser) if("${homeroomTeacher.grade}${homeroomTeacher.classNum}" != user.stuNum.substring(0, 1)) throw InvalidGradeClassException } } From 31c0efb0561d3deaff17663318207edd6d05a21a Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 09:28:13 +0900 Subject: [PATCH 103/183] =?UTF-8?q?:bug:=20=EC=A0=91=EA=B7=BC=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index ce432785..ae6a6c46 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -72,7 +72,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.PATCH,"/authentication/{uuid}").hasAuthority(STUDENT) - .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAnyAuthority(PRINCIPAL, DEPUTY_PRINCIPAL, DIRECTOR, HOMEROOM) + .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() From 53fdcde2bbe0d856839d2e482d56bd553e0a9dff Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 15:09:39 +0900 Subject: [PATCH 104/183] =?UTF-8?q?:sparkles:=20=EC=84=A0=EC=83=9D?= =?UTF-8?q?=EB=8B=98=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryRequestedAuthenticationUseCase.kt | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt index beb86206..abf13230 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt @@ -6,6 +6,8 @@ import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.req.FiltersRequestData import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationListResponseData import team.msg.sms.domain.authentication.dto.res.RequestedAuthenticationResponseData +import team.msg.sms.domain.authentication.exception.InvalidGradeClassException +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.teacher.service.HomeroomTeacherService import team.msg.sms.domain.user.service.UserService @@ -26,11 +28,21 @@ class QueryRequestedAuthenticationUseCase( val user = userService.getCurrentUser() val authentications = authenticationService.getRequestedAuthentications() - val filteredAuthentications = if(user.roles.contains(Role.ROLE_HOMEROOM)){ - val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(user.id) - authenticationService.filterAuthenticationsForHomeroomTeacher(authentications, filterRequestData, homeroomTeacher) - } else { - authenticationService.filterAuthenticationsForTeacher(authentications, filterRequestData) + val filteredAuthentications = when { + Role.ROLE_HOMEROOM in user.roles -> { + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(user.id) + + if("${homeroomTeacher.grade}${homeroomTeacher.classNum}" != user.stuNum.substring(0, 1)) + throw InvalidGradeClassException + + authenticationService.filterAuthenticationsForHomeroomTeacher(authentications, filterRequestData, homeroomTeacher) + } + Role.ROLE_DIRECTOR in user.roles || + Role.ROLE_PRINCIPAL in user.roles || + Role.ROLE_DEPUTY_PRINCIPAL in user.roles -> { + authenticationService.filterAuthenticationsForTeacher(authentications, filterRequestData) + } + else -> throw PermissionRoleDeniedException } val authenticationPage = filteredAuthentications.toDomainPageWithUserInfo(page, size) From 21f7c474ac32d565da8b8d8c69846d3899c13c6c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 16:58:38 +0900 Subject: [PATCH 105/183] =?UTF-8?q?:bug:=20403=20error=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 54192a72..6b1816af 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -69,12 +69,12 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER ) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.PATCH,"/authentication/{uuid}").hasAuthority(STUDENT) - .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() From 98beea16f01c0b1484b8d00047e0c780e3cbfc30 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 17:04:31 +0900 Subject: [PATCH 106/183] =?UTF-8?q?:sparkles:=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FilterAuthenticationServiceImpl.kt | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt index ef32209a..172c9052 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/FilterAuthenticationServiceImpl.kt @@ -12,30 +12,42 @@ class FilterAuthenticationServiceImpl : FilterAuthenticationService { authentications: List, filters: FiltersRequestData ) : List { - var filteredAuthentication = authentications + var filteredAuthentications = authentications filters.grade?.let { grade -> if (filters.grade.isNotEmpty()) - filteredAuthentication = filteredAuthentication.filter { authentication -> + filteredAuthentications = filteredAuthentications.filter { authentication -> authentication.stuNum.substring(0, 1).toInt() in grade } } filters.classNum?.let { classNum -> if (filters.classNum.isNotEmpty()) - filteredAuthentication = filteredAuthentication.filter { authentication -> + filteredAuthentications = filteredAuthentications.filter { authentication -> authentication.stuNum.substring(1, 2).toInt() in classNum } } filters.department?.let { departments -> if (filters.department.isNotEmpty()) - filteredAuthentication = filteredAuthentication.filter { authentication -> + filteredAuthentications = filteredAuthentications.filter { authentication -> authentication.department in departments } } - return filteredAuthentication + filters.stuNumSort?.let { stuNumSort -> + filteredAuthentications = + if (stuNumSort == "ASCENDING") filteredAuthentications.sortedBy { it.stuNum } + else filteredAuthentications.sortedBy { it.stuNum }.reversed() + } + + filters.requestTimeSort?.let { requestTimeSort -> + filteredAuthentications = + if (requestTimeSort == "ASCENDING") filteredAuthentications.sortedBy { it.requestedTime } + else filteredAuthentications.sortedBy { it.requestedTime }.reversed() + } + + return filteredAuthentications } override fun filterAuthenticationsForHomeroomTeacher( @@ -43,16 +55,28 @@ class FilterAuthenticationServiceImpl : FilterAuthenticationService { filters: FiltersRequestData, homeroomTeacher: HomeroomTeacher ) : List { - var filteredAuthentication = authentications + var filteredAuthentications = authentications - filteredAuthentication = filteredAuthentication.filter { authentication -> + filteredAuthentications = filteredAuthentications.filter { authentication -> authentication.stuNum.substring(0, 1).toInt() == homeroomTeacher.grade } - filteredAuthentication = filteredAuthentication.filter { authentication -> + filteredAuthentications = filteredAuthentications.filter { authentication -> authentication.stuNum.substring(1, 2).toInt() == homeroomTeacher.classNum } - return filteredAuthentication + filters.stuNumSort?.let { stuNumSort -> + filteredAuthentications = + if (stuNumSort == "ASCENDING") filteredAuthentications.sortedBy { it.stuNum } + else filteredAuthentications.sortedBy { it.stuNum }.reversed() + } + + filters.requestTimeSort?.let { requestTimeSort -> + filteredAuthentications = + if (requestTimeSort == "ASCENDING") filteredAuthentications.sortedBy { it.requestedTime } + else filteredAuthentications.sortedBy { it.requestedTime }.reversed() + } + + return filteredAuthentications } } \ No newline at end of file From c8744827791ca1b85e4dcdab2a88773bedb92eaf Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 17:05:08 +0900 Subject: [PATCH 107/183] =?UTF-8?q?:bug:=20=EB=8B=B4=EC=9E=84=20=EC=84=A0?= =?UTF-8?q?=EC=83=9D=EB=8B=98=20=EA=B6=8C=ED=95=9C=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/QueryRequestedAuthenticationUseCase.kt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt index abf13230..e85a7e34 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationUseCase.kt @@ -6,7 +6,6 @@ import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.req.FiltersRequestData import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationListResponseData import team.msg.sms.domain.authentication.dto.res.RequestedAuthenticationResponseData -import team.msg.sms.domain.authentication.exception.InvalidGradeClassException import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.teacher.service.HomeroomTeacherService @@ -29,14 +28,8 @@ class QueryRequestedAuthenticationUseCase( val authentications = authenticationService.getRequestedAuthentications() val filteredAuthentications = when { - Role.ROLE_HOMEROOM in user.roles -> { - val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(user.id) - - if("${homeroomTeacher.grade}${homeroomTeacher.classNum}" != user.stuNum.substring(0, 1)) - throw InvalidGradeClassException - - authenticationService.filterAuthenticationsForHomeroomTeacher(authentications, filterRequestData, homeroomTeacher) - } + Role.ROLE_HOMEROOM in user.roles -> homeroomTeacherService.getHomeroomTeacherByUserId(user.id) + .let { authenticationService.filterAuthenticationsForHomeroomTeacher(authentications, filterRequestData, it) } Role.ROLE_DIRECTOR in user.roles || Role.ROLE_PRINCIPAL in user.roles || Role.ROLE_DEPUTY_PRINCIPAL in user.roles -> { From bc3d1539a34cb80ee212d7305edd88630bbab4cc Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 12 Mar 2024 17:37:21 +0900 Subject: [PATCH 108/183] =?UTF-8?q?:recycle:=20=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EA=B0=92=EB=A7=8C=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationPersistenceAdapter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt index 9b5a5008..893ab899 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -38,7 +38,7 @@ class AuthenticationPersistenceAdapter( } override fun queryRequestedAuthentications(): List = - queryFactory.select(authentication,history) + queryFactory.select(authentication,history.createdAt) .from(authentication) .leftJoin(history).on(authentication.eq(history.authentication)) .where( @@ -47,7 +47,7 @@ class AuthenticationPersistenceAdapter( ) .fetch() .map { - it[authentication]!!.toDomainWithUserInfoAndRequestedTime(it[history]!!.createdAt) + it[authentication]!!.toDomainWithUserInfoAndRequestedTime(it[history.createdAt]!!) } private fun queryLastedAuthentication() = From fc0b909f5a3520793374d7c9772bdee107775270 Mon Sep 17 00:00:00 2001 From: enbraining Date: Tue, 12 Mar 2024 23:08:03 +0900 Subject: [PATCH 109/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20=EC=8B=9C?= =?UTF-8?q?=ED=81=90=EB=A6=AC=ED=8B=B0=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 6b1816af..33ecb040 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -71,6 +71,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER ) + .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) From 1c9301a58bfd1f1b3650abe97c70463d78a6987f Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:08:15 +0900 Subject: [PATCH 110/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Persistence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationPersistenceAdapter.kt | 5 +++++ .../repository/AuthenticationJpaRepository.kt | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt index 893ab899..a8a7cfaf 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/AuthenticationPersistenceAdapter.kt @@ -37,6 +37,11 @@ class AuthenticationPersistenceAdapter( authenticationJpaRepository.deleteById(uuid) } + override fun queryMyAuthenticationByStudent(student: Student, user: User): List { + return authenticationJpaRepository.findByStudent(student.toEntity(user.toEntity())) + .map { authenticationJpaEntity -> authenticationJpaEntity.toDomain() } + } + override fun queryRequestedAuthentications(): List = queryFactory.select(authentication,history.createdAt) .from(authentication) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt index 80ba09d2..d0f1e825 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt @@ -2,8 +2,13 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity +import team.msg.sms.persistence.student.entity.StudentJpaEntity import java.util.* @Repository -interface AuthenticationJpaRepository : JpaRepository \ No newline at end of file +interface AuthenticationJpaRepository : JpaRepository { + fun findByStudent(studentJpaEntity: StudentJpaEntity): List +} \ No newline at end of file From 07ca6a856d3099ec7c99534ec9c6241b31f031ae Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:08:26 +0900 Subject: [PATCH 111/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/QueryMyAuthenticationListResponseData.kt | 5 +++++ .../dto/res/RequestMyAuthenticationResponseData.kt | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListResponseData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestMyAuthenticationResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListResponseData.kt new file mode 100644 index 00000000..54a26282 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListResponseData.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryMyAuthenticationListResponseData ( + val activities: List +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestMyAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestMyAuthenticationResponseData.kt new file mode 100644 index 00000000..1315341a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestMyAuthenticationResponseData.kt @@ -0,0 +1,14 @@ +package team.msg.sms.domain.authentication.dto.res + +import org.assertj.core.internal.Integers +import team.msg.sms.domain.authentication.model.ActivityStatus +import java.time.LocalDate +import java.util.UUID + +data class RequestMyAuthenticationResponseData( + val id: UUID, + val title: String, + val lastModifiedDate: LocalDate, + val score: Int, + val activityStatus: ActivityStatus +) From ce77cc12084388ac6184ef6469d229a18acd8bf9 Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:08:32 +0900 Subject: [PATCH 112/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Web=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/QueryMyAuthenticationListWebResponse.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListWebResponse.kt new file mode 100644 index 00000000..8961b580 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryMyAuthenticationListWebResponse.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryMyAuthenticationListWebResponse ( + val activities: List +) \ No newline at end of file From 47416460277772273477289d0ecd054109a6cb4d Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:08:46 +0900 Subject: [PATCH 113/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Web=20Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/spi/QueryAuthenticationPort.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt index b9ce0129..24ffa675 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/QueryAuthenticationPort.kt @@ -1,9 +1,13 @@ package team.msg.sms.domain.authentication.spi import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User import java.util.UUID interface QueryAuthenticationPort { fun queryAuthenticationByUuid(uuid: UUID): Authentication? fun queryRequestedAuthentications(): List + + fun queryMyAuthenticationByStudent(student: Student, user: User): List } \ No newline at end of file From 4f2b0a8ed8bcc5aca0b99d74283da37ada02a15e Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:09:13 +0900 Subject: [PATCH 114/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/QueryMyAuthenticationUseCase.kt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt new file mode 100644 index 00000000..7b0ec2a1 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt @@ -0,0 +1,47 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role +import team.msg.sms.domain.authentication.dto.req.FiltersRequestData +import team.msg.sms.domain.authentication.dto.res.QueryMyAuthenticationListResponseData +import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationListResponseData +import team.msg.sms.domain.authentication.dto.res.RequestMyAuthenticationResponseData +import team.msg.sms.domain.authentication.dto.res.RequestedAuthenticationResponseData +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.user.service.UserService +import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithPageInfo as AuthenticationWithPageInfo +import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithStudentInfoAndRequestedTime as AuthenticationWithStudentInfoAndRequestedTime + +@UseCase +class QueryMyAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val studentService: StudentService, + private val userService: UserService +) { + @Transactional(readOnly = true) + fun execute(): QueryMyAuthenticationListResponseData { + val user = userService.getCurrentUser() + val student = studentService.getStudentByUser(user) + val authenticationList = authenticationService.getAuthenticationByStudent(student, user) + + return QueryMyAuthenticationListResponseData( + activities = authenticationList.map { authentication -> + val latestHistory = authenticationHistoryService.getLatestAuthenticationHistory(authentication, student, user) + + RequestMyAuthenticationResponseData( + id = authentication.id, + title = authentication.title, + score = authentication.score, + activityStatus = authentication.activityStatus, + lastModifiedDate = latestHistory.createdAt.toLocalDate() + ) + } + ) + } +} \ No newline at end of file From 5cb355fda230dae7a9b6a7e23c46ee918de503a3 Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:09:21 +0900 Subject: [PATCH 115/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/service/GetAuthenticationService.kt | 3 +++ .../service/impl/GetAuthenticationServiceImpl.kt | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt index d99e56fe..f366afb0 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/GetAuthenticationService.kt @@ -1,9 +1,12 @@ package team.msg.sms.domain.authentication.service import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User import java.util.UUID interface GetAuthenticationService { fun getAuthenticationByUuid(uuid: UUID): Authentication fun getRequestedAuthentications(): List + fun getAuthenticationByStudent(student: Student, user: User): List } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt index 08751d28..423c0e8a 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/GetAuthenticationServiceImpl.kt @@ -5,6 +5,8 @@ import team.msg.sms.domain.authentication.exception.AuthenticationNotFoundExcept import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.GetAuthenticationService import team.msg.sms.domain.authentication.spi.QueryAuthenticationPort +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.user.model.User import java.util.UUID @Service @@ -16,4 +18,7 @@ class GetAuthenticationServiceImpl( override fun getRequestedAuthentications(): List = queryAuthenticationPort.queryRequestedAuthentications() + + override fun getAuthenticationByStudent(student: Student, user: User): List = + queryAuthenticationPort.queryMyAuthenticationByStudent(student, user) } \ No newline at end of file From 11a1b915d01af000a2bfa61ffe24288d0360ed01 Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:09:33 +0900 Subject: [PATCH 116/183] =?UTF-8?q?=E2=9C=A8=20=EB=82=B4=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=20Adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationWebAdapter.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 90114635..5519b54b 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -24,13 +24,20 @@ class AuthenticationWebAdapter( private val queryRequestedAuthenticationUseCase: QueryRequestedAuthenticationUseCase, private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase, private val requestAuthenticationUseCase: RequestAuthenticationUseCase, - private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase + private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase, + private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = createAuthenticationUseCase.execute(request.toData()) .let { ResponseEntity.status(HttpStatus.CREATED).body(it.toResponse()) } + @GetMapping("/my") + fun queryMyAuthentication(): ResponseEntity { + return queryMyAuthenticationUseCase.execute() + .let { ResponseEntity.ok(it.toResponse()) } + } + @DeleteMapping("/{uuid}") fun deleteAuthentication(@PathVariable uuid: String): ResponseEntity { if(!isValidUUID(uuid)) throw InvalidUuidException @@ -68,6 +75,10 @@ class AuthenticationWebAdapter( queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) .let { ResponseEntity.ok(it.toResponse()) } + private fun QueryMyAuthenticationListResponseData.toResponse() = QueryMyAuthenticationListWebResponse( + activities = activities + ) + private fun CreateAuthenticationResponseData.toResponse() = CreateAuthenticationWebResponse( id = id ) From 6dfca0357e5440c3db3317b499c08f4ae0ee7db7 Mon Sep 17 00:00:00 2001 From: enbraining Date: Wed, 13 Mar 2024 00:10:52 +0900 Subject: [PATCH 117/183] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=9E=84=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/QueryMyAuthenticationUseCase.kt | 8 -------- .../repository/AuthenticationJpaRepository.kt | 2 -- 2 files changed, 10 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt index 7b0ec2a1..d2b0865b 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryMyAuthenticationUseCase.kt @@ -2,20 +2,12 @@ package team.msg.sms.domain.authentication.usecase import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase -import team.msg.sms.domain.auth.model.Role -import team.msg.sms.domain.authentication.dto.req.FiltersRequestData import team.msg.sms.domain.authentication.dto.res.QueryMyAuthenticationListResponseData -import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationListResponseData import team.msg.sms.domain.authentication.dto.res.RequestMyAuthenticationResponseData -import team.msg.sms.domain.authentication.dto.res.RequestedAuthenticationResponseData -import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException import team.msg.sms.domain.authentication.service.AuthenticationHistoryService import team.msg.sms.domain.authentication.service.AuthenticationService import team.msg.sms.domain.student.service.StudentService -import team.msg.sms.domain.teacher.service.HomeroomTeacherService import team.msg.sms.domain.user.service.UserService -import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithPageInfo as AuthenticationWithPageInfo -import team.msg.sms.domain.authentication.model.Authentication.AuthenticationWithStudentInfoAndRequestedTime as AuthenticationWithStudentInfoAndRequestedTime @UseCase class QueryMyAuthenticationUseCase( diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt index d0f1e825..9cd853d3 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/authentication/repository/AuthenticationJpaRepository.kt @@ -2,8 +2,6 @@ package team.msg.sms.persistence.authentication.repository import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository -import team.msg.sms.domain.student.model.Student -import team.msg.sms.domain.user.model.User import team.msg.sms.persistence.authentication.entity.AuthenticationJpaEntity import team.msg.sms.persistence.student.entity.StudentJpaEntity import java.util.* From dfffd5f3898dd098d18570a2e3ee51c8f32dba6b Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:12:16 +0900 Subject: [PATCH 118/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20Security=20Matcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 33ecb040..2803d338 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -72,6 +72,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER ) .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) + .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) From fbdca1b27307a6956c72bc66d0d69946aab2108c Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:15:14 +0900 Subject: [PATCH 119/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=A0=91=EA=B7=BC?= =?UTF-8?q?=20=EA=B6=8C=ED=95=9C=20STUDENT=20->=20TEACHER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/team/msg/sms/global/security/SecurityConfig.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 2803d338..125511ab 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -69,10 +69,10 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/teacher/principal").hasAuthority(TEACHER) .antMatchers(HttpMethod.POST, "/teacher/deputy-principal").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) - .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER ) + .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) - .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) From 95eeb20108dffbf4d0f5f89c162ad1d7d418fb39 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:43:05 +0900 Subject: [PATCH 120/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryStudentAuthenticationListResponseData.kt | 5 +++++ .../RequestStudentAuthenticationResponseData.kt | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListResponseData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestStudentAuthenticationResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListResponseData.kt new file mode 100644 index 00000000..9f6db330 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListResponseData.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryStudentAuthenticationListResponseData ( + val activities: List +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestStudentAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestStudentAuthenticationResponseData.kt new file mode 100644 index 00000000..7c9f9999 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/RequestStudentAuthenticationResponseData.kt @@ -0,0 +1,14 @@ +package team.msg.sms.domain.authentication.dto.res + +import org.assertj.core.internal.Integers +import team.msg.sms.domain.authentication.model.ActivityStatus +import java.time.LocalDate +import java.util.UUID + +data class RequestStudentAuthenticationResponseData( + val id: UUID, + val title: String, + val lastModifiedDate: LocalDate, + val score: Int, + val activityStatus: ActivityStatus +) From d9a1f4acafd3a18e459ac759a2b8e261ea1449ca Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:43:19 +0900 Subject: [PATCH 121/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20Web=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/QueryStudentAuthenticationListWebResponse.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListWebResponse.kt new file mode 100644 index 00000000..a32c5bc6 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryStudentAuthenticationListWebResponse.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.authentication.dto.res + +data class QueryStudentAuthenticationListWebResponse ( + val activities: List +) \ No newline at end of file From b747635ef12ccc0ad6d3d61526d4a95e4a6b0344 Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:43:27 +0900 Subject: [PATCH 122/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20Usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryStudentAuthenticationUseCase.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentAuthenticationUseCase.kt new file mode 100644 index 00000000..3f48704d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryStudentAuthenticationUseCase.kt @@ -0,0 +1,41 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.res.QueryStudentAuthenticationListResponseData +import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData +import team.msg.sms.domain.authentication.dto.res.RequestStudentAuthenticationResponseData +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class QueryStudentAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val studentService: StudentService, + private val userService: UserService, +) { + @Transactional(readOnly = true) + fun execute(studentUuid: String): QueryStudentAuthenticationListResponseData { + val student = studentService.getStudentById(UUID.fromString(studentUuid)) + val user = userService.getUserById(student.userId) + val authenticationList = authenticationService.getAuthenticationByStudent(student, user) + + return QueryStudentAuthenticationListResponseData( + activities = authenticationList.map { + val history = authenticationHistoryService.getLatestAuthenticationHistory(it, student, user) + + RequestStudentAuthenticationResponseData( + id = it.id, + title = it.title, + lastModifiedDate = history.createdAt.toLocalDate(), + activityStatus = it.activityStatus, + score = it.score + ) + } + ) + } +} \ No newline at end of file From cf88af90857296a5de634516127a9b49a35eb22f Mon Sep 17 00:00:00 2001 From: enbraining Date: Thu, 14 Mar 2024 22:43:34 +0900 Subject: [PATCH 123/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20Adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationWebAdapter.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 5519b54b..34b02dc2 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -25,7 +25,8 @@ class AuthenticationWebAdapter( private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase, private val requestAuthenticationUseCase: RequestAuthenticationUseCase, private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase, - private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase + private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase, + private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -75,6 +76,16 @@ class AuthenticationWebAdapter( queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) .let { ResponseEntity.ok(it.toResponse()) } + @GetMapping("/student/{student_id}") + fun queryStudentAuthentication(@PathVariable(name = "student_id") studentUuid: String){ + queryStudentAuthenticationUseCase.execute(studentUuid) + .let { ResponseEntity.ok(it.toResponse()) } + } + + private fun QueryStudentAuthenticationListResponseData.toResponse() = QueryStudentAuthenticationListWebResponse( + activities = activities + ) + private fun QueryMyAuthenticationListResponseData.toResponse() = QueryMyAuthenticationListWebResponse( activities = activities ) From 57d163f6b34cbbbbbbe7bf6f19ade4b504659f36 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Sun, 17 Mar 2024 22:08:54 +0900 Subject: [PATCH 124/183] :sparkles: update authentication data --- .../dto/req/UpdateAuthenticationRequestData.kt | 7 +++++++ .../dto/res/UpdateAuthenticationResponseData.kt | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationRequestData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationRequestData.kt new file mode 100644 index 00000000..65bdf27a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationRequestData.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.req + +data class UpdateAuthenticationRequestData ( + val title: String, + val content: String, + val activityImages: List +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationResponseData.kt new file mode 100644 index 00000000..8d9a8251 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationResponseData.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.util.UUID + +data class UpdateAuthenticationResponseData( + val id: UUID +) From bbaa3fcfcc192ccc81f93422649824a3d55adc41 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Sun, 17 Mar 2024 22:09:15 +0900 Subject: [PATCH 125/183] :sparkles: update authentication usecase --- .../usecase/UpdateAuthenticationUseCase.kt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt new file mode 100644 index 00000000..7d8e5df9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt @@ -0,0 +1,55 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.authentication.dto.req.UpdateAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.res.UpdateAuthenticationResponseData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.exception.OnlyAccessMyselfException +import team.msg.sms.domain.authentication.exception.UnsuitableActivityStatusException +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class UpdateAuthenticationUseCase( + private val userService: UserService, + private val studentService: StudentService, + private val authenticationService: AuthenticationService, + private val applicationEventPublisher: ApplicationEventPublisher +) { + @Transactional(rollbackFor = [Exception::class]) + fun execute(uuid: String, updateData: UpdateAuthenticationRequestData): UpdateAuthenticationResponseData { + val user = userService.getCurrentUser() + val student = studentService.getStudentByUser(user) + + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + + if(authentication.studentId == student.id) + throw OnlyAccessMyselfException + + if(authentication.activityStatus == ActivityStatus.REQUESTED || authentication.activityStatus == ActivityStatus.APPROVED) + throw UnsuitableActivityStatusException + + Authentication( + id = UUID.fromString(uuid), + title = updateData.title, + content = updateData.content, + activityImages = updateData.activityImages, + studentId = student.id + ).let { authenticationService.save(it, student, user) } + + AuthenticationHistoryEvent( + authentication = authentication, + reason = "활동이 수정되었습니다." + ).let { applicationEventPublisher.publishEvent(it) } + + return UpdateAuthenticationResponseData( + id = authentication.id + ) + } +} \ No newline at end of file From 417809abb3dc85a778befbd869c41a95c535aeab Mon Sep 17 00:00:00 2001 From: ani2689 Date: Sun, 17 Mar 2024 22:11:30 +0900 Subject: [PATCH 126/183] :sparkles: update authentication web data --- .../dto/req/UpdateAuthenticationWebRequest.kt | 23 +++++++++++++++++++ .../dto/res/UpdateticationWebResponse.kt | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationWebRequest.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationWebRequest.kt new file mode 100644 index 00000000..e592fdaf --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/UpdateAuthenticationWebRequest.kt @@ -0,0 +1,23 @@ +package team.msg.sms.domain.authentication.dto.req + +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size + +data class UpdateAuthenticationWebRequest ( + @field:NotBlank + val title: String, + + @field:NotBlank + val content: String, + + @field:NotNull + @field:Size(max = 4) + val activityImages: List +) { + fun toData() = UpdateAuthenticationRequestData( + title = title, + content = content, + activityImages = activityImages + ) +} \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt new file mode 100644 index 00000000..155f6413 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.util.UUID + +data class UpdateticationWebResponse ( + val id: UUID +) \ No newline at end of file From 7f540f019c39bd133723a7cfa5e26f078358d65e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Sun, 17 Mar 2024 22:13:12 +0900 Subject: [PATCH 127/183] =?UTF-8?q?:pencil2:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...icationWebResponse.kt => UpdateAuthenticationWebResponse.kt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/{UpdateticationWebResponse.kt => UpdateAuthenticationWebResponse.kt} (67%) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationWebResponse.kt similarity index 67% rename from sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt rename to sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationWebResponse.kt index 155f6413..c0487726 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateticationWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/UpdateAuthenticationWebResponse.kt @@ -2,6 +2,6 @@ package team.msg.sms.domain.authentication.dto.res import java.util.UUID -data class UpdateticationWebResponse ( +data class UpdateAuthenticationWebResponse ( val id: UUID ) \ No newline at end of file From e244ff249628718bb64afc0c99363ddb73b5a930 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Sun, 17 Mar 2024 22:17:03 +0900 Subject: [PATCH 128/183] :sparkles: updateAuthentication endpoint --- .../team/msg/sms/global/security/SecurityConfig.kt | 1 + .../authentication/AuthenticationWebAdapter.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 125511ab..3f0146c6 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -77,6 +77,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.DELETE, "/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.PATCH,"/authentication/{uuid}").hasAuthority(STUDENT) + .antMatchers(HttpMethod.PUT,"/authentication/{uuid}").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST, "/file").authenticated() .antMatchers(HttpMethod.POST, "/file/image").authenticated() diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 34b02dc2..1ed9275d 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -9,6 +9,7 @@ import team.msg.sms.domain.authentication.res.QueryAuthenticationHistoriesWebRes import team.msg.sms.domain.authentication.usecase.* import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationWebRequest import team.msg.sms.domain.authentication.dto.req.FindRequestedAuthenticationFiltersWebRequest +import team.msg.sms.domain.authentication.dto.req.UpdateAuthenticationWebRequest import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase import team.msg.sms.domain.authentication.usecase.QueryRequestedAuthenticationUseCase @@ -20,6 +21,7 @@ import javax.validation.Valid @RequestMapping("/authentication") class AuthenticationWebAdapter( private val createAuthenticationUseCase: CreateAuthenticationUseCase, + private val updateAuthenticationUseCase: UpdateAuthenticationUseCase, private val queryAuthenticationDetailsUseCase: QueryAuthenticationDetailsUseCase, private val queryRequestedAuthenticationUseCase: QueryRequestedAuthenticationUseCase, private val deleteAuthenticationUseCase: DeleteAuthenticationUseCase, @@ -53,6 +55,13 @@ class AuthenticationWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @PutMapping("/{uuid}") + fun updateAuthentication(@PathVariable uuid: String, @Valid @RequestBody request: UpdateAuthenticationWebRequest): ResponseEntity { + if (!isValidUUID(uuid)) throw InvalidUuidException + return updateAuthenticationUseCase.execute(uuid, request.toData()) + .let { ResponseEntity.ok(it.toResponse()) } + } + @GetMapping("/{uuid}/history") fun queryAuthenticationHistories(@PathVariable uuid: String): ResponseEntity { if(!isValidUUID(uuid)) throw InvalidUuidException @@ -94,6 +103,10 @@ class AuthenticationWebAdapter( id = id ) + private fun UpdateAuthenticationResponseData.toResponse() = UpdateAuthenticationWebResponse( + id = id + ) + private fun QueryAuthenticationHistoriesResponseData.toResponse() = QueryAuthenticationHistoriesWebResponse( histories = histories ) From 1e090e504ed50d52b9fd2f66109ad830974eb042 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 18 Mar 2024 01:53:46 +0900 Subject: [PATCH 129/183] :sparkles: query requested authentication details usecase --- ...uestedAuthenticationDetailsResponseData.kt | 13 ++++ ...ryRequestedAuthenticationDetailsUseCase.kt | 64 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsResponseData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationDetailsUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsResponseData.kt new file mode 100644 index 00000000..06ffbd84 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsResponseData.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.time.LocalDate +import java.util.* + +data class QueryRequestedAuthenticationDetailsResponseData ( + val id: UUID, + val title: String, + val content: String, + val activityImages: List, + val lastModifiedDate: LocalDate, + val score: Int +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationDetailsUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationDetailsUseCase.kt new file mode 100644 index 00000000..90a3f61a --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/QueryRequestedAuthenticationDetailsUseCase.kt @@ -0,0 +1,64 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role +import team.msg.sms.domain.authentication.dto.res.QueryAuthenticationDetailsResponseData +import team.msg.sms.domain.authentication.dto.res.QueryRequestedAuthenticationDetailsResponseData +import team.msg.sms.domain.authentication.exception.InvalidGradeClassException +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException +import team.msg.sms.domain.authentication.exception.UnsuitableActivityStatusException +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.service.AuthenticationHistoryService +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.GetHomeroomTeacherService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.teacher.service.TeacherService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class QueryRequestedAuthenticationDetailsUseCase( + private val authenticationService: AuthenticationService, + private val authenticationHistoryService: AuthenticationHistoryService, + private val homeroomTeacherService: HomeroomTeacherService, + private val studentService: StudentService, + private val userService: UserService +) { + @Transactional(readOnly = true) + fun execute(uuid: String): QueryRequestedAuthenticationDetailsResponseData { + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + + if(authentication.activityStatus != ActivityStatus.REQUESTED) + throw UnsuitableActivityStatusException + + val user = userService.getCurrentUser() + + when { + Role.ROLE_HOMEROOM in user.roles -> { + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(user.id) + + if("${homeroomTeacher.grade}${homeroomTeacher.classNum}" != user.stuNum.substring(0, 1)) + throw InvalidGradeClassException + } + Role.ROLE_PRINCIPAL in user.roles || + Role.ROLE_DEPUTY_PRINCIPAL in user.roles || + Role.ROLE_DIRECTOR in user.roles -> {} + else -> throw PermissionRoleDeniedException + } + + val student = studentService.getStudentById(authentication.studentId) + val studentUser = userService.getUserById(student.userId) + val history = authenticationHistoryService.getLatestAuthenticationHistory(authentication, student, studentUser) + + return QueryRequestedAuthenticationDetailsResponseData( + id = authentication.id, + title = authentication.title, + content = authentication.title, + activityImages = authentication.activityImages, + lastModifiedDate = history.createdAt.toLocalDate(), + score = authentication.score + ) + } +} \ No newline at end of file From 905d3bea64f4901e43811b1727fe2321c69cfb61 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 18 Mar 2024 02:00:06 +0900 Subject: [PATCH 130/183] :sparkles: query requested authentication details web endpoint --- .../msg/sms/global/security/SecurityConfig.kt | 1 + .../AuthenticationWebAdapter.kt | 19 ++++++++++++++++++- ...questedAuthenticationDetailsWebResponse.kt | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsWebResponse.kt diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 125511ab..fa663f73 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -71,6 +71,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET,"/authentication/teacher/{uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 34b02dc2..ac8b268b 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -26,7 +26,8 @@ class AuthenticationWebAdapter( private val requestAuthenticationUseCase: RequestAuthenticationUseCase, private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase, private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase, - private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase + private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase, + private val queryRequestedAuthenticationDetailsUseCase: QueryRequestedAuthenticationDetailsUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -76,6 +77,13 @@ class AuthenticationWebAdapter( queryRequestedAuthenticationUseCase.execute(page, size, filterRequestData.toData()) .let { ResponseEntity.ok(it.toResponse()) } + @GetMapping("/teacher/{uuid}") + fun queryRequestedAuthenticationDetails(@PathVariable uuid: String): ResponseEntity { + if (!isValidUUID(uuid)) throw InvalidUuidException + return queryRequestedAuthenticationDetailsUseCase.execute(uuid) + .let { ResponseEntity.ok(it.toResponse()) } + } + @GetMapping("/student/{student_id}") fun queryStudentAuthentication(@PathVariable(name = "student_id") studentUuid: String){ queryStudentAuthenticationUseCase.execute(studentUuid) @@ -108,6 +116,15 @@ class AuthenticationWebAdapter( activityStatus = activityStatus ) + private fun QueryRequestedAuthenticationDetailsResponseData.toResponse() = QueryRequestedAuthenticationDetailsWebResponse( + id = id, + title = title, + content = content, + activityImages = activityImages, + lastModifiedDate = lastModifiedDate, + score = score + ) + private fun RequestAuthenticationResponseData.toResponse() = RequestAuthenticationWebResponse( id = id ) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsWebResponse.kt new file mode 100644 index 00000000..115ed25e --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/res/QueryRequestedAuthenticationDetailsWebResponse.kt @@ -0,0 +1,13 @@ +package team.msg.sms.domain.authentication.dto.res + +import java.time.LocalDate +import java.util.* + +data class QueryRequestedAuthenticationDetailsWebResponse( + val id: UUID, + val title: String, + val content: String, + val activityImages: List, + val lastModifiedDate: LocalDate, + val score: Int +) From 9a73fc5b13bd82a587f7fad103b8150bd969065c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 18 Mar 2024 19:48:25 +0900 Subject: [PATCH 131/183] =?UTF-8?q?:bug:=20=EA=B6=8C=ED=95=9C=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=3D=3D=20->=20!=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/usecase/UpdateAuthenticationUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt index 7d8e5df9..744bbd95 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/UpdateAuthenticationUseCase.kt @@ -29,7 +29,7 @@ class UpdateAuthenticationUseCase( val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) - if(authentication.studentId == student.id) + if(authentication.studentId != student.id) throw OnlyAccessMyselfException if(authentication.activityStatus == ActivityStatus.REQUESTED || authentication.activityStatus == ActivityStatus.APPROVED) From c3579b3420ef359751d91b4914e35469e9b28901 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 20:50:37 +0900 Subject: [PATCH 132/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Security?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 125511ab..d864abe5 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -71,6 +71,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) + .antMatchers(HttpMethod.PATCH,"/authentication/teacher/{uuid}/approve").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) .antMatchers(HttpMethod.POST,"/authentication").hasAuthority(STUDENT) From c98fe283aa2c14814fd365e912b8d95e447e64df Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:06:13 +0900 Subject: [PATCH 133/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Exception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AlreadyGivenScoreException.kt | 8 ++++++++ .../exception/NoRequestedActivityException.kt | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyGivenScoreException.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/NoRequestedActivityException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyGivenScoreException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyGivenScoreException.kt new file mode 100644 index 00000000..ab93606d --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/AlreadyGivenScoreException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object AlreadyGivenScoreException : SmsException( + AuthenticationErrorCode.ALREADY_GIVEN_SCORE +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/NoRequestedActivityException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/NoRequestedActivityException.kt new file mode 100644 index 00000000..eae077f0 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/NoRequestedActivityException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.authentication.exception.error.AuthenticationErrorCode + +object NoRequestedActivityException : SmsException( + AuthenticationErrorCode.NO_REQUESTED_ACTIVITY +) \ No newline at end of file From 911910a15cf3db88cf8421948de1e54b0eaf3877 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:06:22 +0900 Subject: [PATCH 134/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/ApproveAuthenticationRequestData.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt new file mode 100644 index 00000000..7270a5cd --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.authentication.dto.req + +import java.util.UUID + +data class ApproveAuthenticationRequestData ( + val score: Int, + val reason: String, +) \ No newline at end of file From 7316bf86d42ac5fa18324051fc1a280457bc3212 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:06:30 +0900 Subject: [PATCH 135/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/ApproveAuthenticationWebRequest.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt new file mode 100644 index 00000000..c8ef82dd --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt @@ -0,0 +1,18 @@ +package team.msg.sms.domain.authentication.dto.req + +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size + +data class ApproveAuthenticationWebRequest ( + @field:NotBlank + val score: Int, + + @field:NotBlank + val reason: String, +) { + fun toData() = ApproveAuthenticationRequestData( + score = score, + reason = reason + ) +} \ No newline at end of file From 41c0991d4051231af6f686fc09a050455a533a94 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:06:57 +0900 Subject: [PATCH 136/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20Except?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/exception/error/AuthenticationErrorCode.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt index b617d4f8..17a05341 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/exception/error/AuthenticationErrorCode.kt @@ -12,7 +12,9 @@ enum class AuthenticationErrorCode( ALREADY_AWARDED_SCORE(ErrorStatus.CONFLICT, "활동에 이미 점수가 부여된 상태입니다."), PERMISSION_ROLE_DENIED(ErrorStatus.FORBIDDEN, "학생이거나 교장, 교감, 부장, 담임 선생님만 조회할 수 있습니다."), ONLY_ACCESS_MYSELF(ErrorStatus.FORBIDDEN, "자기 자신만 조회할 수 있습니다."), - INVALID_GRADE_CLASS(ErrorStatus.FORBIDDEN, "담임 선생님만 조회할 수 있습니다.") + INVALID_GRADE_CLASS(ErrorStatus.FORBIDDEN, "담임 선생님만 조회할 수 있습니다."), + ALREADY_GIVEN_SCORE(ErrorStatus.CONFLICT, "이미 활동에 점수가 부여되었습니다."), + NO_REQUESTED_ACTIVITY(ErrorStatus.CONFLICT, "활동이 아직 요청되지 않았습니다.") ; override fun status(): Int = status From 91dfb52a95b49814f606b68e5d7c218f8a26b39f Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:07:06 +0900 Subject: [PATCH 137/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20Servic?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/service/CommandAuthenticationService.kt | 1 + .../service/impl/CommandAuthenticationServiceImpl.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt index f24ba220..9a9f9146 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt @@ -1,5 +1,6 @@ package team.msg.sms.domain.authentication.service +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt index dff165cc..ce4b5c45 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt @@ -1,6 +1,7 @@ package team.msg.sms.domain.authentication.service.impl import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.CommandAuthenticationService import team.msg.sms.domain.authentication.spi.AuthenticationPort From 729d1e2c93226fd3884fc8eef1b1326373fde650 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:07:11 +0900 Subject: [PATCH 138/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/domain/authentication/spi/CommandAuthenticationPort.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt index da89dd69..a0787a03 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt @@ -1,5 +1,6 @@ package team.msg.sms.domain.authentication.spi +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User From a18f01aa5e517890b618a309f990bcfa7ff66850 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:07:16 +0900 Subject: [PATCH 139/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20Usecas?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApproveRequestAuthenticationUseCase.kt | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt new file mode 100644 index 00000000..c094a202 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -0,0 +1,71 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEvent +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.exception.AlreadyGivenScoreException +import team.msg.sms.domain.authentication.exception.NoRequestedActivityException +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException +import team.msg.sms.domain.authentication.exception.UnsuitableActivityStatusException +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.teacher.service.TeacherService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class ApproveRequestAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val studentService: StudentService, + private val userService: UserService, + private val applicationEventPublisher: ApplicationEventPublisher, + private val teacherService: TeacherService, + private val homeroomTeacherService: HomeroomTeacherService +) { + @Transactional(rollbackFor = [Exception::class]) + fun execute(approveAuthenticationRequestData: ApproveAuthenticationRequestData, uuid: String) { + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) + + val currentUser = userService.getCurrentUser() + val teacher = teacherService.getTeacherByUser(currentUser) + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(currentUser.id) + + if(user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}" && + Role.ROLE_DIRECTOR !in currentUser.roles && + Role.ROLE_HOMEROOM in currentUser.roles){ + throw PermissionRoleDeniedException + } + + if(authentication.score != 0) throw AlreadyGivenScoreException + + if(authentication.activityStatus != ActivityStatus.REQUESTED) throw NoRequestedActivityException + + val updatedAuthentication = Authentication( + score = approveAuthenticationRequestData.score, + id = authentication.id, + title = authentication.title, + content = authentication.content, + activityImages = authentication.activityImages, + activityStatus = authentication.activityStatus, + studentId = authentication.studentId, + ) + + authenticationService.save(authentication, student, user) + + applicationEventPublisher.publishEvent(AuthenticationHistoryEvent( + authentication = updatedAuthentication, + reason = approveAuthenticationRequestData.reason, + teacherId = teacher.id + )) + } +} \ No newline at end of file From 8efbe5a1767b0e4c761d00bd140e85e59c297f7a Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:07:20 +0900 Subject: [PATCH 140/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EC=8A=B9=EC=9D=B8=20API=20Web=20Adapte?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationWebAdapter.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index 34b02dc2..0ca23e7a 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -4,6 +4,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationWebRequest import team.msg.sms.domain.authentication.dto.res.* import team.msg.sms.domain.authentication.res.QueryAuthenticationHistoriesWebResponse import team.msg.sms.domain.authentication.usecase.* @@ -26,7 +27,8 @@ class AuthenticationWebAdapter( private val requestAuthenticationUseCase: RequestAuthenticationUseCase, private val queryAuthenticationHistoriesUseCase: QueryAuthenticationHistoriesUseCase, private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase, - private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase + private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase, + private val approveRequestAuthenticationUseCase: ApproveRequestAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -82,6 +84,15 @@ class AuthenticationWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @PatchMapping("/teacher/{uuid}/approve") + fun approveAuthentication( + @PathVariable(name = "uuid") uuid: String, + approveAuthenticationWebRequest: ApproveAuthenticationWebRequest + ): ResponseEntity { + approveRequestAuthenticationUseCase.execute(approveAuthenticationWebRequest.toData(), uuid) + return ResponseEntity.noContent().build() + } + private fun QueryStudentAuthenticationListResponseData.toResponse() = QueryStudentAuthenticationListWebResponse( activities = activities ) From 3eb268dea2c3766ecbfcd6cd9462c9c1828dbeae Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:09:09 +0900 Subject: [PATCH 141/183] =?UTF-8?q?=F0=9F=94=A5=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=9E=84=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/dto/req/ApproveAuthenticationRequestData.kt | 2 -- .../authentication/service/CommandAuthenticationService.kt | 1 - .../service/impl/CommandAuthenticationServiceImpl.kt | 1 - .../sms/domain/authentication/spi/CommandAuthenticationPort.kt | 1 - .../usecase/ApproveRequestAuthenticationUseCase.kt | 3 --- .../authentication/dto/req/ApproveAuthenticationWebRequest.kt | 2 -- 6 files changed, 10 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt index 7270a5cd..0f6967ef 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationRequestData.kt @@ -1,7 +1,5 @@ package team.msg.sms.domain.authentication.dto.req -import java.util.UUID - data class ApproveAuthenticationRequestData ( val score: Int, val reason: String, diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt index 9a9f9146..f24ba220 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/CommandAuthenticationService.kt @@ -1,6 +1,5 @@ package team.msg.sms.domain.authentication.service -import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt index ce4b5c45..dff165cc 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/service/impl/CommandAuthenticationServiceImpl.kt @@ -1,7 +1,6 @@ package team.msg.sms.domain.authentication.service.impl import team.msg.sms.common.annotation.Service -import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.CommandAuthenticationService import team.msg.sms.domain.authentication.spi.AuthenticationPort diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt index a0787a03..da89dd69 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/spi/CommandAuthenticationPort.kt @@ -1,6 +1,5 @@ package team.msg.sms.domain.authentication.spi -import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.student.model.Student import team.msg.sms.domain.user.model.User diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index c094a202..4089feab 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -1,17 +1,14 @@ package team.msg.sms.domain.authentication.usecase -import org.springframework.context.ApplicationEvent import org.springframework.context.ApplicationEventPublisher import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData -import team.msg.sms.domain.authentication.dto.res.RequestAuthenticationResponseData import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent import team.msg.sms.domain.authentication.exception.AlreadyGivenScoreException import team.msg.sms.domain.authentication.exception.NoRequestedActivityException import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException -import team.msg.sms.domain.authentication.exception.UnsuitableActivityStatusException import team.msg.sms.domain.authentication.model.ActivityStatus import team.msg.sms.domain.authentication.model.Authentication import team.msg.sms.domain.authentication.service.AuthenticationService diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt index c8ef82dd..50736771 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/ApproveAuthenticationWebRequest.kt @@ -1,8 +1,6 @@ package team.msg.sms.domain.authentication.dto.req import javax.validation.constraints.NotBlank -import javax.validation.constraints.NotNull -import javax.validation.constraints.Size data class ApproveAuthenticationWebRequest ( @field:NotBlank From 476fb8b74023b32f39cf286b88e19ba6ff381656 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 21:20:32 +0900 Subject: [PATCH 142/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EA=B0=80=EB=8F=85?= =?UTF-8?q?=EC=84=B1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ApproveRequestAuthenticationUseCase.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index 4089feab..477fc446 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -37,10 +37,9 @@ class ApproveRequestAuthenticationUseCase( val teacher = teacherService.getTeacherByUser(currentUser) val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(currentUser.id) - if(user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}" && - Role.ROLE_DIRECTOR !in currentUser.roles && - Role.ROLE_HOMEROOM in currentUser.roles){ - throw PermissionRoleDeniedException + if(Role.ROLE_DIRECTOR !in currentUser.roles && Role.ROLE_HOMEROOM in currentUser.roles){ + if(user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}") + throw PermissionRoleDeniedException } if(authentication.score != 0) throw AlreadyGivenScoreException From 269bd2ef4e567810df9a665ebc522848a6de319e Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:04:17 +0900 Subject: [PATCH 143/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EA=B5=90=EC=9E=A5?= =?UTF-8?q?,=20=EA=B5=90=EA=B0=90,=20=EB=B6=80=EC=9E=A5=20=EB=98=90?= =?UTF-8?q?=EB=8A=94=20=EB=8B=B4=EC=9E=84=20=EC=84=A0=EC=83=9D=EB=8B=98?= =?UTF-8?q?=EC=9D=B4=20=EC=95=84=EB=8B=8C=20=EA=B2=BD=EC=9A=B0=20=EC=97=91?= =?UTF-8?q?=EC=84=B8=EC=8A=A4=ED=95=A0=20=EC=88=98=20=EC=97=86=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ApproveRequestAuthenticationUseCase.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index 477fc446..17b75dd0 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -37,9 +37,12 @@ class ApproveRequestAuthenticationUseCase( val teacher = teacherService.getTeacherByUser(currentUser) val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(currentUser.id) - if(Role.ROLE_DIRECTOR !in currentUser.roles && Role.ROLE_HOMEROOM in currentUser.roles){ - if(user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}") - throw PermissionRoleDeniedException + val allowedRole = listOf(Role.ROLE_HOMEROOM, Role.ROLE_DIRECTOR, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL) + if(currentUser.roles.none { it in allowedRole }) throw PermissionRoleDeniedException + + if(Role.ROLE_HOMEROOM in currentUser.roles && + user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}"){ + throw PermissionRoleDeniedException } if(authentication.score != 0) throw AlreadyGivenScoreException From 5799559ef8887da9a42b357b7b1cfe09a07a0fe0 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:08:01 +0900 Subject: [PATCH 144/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Activity=20Status?= =?UTF-8?q?=EB=A5=BC=20APROVED=EB=A1=9C=20=EB=B0=94=EA=BF=94=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ApproveRequestAuthenticationUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index 17b75dd0..8731cc81 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -51,11 +51,11 @@ class ApproveRequestAuthenticationUseCase( val updatedAuthentication = Authentication( score = approveAuthenticationRequestData.score, + activityStatus = ActivityStatus.APPROVED, id = authentication.id, title = authentication.title, content = authentication.content, activityImages = authentication.activityImages, - activityStatus = authentication.activityStatus, studentId = authentication.studentId, ) From 8cf43ce4952107f8bd57cd9d3c1119c18282e04e Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:15:59 +0900 Subject: [PATCH 145/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EB=B0=98=EB=A0=A4=20API=20Spring=20Sec?= =?UTF-8?q?urity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 75d90afb..a96d94ce 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -72,6 +72,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET,"/authentication/student/{student_uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/teacher").hasAuthority(TEACHER) .antMatchers(HttpMethod.PATCH,"/authentication/teacher/{uuid}/approve").hasAuthority(TEACHER) + .antMatchers(HttpMethod.PATCH,"/authentication/teacher/{uuid}/reject").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/teacher/{uuid}").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET,"/authentication/{uuid}/history").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET,"/authentication/my").hasAuthority(STUDENT) From aef15d1518400d167c4631a14da0feeeb02bce83 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:18:52 +0900 Subject: [PATCH 146/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EB=B0=98=EB=A0=A4=20API=20Adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationWebAdapter.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index c8848dbc..d907a422 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -4,13 +4,10 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException -import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationWebRequest +import team.msg.sms.domain.authentication.dto.req.* import team.msg.sms.domain.authentication.dto.res.* import team.msg.sms.domain.authentication.res.QueryAuthenticationHistoriesWebResponse import team.msg.sms.domain.authentication.usecase.* -import team.msg.sms.domain.authentication.dto.req.CreateAuthenticationWebRequest -import team.msg.sms.domain.authentication.dto.req.FindRequestedAuthenticationFiltersWebRequest -import team.msg.sms.domain.authentication.dto.req.UpdateAuthenticationWebRequest import team.msg.sms.domain.authentication.usecase.CreateAuthenticationUseCase import team.msg.sms.domain.authentication.usecase.QueryAuthenticationDetailsUseCase import team.msg.sms.domain.authentication.usecase.QueryRequestedAuthenticationUseCase @@ -110,6 +107,15 @@ class AuthenticationWebAdapter( return ResponseEntity.noContent().build() } + @PatchMapping("/teacher/{uuid}/reject") + fun rejectAuthentication( + @PathVariable(name = "uuid") uuid: String, + rejectAuthenticationWebRequest: RejectAuthenticationWebRequest + ): ResponseEntity { + approveRequestAuthenticationUseCase.execute(rejectAuthenticationWebRequest.toData(), uuid) + return ResponseEntity.noContent().build() + } + private fun QueryStudentAuthenticationListResponseData.toResponse() = QueryStudentAuthenticationListWebResponse( activities = activities ) From 5e770efc873ee8d2ea85c0a106fa2b6993774977 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:18:58 +0900 Subject: [PATCH 147/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EB=B0=98=EB=A0=A4=20API=20Adapter=20We?= =?UTF-8?q?b=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/RejectAuthenticationWebRequest.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt new file mode 100644 index 00000000..40d06c20 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt @@ -0,0 +1,16 @@ +package team.msg.sms.domain.authentication.dto.req + +import javax.validation.constraints.NotBlank + +data class RejectAuthenticationWebRequest ( + @field:NotBlank + val score: Int, + + @field:NotBlank + val reason: String, +) { + fun toData() = ApproveAuthenticationRequestData( + score = score, + reason = reason + ) +} \ No newline at end of file From 0b4fa64586c8bfaab2524c7bd056357ee62b22c3 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:19:03 +0900 Subject: [PATCH 148/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EB=B0=98=EB=A0=A4=20API=20Adapter=20Us?= =?UTF-8?q?ecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RejectRequestAuthenticationUseCase.kt | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt new file mode 100644 index 00000000..4d945486 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt @@ -0,0 +1,70 @@ +package team.msg.sms.domain.authentication.usecase + +import org.springframework.context.ApplicationEventPublisher +import org.springframework.transaction.annotation.Transactional +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.domain.auth.model.Role +import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData +import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent +import team.msg.sms.domain.authentication.exception.AlreadyGivenScoreException +import team.msg.sms.domain.authentication.exception.NoRequestedActivityException +import team.msg.sms.domain.authentication.exception.PermissionRoleDeniedException +import team.msg.sms.domain.authentication.model.ActivityStatus +import team.msg.sms.domain.authentication.model.Authentication +import team.msg.sms.domain.authentication.service.AuthenticationService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.teacher.service.HomeroomTeacherService +import team.msg.sms.domain.teacher.service.TeacherService +import team.msg.sms.domain.user.service.UserService +import java.util.* + +@UseCase +class RejectRequestAuthenticationUseCase( + private val authenticationService: AuthenticationService, + private val studentService: StudentService, + private val userService: UserService, + private val applicationEventPublisher: ApplicationEventPublisher, + private val teacherService: TeacherService, + private val homeroomTeacherService: HomeroomTeacherService +) { + @Transactional(rollbackFor = [Exception::class]) + fun execute(approveAuthenticationRequestData: ApproveAuthenticationRequestData, uuid: String) { + val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) + val student = studentService.getStudentById(authentication.studentId) + val user = userService.getUserById(student.userId) + + val currentUser = userService.getCurrentUser() + val teacher = teacherService.getTeacherByUser(currentUser) + val homeroomTeacher = homeroomTeacherService.getHomeroomTeacherByUserId(currentUser.id) + + val allowedRole = listOf(Role.ROLE_HOMEROOM, Role.ROLE_DIRECTOR, Role.ROLE_PRINCIPAL, Role.ROLE_DEPUTY_PRINCIPAL) + if(currentUser.roles.none { it in allowedRole }) throw PermissionRoleDeniedException + + if(Role.ROLE_HOMEROOM in currentUser.roles && + user.stuNum.substring(0, 1) != "${homeroomTeacher.grade}${homeroomTeacher.classNum}"){ + throw PermissionRoleDeniedException + } + + if(authentication.score != 0) throw AlreadyGivenScoreException + + if(authentication.activityStatus != ActivityStatus.REQUESTED) throw NoRequestedActivityException + + val updatedAuthentication = Authentication( + score = approveAuthenticationRequestData.score, + activityStatus = ActivityStatus.REJECTED, + id = authentication.id, + title = authentication.title, + content = authentication.content, + activityImages = authentication.activityImages, + studentId = authentication.studentId, + ) + + authenticationService.save(authentication, student, user) + + applicationEventPublisher.publishEvent(AuthenticationHistoryEvent( + authentication = updatedAuthentication, + reason = approveAuthenticationRequestData.reason, + teacherId = teacher.id + )) + } +} \ No newline at end of file From 7dcd9c29d8315fc1be10601005db9edc9ff35cea Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:21:05 +0900 Subject: [PATCH 149/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20usecase=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20DTO=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/RejectRequestAuthenticationUseCase.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt index 4d945486..d5f0a9ed 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/RejectRequestAuthenticationUseCase.kt @@ -4,7 +4,7 @@ import org.springframework.context.ApplicationEventPublisher import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.auth.model.Role -import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.req.RejectAuthenticationRequestData import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent import team.msg.sms.domain.authentication.exception.AlreadyGivenScoreException import team.msg.sms.domain.authentication.exception.NoRequestedActivityException @@ -28,7 +28,7 @@ class RejectRequestAuthenticationUseCase( private val homeroomTeacherService: HomeroomTeacherService ) { @Transactional(rollbackFor = [Exception::class]) - fun execute(approveAuthenticationRequestData: ApproveAuthenticationRequestData, uuid: String) { + fun execute(approveAuthenticationRequestData: RejectAuthenticationRequestData, uuid: String) { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) val user = userService.getUserById(student.userId) From 96def3848112276547080d3844afeaaa8e54953c Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:21:21 +0900 Subject: [PATCH 150/183] =?UTF-8?q?=E2=9C=A8=20=EC=9A=94=EC=B2=AD=EB=90=9C?= =?UTF-8?q?=20=ED=99=9C=EB=8F=99=20=EB=B0=98=EB=A0=A4=20API=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/RejectAuthenticationRequestData.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationRequestData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationRequestData.kt new file mode 100644 index 00000000..bcb50cfb --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationRequestData.kt @@ -0,0 +1,6 @@ +package team.msg.sms.domain.authentication.dto.req + +data class RejectAuthenticationRequestData ( + val score: Int, + val reason: String, +) \ No newline at end of file From 0a3cfe793a1cf5d26748c2d7c4ea58547be66302 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:21:58 +0900 Subject: [PATCH 151/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20DTO=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/dto/req/RejectAuthenticationWebRequest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt index 40d06c20..fa42accb 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/dto/req/RejectAuthenticationWebRequest.kt @@ -9,7 +9,7 @@ data class RejectAuthenticationWebRequest ( @field:NotBlank val reason: String, ) { - fun toData() = ApproveAuthenticationRequestData( + fun toData() = RejectAuthenticationRequestData( score = score, reason = reason ) From e631f966a4a67c367861e42c61fb1021a8722ba7 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:22:42 +0900 Subject: [PATCH 152/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Usecase=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ApproveRequestAuthenticationUseCase.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index 8731cc81..f1fd7b62 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -5,6 +5,7 @@ import org.springframework.transaction.annotation.Transactional import team.msg.sms.common.annotation.UseCase import team.msg.sms.domain.auth.model.Role import team.msg.sms.domain.authentication.dto.req.ApproveAuthenticationRequestData +import team.msg.sms.domain.authentication.dto.req.RejectAuthenticationRequestData import team.msg.sms.domain.authentication.event.AuthenticationHistoryEvent import team.msg.sms.domain.authentication.exception.AlreadyGivenScoreException import team.msg.sms.domain.authentication.exception.NoRequestedActivityException @@ -28,7 +29,7 @@ class ApproveRequestAuthenticationUseCase( private val homeroomTeacherService: HomeroomTeacherService ) { @Transactional(rollbackFor = [Exception::class]) - fun execute(approveAuthenticationRequestData: ApproveAuthenticationRequestData, uuid: String) { + fun execute(rejectAuthenticationRequestData: RejectAuthenticationRequestData, uuid: String) { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) val user = userService.getUserById(student.userId) @@ -50,7 +51,7 @@ class ApproveRequestAuthenticationUseCase( if(authentication.activityStatus != ActivityStatus.REQUESTED) throw NoRequestedActivityException val updatedAuthentication = Authentication( - score = approveAuthenticationRequestData.score, + score = rejectAuthenticationRequestData.score, activityStatus = ActivityStatus.APPROVED, id = authentication.id, title = authentication.title, @@ -63,7 +64,7 @@ class ApproveRequestAuthenticationUseCase( applicationEventPublisher.publishEvent(AuthenticationHistoryEvent( authentication = updatedAuthentication, - reason = approveAuthenticationRequestData.reason, + reason = rejectAuthenticationRequestData.reason, teacherId = teacher.id )) } From 2e0c65cf8698315db7f1218e3b5e73b94a3718d9 Mon Sep 17 00:00:00 2001 From: enbraining Date: Mon, 18 Mar 2024 23:24:50 +0900 Subject: [PATCH 153/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/ApproveRequestAuthenticationUseCase.kt | 6 +++--- .../sms/domain/authentication/AuthenticationWebAdapter.kt | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt index f1fd7b62..77f4a2e8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/authentication/usecase/ApproveRequestAuthenticationUseCase.kt @@ -29,7 +29,7 @@ class ApproveRequestAuthenticationUseCase( private val homeroomTeacherService: HomeroomTeacherService ) { @Transactional(rollbackFor = [Exception::class]) - fun execute(rejectAuthenticationRequestData: RejectAuthenticationRequestData, uuid: String) { + fun execute(approveAuthenticationRequestData: ApproveAuthenticationRequestData, uuid: String) { val authentication = authenticationService.getAuthenticationByUuid(UUID.fromString(uuid)) val student = studentService.getStudentById(authentication.studentId) val user = userService.getUserById(student.userId) @@ -51,7 +51,7 @@ class ApproveRequestAuthenticationUseCase( if(authentication.activityStatus != ActivityStatus.REQUESTED) throw NoRequestedActivityException val updatedAuthentication = Authentication( - score = rejectAuthenticationRequestData.score, + score = approveAuthenticationRequestData.score, activityStatus = ActivityStatus.APPROVED, id = authentication.id, title = authentication.title, @@ -64,7 +64,7 @@ class ApproveRequestAuthenticationUseCase( applicationEventPublisher.publishEvent(AuthenticationHistoryEvent( authentication = updatedAuthentication, - reason = rejectAuthenticationRequestData.reason, + reason = approveAuthenticationRequestData.reason, teacherId = teacher.id )) } diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt index d907a422..82d1a6a4 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/authentication/AuthenticationWebAdapter.kt @@ -28,7 +28,8 @@ class AuthenticationWebAdapter( private val queryMyAuthenticationUseCase: QueryMyAuthenticationUseCase, private val queryStudentAuthenticationUseCase: QueryStudentAuthenticationUseCase, private val approveRequestAuthenticationUseCase: ApproveRequestAuthenticationUseCase, - private val queryRequestedAuthenticationDetailsUseCase: QueryRequestedAuthenticationDetailsUseCase + private val queryRequestedAuthenticationDetailsUseCase: QueryRequestedAuthenticationDetailsUseCase, + private val rejectRequestAuthenticationUseCase: RejectRequestAuthenticationUseCase ) { @PostMapping fun createAuthentication(@Valid @RequestBody request: CreateAuthenticationWebRequest): ResponseEntity = @@ -112,7 +113,7 @@ class AuthenticationWebAdapter( @PathVariable(name = "uuid") uuid: String, rejectAuthenticationWebRequest: RejectAuthenticationWebRequest ): ResponseEntity { - approveRequestAuthenticationUseCase.execute(rejectAuthenticationWebRequest.toData(), uuid) + rejectRequestAuthenticationUseCase.execute(rejectAuthenticationWebRequest.toData(), uuid) return ResponseEntity.noContent().build() } From cea237c680f65f8b93265b3f9715643182f3243c Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 11 Apr 2024 14:49:33 +0900 Subject: [PATCH 154/183] =?UTF-8?q?=F0=9F=92=9A=20develop=20server?= =?UTF-8?q?=EB=A5=BC=20cloudtype=EC=9C=BC=EB=A1=9C=20=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_cloudtype_develop_cd.yml | 7 ++++--- .github/workflows/sms_backend_develop_cd.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sms_backend_cloudtype_develop_cd.yml b/.github/workflows/sms_backend_cloudtype_develop_cd.yml index 40aac2b7..995f65c2 100644 --- a/.github/workflows/sms_backend_cloudtype_develop_cd.yml +++ b/.github/workflows/sms_backend_cloudtype_develop_cd.yml @@ -2,7 +2,7 @@ name: Deploy to cloudtype on: push: branches: - - 'feature/cloudtype' + - develop jobs: deploy: runs-on: ubuntu-latest @@ -26,7 +26,7 @@ jobs: uses: cloudtype-github-actions/deploy@v1 with: token: ${{ secrets.CLOUDTYPE_TOKEN }} - project: seungwon/movie + project: sms-backend/sms-dev stage: main yaml: > name: sms-backend @@ -35,6 +35,7 @@ jobs: options: ports: 8080 + start: java -jar sms-infrastructure/build/libs/sms-infrastructure-0.0.1-SNAPSHOT.jar includes: sms-infrastructure env: - name: AWS_ACCESS_KEY @@ -71,7 +72,7 @@ jobs: value: ${{ secrets.S3_LOG_BUCKET }} - name: SECURITY_SECRET_KEY value: ${{ secrets.SECURITY_SECRET_KEY }} - start: java -jar sms-infrastructure/build/libs/sms-infrastructure-0.0.1-SNAPSHOT.jar + healthz: /health context: git: url: git@github.com:${{ github.repository }}.git diff --git a/.github/workflows/sms_backend_develop_cd.yml b/.github/workflows/sms_backend_develop_cd.yml index 4e8fdb1c..a7c35b76 100644 --- a/.github/workflows/sms_backend_develop_cd.yml +++ b/.github/workflows/sms_backend_develop_cd.yml @@ -3,7 +3,7 @@ name: Deploy to Develop server on: push: branches: - - develop + - aws-develop-server jobs: CD: From 98a39d0df565f07e060a66d67aadf023ef6ad3f1 Mon Sep 17 00:00:00 2001 From: seon0025 Date: Thu, 11 Apr 2024 15:32:53 +0900 Subject: [PATCH 155/183] =?UTF-8?q?=F0=9F=92=9A=20project=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EB=B3=80=EC=88=98=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_cloudtype_develop_cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sms_backend_cloudtype_develop_cd.yml b/.github/workflows/sms_backend_cloudtype_develop_cd.yml index 995f65c2..5441d36e 100644 --- a/.github/workflows/sms_backend_cloudtype_develop_cd.yml +++ b/.github/workflows/sms_backend_cloudtype_develop_cd.yml @@ -26,7 +26,7 @@ jobs: uses: cloudtype-github-actions/deploy@v1 with: token: ${{ secrets.CLOUDTYPE_TOKEN }} - project: sms-backend/sms-dev + project: ${{ secrets.PROJECT_NAME }} stage: main yaml: > name: sms-backend From ba9e742b955d20f21af72e9e31fba8e01563773f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 18 Apr 2024 17:51:36 +0900 Subject: [PATCH 156/183] =?UTF-8?q?update=20::=20gauth=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=202=20->=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/DependencyVersions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/DependencyVersions.kt b/buildSrc/src/main/kotlin/DependencyVersions.kt index 03ca81fa..7b8136d0 100644 --- a/buildSrc/src/main/kotlin/DependencyVersions.kt +++ b/buildSrc/src/main/kotlin/DependencyVersions.kt @@ -6,7 +6,7 @@ object DependencyVersions { const val MOCKITO_VERSION = "4.0.0" const val AWS_VERSION = "2.2.6.RELEASE" const val SERVLET_VERSION = "4.0.1" - const val GAUTH_VERSION = "2.0.0" + const val GAUTH_VERSION = "3.0.0" const val SPRING_TRANSACTION = "5.3.22" const val QUERYDSL = "5.0.0" const val MARIA_VERSION = "2.1.2" From 43ac006bb55b954ddac08d69ac103012cf51c786 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 20 May 2024 18:10:30 +0900 Subject: [PATCH 157/183] =?UTF-8?q?update=20::=20=EC=A1=B8=EC=97=85?= =?UTF-8?q?=EC=83=9D=EB=8F=84=20=ED=95=99=EB=B2=88=EC=9D=84=20null?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=9B=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt index ccda88d1..0c20e0ae 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt @@ -73,6 +73,6 @@ class SignInUseCase( } private fun getStuNumValid(role: Role, gAuthUserInfo: GAuthUserInfo) = - if (role.name != "ROLE_TEACHER") "${gAuthUserInfo.grade}${gAuthUserInfo.classNum}${gAuthUserInfo.getNumber()}" else "" + if (role.name == "ROLE_STUDENT") "${gAuthUserInfo.grade}${gAuthUserInfo.classNum}${gAuthUserInfo.getNumber()}" else "" private fun GAuthUserInfo.getNumber() = String.format("%02d", this.num) \ No newline at end of file From 185e2fb788c3e41dbe5d73f6ae7496f0538455e4 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 20 May 2024 20:02:50 +0900 Subject: [PATCH 158/183] =?UTF-8?q?add=20::=20gauth=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20=ED=95=99=EB=B2=88=EC=9D=B4=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B4=EB=A9=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/sms/domain/auth/usecase/SignInUseCase.kt | 8 +++++++- .../msg/sms/domain/user/service/CommandUserService.kt | 1 + .../domain/user/service/impl/CommandUserServiceImpl.kt | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt index 0c20e0ae..1c8a9477 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/SignInUseCase.kt @@ -33,16 +33,22 @@ class SignInUseCase( val role = userService.getRoleByGAuthInfo(gAuthUserInfo.email, gAuthUserInfo.role) val isExistsUser = userService.checkUserExistByEmail(gAuthUserInfo.email) + + val stuNum = getStuNumValid(role, gAuthUserInfo) + val user = userService.createUserWhenNotExistUser( isExistsUser, User( name = gAuthUserInfo.name, email = gAuthUserInfo.email, - stuNum = getStuNumValid(role, gAuthUserInfo), + stuNum = stuNum, roles = mutableListOf(role) ) ) + if(user.stuNum != stuNum) + userService.updateStuNum(user, stuNum) + val (accessToken, accessTokenExp, refreshToken, refreshTokenExp) = jwtPort.receiveToken(user.id, role) refreshTokenPort.saveRefreshToken(RefreshToken(refreshToken, user.id)) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/CommandUserService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/CommandUserService.kt index a4e53f2d..180ef082 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/CommandUserService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/CommandUserService.kt @@ -6,6 +6,7 @@ import java.util.UUID interface CommandUserService { fun createUserWhenNotExistUser(existUser: Boolean, user: User): User + fun updateStuNum(user: User, stuNum: String): User fun saveRoles(user: User, role: List): User fun deleteByUuid(userId: UUID) } \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/impl/CommandUserServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/impl/CommandUserServiceImpl.kt index 68030391..0d1ea4a9 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/impl/CommandUserServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/user/service/impl/CommandUserServiceImpl.kt @@ -16,10 +16,17 @@ class CommandUserServiceImpl( return if(existUser) { userPort.queryUserByEmail(user.email) ?: throw UserNotFoundException } else { - userPort.saveUser(user)!! + userPort.saveUser(user) } } + override fun updateStuNum(user: User, stuNum: String) = + userPort.saveUser( + user.copy( + stuNum = stuNum + ) + ) + override fun saveRoles(user: User, role: List): User { user.roles.addAll(role) return userPort.saveUser(user) From c665c295afce7ed62549ff38089d8c745a6d5196 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:47:22 +0900 Subject: [PATCH 159/183] =?UTF-8?q?:sparkles:=20=EC=99=B8=EB=B6=80?= =?UTF-8?q?=EC=9D=B8=EC=9B=90=20=ED=95=99=EC=83=9D=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=EC=97=90=20=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EA=B0=88=20=ED=86=A0=ED=81=B0=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=9C=A0=ED=8B=B8=EB=A6=AC?= =?UTF-8?q?=ED=8B=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/sms/common/util/PasswordUtil.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt b/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt new file mode 100644 index 00000000..6837a089 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt @@ -0,0 +1,25 @@ +package team.msg.sms.common.util + +import java.security.SecureRandom +import java.util.stream.Collectors +import java.util.stream.IntStream + +object PasswordUtil { + // 소문자와 숫자로 이루어진 length 만큼의 길이를 가진 문자열을 생성하는 함수 + fun generateSecret(length: Int): String { + val secureRandom = SecureRandom() + + val password = IntStream.concat( + IntStream.rangeClosed(48, 57), + IntStream.rangeClosed(97, 122) + ).mapToObj { i -> i.toChar().toString() }.collect(Collectors.joining()) + + val builder = StringBuilder() + + for (i in 0 until length) { + builder.append(password[secureRandom.nextInt(password.length)]) + } + + return builder.toString() + } +} \ No newline at end of file From 4204981b7c4662cf8531f26b18aad58f63522929 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:50:02 +0900 Subject: [PATCH 160/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student/entity/StudentLinkEntity.kt | 20 +++++++++++++++++++ .../student/mapper/StudentLinkMapper.kt | 20 +++++++++++++++++++ .../repository/StudentLinkRepository.kt | 10 ++++++++++ 3 files changed, 50 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt new file mode 100644 index 00000000..077e385c --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt @@ -0,0 +1,20 @@ +package team.msg.sms.persistence.student.entity + +import org.springframework.data.annotation.Id +import org.springframework.data.redis.core.RedisHash +import org.springframework.data.redis.core.TimeToLive +import org.springframework.data.redis.core.index.Indexed +import java.util.UUID + +@RedisHash(value = "student_link") +class StudentLinkEntity ( + @Id + @Indexed + val token: String, + + @Indexed + val studentId: UUID, + + @TimeToLive + val timeToLive: Long +) \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt new file mode 100644 index 00000000..50f265f1 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt @@ -0,0 +1,20 @@ +package team.msg.sms.persistence.student.mapper + +import team.msg.sms.domain.auth.model.RefreshToken +import team.msg.sms.domain.student.model.StudentLink +import team.msg.sms.persistence.auth.entity.RefreshTokenEntity +import team.msg.sms.persistence.student.entity.StudentLinkEntity + +fun StudentLinkEntity.toDomain(): StudentLink = + StudentLink( + token = token, + studentId = studentId, + timeToLive = timeToLive + ) + +fun StudentLink.toEntity(): StudentLinkEntity = + StudentLinkEntity( + token = token, + studentId = studentId, + timeToLive = timeToLive + ) \ No newline at end of file diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt new file mode 100644 index 00000000..8d9c1186 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt @@ -0,0 +1,10 @@ +package team.msg.sms.persistence.student.repository + +import org.springframework.data.repository.CrudRepository +import org.springframework.stereotype.Repository +import team.msg.sms.persistence.student.entity.StudentLinkEntity + +@Repository +interface StudentLinkRepository: CrudRepository { + fun existsByToken(token: String): Boolean +} \ No newline at end of file From a23ad2a3354c1c57d82c014c7c54f003eb29d03c Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:50:41 +0900 Subject: [PATCH 161/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20Presentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/student/StudentWebAdapter.kt | 15 ++++++++++++++- .../dto/req/CreateStudentLinkWebRequest.kt | 12 ++++++++++++ .../dto/res/CreateStudentLinkWebResponse.kt | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt index 1ceeda25..9ca63c0d 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt @@ -3,6 +3,7 @@ package team.msg.sms.domain.student import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import team.msg.sms.common.exception.InvalidUuidException +import team.msg.sms.domain.student.dto.req.CreateStudentLinkWebRequest import team.msg.sms.domain.student.dto.req.FindAllFiltersWebRequest import team.msg.sms.domain.student.dto.req.ModifyStudentInfoWebRequest import team.msg.sms.domain.student.dto.req.SignUpWebRequest @@ -19,7 +20,8 @@ class StudentWebAdapter( private val studentInfoAnonymousUseCase: StudentInfoAnonymousUseCase, private val studentInfoDetailUseCase: StudentInfoDetailUseCase, private val studentInfoTeacherUseCase: StudentInfoTeacherUseCase, - private val modifyStudentInfoUseCase: ModifyStudentInfoUseCase + private val modifyStudentInfoUseCase: ModifyStudentInfoUseCase, + private val createStudentLinkUseCase: CreateStudentLinkUseCase ) { @GetMapping fun findAll( @@ -35,6 +37,12 @@ class StudentWebAdapter( signUpUseCase.execute(signUpWebRequest.toData()) .run { ResponseEntity.ok().build() } + @PostMapping("/link") + fun createStudentLink(@RequestBody @Valid createStudentLinkWebRequest: CreateStudentLinkWebRequest): ResponseEntity { + return createStudentLinkUseCase.execute(createStudentLinkWebRequest.toData()) + .let { ResponseEntity.ok(it.toResponse()) } + } + @PutMapping fun modifyStudentInfo(@RequestBody modifyStudentInfoWebRequest: ModifyStudentInfoWebRequest) { modifyStudentInfoUseCase.execute(modifyStudentInfoWebRequest.toData()) @@ -125,6 +133,11 @@ class StudentWebAdapter( prizes = this.prizes ) + fun CreateStudentLinkResponseData.toResponse(): CreateStudentLinkWebResponse = + CreateStudentLinkWebResponse( + token = this.token + ) + private fun isValidUUID(uuid: String): Boolean { return try { UUID.fromString(uuid) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt new file mode 100644 index 00000000..155532af --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt @@ -0,0 +1,12 @@ +package team.msg.sms.domain.student.dto.req + +data class CreateStudentLinkWebRequest ( + val studentId: String, + val periodDay: Long +) { + fun toData(): CreateStudentLinkRequestData = + CreateStudentLinkRequestData( + studentId, + periodDay + ) +} \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt new file mode 100644 index 00000000..dbb2de79 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.student.dto.res + +data class CreateStudentLinkWebResponse ( + val token: String +) \ No newline at end of file From 0487d452bf9f716cc4ffa4554711090d037e4b4a Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:51:14 +0900 Subject: [PATCH 162/183] =?UTF-8?q?=E2=9C=A8=20=ED=95=99=EC=83=9D=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20Adapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student/StudentLinkPersistenceAdapter.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt new file mode 100644 index 00000000..0ae13f33 --- /dev/null +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt @@ -0,0 +1,24 @@ +package team.msg.sms.persistence.student + +import org.springframework.stereotype.Component +import team.msg.sms.domain.student.model.StudentLink +import team.msg.sms.domain.student.spi.StudentLinkPort +import team.msg.sms.persistence.student.mapper.toDomain +import team.msg.sms.persistence.student.mapper.toEntity +import team.msg.sms.persistence.student.repository.StudentJpaRepository +import team.msg.sms.persistence.student.repository.StudentLinkRepository + +@Component +class StudentLinkPersistenceAdapter( + private val studentLinkRepository: StudentLinkRepository +) : StudentLinkPort { + override fun save(studentLink: StudentLink): StudentLink { + return studentLinkRepository.save( + studentLink.toEntity() + ).toDomain() + } + + override fun existsByToken(token: String): Boolean { + return studentLinkRepository.existsByToken(token) + } +} \ No newline at end of file From 897e9b617e68614e6e43a9c69d7ee8b385f2c836 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:51:49 +0900 Subject: [PATCH 163/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?Usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/CreateStudentLinkUseCase.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt new file mode 100644 index 00000000..24ec9dc9 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt @@ -0,0 +1,32 @@ +package team.msg.sms.domain.student.usecase + +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.common.util.PasswordUtil.generateSecret +import team.msg.sms.domain.student.dto.req.CreateStudentLinkRequestData +import team.msg.sms.domain.student.dto.res.CreateStudentLinkResponseData +import team.msg.sms.domain.student.model.StudentLink +import team.msg.sms.domain.student.service.StudentLinkService +import team.msg.sms.domain.student.service.StudentService +import java.util.* + +@UseCase +class CreateStudentLinkUseCase ( + private val studentService: StudentService, + private val studentLinkService: StudentLinkService, +) { + fun execute(createStudentLinkData: CreateStudentLinkRequestData): CreateStudentLinkResponseData { + val student = studentService.getStudentById(UUID.fromString(createStudentLinkData.studentId)) + val token = generateSecret(32) + + val studentLink = StudentLink( + token = token, + studentId = student.id, + timeToLive = createStudentLinkData.periodDay * 86400 + ) + studentLinkService.save(studentLink) + + return CreateStudentLinkResponseData( + token = token + ) + } +} \ No newline at end of file From 5f165309d446deee220975b7e26e6ba1cf2fd0f3 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:52:05 +0900 Subject: [PATCH 164/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?Port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/domain/student/spi/CommandStudentLinkPort.kt | 7 +++++++ .../msg/sms/domain/student/spi/QueryStudentLinkPort.kt | 5 +++++ .../team/msg/sms/domain/student/spi/StudentLinkPort.kt | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt new file mode 100644 index 00000000..7a410f8b --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.student.spi + +import team.msg.sms.domain.student.model.StudentLink + +interface CommandStudentLinkPort { + fun save(studentLink: StudentLink): StudentLink +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt new file mode 100644 index 00000000..477a946b --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.student.spi + +interface QueryStudentLinkPort { + fun existsByToken(token: String): Boolean +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt new file mode 100644 index 00000000..86cef506 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.student.spi + +interface StudentLinkPort: + CommandStudentLinkPort, + QueryStudentLinkPort \ No newline at end of file From cc569852de68138eb82d679895a7cc7d4ab914ed Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:52:23 +0900 Subject: [PATCH 165/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student/service/CheckStudentLinkService.kt | 5 +++++ .../student/service/CommandStudentLinkService.kt | 9 +++++++++ .../domain/student/service/StudentLinkService.kt | 10 ++++++++++ .../service/impl/CheckStudentLinkServiceImpl.kt | 14 ++++++++++++++ .../service/impl/CommandStudentLinkServiceImpl.kt | 15 +++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt new file mode 100644 index 00000000..d79f8c50 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.student.service + +interface CheckStudentLinkService { + fun checkExistsByToken(token: String): Boolean +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt new file mode 100644 index 00000000..cd4cee94 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt @@ -0,0 +1,9 @@ +package team.msg.sms.domain.student.service + +import team.msg.sms.domain.student.model.StudentLink + +interface CommandStudentLinkService { + fun save( + studentLink: StudentLink + ): StudentLink +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt new file mode 100644 index 00000000..a5a38c0b --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt @@ -0,0 +1,10 @@ +package team.msg.sms.domain.student.service + +import team.msg.sms.common.annotation.Service + +@Service +class StudentLinkService ( + commandStudentLinkService: CommandStudentLinkService, + checkStudentLinkService: CheckStudentLinkService +): CommandStudentLinkService by commandStudentLinkService, + CheckStudentLinkService by checkStudentLinkService \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt new file mode 100644 index 00000000..796efd13 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt @@ -0,0 +1,14 @@ +package team.msg.sms.domain.student.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.student.service.CheckStudentLinkService +import team.msg.sms.domain.student.spi.StudentLinkPort + +@Service +class CheckStudentLinkServiceImpl ( + private val studentLinkPort: StudentLinkPort +) : CheckStudentLinkService { + override fun checkExistsByToken(token: String): Boolean { + return studentLinkPort.existsByToken(token) + } +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt new file mode 100644 index 00000000..5489c843 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt @@ -0,0 +1,15 @@ +package team.msg.sms.domain.student.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.student.model.StudentLink +import team.msg.sms.domain.student.service.CommandStudentLinkService +import team.msg.sms.domain.student.spi.StudentLinkPort + +@Service +class CommandStudentLinkServiceImpl( + private val studentLinkPort: StudentLinkPort +): CommandStudentLinkService { + override fun save(studentLink: StudentLink): StudentLink { + return studentLinkPort.save(studentLink) + } +} \ No newline at end of file From e30b9ba6455959254fd706ca4d5a404966c0384d Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:52:38 +0900 Subject: [PATCH 166/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/dto/req/CreateStudentLinkRequestData.kt | 6 ++++++ .../domain/student/dto/res/CreateStudentLinkResponseData.kt | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt new file mode 100644 index 00000000..01f427e8 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt @@ -0,0 +1,6 @@ +package team.msg.sms.domain.student.dto.req + +data class CreateStudentLinkRequestData ( + val studentId: String, + val periodDay: Long +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt new file mode 100644 index 00000000..7868e646 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt @@ -0,0 +1,5 @@ +package team.msg.sms.domain.student.dto.res + +data class CreateStudentLinkResponseData ( + val token: String +) \ No newline at end of file From 3414ead1edeeaa65eb80daa7bbc057b1a1a9d4e9 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:52:53 +0900 Subject: [PATCH 167/183] =?UTF-8?q?:sparkles:=20=ED=95=99=EC=83=9D?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?Model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/sms/domain/student/model/StudentLink.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/model/StudentLink.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/model/StudentLink.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/model/StudentLink.kt new file mode 100644 index 00000000..b86f9d9b --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/model/StudentLink.kt @@ -0,0 +1,11 @@ +package team.msg.sms.domain.student.model + +import team.msg.sms.common.annotation.Aggregate +import java.util.UUID + +@Aggregate +data class StudentLink( + val token: String, + val studentId: UUID, + val timeToLive: Long +) From 56a331e66ef8419c462dabb57e2ec7c6a9374fa6 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 10:54:34 +0900 Subject: [PATCH 168/183] =?UTF-8?q?=E2=99=BB=EF=B8=8F=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?Security=20Matcher=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index a96d94ce..f0682ce7 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -61,6 +61,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/student").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET, "/student").permitAll() .antMatchers(HttpMethod.GET, "/student/{uuid}").hasAnyAuthority(STUDENT, TEACHER) + .antMatchers(HttpMethod.POST, "/student/link").hasAuthority(TEACHER) .antMatchers(HttpMethod.GET, "/student/anonymous/{uuid}").permitAll() .antMatchers(HttpMethod.POST, "/teacher/common").hasAuthority(TEACHER) From 9f1fb2f475eedb08b6eadaedb810cb6cca4e497d Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 11:07:00 +0900 Subject: [PATCH 169/183] =?UTF-8?q?:recycle:=20Request=20DTO=EC=97=90?= =?UTF-8?q?=EC=84=9C=20studentId=EB=A5=BC=20String=20->=20UUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/dto/req/CreateStudentLinkRequestData.kt | 4 +++- .../sms/domain/student/usecase/CreateStudentLinkUseCase.kt | 2 +- .../sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt index 01f427e8..f90d8420 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt @@ -1,6 +1,8 @@ package team.msg.sms.domain.student.dto.req +import java.util.UUID + data class CreateStudentLinkRequestData ( - val studentId: String, + val studentId: UUID, val periodDay: Long ) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt index 24ec9dc9..2d9a8ad8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt @@ -15,7 +15,7 @@ class CreateStudentLinkUseCase ( private val studentLinkService: StudentLinkService, ) { fun execute(createStudentLinkData: CreateStudentLinkRequestData): CreateStudentLinkResponseData { - val student = studentService.getStudentById(UUID.fromString(createStudentLinkData.studentId)) + val student = studentService.getStudentById(createStudentLinkData.studentId) val token = generateSecret(32) val studentLink = StudentLink( diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt index 155532af..8a4a4ac5 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt @@ -1,7 +1,9 @@ package team.msg.sms.domain.student.dto.req +import java.util.UUID + data class CreateStudentLinkWebRequest ( - val studentId: String, + val studentId: UUID, val periodDay: Long ) { fun toData(): CreateStudentLinkRequestData = From 305f3c638c1e0d77fae697d894aa23be80b6516b Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 11:16:55 +0900 Subject: [PATCH 170/183] =?UTF-8?q?:recycle:=20=EB=A7=88=EC=A7=80=EB=A7=89?= =?UTF-8?q?=20=EC=A4=84=20=EA=B0=9C=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt | 2 +- .../sms/domain/student/dto/req/CreateStudentLinkRequestData.kt | 2 +- .../sms/domain/student/dto/res/CreateStudentLinkResponseData.kt | 2 +- .../msg/sms/domain/student/service/CheckStudentLinkService.kt | 2 +- .../msg/sms/domain/student/service/CommandStudentLinkService.kt | 2 +- .../team/msg/sms/domain/student/service/StudentLinkService.kt | 2 +- .../domain/student/service/impl/CheckStudentLinkServiceImpl.kt | 2 +- .../student/service/impl/CommandStudentLinkServiceImpl.kt | 2 +- .../team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt | 2 +- .../team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt | 2 +- .../kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt | 2 +- .../msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt | 2 +- .../sms/persistence/student/StudentLinkPersistenceAdapter.kt | 2 +- .../msg/sms/persistence/student/entity/StudentLinkEntity.kt | 2 +- .../msg/sms/persistence/student/mapper/StudentLinkMapper.kt | 2 +- .../sms/persistence/student/repository/StudentLinkRepository.kt | 2 +- .../kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt | 2 +- .../sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt | 2 +- .../sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt b/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt index 6837a089..55d4d093 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/common/util/PasswordUtil.kt @@ -22,4 +22,4 @@ object PasswordUtil { return builder.toString() } -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt index f90d8420..7375a54d 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkRequestData.kt @@ -5,4 +5,4 @@ import java.util.UUID data class CreateStudentLinkRequestData ( val studentId: UUID, val periodDay: Long -) \ No newline at end of file +) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt index 7868e646..9a64a7a4 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkResponseData.kt @@ -2,4 +2,4 @@ package team.msg.sms.domain.student.dto.res data class CreateStudentLinkResponseData ( val token: String -) \ No newline at end of file +) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt index d79f8c50..7d4c8a03 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CheckStudentLinkService.kt @@ -2,4 +2,4 @@ package team.msg.sms.domain.student.service interface CheckStudentLinkService { fun checkExistsByToken(token: String): Boolean -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt index cd4cee94..a3eefbe5 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/CommandStudentLinkService.kt @@ -6,4 +6,4 @@ interface CommandStudentLinkService { fun save( studentLink: StudentLink ): StudentLink -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt index a5a38c0b..97637344 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt @@ -7,4 +7,4 @@ class StudentLinkService ( commandStudentLinkService: CommandStudentLinkService, checkStudentLinkService: CheckStudentLinkService ): CommandStudentLinkService by commandStudentLinkService, - CheckStudentLinkService by checkStudentLinkService \ No newline at end of file + CheckStudentLinkService by checkStudentLinkService diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt index 796efd13..ac78c9a9 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CheckStudentLinkServiceImpl.kt @@ -11,4 +11,4 @@ class CheckStudentLinkServiceImpl ( override fun checkExistsByToken(token: String): Boolean { return studentLinkPort.existsByToken(token) } -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt index 5489c843..a87e349c 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/CommandStudentLinkServiceImpl.kt @@ -12,4 +12,4 @@ class CommandStudentLinkServiceImpl( override fun save(studentLink: StudentLink): StudentLink { return studentLinkPort.save(studentLink) } -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt index 7a410f8b..3b7098c8 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/CommandStudentLinkPort.kt @@ -4,4 +4,4 @@ import team.msg.sms.domain.student.model.StudentLink interface CommandStudentLinkPort { fun save(studentLink: StudentLink): StudentLink -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt index 477a946b..581cd19a 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt @@ -2,4 +2,4 @@ package team.msg.sms.domain.student.spi interface QueryStudentLinkPort { fun existsByToken(token: String): Boolean -} \ No newline at end of file +} diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt index 86cef506..f7e63c1a 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/StudentLinkPort.kt @@ -2,4 +2,4 @@ package team.msg.sms.domain.student.spi interface StudentLinkPort: CommandStudentLinkPort, - QueryStudentLinkPort \ No newline at end of file + QueryStudentLinkPort diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt index 2d9a8ad8..5d852d5c 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/CreateStudentLinkUseCase.kt @@ -29,4 +29,4 @@ class CreateStudentLinkUseCase ( token = token ) } -} \ No newline at end of file +} diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt index 0ae13f33..d5895ec3 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt @@ -21,4 +21,4 @@ class StudentLinkPersistenceAdapter( override fun existsByToken(token: String): Boolean { return studentLinkRepository.existsByToken(token) } -} \ No newline at end of file +} diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt index 077e385c..7edcb406 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/entity/StudentLinkEntity.kt @@ -17,4 +17,4 @@ class StudentLinkEntity ( @TimeToLive val timeToLive: Long -) \ No newline at end of file +) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt index 50f265f1..4021e43e 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/mapper/StudentLinkMapper.kt @@ -17,4 +17,4 @@ fun StudentLink.toEntity(): StudentLinkEntity = token = token, studentId = studentId, timeToLive = timeToLive - ) \ No newline at end of file + ) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt index 8d9c1186..8f99f83d 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt @@ -7,4 +7,4 @@ import team.msg.sms.persistence.student.entity.StudentLinkEntity @Repository interface StudentLinkRepository: CrudRepository { fun existsByToken(token: String): Boolean -} \ No newline at end of file +} diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt index 9ca63c0d..1f77d268 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt @@ -146,4 +146,4 @@ class StudentWebAdapter( false } } -} \ No newline at end of file +} diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt index 8a4a4ac5..2d35c6f9 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt @@ -11,4 +11,4 @@ data class CreateStudentLinkWebRequest ( studentId, periodDay ) -} \ No newline at end of file +} diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt index dbb2de79..41b5d32d 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/CreateStudentLinkWebResponse.kt @@ -2,4 +2,4 @@ package team.msg.sms.domain.student.dto.res data class CreateStudentLinkWebResponse ( val token: String -) \ No newline at end of file +) From 01470466b76fee9033db1e4e203c44dade5fd302 Mon Sep 17 00:00:00 2001 From: enbraining Date: Sun, 26 May 2024 23:34:15 +0900 Subject: [PATCH 171/183] =?UTF-8?q?:recycle:=20=EC=BB=A8=EB=B2=A4=EC=85=98?= =?UTF-8?q?=20=EB=A7=9E=EC=B6=94=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/student/repository/StudentLinkRepository.kt | 2 +- .../domain/student/dto/req/CreateStudentLinkWebRequest.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt index 8f99f83d..cfc8cdd7 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt @@ -5,6 +5,6 @@ import org.springframework.stereotype.Repository import team.msg.sms.persistence.student.entity.StudentLinkEntity @Repository -interface StudentLinkRepository: CrudRepository { +interface StudentLinkRepository : CrudRepository { fun existsByToken(token: String): Boolean } diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt index 2d35c6f9..f4449855 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/req/CreateStudentLinkWebRequest.kt @@ -8,7 +8,7 @@ data class CreateStudentLinkWebRequest ( ) { fun toData(): CreateStudentLinkRequestData = CreateStudentLinkRequestData( - studentId, - periodDay - ) + studentId, + periodDay + ) } From 76ef60d39ae79c9fdf5292a57222cfde64776941 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:55:32 +0900 Subject: [PATCH 172/183] create :: student info data --- .../res/DetailStudentInfoTokenResponseData.kt | 31 +++++++++++++++++ .../res/DetailStudentInfoTokenWebResponse.kt | 33 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenResponseData.kt create mode 100644 sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenWebResponse.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenResponseData.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenResponseData.kt new file mode 100644 index 00000000..b8524120 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenResponseData.kt @@ -0,0 +1,31 @@ +package team.msg.sms.domain.student.dto.res + +import team.msg.sms.domain.languagecertificate.model.LanguageCertificate +import team.msg.sms.domain.prize.dto.res.PrizeResponseData +import team.msg.sms.domain.project.dto.res.ProjectResponseData +import team.msg.sms.domain.student.model.Department +import team.msg.sms.domain.student.model.FormOfEmployment +import team.msg.sms.domain.student.model.MilitaryService + +data class DetailStudentInfoTokenResponseData( + val name: String, + val introduce: String, + val portfolioUrl: String?, + val grade: Int, + val classNum: Int, + val number: Int, + val department: Department, + val major: String, + val profileImg: String, + val contactEmail: String, + val gsmAuthenticationScore: Int, + val formOfEmployment: FormOfEmployment, + val regions: List, // 근무지역 + val militaryService: MilitaryService, + val salary: Int, + val languageCertificates: List, + val certificates: List, + val techStacks: List, + val projects: List, + val prizes: List +) \ No newline at end of file diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenWebResponse.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenWebResponse.kt new file mode 100644 index 00000000..f8928875 --- /dev/null +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/dto/res/DetailStudentInfoTokenWebResponse.kt @@ -0,0 +1,33 @@ +package team.msg.sms.domain.student.dto.res + +import team.msg.sms.domain.languagecertificate.model.LanguageCertificate +import team.msg.sms.domain.prize.dto.res.PrizeResponseData +import team.msg.sms.domain.project.dto.res.ProjectResponseData +import team.msg.sms.domain.student.model.Department +import team.msg.sms.domain.student.model.FormOfEmployment +import team.msg.sms.domain.student.model.MilitaryService + +data class DetailStudentInfoTokenWebResponse( + val name: String, + val introduce: String, + val portfolioUrl: String?, + val grade: Int, + val classNum: Int, + val number: Int, + val department: Department, + val major: String, + val profileImgUrl: String, + @Deprecated(message = "전 Beta Version 사용자들의 접근성을 개방하기 위하여 현재버전에서는 사용하지 않습니다.") + val profileImg: String, + val contactEmail: String, + val gsmAuthenticationScore: Int, + val formOfEmployment: FormOfEmployment, + val regions: List, // 근무지역 + val militaryService: MilitaryService, + val salary: Int, + val languageCertificates: List, + val certificates: List, + val techStacks: List, + val projects: List, + val prizes: List +) \ No newline at end of file From af70290047e4f0c80bf12ebda4a9b9e16469ad69 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:56:46 +0900 Subject: [PATCH 173/183] =?UTF-8?q?add=20::=20token=EC=9C=BC=EB=A1=9C=20St?= =?UTF-8?q?udent=20id=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt | 3 +++ .../sms/persistence/student/StudentLinkPersistenceAdapter.kt | 5 +++++ .../persistence/student/repository/StudentLinkRepository.kt | 1 + 3 files changed, 9 insertions(+) diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt index 581cd19a..e563cad3 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/spi/QueryStudentLinkPort.kt @@ -1,5 +1,8 @@ package team.msg.sms.domain.student.spi +import java.util.UUID + interface QueryStudentLinkPort { fun existsByToken(token: String): Boolean + fun findStudentIdByToken(token: String): UUID? } diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt index d5895ec3..18bc5477 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/StudentLinkPersistenceAdapter.kt @@ -7,6 +7,7 @@ import team.msg.sms.persistence.student.mapper.toDomain import team.msg.sms.persistence.student.mapper.toEntity import team.msg.sms.persistence.student.repository.StudentJpaRepository import team.msg.sms.persistence.student.repository.StudentLinkRepository +import java.util.* @Component class StudentLinkPersistenceAdapter( @@ -21,4 +22,8 @@ class StudentLinkPersistenceAdapter( override fun existsByToken(token: String): Boolean { return studentLinkRepository.existsByToken(token) } + + override fun findStudentIdByToken(token: String): UUID? { + return studentLinkRepository.findByToken(token)?.studentId + } } diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt index cfc8cdd7..57e58c2a 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/student/repository/StudentLinkRepository.kt @@ -7,4 +7,5 @@ import team.msg.sms.persistence.student.entity.StudentLinkEntity @Repository interface StudentLinkRepository : CrudRepository { fun existsByToken(token: String): Boolean + fun findByToken(token: String): StudentLinkEntity? } From fa124ddb10d5a8393e3e1fd8f272a65055ef3bf5 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:57:15 +0900 Subject: [PATCH 174/183] =?UTF-8?q?add=20::=20=EC=83=9D=EC=84=B1=EB=90=9C?= =?UTF-8?q?=20Student=20link=EB=A5=BC=20=EC=B0=BE=EC=9D=84=20=EC=88=98=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EB=95=8C=20=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student/exception/StudentLinkNotFoundException.kt | 8 ++++++++ .../domain/student/exception/error/StudentErrorCode.kt | 1 + 2 files changed, 9 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/StudentLinkNotFoundException.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/StudentLinkNotFoundException.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/StudentLinkNotFoundException.kt new file mode 100644 index 00000000..d3567c67 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/StudentLinkNotFoundException.kt @@ -0,0 +1,8 @@ +package team.msg.sms.domain.student.exception + +import team.msg.sms.common.error.SmsException +import team.msg.sms.domain.student.exception.error.StudentErrorCode + +object StudentLinkNotFoundException : SmsException( + StudentErrorCode.STUDENT_LINK_NOT_FOUND +) \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/error/StudentErrorCode.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/error/StudentErrorCode.kt index 30813e91..1059f85d 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/error/StudentErrorCode.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/exception/error/StudentErrorCode.kt @@ -11,6 +11,7 @@ enum class StudentErrorCode( STUDENT_NOT_FOUND(ErrorStatus.NOT_FOUND, "학생이 존재하지 않습니다."), STU_NUM_NOR_RIGHT(ErrorStatus.BAD_REQUEST, "올바르지 않은 학번입니다."), STUDENT_ALREADY(ErrorStatus.CONFLICT, "학생 정보가 존재하는 유저입니다"), + STUDENT_LINK_NOT_FOUND(ErrorStatus.CONFLICT, "학생 열람 정보가 존재하지 않습니다."), ; override fun status(): Int = status From 4f9e9847b3e695af234b42a54c5367bc630f3c53 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:57:47 +0900 Subject: [PATCH 175/183] =?UTF-8?q?create=20::=20token=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20student=20info=20=EC=A1=B0=ED=9A=8C=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student/service/GetStudentLinkService.kt | 7 ++++++ .../student/service/StudentLinkService.kt | 8 ++++--- .../service/impl/GetStudentLinkServiceImpl.kt | 22 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentLinkService.kt create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentLinkServiceImpl.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentLinkService.kt new file mode 100644 index 00000000..fe0bb802 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/GetStudentLinkService.kt @@ -0,0 +1,7 @@ +package team.msg.sms.domain.student.service + +import team.msg.sms.domain.student.model.Student.StudentWithUserInfo + +interface GetStudentLinkService { + fun getStudentUserInfoByToken(token: String) : StudentWithUserInfo +} \ No newline at end of file diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt index 97637344..01d682e3 100644 --- a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/StudentLinkService.kt @@ -5,6 +5,8 @@ import team.msg.sms.common.annotation.Service @Service class StudentLinkService ( commandStudentLinkService: CommandStudentLinkService, - checkStudentLinkService: CheckStudentLinkService -): CommandStudentLinkService by commandStudentLinkService, - CheckStudentLinkService by checkStudentLinkService + checkStudentLinkService: CheckStudentLinkService, + getStudentLinkService: GetStudentLinkService +) : CommandStudentLinkService by commandStudentLinkService, + CheckStudentLinkService by checkStudentLinkService, + GetStudentLinkService by getStudentLinkService diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentLinkServiceImpl.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentLinkServiceImpl.kt new file mode 100644 index 00000000..5c0b5d67 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/service/impl/GetStudentLinkServiceImpl.kt @@ -0,0 +1,22 @@ +package team.msg.sms.domain.student.service.impl + +import team.msg.sms.common.annotation.Service +import team.msg.sms.domain.student.exception.StudentLinkNotFoundException +import team.msg.sms.domain.student.exception.StudentNotFoundException +import team.msg.sms.domain.student.model.Student.StudentWithUserInfo +import team.msg.sms.domain.student.service.GetStudentLinkService +import team.msg.sms.domain.student.spi.StudentLinkPort +import team.msg.sms.domain.student.spi.StudentPort + +@Service +class GetStudentLinkServiceImpl( + private val studentLinkPort: StudentLinkPort, + private val studentPort: StudentPort +) : GetStudentLinkService { + override fun getStudentUserInfoByToken(token: String): StudentWithUserInfo { + val studentId = studentLinkPort.findStudentIdByToken(token) ?: throw StudentNotFoundException + val studentWithUserInfo = studentPort.queryStudentWithUserInfoById(studentId) ?: throw StudentLinkNotFoundException + + return studentWithUserInfo + } +} \ No newline at end of file From 25f8f3ff13278ca6a3b93d66a3a0546cd2b05816 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:58:03 +0900 Subject: [PATCH 176/183] =?UTF-8?q?create=20::=20token=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20student=20info=20=EC=A1=B0=ED=9A=8C=20usecase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/StudentInfoTokenUseCase.kt | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/StudentInfoTokenUseCase.kt diff --git a/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/StudentInfoTokenUseCase.kt b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/StudentInfoTokenUseCase.kt new file mode 100644 index 00000000..231248a4 --- /dev/null +++ b/sms-core/src/main/kotlin/team/msg/sms/domain/student/usecase/StudentInfoTokenUseCase.kt @@ -0,0 +1,97 @@ +package team.msg.sms.domain.student.usecase + +import team.msg.sms.common.annotation.UseCase +import team.msg.sms.common.util.PrizeUtil.generatePrizeResponseData +import team.msg.sms.common.util.ProjectUtil.generateProjectResponseData +import team.msg.sms.domain.certificate.service.CertificateService +import team.msg.sms.domain.file.service.ImageService +import team.msg.sms.domain.languagecertificate.model.LanguageCertificate +import team.msg.sms.domain.languagecertificate.service.LanguageCertificateService +import team.msg.sms.domain.prize.service.PrizeService +import team.msg.sms.domain.project.service.ProjectLinkService +import team.msg.sms.domain.project.service.ProjectService +import team.msg.sms.domain.project.service.ProjectTechStackService +import team.msg.sms.domain.region.service.RegionService +import team.msg.sms.domain.student.dto.res.DetailStudentInfoTokenResponseData +import team.msg.sms.domain.student.model.Student +import team.msg.sms.domain.student.model.StudentTechStack +import team.msg.sms.domain.student.service.StudentLinkService +import team.msg.sms.domain.student.service.StudentService +import team.msg.sms.domain.student.service.StudentTechStackService +import team.msg.sms.domain.techstack.model.TechStack +import team.msg.sms.domain.techstack.service.TechStackService + +@UseCase +class StudentInfoTokenUseCase( + private val studentService: StudentService, + private val certificateService: CertificateService, + private val studentTechStackService: StudentTechStackService, + private val projectService: ProjectService, + private val techStackService: TechStackService, + private val projectTechStackService: ProjectTechStackService, + private val projectLinkService: ProjectLinkService, + private val imageService: ImageService, + private val languageCertificateService: LanguageCertificateService, + private val regionService: RegionService, + private val prizeService: PrizeService, + private val studentLinkService: StudentLinkService +) { + fun execute(token: String): DetailStudentInfoTokenResponseData { + val student: Student.StudentWithUserInfo = studentLinkService.getStudentUserInfoByToken(token) + + val projects = projectService.getAllProjectByStudentId(studentId = student.id) + val certificates = certificateService.getCertificateByUuid(student.id).map { it.certificateName } + val languageCertificates = + languageCertificateService.getLanguageCertificateByStudentUuid(student.id) + .map { toLanguageCertificateScore(languageCertificate = it) } + val regions = regionService.getRegionByStudentUuid(student.id).map { it.region } + val techStacks = techStackService.getAllTechStack() + val prizes = prizeService.getAllPrizeByStudentId(studentId = student.id) + val studentTechStacks = studentTechStackService.getStudentTechStackByStudentId(student.id) + + return DetailStudentInfoTokenResponseData( + name = student.name, + introduce = student.introduce, + portfolioUrl = student.portfolioUrl, + grade = student.stuNum.substring(0, 1).toInt(), + classNum = student.stuNum.substring(1, 2).toInt(), + number = student.stuNum.substring(2, 4).toInt(), + department = student.department, + major = student.major, + profileImg = student.profileImgUrl, + contactEmail = student.contactEmail, + gsmAuthenticationScore = student.gsmAuthenticationScore, + formOfEmployment = student.formOfEmployment, + regions = regions, + militaryService = student.militaryService, + salary = student.salary, + languageCertificates = languageCertificates, + certificates = certificates, + techStacks = studentTechStacks.map { + toStudentTechStacks(techStacks, it)?.stack ?: "" + }, + projects = generateProjectResponseData( + projects = projects, + projectLinkService = projectLinkService, + projectTechStackService = projectTechStackService, + imageService = imageService, + techStacks = techStacks + ), + prizes = generatePrizeResponseData( + prizes = prizes + ) + ) + } + + private fun toLanguageCertificateScore( + languageCertificate: LanguageCertificate, + ): LanguageCertificate.LanguageCertificateScore = + LanguageCertificate.LanguageCertificateScore( + languageCertificateName = languageCertificate.languageCertificateName, + score = languageCertificate.score, + ) + + private fun toStudentTechStacks(techStacks: List, studentTechStack: StudentTechStack): TechStack? = + techStacks.find { it.id == studentTechStack.techStackId } +} + From d01732b97c5ddaed1c18a1932ff7493376282563 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 10:59:53 +0900 Subject: [PATCH 177/183] =?UTF-8?q?add=20::=20token=EC=9C=BC=EB=A1=9C=20st?= =?UTF-8?q?udent=20info=20=EC=A1=B0=ED=9A=8C=20web=20mapping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/sms/global/security/SecurityConfig.kt | 3 +- .../sms/domain/student/StudentWebAdapter.kt | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index f0682ce7..8b8582b5 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -60,8 +60,9 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/student").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET, "/student").permitAll() - .antMatchers(HttpMethod.GET, "/student/{uuid}").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.POST, "/student/link").hasAuthority(TEACHER) + .antMatchers(HttpMethod.GET, "/student/link").authenticated() + .antMatchers(HttpMethod.GET, "/student/{uuid}").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET, "/student/anonymous/{uuid}").permitAll() .antMatchers(HttpMethod.POST, "/teacher/common").hasAuthority(TEACHER) diff --git a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt index 1f77d268..a6c8f62d 100644 --- a/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt +++ b/sms-presentation/src/main/kotlin/team/msg/sms/domain/student/StudentWebAdapter.kt @@ -20,6 +20,7 @@ class StudentWebAdapter( private val studentInfoAnonymousUseCase: StudentInfoAnonymousUseCase, private val studentInfoDetailUseCase: StudentInfoDetailUseCase, private val studentInfoTeacherUseCase: StudentInfoTeacherUseCase, + private val studentInfoTokenUseCase: StudentInfoTokenUseCase, private val modifyStudentInfoUseCase: ModifyStudentInfoUseCase, private val createStudentLinkUseCase: CreateStudentLinkUseCase ) { @@ -43,6 +44,11 @@ class StudentWebAdapter( .let { ResponseEntity.ok(it.toResponse()) } } + @GetMapping("/link") + fun findByToken(@RequestParam token: String): ResponseEntity = + studentInfoTokenUseCase.execute(token) + .let { ResponseEntity.ok(it.toResponse()) } + @PutMapping fun modifyStudentInfo(@RequestBody modifyStudentInfoWebRequest: ModifyStudentInfoWebRequest) { modifyStudentInfoUseCase.execute(modifyStudentInfoWebRequest.toData()) @@ -138,6 +144,31 @@ class StudentWebAdapter( token = this.token ) + fun DetailStudentInfoTokenResponseData.toResponse(): DetailStudentInfoTokenWebResponse = + DetailStudentInfoTokenWebResponse( + name = this.name, + introduce = this.introduce, + portfolioUrl = this.portfolioUrl, + grade = this.grade, + classNum = this.classNum, + number = this.number, + department = this.department, + major = this.major, + profileImgUrl = this.profileImg, + profileImg = this.profileImg, + contactEmail = this.contactEmail, + gsmAuthenticationScore = this.gsmAuthenticationScore, + formOfEmployment = this.formOfEmployment, + regions = this.regions, + militaryService = this.militaryService, + salary = this.salary, + languageCertificates = this.languageCertificates, + certificates = this.certificates, + techStacks = this.techStacks, + projects = this.projects, + prizes = this.prizes + ) + private fun isValidUUID(uuid: String): Boolean { return try { UUID.fromString(uuid) From bb78faf50ab9076e90261a5400c0519eb15dcd48 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Tue, 28 May 2024 16:14:56 +0900 Subject: [PATCH 178/183] =?UTF-8?q?fix=20::=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=84=20=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=84=EB=8F=84=20?= =?UTF-8?q?=EB=B3=BC=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/sms/global/security/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt index 8b8582b5..4924a1ca 100644 --- a/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt +++ b/sms-infrastructure/src/main/kotlin/team/msg/sms/global/security/SecurityConfig.kt @@ -61,7 +61,7 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/student").hasAuthority(STUDENT) .antMatchers(HttpMethod.GET, "/student").permitAll() .antMatchers(HttpMethod.POST, "/student/link").hasAuthority(TEACHER) - .antMatchers(HttpMethod.GET, "/student/link").authenticated() + .antMatchers(HttpMethod.GET, "/student/link").permitAll() .antMatchers(HttpMethod.GET, "/student/{uuid}").hasAnyAuthority(STUDENT, TEACHER) .antMatchers(HttpMethod.GET, "/student/anonymous/{uuid}").permitAll() From e77dafd33bfb49e4249b5a217304de53af2177f0 Mon Sep 17 00:00:00 2001 From: HumanIearning Date: Tue, 28 May 2024 17:20:23 +0900 Subject: [PATCH 179/183] =?UTF-8?q?feat:=20workflow=20=EC=8B=A4=ED=96=89?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=EC=97=90=20=EC=88=98=EB=8F=99=20=ED=8A=B8?= =?UTF-8?q?=EB=A6=AC=EA=B1=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_master_cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index 423a20ac..b00416e0 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -2,6 +2,8 @@ on: push: branches: [ "master" ] + workflow_dispatch: + jobs: CD: name: CD From 44a96b43b1dc51d26884ace7c2f7b78fd6feb691 Mon Sep 17 00:00:00 2001 From: aeongsseu <81360154+HumanIearning@users.noreply.github.com> Date: Tue, 28 May 2024 17:23:23 +0900 Subject: [PATCH 180/183] =?UTF-8?q?Revert=20"cd=20workflow=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EB=8F=99=20=ED=8A=B8=EB=A6=AC=EA=B1=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 28 +++------------------ .github/workflows/sms_backend_master_cd.yml | 2 -- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c4c12b74..13218d94 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,31 +1,11 @@ -## 💡 배경 및 개요 - -> PR을 하게 된 문제상황, 배경 및 개요에 대해서 작성해주세요! -> -> 퍼블리싱의 경우 스크린샷/동영상도 추가해주면 좋아요! - -Resolves: #{이슈번호} +## 💡 개요 ## 📃 작업내용 -> PR에서 한 작업을 작성해주세요! - -## 🙋‍♂️ 리뷰노트 - -> 구현 시에 고민이었던 점들 혹은 특정 부분에 대한 의도가 있었다면 PR 리뷰의 이해를 돕기 위해 서술해주세요! -> -> 또한 리뷰어에게 특정 부분에 대한 집중 혹은 코멘트 혹은 질문을 요청하는 경우에 작성하면 좋아요! -> -> e.g. 작업을 끝내야할 시간이 얼마 없어 확장성보다는 동작을 위주로 만들었어요! 감안하고 리뷰해주세요! - -## ✅ PR 체크리스트 +## 🔀 변경사항 -> 템플릿 체크리스트 말고도 추가적으로 필요한 체크리스트는 추가해주세요! +## 🙋‍♂️ 질문사항 -- [ ] 이 작업으로 인해 변경이 필요한 문서가 변경되었나요? (e.g. `.env`, `노션`, `README`) -- [ ] 이 작업을 하고나서 공유해야할 팀원들에게 공유되었나요? (e.g. `"API 개발 완료됐어요"`, `"환경값 추가되었어요"`) -- [ ] 작업한 코드가 정상적으로 동작하나요? -- [ ] Merge 대상 브랜치가 올바른가요? -- [ ] PR과 관련 없는 작업이 있지는 않나요? +## 🍴 사용방법 ## 🎸 기타 diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index 57a0e921..cbfe2fbe 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -2,8 +2,6 @@ on: push: branches: [ "master" ] - workflow_dispatch: - jobs: CD: name: CD From 43cdf9f43642214d97ad2c73072893129c2c9acc Mon Sep 17 00:00:00 2001 From: aeongsseu <81360154+HumanIearning@users.noreply.github.com> Date: Tue, 28 May 2024 17:59:25 +0900 Subject: [PATCH 181/183] =?UTF-8?q?Revert=20"=EB=82=98=EC=A4=91=EC=97=90?= =?UTF-8?q?=20commit=20=EC=9D=B4=EC=83=81=ED=95=98=EA=B2=8C=20=EA=BC=AC?= =?UTF-8?q?=EC=9D=B4=EB=A9=B4=20=EC=9D=B4=20pr=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EC=84=B8=EC=9A=94"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sms_backend_master_cd.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index f57dd03b..cbfe2fbe 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -1,8 +1,6 @@ on: push: branches: [ "master" ] - workflow_dispatch: - jobs: CD: From 784c0e5e80875e6e33cab58541f0030c2cfb8093 Mon Sep 17 00:00:00 2001 From: aeongsseu <81360154+HumanIearning@users.noreply.github.com> Date: Tue, 28 May 2024 18:02:52 +0900 Subject: [PATCH 182/183] =?UTF-8?q?Revert=20"Revert=20"cd=20workflow?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=88=98=EB=8F=99=20=ED=8A=B8=EB=A6=AC?= =?UTF-8?q?=EA=B1=B0=20=EC=B6=94=EA=B0=80""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 28 ++++++++++++++++++--- .github/workflows/sms_backend_master_cd.yml | 2 ++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 13218d94..c4c12b74 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,31 @@ -## 💡 개요 +## 💡 배경 및 개요 + +> PR을 하게 된 문제상황, 배경 및 개요에 대해서 작성해주세요! +> +> 퍼블리싱의 경우 스크린샷/동영상도 추가해주면 좋아요! + +Resolves: #{이슈번호} ## 📃 작업내용 -## 🔀 변경사항 +> PR에서 한 작업을 작성해주세요! + +## 🙋‍♂️ 리뷰노트 + +> 구현 시에 고민이었던 점들 혹은 특정 부분에 대한 의도가 있었다면 PR 리뷰의 이해를 돕기 위해 서술해주세요! +> +> 또한 리뷰어에게 특정 부분에 대한 집중 혹은 코멘트 혹은 질문을 요청하는 경우에 작성하면 좋아요! +> +> e.g. 작업을 끝내야할 시간이 얼마 없어 확장성보다는 동작을 위주로 만들었어요! 감안하고 리뷰해주세요! + +## ✅ PR 체크리스트 -## 🙋‍♂️ 질문사항 +> 템플릿 체크리스트 말고도 추가적으로 필요한 체크리스트는 추가해주세요! -## 🍴 사용방법 +- [ ] 이 작업으로 인해 변경이 필요한 문서가 변경되었나요? (e.g. `.env`, `노션`, `README`) +- [ ] 이 작업을 하고나서 공유해야할 팀원들에게 공유되었나요? (e.g. `"API 개발 완료됐어요"`, `"환경값 추가되었어요"`) +- [ ] 작업한 코드가 정상적으로 동작하나요? +- [ ] Merge 대상 브랜치가 올바른가요? +- [ ] PR과 관련 없는 작업이 있지는 않나요? ## 🎸 기타 diff --git a/.github/workflows/sms_backend_master_cd.yml b/.github/workflows/sms_backend_master_cd.yml index cbfe2fbe..57a0e921 100644 --- a/.github/workflows/sms_backend_master_cd.yml +++ b/.github/workflows/sms_backend_master_cd.yml @@ -2,6 +2,8 @@ on: push: branches: [ "master" ] + workflow_dispatch: + jobs: CD: name: CD From 3d5be9698d32b045776d910baab5e0000195d744 Mon Sep 17 00:00:00 2001 From: huuuunee Date: Tue, 28 May 2024 23:07:01 +0900 Subject: [PATCH 183/183] =?UTF-8?q?:recycle:=20=ED=85=8C=EC=9D=B4=EB=B8=94?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20users=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/sms/persistence/user/entity/UserJpaEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/user/entity/UserJpaEntity.kt b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/user/entity/UserJpaEntity.kt index 0e351530..8c70df82 100644 --- a/sms-persistence/src/main/kotlin/team/msg/sms/persistence/user/entity/UserJpaEntity.kt +++ b/sms-persistence/src/main/kotlin/team/msg/sms/persistence/user/entity/UserJpaEntity.kt @@ -6,7 +6,7 @@ import java.util.UUID import javax.persistence.* @Entity -@Table(name = "user") +@Table(name = "users") class UserJpaEntity( override val id: UUID,