Skip to content

Commit 08586b7

Browse files
authored
prod (#313)
* 교과목 정렬, 쿠키 secure 옵션 추가 (#308) * feat: 교과목 정렬 * feat: 쿠키 secure 옵션 추가 * referrer policy 헤더 추가 (#311) * referrer policy 헤더 추가 * 헤더 수정 * feat: scholarship CRUD (#309) * feat: scholarship CRUD * 불필요한 라인 삭제 * 리뷰 반영 * Update deploy_dev.yaml * 강의실 예약 제한 (#312)
1 parent 3148591 commit 08586b7

File tree

14 files changed

+216
-52
lines changed

14 files changed

+216
-52
lines changed

.github/workflows/deploy_dev.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- settings.gradle.kts
1313
- src/**
1414
- gradle/**
15-
- .github/workflows/deploy.yaml
15+
- .github/workflows/deploy_dev.yaml
1616

1717
jobs:
1818
build-and-deploy:
@@ -63,15 +63,15 @@ jobs:
6363
# echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env
6464
# echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env
6565
66-
- name: SCP Command to Transfer Files
67-
uses: appleboy/[email protected]
68-
with:
69-
host: ${{secrets.SSH_HOST_DEV}}
70-
username: ${{secrets.SSH_USER}}
71-
key: ${{secrets.SSH_KEY}}
72-
source: "docker-compose-backend.yml, .env"
73-
target: "~/app"
74-
overwrite: true
66+
# - name: SCP Command to Transfer Files
67+
# uses: appleboy/[email protected]
68+
# with:
69+
# host: ${{secrets.SSH_HOST_DEV}}
70+
# username: ${{secrets.SSH_USER}}
71+
# key: ${{secrets.SSH_KEY}}
72+
# source: "docker-compose-backend.yml, .env"
73+
# target: "~/app"
74+
# overwrite: true
7575
- name: SSH Remote Commands
7676
uses: appleboy/[email protected]
7777
with:

src/main/kotlin/com/wafflestudio/csereal/common/config/SecurityConfig.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.springframework.security.core.Authentication
1515
import org.springframework.security.web.SecurityFilterChain
1616
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler
1717
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler
18+
import org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter
1819
import org.springframework.web.cors.CorsConfiguration
1920
import org.springframework.web.cors.CorsConfigurationSource
2021
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
@@ -59,6 +60,11 @@ class SecurityConfig(
5960
.requestMatchers("/api/v1/login").authenticated()
6061
.anyRequest().permitAll()
6162
}
63+
.headers { header ->
64+
header.referrerPolicy {
65+
it.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
66+
}
67+
}
6268
.build()
6369
}
6470

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.wafflestudio.csereal.core.academics.api.req
2+
3+
data class CreateScholarshipReq(
4+
val koName: String,
5+
val koDescription: String,
6+
val enName: String,
7+
val enDescription: String
8+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.wafflestudio.csereal.core.academics.api.req
2+
3+
data class UpdateScholarshipPageReq(
4+
val description: String
5+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.wafflestudio.csereal.core.academics.api.req
2+
3+
import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto
4+
5+
class UpdateScholarshipReq(
6+
val ko: ScholarshipDto,
7+
val en: ScholarshipDto
8+
)

src/main/kotlin/com/wafflestudio/csereal/core/academics/api/v1/AcademicsController.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class AcademicsController(
8686
) = academicsService.deleteAcademicsYearResponse(language, studentType, postType, year)
8787

8888
//교과목 정보
89-
89+
@Deprecated(message = "Use V2 API")
9090
@GetMapping("/{studentType}/courses")
9191
fun readAllCourses(
9292
@RequestParam(required = false, defaultValue = "ko") language: String,
@@ -110,16 +110,6 @@ class AcademicsController(
110110
@RequestPart newAttachments: List<MultipartFile>?
111111
) = academicsService.updateDegreeRequirements(language, request, newAttachments)
112112

113-
@AuthenticatedStaff
114-
@PostMapping("/{studentType}/scholarshipDetail")
115-
fun createScholarshipDetail(
116-
@PathVariable studentType: String,
117-
@Valid @RequestBody
118-
request: ScholarshipDto
119-
): ResponseEntity<ScholarshipDto> {
120-
return ResponseEntity.ok(academicsService.createScholarshipDetail(studentType, request))
121-
}
122-
123113
@GetMapping("/{studentType}/scholarship")
124114
fun readAllScholarship(
125115
@RequestParam(required = false, defaultValue = "ko") language: String,
@@ -128,6 +118,7 @@ class AcademicsController(
128118
return ResponseEntity.ok(academicsService.readAllScholarship(language, studentType))
129119
}
130120

121+
@Deprecated(message = "Use V2 API")
131122
@GetMapping("/scholarship/{scholarshipId}")
132123
fun getScholarship(
133124
@PathVariable scholarshipId: Long

src/main/kotlin/com/wafflestudio/csereal/core/academics/api/v2/AcademicsController.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.wafflestudio.csereal.core.academics.api.v2
22

33
import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
4+
import com.wafflestudio.csereal.core.academics.api.req.CreateScholarshipReq
5+
import com.wafflestudio.csereal.core.academics.api.req.UpdateScholarshipPageReq
6+
import com.wafflestudio.csereal.core.academics.api.req.UpdateScholarshipReq
47
import com.wafflestudio.csereal.core.academics.dto.GroupedCourseDto
8+
import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto
59
import com.wafflestudio.csereal.core.academics.service.AcademicsService
610
import jakarta.validation.Valid
711
import org.springframework.web.bind.annotation.*
@@ -20,8 +24,11 @@ class AcademicsController(
2024
) = academicsService.createCourse(request)
2125

2226
@GetMapping("/courses")
23-
fun readAllGroupedCourses(@RequestParam studentType: String): List<GroupedCourseDto> =
24-
academicsService.readAllGroupedCourses(studentType)
27+
fun readAllGroupedCourses(
28+
@RequestParam studentType: String,
29+
@RequestParam(required = false, defaultValue = "ko") sort: String
30+
): List<GroupedCourseDto> =
31+
academicsService.readAllGroupedCourses(studentType, sort)
2532

2633
@AuthenticatedStaff
2734
@PutMapping("/courses")
@@ -30,4 +37,33 @@ class AcademicsController(
3037
@AuthenticatedStaff
3138
@DeleteMapping("/courses/{code}")
3239
fun deleteCourse(@PathVariable code: String) = academicsService.deleteCourse(code)
40+
41+
@AuthenticatedStaff
42+
@PostMapping("/{studentType}/scholarship")
43+
fun createScholarship(
44+
@PathVariable studentType: String,
45+
@Valid @RequestBody
46+
request: CreateScholarshipReq
47+
) = academicsService.createScholarship(studentType, request)
48+
49+
@GetMapping("/scholarship/{scholarshipId}")
50+
fun getScholarship(
51+
@PathVariable scholarshipId: Long
52+
): Pair<ScholarshipDto, ScholarshipDto> = academicsService.readScholarshipV2(scholarshipId)
53+
54+
@AuthenticatedStaff
55+
@PutMapping("/scholarship")
56+
fun updateScholarship(@RequestBody request: UpdateScholarshipReq) = academicsService.updateScholarship(request)
57+
58+
@AuthenticatedStaff
59+
@DeleteMapping("/scholarship/{scholarshipId}")
60+
fun deleteScholarship(@PathVariable scholarshipId: Long) = academicsService.deleteScholarship(scholarshipId)
61+
62+
@AuthenticatedStaff
63+
@PutMapping("/{studentType}/scholarship")
64+
fun updateScholarshipPage(
65+
@RequestParam(required = false, defaultValue = "ko") language: String,
66+
@PathVariable studentType: String,
67+
@RequestBody request: UpdateScholarshipPageReq
68+
) = academicsService.updateScholarshipPage(language, studentType, request)
3369
}

src/main/kotlin/com/wafflestudio/csereal/core/academics/database/ScholarshipEntity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.wafflestudio.csereal.core.academics.database
22

33
import com.wafflestudio.csereal.common.config.BaseTimeEntity
44
import com.wafflestudio.csereal.common.enums.LanguageType
5-
import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto
65
import jakarta.persistence.*
76

87
@Entity(name = "scholarship")
@@ -13,10 +12,10 @@ class ScholarshipEntity(
1312
@Enumerated(EnumType.STRING)
1413
var language: LanguageType,
1514

16-
val name: String,
15+
var name: String,
1716

1817
@Column(columnDefinition = "text")
19-
val description: String,
18+
var description: String,
2019

2120
@OneToOne(mappedBy = "scholarship", cascade = [CascadeType.ALL], orphanRemoval = true)
2221
var academicsSearch: AcademicsSearchEntity? = null
@@ -27,13 +26,14 @@ class ScholarshipEntity(
2726
fun of(
2827
languageType: LanguageType,
2928
studentType: AcademicsStudentType,
30-
scholarshipDto: ScholarshipDto
29+
name: String,
30+
description: String
3131
): ScholarshipEntity {
3232
return ScholarshipEntity(
3333
language = languageType,
3434
studentType = studentType,
35-
name = scholarshipDto.name,
36-
description = scholarshipDto.description
35+
name = name,
36+
description = description
3737
)
3838
}
3939
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.wafflestudio.csereal.core.academics.database
2+
3+
import com.wafflestudio.csereal.common.config.BaseTimeEntity
4+
import jakarta.persistence.*
5+
6+
@Entity(name = "scholarship_language")
7+
class ScholarshipLanguageEntity(
8+
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL], orphanRemoval = true)
9+
@JoinColumn(name = "korean_id")
10+
val koScholarship: ScholarshipEntity,
11+
12+
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL], orphanRemoval = true)
13+
@JoinColumn(name = "english_id")
14+
val enScholarship: ScholarshipEntity
15+
) : BaseTimeEntity()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.wafflestudio.csereal.core.academics.database
2+
3+
import org.springframework.data.jpa.repository.JpaRepository
4+
5+
interface ScholarshipLanguageRepository : JpaRepository<ScholarshipLanguageEntity, Long> {
6+
fun findByKoScholarship(koScholarshipEntity: ScholarshipEntity): ScholarshipLanguageEntity?
7+
fun findByEnScholarship(enScholarshipEntity: ScholarshipEntity): ScholarshipLanguageEntity?
8+
}

0 commit comments

Comments
 (0)