Skip to content

Commit

Permalink
feat: 추천인을 저장할 엔티티를 추가한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devbelly committed Aug 22, 2024
1 parent 2776c8e commit 01b65e2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
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))
}
}
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,
)
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)
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>

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)
}
}
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;

0 comments on commit 01b65e2

Please sign in to comment.