generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from GSM-MSG/feat/project_info
๐ :: 159 - ํ๋ก์ ํธ ์ถ๊ฐ
- Loading branch information
Showing
122 changed files
with
1,592 additions
and
173 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
sms-core/src/main/kotlin/team/msg/sms/common/util/ProjectUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package team.msg.sms.common.util | ||
|
||
import team.msg.sms.domain.file.model.Image | ||
import team.msg.sms.domain.file.service.ImageService | ||
import team.msg.sms.domain.project.dto.res.ProjectInProgressResponseData | ||
import team.msg.sms.domain.project.dto.res.ProjectLinkResponseData | ||
import team.msg.sms.domain.project.dto.res.ProjectResponseData | ||
import team.msg.sms.domain.project.model.Project | ||
import team.msg.sms.domain.project.model.ProjectLink | ||
import team.msg.sms.domain.project.model.ProjectTechStack | ||
import team.msg.sms.domain.project.service.ProjectLinkService | ||
import team.msg.sms.domain.project.service.ProjectTechStackService | ||
import team.msg.sms.domain.techstack.model.TechStack | ||
|
||
object ProjectUtil { | ||
|
||
fun generateProjectResponseData( | ||
imageService: ImageService, | ||
projectLinkService: ProjectLinkService, | ||
projectTechStackService: ProjectTechStackService, | ||
projects: List<Project>, | ||
techStacks: List<TechStack> | ||
) : List<ProjectResponseData> = | ||
projects.map { | ||
val image = imageService.getAllByProjectId(projectId = it.id) | ||
val link = projectLinkService.getAllByProjectId(projectId = it.id) | ||
val projectTechStack = projectTechStackService.getAllByProjectId(projectId = it.id) | ||
toProjectResponseData( | ||
project = it, | ||
projectLink = link, | ||
projectImage = image, | ||
projectTechStack = projectTechStack, | ||
techStack = techStacks | ||
) | ||
} | ||
|
||
private fun toProjectTechStacks(techStacks: List<TechStack>, projectTechStack: ProjectTechStack): TechStack? = | ||
techStacks.find { it.id == projectTechStack.techStackId } | ||
|
||
private fun toProjectResponseData( | ||
project: Project, | ||
projectLink: List<ProjectLink>, | ||
projectImage: List<Image>, | ||
projectTechStack: List<ProjectTechStack>, | ||
techStack: List<TechStack> | ||
): ProjectResponseData = | ||
ProjectResponseData( | ||
id = project.id, | ||
description = project.description, | ||
inProgress = toInProgressResponseData(project.startDate, project.endDate), | ||
links = projectLink.map { toLinkResponseData(it) }, | ||
myActivity = project.myActivity, | ||
previewImages = projectImage.map { it.imageUrl }, | ||
projectTechStacks = projectTechStack.map { | ||
toProjectTechStacks(techStack, it)?.stack ?: "" | ||
}, | ||
name = project.title, | ||
) | ||
|
||
|
||
private fun toLinkResponseData(projectLink: ProjectLink) = | ||
ProjectLinkResponseData( | ||
id = projectLink.projectId, | ||
name = projectLink.name, | ||
url = projectLink.url | ||
) | ||
|
||
private fun toInProgressResponseData(start: String, end: String?) = | ||
ProjectInProgressResponseData( | ||
start = start, | ||
end = end | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 34 additions & 11 deletions
45
sms-core/src/main/kotlin/team/msg/sms/domain/auth/usecase/WithdrawalUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,62 @@ | ||
package team.msg.sms.domain.auth.usecase | ||
|
||
import org.springframework.transaction.annotation.Transactional | ||
import team.msg.sms.common.annotation.UseCase | ||
import team.msg.sms.domain.certificate.service.CertificateService | ||
import team.msg.sms.domain.file.service.ImageService | ||
import team.msg.sms.domain.languagecertificate.service.LanguageCertificateService | ||
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.service.StudentService | ||
import team.msg.sms.domain.techstack.service.TechStackService | ||
import team.msg.sms.domain.student.service.StudentTechStackService | ||
import team.msg.sms.domain.user.service.UserService | ||
|
||
@UseCase | ||
class WithdrawalUseCase( | ||
private val userService: UserService, | ||
private val studentService: StudentService, | ||
private val techStackService: TechStackService, | ||
private val projectService: ProjectService, | ||
private val projectTechStackService: ProjectTechStackService, | ||
private val regionService: RegionService, | ||
private val studentTechStackService: StudentTechStackService, | ||
private val languageCertificateService: LanguageCertificateService, | ||
private val certificateService: CertificateService | ||
private val imageService: ImageService, | ||
private val certificateService: CertificateService, | ||
private val projectLinkService: ProjectLinkService | ||
) { | ||
fun execute() { | ||
val user = userService.getCurrentUser() | ||
if (user.roles[0].name == "ROLE_STUDENT") { | ||
val student = studentService.getStudentByUser(user) | ||
val project = projectService.getAllProjectByStudentId(student.id) | ||
|
||
listOf( | ||
techStackService::deleteAllByStudent, | ||
val deleteProjectActions = listOf( | ||
projectLinkService::deleteAllByProjects, | ||
projectTechStackService::deleteAllByProjects, | ||
imageService::deleteAllByProjects | ||
) | ||
|
||
val deleteStudentActions = listOf( | ||
projectService::deleteAllByStudent, | ||
regionService::deleteAllByStudent, | ||
languageCertificateService::deleteAllByStudent, | ||
certificateService::deleteAllByStudent | ||
).forEach { service -> | ||
service(student, user) | ||
} | ||
certificateService::deleteAllByStudent, | ||
studentTechStackService::deleteAllByStudent | ||
) | ||
|
||
deleteActions(deleteProjectActions, project) | ||
deleteActions(deleteStudentActions, student) | ||
|
||
studentService.deleteByUuid(studentId = student.id) | ||
} | ||
userService.deleteByUuid(userId = user.id) | ||
} | ||
} | ||
} | ||
|
||
fun <T> deleteActions(actions: List<(T) -> Unit>, target: T) { | ||
actions.forEach { action -> | ||
action(target) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
sms-core/src/main/kotlin/team/msg/sms/domain/file/model/Image.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package team.msg.sms.domain.file.model | ||
|
||
import team.msg.sms.common.annotation.Aggregate | ||
|
||
@Aggregate | ||
data class Image( | ||
val id: Long, | ||
val imageUrl: String, | ||
val projectId: Long | ||
) |
9 changes: 9 additions & 0 deletions
9
sms-core/src/main/kotlin/team/msg/sms/domain/file/service/CommandImageService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.msg.sms.domain.file.service | ||
|
||
import team.msg.sms.domain.file.model.Image | ||
import team.msg.sms.domain.project.model.Project | ||
|
||
interface CommandImageService { | ||
fun saveAll(images: List<Image>) | ||
fun deleteAllByProjects(projects: List<Project>) | ||
} |
7 changes: 7 additions & 0 deletions
7
sms-core/src/main/kotlin/team/msg/sms/domain/file/service/GetImageService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package team.msg.sms.domain.file.service | ||
|
||
import team.msg.sms.domain.file.model.Image | ||
|
||
interface GetImageService { | ||
fun getAllByProjectId(projectId: Long): List<Image> | ||
} |
10 changes: 10 additions & 0 deletions
10
sms-core/src/main/kotlin/team/msg/sms/domain/file/service/ImageService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package team.msg.sms.domain.file.service | ||
|
||
import team.msg.sms.common.annotation.Service | ||
|
||
@Service | ||
class ImageService( | ||
commandImageService: CommandImageService, | ||
getImageService: GetImageService | ||
) : CommandImageService by commandImageService, | ||
GetImageService by getImageService |
18 changes: 18 additions & 0 deletions
18
sms-core/src/main/kotlin/team/msg/sms/domain/file/service/impl/CommandImageServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package team.msg.sms.domain.file.service.impl | ||
|
||
import team.msg.sms.common.annotation.Service | ||
import team.msg.sms.domain.file.model.Image | ||
import team.msg.sms.domain.file.service.CommandImageService | ||
import team.msg.sms.domain.file.spi.ImagePort | ||
import team.msg.sms.domain.project.model.Project | ||
|
||
@Service | ||
class CommandImageServiceImp( | ||
private val imagePort: ImagePort | ||
) : CommandImageService { | ||
override fun saveAll(images: List<Image>) = | ||
imagePort.saveAll(images) | ||
|
||
override fun deleteAllByProjects(projects: List<Project>) = | ||
imagePort.deleteAllByProjects(projects) | ||
} |
14 changes: 14 additions & 0 deletions
14
sms-core/src/main/kotlin/team/msg/sms/domain/file/service/impl/GetImageServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package team.msg.sms.domain.file.service.impl | ||
|
||
import team.msg.sms.common.annotation.Service | ||
import team.msg.sms.domain.file.model.Image | ||
import team.msg.sms.domain.file.service.GetImageService | ||
import team.msg.sms.domain.file.spi.ImagePort | ||
|
||
@Service | ||
class GetImageServiceImpl( | ||
private val imagePort: ImagePort | ||
) : GetImageService { | ||
override fun getAllByProjectId(projectId: Long): List<Image> = | ||
imagePort.queryAllByProjectId(projectId) | ||
} |
9 changes: 9 additions & 0 deletions
9
sms-core/src/main/kotlin/team/msg/sms/domain/file/spi/CommandImagePort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package team.msg.sms.domain.file.spi | ||
|
||
import team.msg.sms.domain.file.model.Image | ||
import team.msg.sms.domain.project.model.Project | ||
|
||
interface CommandImagePort { | ||
fun saveAll(images: List<Image>) | ||
fun deleteAllByProjects(projects: List<Project>) | ||
} |
5 changes: 5 additions & 0 deletions
5
sms-core/src/main/kotlin/team/msg/sms/domain/file/spi/ImagePort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package team.msg.sms.domain.file.spi | ||
|
||
interface ImagePort : | ||
CommandImagePort, | ||
QueryImagePort |
7 changes: 7 additions & 0 deletions
7
sms-core/src/main/kotlin/team/msg/sms/domain/file/spi/QueryImagePort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package team.msg.sms.domain.file.spi | ||
|
||
import team.msg.sms.domain.file.model.Image | ||
|
||
interface QueryImagePort { | ||
fun queryAllByProjectId(projectId: Long): List<Image> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
sms-core/src/main/kotlin/team/msg/sms/domain/project/dto/req/LinkRequestData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package team.msg.sms.domain.project.dto.req | ||
|
||
data class LinkRequestData( | ||
val name: String, | ||
val url: String | ||
) |
6 changes: 6 additions & 0 deletions
6
sms-core/src/main/kotlin/team/msg/sms/domain/project/dto/req/ProjectInProgressData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package team.msg.sms.domain.project.dto.req | ||
|
||
data class ProjectInProgressData( | ||
val start: String, | ||
val end: String? | ||
) |
12 changes: 12 additions & 0 deletions
12
sms-core/src/main/kotlin/team/msg/sms/domain/project/dto/req/ProjectRequestData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package team.msg.sms.domain.project.dto.req | ||
|
||
data class ProjectRequestData( | ||
val name: String, | ||
val icon: String, | ||
val previewImages: List<String>, | ||
val description: String, | ||
val links: List<LinkRequestData>, | ||
val techStacks: List<String>, | ||
val myActivity : String, | ||
val inProgress: ProjectInProgressData | ||
) |
6 changes: 6 additions & 0 deletions
6
...core/src/main/kotlin/team/msg/sms/domain/project/dto/res/ProjectInProgressResponseData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package team.msg.sms.domain.project.dto.res | ||
|
||
data class ProjectInProgressResponseData( | ||
val start: String, | ||
val end: String? | ||
) |
7 changes: 7 additions & 0 deletions
7
sms-core/src/main/kotlin/team/msg/sms/domain/project/dto/res/ProjectLinkResponseData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package team.msg.sms.domain.project.dto.res | ||
|
||
data class ProjectLinkResponseData( | ||
val id: Long, | ||
val name: String, | ||
val url: String | ||
) |
Oops, something went wrong.