forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
backend/src/main/kotlin/com/dclass/backend/application/RecommendService.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,16 @@ | ||
package com.dclass.backend.application | ||
|
||
import com.dclass.backend.domain.recommend.Recommend | ||
import com.dclass.backend.domain.recommend.RecommendRepository | ||
import jakarta.transaction.Transactional | ||
import org.springframework.stereotype.Service | ||
|
||
@Transactional | ||
@Service | ||
class RecommendService( | ||
private val recommendRepository: RecommendRepository | ||
) { | ||
fun create(userName: String) { | ||
recommendRepository.save(Recommend(userName)) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
backend/src/main/kotlin/com/dclass/backend/application/dto/RecommendDtos.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 com.dclass.backend.application.dto | ||
|
||
|
||
data class RecommendRequest( | ||
val userName: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
backend/src/main/kotlin/com/dclass/backend/domain/recommend/Recommend.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 com.dclass.backend.domain.recommend | ||
|
||
import com.dclass.support.domain.BaseEntity | ||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
|
||
@Entity | ||
class Recommend( | ||
@Column(nullable = false) | ||
val userName: String, | ||
id: Long = 0L, | ||
) : BaseEntity(id) |
6 changes: 6 additions & 0 deletions
6
backend/src/main/kotlin/com/dclass/backend/domain/recommend/RecommendRepository.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 com.dclass.backend.domain.recommend | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface RecommendRepository : JpaRepository<Recommend, Long> | ||
|
19 changes: 19 additions & 0 deletions
19
backend/src/main/kotlin/com/dclass/backend/ui/api/RecommendController.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,19 @@ | ||
package com.dclass.backend.ui.api | ||
|
||
import com.dclass.backend.application.RecommendService | ||
import com.dclass.backend.application.dto.RecommendRequest | ||
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 | ||
|
||
@RestController | ||
@RequestMapping("/api/recommend") | ||
class RecommendController( | ||
private val recommendService: RecommendService, | ||
) { | ||
@PostMapping | ||
fun create(@RequestBody request: RecommendRequest) { | ||
recommendService.create(request.userName) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
backend/src/main/resources/db/migration/V14__create_recommend_table.sql
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 @@ | ||
create table recommend | ||
( | ||
id bigint not null auto_increment, | ||
user_name varchar(255) not null, | ||
primary key (id) | ||
) engine=InnoDB; |