-
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.
Browse files
Browse the repository at this point in the history
[FEAT] 대학교 api 구현
- Loading branch information
Showing
27 changed files
with
1,115 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/umc/networkingService/domain/mascot/entity/MascotType.java
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,14 @@ | ||
package com.umc.networkingService.domain.mascot.entity; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum MascotType { | ||
UU("마스코트 종류 U"), | ||
MM("마스코트 종류 M"), | ||
CC("마스코트 종류 C"); | ||
|
||
private final String description; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/umc/networkingService/domain/mascot/repository/MascotRepository.java
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,13 @@ | ||
package com.umc.networkingService.domain.mascot.repository; | ||
|
||
import com.umc.networkingService.domain.mascot.entity.Mascot; | ||
import com.umc.networkingService.domain.mascot.entity.MascotType; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface MascotRepository extends JpaRepository<Mascot, UUID> { | ||
Optional<Mascot> findByStartLevelAndType(int startLevel, MascotType type); | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/umc/networkingService/domain/mascot/service/MascotService.java
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,8 @@ | ||
package com.umc.networkingService.domain.mascot.service; | ||
|
||
import com.umc.networkingService.domain.mascot.entity.Mascot; | ||
import com.umc.networkingService.domain.mascot.entity.MascotType; | ||
|
||
public interface MascotService { | ||
Mascot getMascotByStartLevel(int level, MascotType type); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/umc/networkingService/domain/mascot/service/MascotServiceImpl.java
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,27 @@ | ||
package com.umc.networkingService.domain.mascot.service; | ||
|
||
import com.umc.networkingService.domain.mascot.entity.Mascot; | ||
import com.umc.networkingService.domain.mascot.entity.MascotType; | ||
import com.umc.networkingService.domain.mascot.repository.MascotRepository; | ||
import com.umc.networkingService.global.common.exception.ErrorCode; | ||
import com.umc.networkingService.global.common.exception.RestApiException; | ||
import com.umc.networkingService.global.common.exception.code.MascotErrorCode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MascotServiceImpl implements MascotService{ | ||
|
||
private final MascotRepository mascotRepository; | ||
|
||
@Override | ||
public Mascot getMascotByStartLevel(int level, MascotType type) { | ||
Optional<Mascot> optionalMascot = mascotRepository.findByStartLevelAndType(level, type); | ||
return optionalMascot.orElseThrow(() -> new RestApiException(MascotErrorCode.EMPTY_MASCOT_LEVEL)); | ||
} | ||
} | ||
|
||
|
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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/umc/networkingService/domain/member/service/MemberPointService.java
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,7 @@ | ||
package com.umc.networkingService.domain.member.service; | ||
|
||
import com.umc.networkingService.domain.member.entity.MemberPoint; | ||
|
||
public interface MemberPointService { | ||
MemberPoint saveEntity(MemberPoint memberPoint); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/umc/networkingService/domain/member/service/MemberPointServiceImpl.java
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.umc.networkingService.domain.member.service; | ||
|
||
import com.umc.networkingService.domain.member.entity.MemberPoint; | ||
import com.umc.networkingService.domain.member.repository.MemberPointRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberPointServiceImpl implements MemberPointService{ | ||
private final MemberPointRepository memberPointRepository; | ||
|
||
@Override | ||
@Transactional | ||
public MemberPoint saveEntity(MemberPoint memberPoint) { | ||
return memberPointRepository.save(memberPoint); | ||
} | ||
} |
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
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
69 changes: 69 additions & 0 deletions
69
...ava/com/umc/networkingService/domain/university/controller/StaffUniversityController.java
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,69 @@ | ||
package com.umc.networkingService.domain.university.controller; | ||
|
||
import com.umc.networkingService.global.common.base.BaseResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.umc.networkingService.config.security.auth.CurrentMember; | ||
import com.umc.networkingService.domain.member.entity.Member; | ||
import com.umc.networkingService.domain.member.entity.PointType; | ||
import com.umc.networkingService.domain.university.dto.request.UniversityRequest; | ||
import com.umc.networkingService.domain.university.dto.response.UniversityResponse; | ||
import com.umc.networkingService.domain.university.service.UniversityServiceImpl; | ||
import jakarta.validation.Valid; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Slf4j | ||
@Tag(name = "운영진 대학교 API", description = "운영진용 대학교 관련 API") | ||
@RestController | ||
@Validated | ||
@RequestMapping("/staff/universities") | ||
@RequiredArgsConstructor | ||
public class StaffUniversityController { | ||
|
||
private final UniversityServiceImpl universityService; | ||
|
||
@Operation(summary = "학교 생성하기 API",description = "학교 생성하기 API") | ||
@PostMapping("") | ||
public BaseResponse<UniversityResponse.UniversityId> | ||
createUniversity( | ||
@CurrentMember Member member, | ||
@RequestBody @Valid UniversityRequest.universityInfo request | ||
) | ||
{ | ||
return BaseResponse.onSuccess(universityService.createUniversity(request)); | ||
} | ||
|
||
@Operation(summary = "학교 삭제하기 API",description = "학교 삭제하기 API") | ||
@DeleteMapping("/{universityId}") | ||
public BaseResponse<UniversityResponse.UniversityId> | ||
deleteUniversity( | ||
@CurrentMember Member member, | ||
@PathVariable @Valid UUID universityId | ||
){ | ||
return BaseResponse.onSuccess(universityService.deleteUniversity(universityId)); | ||
} | ||
|
||
@Operation(summary = "학교 정보 수정하기 API",description = "학교 정보 수정하기 API") | ||
@PatchMapping("/{universityId}") | ||
public BaseResponse<UniversityResponse.UniversityId> | ||
patchUniversity( | ||
@CurrentMember Member member, | ||
@PathVariable @Valid UUID universityId, | ||
@RequestBody @Valid UniversityRequest.universityInfo request | ||
){ | ||
return BaseResponse.onSuccess(universityService.patchUniversity(request, universityId)); | ||
} | ||
|
||
} | ||
|
||
|
108 changes: 108 additions & 0 deletions
108
...ain/java/com/umc/networkingService/domain/university/controller/UniversityController.java
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,108 @@ | ||
package com.umc.networkingService.domain.university.controller; | ||
|
||
import com.umc.networkingService.config.security.auth.CurrentMember; | ||
import com.umc.networkingService.domain.member.entity.Member; | ||
import com.umc.networkingService.domain.member.entity.PointType; | ||
import com.umc.networkingService.domain.university.dto.request.UniversityRequest; | ||
import com.umc.networkingService.domain.university.dto.response.UniversityResponse; | ||
import com.umc.networkingService.domain.university.service.UniversityServiceImpl; | ||
import com.umc.networkingService.global.common.base.BaseResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Slf4j | ||
@Tag(name = "대학교 API", description = "일반 유저용 대학교 관련 API") | ||
@RestController | ||
@Validated | ||
@RequestMapping("/universities") | ||
@RequiredArgsConstructor | ||
public class UniversityController { | ||
|
||
private final UniversityServiceImpl universityService; | ||
|
||
@Operation(summary = "전체 학교 조회 API",description = "전체 학교 조회 API") | ||
@GetMapping("") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공") | ||
}) | ||
public BaseResponse<UniversityResponse.JoinUniversities> | ||
joinUniversityList( | ||
@CurrentMember Member member //학교 많으면 추후에 페이징 처리하기 | ||
){ | ||
return BaseResponse.onSuccess(universityService.joinUniversityList()); | ||
} | ||
|
||
@Operation(summary = "우리 학교 세부 정보 조회 API",description = "우리 학교 정보 조회 API") | ||
@GetMapping("/details") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공") | ||
}) | ||
public BaseResponse<UniversityResponse.joinUniversityDetail> | ||
joinUniversityDetail( | ||
@CurrentMember Member member | ||
){ | ||
return BaseResponse.onSuccess(universityService.joinUniversityDetail(member)); | ||
} | ||
|
||
@Operation(summary = "전체 학교 랭킹 조회 API",description = "전체 학교 랭킹 조회 API") | ||
@GetMapping("/ranks") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공") | ||
}) | ||
public BaseResponse<UniversityResponse.JoinUniversityRanks> | ||
joinUniversityRanking( | ||
){ | ||
return BaseResponse.onSuccess(universityService.joinUniversityRankingList()); | ||
} | ||
|
||
@Operation(summary = "우리 학교 전체 기여도 랭킹 조회 API",description = "학교 전체 기여도 조회 API") | ||
@GetMapping("/members") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공") | ||
}) | ||
public BaseResponse<UniversityResponse.JoinContributionRanks> | ||
joinUniversityContribution( | ||
@CurrentMember Member member | ||
){ | ||
return BaseResponse.onSuccess(universityService.joinContributionRankingList(member)); | ||
} | ||
|
||
@Operation(summary = "우리 학교 마스코트 조회 API",description = "학교 마스코트 조회 API") | ||
@GetMapping("/mascot") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공"), | ||
@ApiResponse(responseCode = "BRANCH001", description = "지부가 존재하지 않음") | ||
}) | ||
public BaseResponse<UniversityResponse.joinUniversityMascot> | ||
joinUniversityMascot( | ||
@CurrentMember Member member | ||
){ | ||
return BaseResponse.onSuccess(universityService.joinUniversityMascot(member)); | ||
} | ||
|
||
@Operation(summary = "우리 학교 마스코트 먹이주기 API",description = "학교 마스코트 먹이주기 API") | ||
@PostMapping("/mascot") | ||
@ApiResponses( value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공"), | ||
@ApiResponse(responseCode = "MEMBER008", description = "마스코트에 줄 포인트가 충분하지 않음") | ||
}) | ||
public BaseResponse<UniversityResponse.JoinUniversityMascotFeed> | ||
postMascotPoint( | ||
@CurrentMember Member member, | ||
@RequestParam @Valid PointType pointType | ||
){ | ||
return BaseResponse.onSuccess(universityService.feedUniversityMascot(member, pointType)); //현재 대학 포인트 | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.