-
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.
Added committee GET /all , service/repository/controller
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/example/autobank/controller/CommitteeController.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,33 @@ | ||
package com.example.autobank.controller | ||
|
||
import com.example.autobank.data.Committee | ||
import com.example.autobank.data.Economicrequest | ||
import com.example.autobank.data.user.OnlineUser | ||
import com.example.autobank.repository.CommitteeRepository | ||
import com.example.autobank.service.AdminService | ||
import com.example.autobank.service.CommitteeService | ||
import com.example.autobank.service.EconomicRequestReviewService | ||
import com.example.autobank.service.EconomicrequestService | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping("/api/committee") | ||
class CommitteeController( | ||
) { | ||
|
||
@Autowired | ||
lateinit var committeeService: CommitteeService | ||
|
||
@GetMapping("/all") | ||
fun getAllCommittees(): ResponseEntity<List<Committee>> { | ||
return try { | ||
val committees = committeeService.getAllCommittees() | ||
ResponseEntity.ok(committees) | ||
} catch (e: Exception) { | ||
ResponseEntity.badRequest().build() | ||
} | ||
|
||
} | ||
} |
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.example.autobank.data | ||
|
||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "committee") | ||
class Committee ( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Int, | ||
val name: String | ||
) |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/example/autobank/repository/CommitteeRepository.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.example.autobank.repository; | ||
|
||
import com.example.autobank.data.Committee | ||
import com.example.autobank.data.Economicrequest | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
interface CommitteeRepository : JpaRepository<Committee, Int> { | ||
|
||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/example/autobank/service/CommitteeService.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,9 +1,17 @@ | ||
package com.example.autobank.service; | ||
|
||
import com.example.autobank.data.Committee | ||
import com.example.autobank.repository.CommitteeRepository | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class CommitteeService() { | ||
|
||
@Autowired | ||
lateinit var committeeRepository: CommitteeRepository | ||
|
||
fun getAllCommittees(): List<Committee> { | ||
return committeeRepository.findAll() | ||
} | ||
} |