Skip to content

Commit

Permalink
feat: add the user soft-delete feign request
Browse files Browse the repository at this point in the history
  • Loading branch information
JIUNG9 committed Dec 21, 2023
1 parent 9b95238 commit 0b70cec
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bit.lotte.flower.user.admin.http.feign;

import bloomingblooms.response.CommonResponse;
import com.bit.lotte.flower.user.common.valueobject.StoreManagerStatus;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
Expand All @@ -8,8 +9,7 @@

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class GetUserApplicationByIdRequestImpl implements

@Override
public List<Long> request(StoreManagerStatus storeManagerStatus) {
return feignRequest.getStoreManagerApplications(storeManagerStatus);
return feignRequest.getStoreManagerApplications(storeManagerStatus).getData();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
public class SocialUser extends BaseEntity{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Long oauthId;
private String email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@ public class SocialUserRestController {
private final GetUserLikesCntRequest getUserLikesCntRequest;
private final GetUserCouponCntRequest getUserCouponCntRequest;
private final GetUserInfoServiceImpl getUserInfoServiceImpl;
private final SocialUserLoginManager socialUserLoginManager;
private final SocialUpdateUserService socialUserService;

@PostMapping("/social")
public ResponseEntity<UserLoginDataResponse> userLogin(
@RequestBody UserLoginCommand userLoginCommand) {
UserLoginDataResponse response = socialUserLoginManager.process(userLoginCommand);
return ResponseEntity.ok(response);
}

@PutMapping("/social/phone-number")
public CommonResponse<String> userPhoneNumberUpdate(
Expand All @@ -61,7 +54,6 @@ public CommonResponse<String> updateUserData(@RequestHeader Long userId,
socialUserService.updateUserInfo(userId, command.getNickname(), command.getEmail(),
command.getPhoneNumber());
return CommonResponse.success("업데이트 성공");

}

private UserMypageResponse<UserDataDto> getUserMypageResponse(UserDataDto userDataDto, Long likesCnt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,37 @@

import bloomingblooms.response.CommonResponse;
import com.bit.lotte.flower.user.common.valueobject.UserId;
import com.bit.lotte.flower.user.social.dto.feign.SoftDeleteSocialUserDto;
import com.bit.lotte.flower.user.social.dto.command.UserLoginCommand;
import com.bit.lotte.flower.user.social.dto.response.UserLoginDataResponse;
import com.bit.lotte.flower.user.social.service.SocialUserLoginManager;
import com.bit.lotte.flower.user.social.service.SoftDeleteStrategyService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class UserFeignController {

private final SoftDeleteStrategyService softDeleteStrategyService;
private final SocialUserLoginManager socialUserLoginManager;

@DeleteMapping( "/client/users")
CommonResponse<Boolean> delete(SoftDeleteSocialUserDto<UserId> deleteUserDto){
softDeleteStrategyService.userWithdrawal(deleteUserDto.getSocialId());

@PostMapping("/client/social")
public CommonResponse<UserLoginDataResponse> userLogin(
@RequestBody UserLoginCommand userLoginCommand) {
UserLoginDataResponse response = socialUserLoginManager.process(userLoginCommand);
return CommonResponse.success(response);
}


@PutMapping("/client/users/{userId}")
CommonResponse<Boolean> delete(@PathVariable Long userId) {
softDeleteStrategyService.userWithdrawal(new UserId(userId));
return CommonResponse.success(Boolean.TRUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public SocialUser findUserElseThrowError(Long id) {
throw new SocialUserDomainException("존재하지 않는 회원입니다.");
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.bit.lotte.flower.user.social.mapper.SocialUserMapper;
import com.bit.lotte.flower.user.social.repository.FindSocialUserByLongIdService;
import com.bit.lotte.flower.user.social.repository.SocialUserJpaRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -18,9 +19,22 @@ public class SoftDeleteStrategyService implements UserWithdrawalService<UserId>
@Override
public void userWithdrawal(UserId userId) {
SocialUser socialUser = findSocialUserByLongIdService.findUserElseThrowError(userId.getValue());
SocialUser updatedToDeleted = SocialUserMapper.changeUserStatus(socialUser,Boolean.TRUE);

SocialUser notSoftDeletedUser = getNotSoftDeletedUser(repository
.findAllByOauthId(socialUser.getOauthId()));

SocialUser updatedToDeleted = SocialUserMapper.changeUserStatus(notSoftDeletedUser,
Boolean.TRUE);
repository.save(updatedToDeleted);
}


private SocialUser getNotSoftDeletedUser(List<SocialUser> allSocialUserByOauthId) {

return allSocialUserByOauthId.stream()
.filter(user -> !user.getIsDeleted())
.findFirst()
.orElse(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "init-storemanager-status",url = "${service.auth.domain}")
@FeignClient(name = "init-store-manager-status",url = "${service.auth.domain}")
public interface InitStoreManagerStatusPendingFeignRequest {
@PatchMapping("/admin/store-manager")
@PatchMapping("/client/admin/store-manager")
public void publish(@RequestBody UpdateStoreManagerPendingStausDto dto);
}

0 comments on commit 0b70cec

Please sign in to comment.