Skip to content

Commit

Permalink
Api-Release-v0.0.2-26
Browse files Browse the repository at this point in the history
Api-Release-v0.0.2-26
  • Loading branch information
imenuuu committed Jan 22, 2024
2 parents 6d45136 + 89b0617 commit f05666f
Show file tree
Hide file tree
Showing 26 changed files with 238 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-12-07T09:51:10+0900",
date = "2024-01-17T19:31:30+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)"
)
public class AdminNoticeMapperImpl implements AdminNoticeMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-12-07T13:17:18+0900",
date = "2024-01-17T19:31:30+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)"
)
public class OrderMapperImpl implements OrderMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-12-07T13:17:18+0900",
date = "2024-01-17T19:31:30+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 11.0.19 (Oracle Corporation)"
)
public class PaymentMapperImpl implements PaymentMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AdminBannerController {
@Operation(summary = "ADMIN-08-01 배너 업로드")
public CommonResponse<List<BannerRes.BannerList>> uploadBanner(
@RequestPart MultipartFile bannerImage,
@RequestPart("bannerUploadDto") BannerReq.BannerUpload bannerUploadDto
@Parameter(name = "bannerUploadDto", required = true) @RequestPart(value = "bannerUploadDto", required = true) BannerReq.BannerUpload bannerUploadDto
){
return CommonResponse.onSuccess(adminBannerService.uploadBanner(BannerType.CONTENTS, bannerImage, bannerUploadDto));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public CommonResponse<DonationRes.RegularInfoDto> getRegularInfo(){
}



@GetMapping("/{donationId}")
@ApiErrorCodeExample(UserAuthErrorCode.class)
@Operation(summary = "ADMIN-05-02 기부금 상세조회 API", description = "기부금 상세조회 API")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.matchapi.admin.donation.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.matchapi.admin.donation.service.AdminDonationService;
import com.example.matchapi.donation.dto.DonationRes;
import com.example.matchcommon.annotation.ApiErrorCodeExample;
import com.example.matchcommon.reponse.CommonResponse;
import com.example.matchdomain.user.exception.UserAuthErrorCode;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@Tag(name = "ADMIN-05-Donation V2💸 관리자 기부금 관련 API 입니다.", description = "기부금 관련 API 입니다.")
@RequestMapping("/admin/v2/donations")
@RequiredArgsConstructor
public class AdminDonationV2Controller {
private final AdminDonationService adminDonationService;
@GetMapping("/regular")
@ApiErrorCodeExample(UserAuthErrorCode.class)
@Operation(summary = "ADMIN-05-01-01 V2 정기 결제 현황 파악", description = "정기 결제 현황파악")
public CommonResponse<DonationRes.RegularInfoV2Dto> getRegularInfoV2(){
return CommonResponse.onSuccess(adminDonationService.getRegularInfoV2());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ public DonationRes.RegularInfoDto convertToRegularInfoDto(Long beforeCnt, Long u
.beforeMonthRegularAmount(beforeMonthRegularAmount)
.build();
}

public DonationRes.RegularInfoV2Dto convertToRegularInfoV2Dto(Long thisMonthRegularCnt, Long thisMonthOneTimeCnt, Long thisMonthStartCnt) {
return DonationRes.RegularInfoV2Dto
.builder()
.thisMonthRegularCnt(thisMonthRegularCnt)
.thisMonthOneTimeCnt(thisMonthOneTimeCnt)
.thisMonthStartCnt(thisMonthStartCnt)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.example.matchdomain.donation.entity.HistoryImage;
import com.example.matchdomain.donation.entity.RegularPayment;
import com.example.matchdomain.donation.entity.enums.RegularPayStatus;
import com.example.matchdomain.donation.entity.enums.RegularStatus;
import com.example.matchdomain.donation.repository.HistoryImageRepository;
import com.example.matchdomain.project.adaptor.ProjectAdaptor;
import com.example.matchdomain.project.entity.Project;
Expand All @@ -35,8 +36,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static com.example.matchcommon.constants.MatchStatic.FIRST_TIME;
import static com.example.matchcommon.constants.MatchStatic.LAST_TIME;
import static com.example.matchcommon.constants.MatchStatic.*;
import static com.example.matchdomain.donation.entity.enums.DonationStatus.*;

@Service
Expand All @@ -63,6 +63,7 @@ public DonationRes.DonationInfo getDonationInfo() {
int weekendDonationAmount = 0;
int monthlyDonationAmount = 0;
int totalDonationAmount = 0;
int beforeMonthRegularAmount = 0;
for (DonationUser donationUser : donationUsers) {
if(donationUser.getCreatedAt().isAfter(LocalDateTime.parse(localDate+FIRST_TIME))&&donationUser.getCreatedAt().isBefore(LocalDateTime.parse(localDate+LAST_TIME))){
oneDayDonationAmount += donationUser.getPrice();
Expand All @@ -73,10 +74,13 @@ public DonationRes.DonationInfo getDonationInfo() {
if(donationUser.getCreatedAt().isAfter(LocalDateTime.parse(localDate.with(TemporalAdjusters.firstDayOfMonth())+FIRST_TIME))&&donationUser.getCreatedAt().isBefore( LocalDateTime.parse(localDate.with(TemporalAdjusters.lastDayOfMonth())+LAST_TIME))){
monthlyDonationAmount += donationUser.getPrice();
}
if(donationUser.getCreatedAt().isAfter(LocalDateTime.parse(localDate.minusMonths(1)+FIRST_TIME))&&donationUser.getCreatedAt().isBefore(LocalDateTime.parse(localDate+LAST_TIME))){
beforeMonthRegularAmount += donationUser.getPrice();
}
totalDonationAmount += donationUser.getPrice();
}

return new DonationRes.DonationInfo(donationHelper.parsePriceComma(oneDayDonationAmount),donationHelper.parsePriceComma(weekendDonationAmount),donationHelper.parsePriceComma(monthlyDonationAmount), donationHelper.parsePriceComma(totalDonationAmount));
return new DonationRes.DonationInfo(donationHelper.parsePriceComma(oneDayDonationAmount),donationHelper.parsePriceComma(weekendDonationAmount),donationHelper.parsePriceComma(monthlyDonationAmount), donationHelper.parsePriceComma(totalDonationAmount), donationHelper.parsePriceComma(beforeMonthRegularAmount));
}

public DonationRes.DonationDetail getDonationDetail(Long donationId) {
Expand Down Expand Up @@ -246,4 +250,26 @@ public Long countByUserId(Long userId) {
public List<DonationUser> findByUserId(Long userId) {
return donationAdaptor.findByUserId(userId);
}

public DonationRes.RegularInfoV2Dto getRegularInfoV2() {
List<DonationUser> donationUsers = donationAdaptor.getRegularDonationLists();
List<RegularPayment> regularPayments = paymentAdaptor.getRegularInfo();

Long thisMonthRegularCnt = 0L, thisMonthOneTimeCnt = 0L, thisMonthStartCnt = 0L;
LocalDate now = LocalDate.now();
for (DonationUser donationUser : donationUsers){
if(now.getMonthValue() == donationUser.getCreatedAt().getMonthValue() && now.getYear() == donationUser.getCreatedAt().getYear()){
if(donationUser.getRegularStatus().equals(RegularStatus.REGULAR)) thisMonthRegularCnt++;
else thisMonthOneTimeCnt++;
}
}

for (RegularPayment regularPayment : regularPayments){
if(now.getMonthValue() == regularPayment.getCreatedAt().getMonthValue() && now.getYear() == regularPayment.getCreatedAt().getYear()){
thisMonthStartCnt++;
}
}

return adminDonationConverter.convertToRegularInfoV2Dto(thisMonthRegularCnt, thisMonthOneTimeCnt, thisMonthStartCnt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AdminKeywordController {
@GetMapping("")
@Operation(summary = "07-01 ADMIN Keyword 추천 조회🔎")
public CommonResponse<List<KeywordRes.KeywordList>> getKeywordList(){
return CommonResponse.onSuccess(keywordService.getKeywordList());
return CommonResponse.onSuccess(adminKeywordService.getKeywordList());
}

@PostMapping("")
Expand All @@ -41,4 +41,12 @@ public CommonResponse<String> deleteKeyword(@PathVariable Long keywordId){
adminKeywordService.deleteKeyword(keywordId);
return CommonResponse.onSuccess("삭제 성공");
}

@PatchMapping("/{keywordId}")
@Operation(summary = "07-04 ADMIN Keyword 수정🔎")
public CommonResponse<String> patchKeyword(@PathVariable Long keywordId,
@RequestParam("keyword") String keyword){
adminKeywordService.patchKeyword(keywordId,keyword);
return CommonResponse.onSuccess("수정 성공");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.matchapi.admin.keyword.dto.AdminKeywordReq;
import com.example.matchapi.keword.converter.KeywordConverter;
import com.example.matchapi.keword.dto.KeywordRes;
import com.example.matchdomain.keyword.adaptor.KeywordAdaptor;
import com.example.matchdomain.keyword.entity.SearchKeyword;
import com.example.matchdomain.keyword.repository.SearchKeywordRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +23,7 @@ public class AdminKeywordService {
private final SearchKeywordRepository searchKeywordRepository;
private final KeywordConverter keywordConverter;
private final AdminKeywordConverter adminKeywordConverter;
private final KeywordAdaptor keywordAdaptor;

@Transactional
@CachePut(cacheNames = "keywordList", key = "'all'", cacheManager = "ehcacheManager")
Expand All @@ -45,4 +47,21 @@ public List<KeywordRes.KeywordList> cachingKeywordList(){
public void deleteKeyword(Long keywordId) {
searchKeywordRepository.deleteById(keywordId);
}

@CacheEvict(cacheNames = "keywordList", key = "'all'",cacheManager = "ehcacheManager")
@Transactional
public void patchKeyword(Long keywordId, String keyword) {
SearchKeyword searchKeyword = keywordAdaptor.findByKeywordId(keywordId);
searchKeyword.setKeyword(keyword);
keywordAdaptor.save(searchKeyword);
}

public List<KeywordRes.KeywordList> getKeywordList() {
List<SearchKeyword> searchKeywords = searchKeywordRepository.findAllByOrderByPriorityAsc();
List<KeywordRes.KeywordList> keywordLists = new ArrayList<>();
searchKeywords.forEach(
result -> keywordLists.add(keywordConverter.convertToKeywordList(result))
);
return keywordLists;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import com.example.matchapi.admin.notice.mapper.AdminNoticeMapper;
import com.example.matchapi.admin.notice.service.AdminNoticeService;
import com.example.matchapi.common.model.ContentsList;
import com.example.matchapi.notice.dto.NoticeRes;
import com.example.matchcommon.reponse.CommonResponse;
import com.example.matchcommon.reponse.PageResponse;
import com.example.matchdomain.notice.entity.Notice;
import com.example.matchdomain.notice.entity.NoticeContent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

Expand All @@ -30,6 +33,14 @@ public CommonResponse<String> uploadNoticeList(@Valid @RequestBody NoticeUploadR
return CommonResponse.onSuccess("업로드 성공");
}

@GetMapping("")
@Operation(summary = "ADMIN-10-02 공지사항 조회")
public CommonResponse<PageResponse<List<NoticeRes.NoticeList>>> getNoticeList(
@RequestParam(value = "page", defaultValue = "0") int page,
@RequestParam(value = "size", defaultValue = "10") int size){
return CommonResponse.onSuccess(adminNoticeService.getNoticeList(page,size));
}

@DeleteMapping("/{noticeId}")
@Operation(summary = "ADMIN-10-02 공지사항 삭제")
public CommonResponse<String> deleteNotice(@PathVariable Long noticeId){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.example.matchapi.admin.notice.service;

import com.example.matchapi.notice.converter.NoticeConverter;
import com.example.matchapi.notice.dto.NoticeRes;
import com.example.matchcommon.reponse.PageResponse;
import com.example.matchdomain.notice.adaptor.NoticeAdapter;
import com.example.matchdomain.notice.adaptor.NoticeContentAdaptor;
import com.example.matchdomain.notice.entity.Notice;
Expand All @@ -9,6 +12,7 @@
import com.example.matchinfrastructure.config.s3.S3UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -21,6 +25,7 @@ public class AdminNoticeService {
private final NoticeContentAdaptor noticeContentAdaptor;
private final NoticeAdapter noticeAdapter;
private final S3UploadService s3UploadService;
private final NoticeConverter noticeConverter;

@CacheEvict(value = "noticeCache", allEntries = true, cacheManager = "ehcacheManager")
public void uploadNoticeList(List<NoticeContent> noticeContents, Notice notice) {
Expand All @@ -41,4 +46,9 @@ public void deleteNotice(Long noticeId) {
}
noticeAdapter.delete(notice);
}

public PageResponse<List<NoticeRes.NoticeList>> getNoticeList(int page, int size) {
Page<Notice> notices = noticeAdapter.getNoticeList(page,size);
return new PageResponse<>(notices.isLast(), notices.getTotalElements(), noticeConverter.convertToNoticeList(notices.getContent()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public CommonResponse<String> imgUpload(
String url = s3UploadService.uploadOneImg(uploadFolder.getFolder(), imgFile);
return CommonResponse.onSuccess(url);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private void configureAuthorizationRequests(HttpSecurity httpSecurity) throws Ex
.antMatchers("/payments/validate").permitAll()
.antMatchers("/payments/info").permitAll()
.antMatchers("/test/**").permitAll()
.antMatchers("/actuator").permitAll()
.and()
.apply(new JwtSecurityConfig(jwtService));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public GroupedOpenApi v2ApiDocs() {
@Bean
public GroupedOpenApi adminApiDocs(){
String[] paths = { "/admin/**" };
String[] excludesPath = {"/admin/v2/**"};


return GroupedOpenApi.builder()
.group("Docs for ADMIN API")
Expand All @@ -80,6 +82,17 @@ public GroupedOpenApi adminApiDocs(){
.build();
}

@Bean
public GroupedOpenApi adminV2ApiDocs(){
String[] paths = { "/admin/v2/**" };

return GroupedOpenApi.builder()
.group("Docs for ADMIN V2 API")
.pathsToMatch(paths)
.addOperationCustomizer(customize())
.build();
}

@Bean
public OpenAPI openAPI() {
Info info = new Info()
Expand Down
16 changes: 4 additions & 12 deletions Match-Api/src/main/java/com/example/matchapi/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
Expand Down Expand Up @@ -57,18 +58,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
.setCacheControl(cacheControl);
}

@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new MappingJackson2HttpMessageConverter());
}

@Bean
public MultipartResolver multipartResolver() {
return new StandardServletMultipartResolver();
public CommonsMultipartResolver multipartResolver() {
return new CommonsMultipartResolver();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public static class DonationInfo {
private String monthDonation;

private String totalDonation;

private String beforeMonthDonation;
}

@Getter
Expand Down Expand Up @@ -427,4 +429,17 @@ public static class RegularInfoDto {

private String beforeMonthRegularAmount;
}

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class RegularInfoV2Dto {
private Long thisMonthRegularCnt;

private Long thisMonthOneTimeCnt;

private Long thisMonthStartCnt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private EventRes.EventList convertToEventListDetail(Event result) {
.title(result.getTitle())
.thumbnail(result.getThumbnail())
.smallTitle(result.getSmallTitle())
.eventType(result.getEventType())
.eventStatus(timeHelper.checkFinishStatus(result.getEventEndDate()))
.startDate(result.getEventStartDate())
.endDate(result.getEventEndDate())
Expand Down
Loading

0 comments on commit f05666f

Please sign in to comment.