Skip to content

Commit

Permalink
feat: api 권한 설정 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeryboy authored Sep 12, 2023
1 parent 028f52d commit 8b9d383
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.about.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.about.dto.AboutDto
import com.wafflestudio.csereal.core.about.dto.CompanyDto
import com.wafflestudio.csereal.core.about.dto.FutureCareersPage
Expand All @@ -19,42 +20,43 @@ class AboutController(
// postType: directions / name -> by-public-transit, by-car, from-far-away

// Todo: 전체 image, file, 학부장 인사말(greetings) signature
@AuthenticatedStaff
@PostMapping("/{postType}")
fun createAbout(
@PathVariable postType: String,
@Valid @RequestPart("request") request: AboutDto,
@RequestPart("mainImage") mainImage: MultipartFile?,
@RequestPart("attachments") attachments: List<MultipartFile>?,
) : ResponseEntity<AboutDto> {
): ResponseEntity<AboutDto> {
return ResponseEntity.ok(aboutService.createAbout(postType, request, mainImage, attachments))
}

// read 목록이 하나
@GetMapping("/{postType}")
fun readAbout(
@PathVariable postType: String,
) : ResponseEntity<AboutDto> {
): ResponseEntity<AboutDto> {
return ResponseEntity.ok(aboutService.readAbout(postType))
}

@GetMapping("/student-clubs")
fun readAllClubs() : ResponseEntity<List<AboutDto>> {
fun readAllClubs(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllClubs())
}

@GetMapping("/facilities")
fun readAllFacilities() : ResponseEntity<List<AboutDto>> {
fun readAllFacilities(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllFacilities())
}


@GetMapping("/directions")
fun readAllDirections() : ResponseEntity<List<AboutDto>> {
fun readAllDirections(): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.readAllDirections())
}
@GetMapping("/future-careers")
fun readFutureCareers(): ResponseEntity<FutureCareersPage> {
return ResponseEntity.ok(aboutService.readFutureCareers())
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.academics.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.academics.dto.*
import com.wafflestudio.csereal.core.academics.service.AcademicsService
import com.wafflestudio.csereal.core.academics.dto.ScholarshipDto
Expand All @@ -13,13 +14,14 @@ import org.springframework.web.multipart.MultipartFile
class AcademicsController(
private val academicsService: AcademicsService
) {
@AuthenticatedStaff
@PostMapping("/{studentType}/{postType}")
fun createAcademics(
@PathVariable studentType: String,
@PathVariable postType: String,
@Valid @RequestPart("request") request: AcademicsDto,
@RequestPart("attachments") attachments: List<MultipartFile>?
) : ResponseEntity<AcademicsDto> {
): ResponseEntity<AcademicsDto> {
return ResponseEntity.ok(academicsService.createAcademics(studentType, postType, request, attachments))
}

Expand All @@ -39,12 +41,13 @@ class AcademicsController(
}

//교과목 정보
@AuthenticatedStaff
@PostMapping("/{studentType}/course")
fun createCourse(
@PathVariable studentType: String,
@Valid @RequestPart("request") request: CourseDto,
@RequestPart("attachments") attachments: List<MultipartFile>?,
) : ResponseEntity<CourseDto> {
): ResponseEntity<CourseDto> {
return ResponseEntity.ok(academicsService.createCourse(studentType, request, attachments))
}

Expand All @@ -63,15 +66,16 @@ class AcademicsController(
}

@GetMapping("/undergraduate/general-studies-requirements")
fun readGeneralStudiesRequirements() : ResponseEntity<GeneralStudiesPageResponse> {
fun readGeneralStudiesRequirements(): ResponseEntity<GeneralStudiesPageResponse> {
return ResponseEntity.ok(academicsService.readGeneralStudies())
}

@AuthenticatedStaff
@PostMapping("/{studentType}/scholarshipDetail")
fun createScholarshipDetail(
@PathVariable studentType: String,
@Valid @RequestBody request: ScholarshipDto,
) : ResponseEntity<ScholarshipDto> {
): ResponseEntity<ScholarshipDto> {
return ResponseEntity.ok(academicsService.createScholarshipDetail(studentType, request))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.admin.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.admin.dto.*
import com.wafflestudio.csereal.core.admin.service.AdminService
import org.springframework.http.ResponseEntity
Expand All @@ -15,27 +16,31 @@ import org.springframework.web.bind.annotation.RestController
class AdminController(
private val adminService: AdminService
) {
@AuthenticatedStaff
@GetMapping("/slide")
fun readAllSlides(
@RequestParam(required = false, defaultValue = "0") pageNum: Long
): ResponseEntity<List<SlideResponse>> {
return ResponseEntity.ok(adminService.readAllSlides(pageNum))
}

@AuthenticatedStaff
@PatchMapping("/slide")
fun unSlideManyNews(
@RequestBody request: NewsIdListRequest
) {
adminService.unSlideManyNews(request.newsIdList)
}

@AuthenticatedStaff
@GetMapping("/important")
fun readAllImportants(
@RequestParam(required = false, defaultValue = "0") pageNum: Long
): ResponseEntity<List<ImportantResponse>> {
return ResponseEntity.ok(adminService.readAllImportants(pageNum))
}

@AuthenticatedStaff
@PatchMapping("/important")
fun makeNotImportants(
@RequestBody request: ImportantRequest
Expand All @@ -44,4 +49,4 @@ class AdminController(
}


}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.admissions.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.admissions.dto.AdmissionsDto
import com.wafflestudio.csereal.core.admissions.service.AdmissionsService
import jakarta.validation.Valid
Expand All @@ -17,34 +18,34 @@ import org.springframework.web.bind.annotation.RestController
class AdmissionsController(
private val admissionsService: AdmissionsService
) {
@AuthenticatedStaff
@PostMapping("/undergraduate/{postType}")
fun createUndergraduateAdmissions(
@PathVariable postType: String,
@Valid @RequestBody request: AdmissionsDto
) : AdmissionsDto {
): AdmissionsDto {
return admissionsService.createUndergraduateAdmissions(postType, request)
}

@AuthenticatedStaff
@PostMapping("/graduate")
fun createGraduateAdmissions(
@Valid @RequestBody request: AdmissionsDto
) : AdmissionsDto {
): AdmissionsDto {
return admissionsService.createGraduateAdmissions(request)
}

@GetMapping("/undergraduate/{postType}")
fun readUndergraduateAdmissions(
@PathVariable postType: String
) : ResponseEntity<AdmissionsDto> {
): ResponseEntity<AdmissionsDto> {
return ResponseEntity.ok(admissionsService.readUndergraduateAdmissions(postType))
}

@GetMapping("/graduate")
fun readGraduateAdmissions() : ResponseEntity<AdmissionsDto> {
fun readGraduateAdmissions(): ResponseEntity<AdmissionsDto> {
return ResponseEntity.ok(admissionsService.readGraduateAdmissions())
}




}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.member.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.member.dto.ProfessorDto
import com.wafflestudio.csereal.core.member.dto.ProfessorPageDto
import com.wafflestudio.csereal.core.member.dto.SimpleProfessorDto
Expand All @@ -14,6 +15,7 @@ class ProfessorController(
private val professorService: ProfessorService
) {

@AuthenticatedStaff
@PostMapping
fun createProfessor(
@RequestPart("request") createProfessorRequest: ProfessorDto,
Expand All @@ -37,6 +39,7 @@ class ProfessorController(
return ResponseEntity.ok(professorService.getInactiveProfessors())
}

@AuthenticatedStaff
@PatchMapping("/{professorId}")
fun updateProfessor(
@PathVariable professorId: Long,
Expand All @@ -46,6 +49,7 @@ class ProfessorController(
return ResponseEntity.ok(professorService.updateProfessor(professorId, updateProfessorRequest, mainImage))
}

@AuthenticatedStaff
@DeleteMapping("/{professorId}")
fun deleteProfessor(@PathVariable professorId: Long): ResponseEntity<Any> {
professorService.deleteProfessor(professorId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.member.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.member.dto.SimpleStaffDto
import com.wafflestudio.csereal.core.member.dto.StaffDto
import com.wafflestudio.csereal.core.member.service.StaffService
Expand All @@ -13,12 +14,13 @@ class StaffController(
private val staffService: StaffService
) {

@AuthenticatedStaff
@PostMapping
fun createStaff(
@RequestPart("request") createStaffRequest: StaffDto,
@RequestPart("mainImage") mainImage: MultipartFile?,
): ResponseEntity<StaffDto> {
return ResponseEntity.ok(staffService.createStaff(createStaffRequest,mainImage))
return ResponseEntity.ok(staffService.createStaff(createStaffRequest, mainImage))
}

@GetMapping("/{staffId}")
Expand All @@ -31,6 +33,7 @@ class StaffController(
return ResponseEntity.ok(staffService.getAllStaff())
}

@AuthenticatedStaff
fun updateStaff(
@PathVariable staffId: Long,
@RequestPart("request") updateStaffRequest: StaffDto,
Expand All @@ -39,6 +42,7 @@ class StaffController(
return ResponseEntity.ok(staffService.updateStaff(staffId, updateStaffRequest, mainImage))
}

@AuthenticatedStaff
@DeleteMapping("/{staffId}")
fun deleteStaff(@PathVariable staffId: Long): ResponseEntity<Any> {
staffService.deleteStaff(staffId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wafflestudio.csereal.core.news.api

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.news.dto.NewsDto
import com.wafflestudio.csereal.core.news.dto.NewsSearchResponse
import com.wafflestudio.csereal.core.news.service.NewsService
Expand Down Expand Up @@ -34,6 +35,7 @@ class NewsController(
return ResponseEntity.ok(newsService.readNews(newsId))
}

@AuthenticatedStaff
@PostMapping
fun createNews(
@Valid @RequestPart("request") request: NewsDto,
Expand All @@ -43,6 +45,7 @@ class NewsController(
return ResponseEntity.ok(newsService.createNews(request, mainImage, attachments))
}

@AuthenticatedStaff
@PatchMapping("/{newsId}")
fun updateNews(
@PathVariable newsId: Long,
Expand All @@ -53,13 +56,15 @@ class NewsController(
return ResponseEntity.ok(newsService.updateNews(newsId, request, mainImage, attachments))
}

@AuthenticatedStaff
@DeleteMapping("/{newsId}")
fun deleteNews(
@PathVariable newsId: Long
) {
newsService.deleteNews(newsId)
}

@AuthenticatedStaff
@PostMapping("/tag")
fun enrollTag(
@RequestBody tagName: Map<String, String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class NoticeController(
return ResponseEntity.ok(noticeService.createNotice(request, attachments))
}

@AuthenticatedStaff
@PatchMapping("/{noticeId}")
fun updateNotice(
@PathVariable noticeId: Long,
Expand All @@ -66,27 +67,31 @@ class NoticeController(
return ResponseEntity.ok(noticeService.updateNotice(noticeId, request, attachments))
}

@AuthenticatedStaff
@DeleteMapping("/{noticeId}")
fun deleteNotice(
@PathVariable noticeId: Long
) {
noticeService.deleteNotice(noticeId)
}

@AuthenticatedStaff
@PatchMapping
fun unpinManyNotices(
@RequestBody request: NoticeIdListRequest
) {
noticeService.unpinManyNotices(request.idList)
}

@AuthenticatedStaff
@DeleteMapping
fun deleteManyNotices(
@RequestBody request: NoticeIdListRequest
) {
noticeService.deleteManyNotices(request.idList)
}

@AuthenticatedStaff
@PostMapping("/tag")
fun enrollTag(
@RequestBody tagName: Map<String, String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile
class ResearchController(
private val researchService: ResearchService
) {
@AuthenticatedStaff
@PostMapping
fun createResearchDetail(
@Valid @RequestPart("request") request: ResearchDto,
Expand All @@ -35,6 +36,7 @@ class ResearchController(
return ResponseEntity.ok(researchService.readAllResearchCenters())
}

@AuthenticatedStaff
@PatchMapping("/{researchId}")
fun updateResearchDetail(
@PathVariable researchId: Long,
Expand All @@ -45,6 +47,7 @@ class ResearchController(
return ResponseEntity.ok(researchService.updateResearchDetail(researchId, request, mainImage, attachments))
}

@AuthenticatedStaff
@PostMapping("/lab")
fun createLab(
@Valid @RequestPart("request") request: LabDto,
Expand Down Expand Up @@ -77,4 +80,4 @@ class ResearchController(
): ResponseEntity<LabDto> {
return ResponseEntity.ok(researchService.updateLab(labId, request, pdf))
}
}
}
Loading

0 comments on commit 8b9d383

Please sign in to comment.