Skip to content

Commit

Permalink
fix: fix the Pegeable requestParam
Browse files Browse the repository at this point in the history
  • Loading branch information
JIUNG9 committed Dec 19, 2023
1 parent bd48230 commit fe33e8a
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.bit.lotte.flower.user.admin.dto;


import com.bit.lotte.flower.user.common.valueobject.StoreId;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor

@Getter
public class StoreManagerApplicationData {
private StoreId key;
private String storeManagerName;
private String storeManagerBusinessNumber;
private LocalDateTime requestDate;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bit.lotte.flower.user.admin.dto;
package com.bit.lotte.flower.user.admin.dto.response;

import com.bit.lotte.flower.user.admin.dto.SettlementDto;
import com.bit.lotte.flower.user.admin.dto.StoreDto;
import com.bit.lotte.flower.user.common.valueobject.StoreId;
import java.util.List;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.bit.lotte.flower.user.admin.dto.response;

import com.bit.lotte.flower.user.admin.dto.StoreManagerApplicationData;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class StoreManagerApplicationFormResponse {

private Integer totalCnt;
private List<StoreManagerApplicationData> data;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
package com.bit.lotte.flower.user.admin;
package com.bit.lotte.flower.user.admin.http.controller;

import bloomingblooms.response.CommonResponse;
import com.bit.lotte.flower.user.admin.dto.SettlementResponse;
import com.bit.lotte.flower.user.common.valueobject.StoreId;
import com.bit.lotte.flower.user.admin.dto.response.StoreManagerApplicationFormResponse;
import com.bit.lotte.flower.user.admin.http.message.GetUserApplicationByIdRequest;
import com.bit.lotte.flower.user.admin.service.GetStoreManagerApplicationService;
import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import com.bit.lotte.flower.user.dto.StoreInfoResponse;
import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties.Pageable;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class SystemAdminRestController {

private final GetStoreManagerApplicationService getStoreManagerApplicationService;
private final GetUserApplicationByIdRequest request;

@GetMapping("/admin/store-manager/applications")
public ResponseEntity<StoreManagerApplicationFormResponse> getStoreManagerApplications(
@RequestParam(defaultValue = "ROLE_STORE_MANAGER_PENDING") StoreManagerStatus status,
Pageable pageable) {
List<Long> storeUserListByStatus = request.request(status);
return ResponseEntity.ok(getStoreManagerApplicationService.getApplications(storeUserListByStatus, pageable));

}

//
// @GetMapping("/admin/settlement")
// public CommonResponse<SettlementResponse<StoreId>> getSettlements(
Expand Down Expand Up @@ -45,5 +60,4 @@ public class SystemAdminRestController {
// }



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.bit.lotte.flower.user.admin.http.feign;

import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@FeignClient(name = "get-store-manager-applications", url = "${service.auth.domain}")
public interface GetUserApplicationsByStatusFeignRequest {

@GetMapping("/store-manager/{status}")
public List<Long> getStoreManagerApplications(@PathVariable StoreManagerStatus status);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.bit.lotte.flower.user.admin.http.message;

import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public interface GetUserApplicationByIdRequest {
public List<Long> request(StoreManagerStatus storeManagerStatus);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.bit.lotte.flower.user.admin.http.message;

import com.bit.lotte.flower.user.admin.http.feign.GetUserApplicationsByStatusFeignRequest;
import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class GetUserApplicationByIdRequestImpl implements
GetUserApplicationByIdRequest {

private final GetUserApplicationsByStatusFeignRequest feignRequest;


@Override
public List<Long> request(StoreManagerStatus storeManagerStatus) {
return feignRequest.getStoreManagerApplications(storeManagerStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.bit.lotte.flower.user.admin.service;


import com.bit.lotte.flower.user.admin.dto.StoreManagerApplicationData;
import com.bit.lotte.flower.user.admin.dto.response.StoreManagerApplicationFormResponse;
import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import com.bit.lotte.flower.user.social.repository.FindSocialUserByLongIdService;
import com.bit.lotte.flower.user.store.entity.StoreManager;
import com.bit.lotte.flower.user.store.repository.StoreManagerJpaRepository;
import com.bit.lotte.flower.user.store.service.FindStoreMangerService;
import java.util.ArrayList;
import java.util.List;
import javax.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class GetStoreManagerApplicationService {

private final FindStoreMangerService findStoreMangerService;

@Transactional
public StoreManagerApplicationFormResponse getApplications(List<Long> storeManagerIdList,
Pageable pageable) {

List<StoreManager> storeManagerListByStatus = new ArrayList<>();

for (Long id : storeManagerIdList) {
storeManagerListByStatus.add(findStoreMangerService.findByLongId(id));
}

List < StoreManagerApplicationData > data = mapToData(storeManagerListByStatus);

return StoreManagerApplicationFormResponse.builder().data(data).totalCnt(data.size()).build();

}

public List<StoreManagerApplicationData> mapToData(List<StoreManager> managerList) {
List<StoreManagerApplicationData> applicationDataList = new ArrayList<>();
for (StoreManager storeManager : managerList) {
applicationDataList.add(StoreManagerApplicationData.builder()
.requestDate(storeManager.getUpdatedAt()).storeManagerName(storeManager.getName())
.storeManagerBusinessNumber(storeManager.getBusinessNumberImage()).build());
}
return applicationDataList;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.bit.lotte.flower.user.common.entity;

import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {

@CreatedDate
@Column(name = "created_at")
private LocalDateTime createdAt;

@LastModifiedDate
@Column(name = "updated_at")
private LocalDateTime updatedAt;

@Column(name = "is_deleted")
private Boolean isDeleted;
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bit.lotte.flower.user.store.entity;


import com.bit.lotte.flower.user.common.entity.BaseEntity;
import javax.persistence.Entity;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
Expand All @@ -13,13 +14,12 @@
@AllArgsConstructor
@Getter
@Entity
public class StoreManager {
public class StoreManager extends BaseEntity {

@Id
private Long id;
private String name;
private String email;
private String businessNumberImage;


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import com.bit.lotte.flower.user.store.entity.StoreManager;
import java.util.Optional;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

public interface StoreManagerJpaRepository extends JpaRepository<StoreManager,Long> {
public interface StoreManagerJpaRepository extends JpaRepository<StoreManager, Long> {

public Optional<StoreManager> findByEmail(String email);



}

0 comments on commit fe33e8a

Please sign in to comment.