Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV TO MAIN#1695 #1700

Merged
merged 65 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c051c45
[FE] FIX: debounce 적용해 코인 내역 페이지 필터 변경시 불필요한 api 요청 보내지 않게 수정 #1677
jnkeniaem Aug 13, 2024
ac7b11e
[FE] FIX: 공유사물함 코드 복사, 클럽 멤버리스트와 아이템 사용 내역 불러오기에서 debouncing 적용#1677
jnkeniaem Aug 13, 2024
a6b4e1d
Merge branch 'dev' of https://github.com/innovationacademy-kr/Cabi in…
jnkeniaem Aug 13, 2024
e9da749
[FE] FIX: AvailablePage에서 필요없는 코드 삭제#1677
jnkeniaem Aug 13, 2024
91e58e9
[BE] local 42auth key refresh
chyo1 Aug 20, 2024
37b3c9b
[BE] FIX: local config fix
chyo1 Aug 20, 2024
47a35ef
[FE] FIX: UserCabinetInfoArea.tsx에서 font color 값 문법적 에러 해결 #1677
jnkeniaem Aug 20, 2024
fb876b1
[FE] FIX: z-index 삭제해서 포인트 컬러 카드에서 색 선택했을때 화면 스타일 카드도 그림자 적용#1682
jnkeniaem Aug 20, 2024
4b6ddf4
[FE] REMOVE: 프로필 연장권 카드 관련 파일 삭제#1682
jnkeniaem Aug 20, 2024
5e11226
Merge pull request #1683 from innovationacademy-kr/fe/dev/fix_point_c…
jnkeniaem Aug 20, 2024
92a5c31
[FE] FIX: 공유코드 클릭했을때 debounce 함수 호출시 key 이름에서 time 내용 삭제#1677
jnkeniaem Aug 20, 2024
048e6c9
[FE] REFACT: getClubInfo와 clickMoreButton의 중복된 setTimeout clickMoreBu…
jnkeniaem Sep 4, 2024
9027033
[FE] FIX: 멤버 더보기 버튼 클릭시 page 변경하는 부분에 debounce 적용#1677
jnkeniaem Sep 6, 2024
3030dfe
[FE] FIX: update local 42auth key#1677
jnkeniaem Sep 6, 2024
7a25cc6
Merge pull request #1679 from innovationacademy-kr/fe/dev/fix_coinlog…
jnkeniaem Sep 6, 2024
43debf7
[BE] fcm 테스트를 위한 dev 환경 설정 임시 변경
chyo1 Sep 13, 2024
5c68481
[BE] fcm 테스트를 위한 dev 환경 설정 변경 후 원상복구
chyo1 Sep 13, 2024
5276f4f
[FE] BUG: 모달에서 링크로 이동 시 모든 창을 닫도록 closeAll 추가 #1668
wet6123 Sep 24, 2024
9539f9c
Merge pull request #1689 from innovationacademy-kr/fe/dev/bug_backgro…
junyoung2015 Oct 8, 2024
9720bc6
[FE] FEAT: MAIN화면 재화 소개 추가#1681 (#1686)
jimchoi9 Oct 8, 2024
919b305
[BE] 이용 정지 최대 기한 180일로 조정
chyo1 Oct 8, 2024
3f1481f
Merge branch 'dev' of github.com:innovationacademy-kr/Cabi into dev
chyo1 Oct 8, 2024
fa05f5c
[FE] BUG: navigate 경로 수정 #1688
wet6123 Oct 8, 2024
bcf8c54
[FE] FIX: 로딩 애니메이션 작동 시, 스크롤바 제거하기 위한 css 추가
jihyunk03 Oct 8, 2024
1b07448
[FE] FIX: 새로고침 시 나타나는 스크롤바 제거하기 위한 로직 수정
jihyunk03 Oct 8, 2024
08660f1
[FE] REFACTOR: 필요없는 css 속성 삭제
jihyunk03 Oct 10, 2024
01136bf
Merge pull request #1693 from innovationacademy-kr/fe/dev/bug_scrollb…
jihyunk03 Oct 18, 2024
cf02dea
[FE] HOTFIX: AvailablePage 에서 4층 제거
junyoung2015 Oct 22, 2024
66db19c
[FE] HOTFIX: 4층에서 알림권을 사용하지 못하도록 설정
junyoung2015 Oct 22, 2024
36becdf
FEAT: item_history 테이블에 amount 컬럼 추가
saewoo1 Oct 22, 2024
74fb875
FEAT: item 테이블에 관리자용 코인 지급 아이템
saewoo1 Oct 22, 2024
4c49f8d
FEAT: ItemHistory 엔티티에 임시적으로 코인 관련 생성자 추가
saewoo1 Oct 22, 2024
6955c86
FEAT: 코인 지급 컨트롤러
saewoo1 Oct 22, 2024
76e942b
FEAT: 어드민 계정에서 여러 유저에게 원하는 양만큼 코인 지급 기능
saewoo1 Oct 22, 2024
1ddb190
Merge pull request #1692 from innovationacademy-kr/fe/dev/fix_present…
wet6123 Oct 22, 2024
30a7130
[FE] BUG: 홈 화면 상세보기 버튼 눌렀을때 최신글로 이동하게 url 변경 #1697
jnkeniaem Oct 23, 2024
eb89e84
[FE] FEAT: 홈 화면 상세보기 버튼에 리디렉션 알려주는 아이콘 추가 #1697
jnkeniaem Oct 23, 2024
a9b48c5
[FE] FIX: 상세보기 글자 위치 조정 #1697
jnkeniaem Oct 23, 2024
ce3b889
[FE] DOCS: link.svg 원래대로 복구 #1697
jnkeniaem Oct 23, 2024
82dd0d3
Merge pull request #1698 from innovationacademy-kr/fe/dev/fix_home_de…
jnkeniaem Oct 23, 2024
2744fb0
[COMMON] ETC: config changed
jnkeniaem Oct 25, 2024
0013d44
Merge branch 'main' of https://github.com/innovationacademy-kr/Cabi i…
jnkeniaem Oct 25, 2024
b3c2463
FIX: amount를 받는 팩토리 메서드 에러 발생 시 asDomainException 변경
saewoo1 Oct 25, 2024
af818cb
[FE] FEAT: 4층 사물함에서 이동하는 유저들에게 코인 및 아이템 지급하기 위해 api 호출 함수 생성 #1695
jnkeniaem Oct 25, 2024
2df4fe5
FEAT: 여러 유저에게 동일한 코인을 지급하는 Bulk add 기능
saewoo1 Oct 25, 2024
412f2c5
Merge branch 'be/dev/refactor-ItemHistory#1695' of https://github.com…
saewoo1 Oct 25, 2024
ab10e97
REFACTOR: 일괄 지급 서비스명 addBulkCoin으로 변경
saewoo1 Oct 25, 2024
0c5b6f4
REFACTOR: 관리자가 유저에게 코인 아이템 지급 시 redis 부분 제거
saewoo1 Oct 25, 2024
8266c4b
REFACTOR: 동전줍기 시 ItemHistory에 코인 주운 양 저장
saewoo1 Oct 25, 2024
0235637
REFACTOR: 동전줍기 시 ItemHistory에 코인 주운 양 저장
saewoo1 Oct 25, 2024
94b9317
[FE] FEAT: 아이템 지급 모달에 코인란 추가 #1695
jnkeniaem Oct 25, 2024
722aba4
REFACTOR: ItemHistory 생성 시 amount 필수 파라미터로 변경
saewoo1 Oct 25, 2024
5bd6160
Merge branch 'be/dev/refactor-ItemHistory#1695' of https://github.com…
saewoo1 Oct 25, 2024
059d11b
FEAT: sku에 코인 보상 추가
saewoo1 Oct 25, 2024
307f533
FEAT: admin에서 지급할 아이템 조회 기능
saewoo1 Oct 25, 2024
100e180
FIX : dto sku 변수명 통일
saewoo1 Oct 25, 2024
d3ec782
FIX : dto sku 변수명 통일
saewoo1 Oct 25, 2024
1615ff9
FEAT: 관리자 계정에서 코인 지급 시 코인이 비어있을 경우 예외 반환
saewoo1 Oct 25, 2024
2fad205
REFACTOR: 코인 내역 조회 시 itemHistory의 amount를 조회하여 반환
saewoo1 Oct 25, 2024
5aabdaa
REFACTOR: Sku에 명확한 보상 내역 명시
saewoo1 Oct 25, 2024
43ba574
[BE] FIX: itemHistory에서 아이템 가격 amount에서 받아오기
chyo1 Oct 25, 2024
800a8a5
REFACTOR: 관리자 계정에서 아이템, 코인 지급 컨트롤러 통합
saewoo1 Oct 25, 2024
04706a5
FIX: 지급 코인 가격 10으로 변경
saewoo1 Oct 25, 2024
6be179e
[FE] FEAT: 유저 아이템 지급 구현 #1695
seonmiki Oct 25, 2024
54ef762
Merge pull request #1696 from innovationacademy-kr/be/dev/refactor-It…
saewoo1 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/database/cabi_local.sql
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ VALUES (1, 0, 'EXTENSION_PREV', 'EXTENSION'),
(17, 200, 'ADMIN_REWARD_200', 'ADMIN_REWARD'),
(18, 500, 'ADMIN_REWARD_500', 'ADMIN_REWARD'),
(19, 1000, 'ADMIN_REWARD_1000', 'ADMIN_REWARD'),
(20, 2000, 'ADMIN_REWARD_2000', 'ADMIN_REWARD');
(20, 2000, 'ADMIN_REWARD_2000', 'ADMIN_REWARD'),
(21, 10, 'ADMIN_REWARD_COIN', 'ADMIN_REWARD');
/*!40000 ALTER TABLE `item`
ENABLE KEYS */;
UNLOCK TABLES;
Expand All @@ -758,6 +759,7 @@ CREATE TABLE `item_history`
`user_id` bigint(20) NOT NULL,
`purchase_at` datetime(6) NOT NULL,
`used_at` datetime(6) DEFAULT NULL,
`amount` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `item_history_item_id` FOREIGN KEY (`item_id`) REFERENCES `item` (`id`),
CONSTRAINT `item_history_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.ftclub.cabinet.admin.dto;

import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.ftclub.cabinet.item.domain.Sku;

@Getter
@AllArgsConstructor
public class AdminCoinAssignRequestDto {

private List<Long> userIds;
private Sku itemSku;
private Long amount;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package org.ftclub.cabinet.admin.item.controller;

import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.mapping;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.ftclub.cabinet.admin.dto.AdminItemHistoryPaginationDto;
import org.ftclub.cabinet.admin.item.service.AdminItemFacadeService;
import org.ftclub.cabinet.admin.statistics.service.AdminStatisticsFacadeService;
import org.ftclub.cabinet.auth.domain.AuthGuard;
import org.ftclub.cabinet.auth.domain.AuthLevel;
import org.ftclub.cabinet.dto.ItemAssignRequestDto;
import org.ftclub.cabinet.dto.ItemCreateDto;
import org.ftclub.cabinet.dto.ItemDetailsDto;
import org.ftclub.cabinet.dto.ItemStoreDto;
import org.ftclub.cabinet.dto.ItemStoreResponseDto;
import org.ftclub.cabinet.item.domain.Item;
import org.ftclub.cabinet.item.domain.ItemType;
import org.ftclub.cabinet.item.service.ItemQueryService;
import org.ftclub.cabinet.log.Logging;
import org.ftclub.cabinet.mapper.ItemMapper;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -24,8 +36,8 @@
public class AdminItemController {

private final AdminItemFacadeService adminItemFacadeService;
private final AdminStatisticsFacadeService adminStatisticsFacadeService;

private final ItemQueryService itemQueryService;
private final ItemMapper itemMapper;

@PostMapping("")
@AuthGuard(level = AuthLevel.ADMIN_ONLY)
Expand All @@ -34,11 +46,29 @@ public void createItem(@RequestBody ItemCreateDto itemCreateDto) {
itemCreateDto.getSku(), itemCreateDto.getType());
}

@GetMapping("")
@AuthGuard(level = AuthLevel.ADMIN_ONLY)
public ItemStoreResponseDto getAllItems() {
List<Item> allItems = itemQueryService.getAllItems();
Map<ItemType, List<ItemDetailsDto>> itemMap = allItems.stream()
.collect(groupingBy(Item::getType,
mapping(itemMapper::toItemDetailsDto, Collectors.toList())));
List<ItemStoreDto> result = itemMap.entrySet().stream()
.map(entry -> {
ItemStoreDto itemStoreDto = itemMapper.toItemStoreDto(entry.getKey(),
entry.getValue());
itemStoreDto.sortBySkuASC();
return itemStoreDto;
})
.collect(Collectors.toList());
return new ItemStoreResponseDto(result);
}

@PostMapping("/assign")
@AuthGuard(level = AuthLevel.ADMIN_ONLY)
public void assignItem(@RequestBody ItemAssignRequestDto itemAssignRequestDto) {
adminItemFacadeService.assignItem(itemAssignRequestDto.getUserIds(),
itemAssignRequestDto.getItemSku());
itemAssignRequestDto.getItemSku(), itemAssignRequestDto.getAmount());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import org.ftclub.cabinet.item.service.ItemCommandService;
import org.ftclub.cabinet.item.service.ItemHistoryCommandService;
import org.ftclub.cabinet.item.service.ItemHistoryQueryService;
import org.ftclub.cabinet.item.service.ItemPolicyService;
import org.ftclub.cabinet.item.service.ItemQueryService;
import org.ftclub.cabinet.item.service.ItemRedisService;
import org.ftclub.cabinet.mapper.ItemMapper;
import org.ftclub.cabinet.user.service.UserCommandService;
import org.ftclub.cabinet.user.service.UserQueryService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand All @@ -33,34 +32,30 @@ public class AdminItemFacadeService {
private final ItemCommandService itemCommandService;
private final ItemHistoryQueryService itemHistoryQueryService;
private final ItemHistoryCommandService itemHistoryCommandService;
private final ItemPolicyService itemPolicyService;
private final ItemMapper itemMapper;

private final ItemRedisService itemRedisService;
private final UserCommandService userCommandService;
private final UserQueryService userQueryService;

@Transactional
public void createItem(Integer Price, Sku sku, ItemType type) {
itemCommandService.createItem(Price, sku, type);
}

@Transactional
public void assignItem(List<Long> userIds, Sku sku) {
public void assignItem(List<Long> userIds, Sku sku, Long amount) {
Item item = itemQueryService.getBySku(sku);
Long price = item.getPrice();
LocalDateTime now = null;
if (price > 0) {
Long coinAmount = item.getPrice();
if (sku.equals(Sku.ADMIN_REWARD_COIN)) {
itemPolicyService.verifyCoinAmount(amount);
coinAmount = amount;
}
if (coinAmount > 0) {
now = LocalDateTime.now();
userIds.forEach(userId -> {
long coinAmount = userQueryService.getUser(userId).getCoin();
itemRedisService.saveCoinCount(userId, coinAmount + item.getPrice());

long totalCoinSupply = itemRedisService.getTotalCoinSupply();
itemRedisService.saveTotalCoinSupply(totalCoinSupply + item.getPrice());
userCommandService.updateCoinAmount(userId, price);
});
userCommandService.addBulkCoin(userIds, coinAmount);
}
itemHistoryCommandService.createItemHistories(userIds, item.getId(), now);
itemHistoryCommandService.createItemHistories(userIds, item.getId(), now, coinAmount);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class CoinHistoryDto {

private LocalDateTime date;
private Integer amount;
private Long amount;
private String history;
private String itemDetails;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public class ItemAssignRequestDto {

private Sku itemSku;
private List<Long> userIds;
private Long amount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public enum ExceptionStatus {
INVALID_JWT_TOKEN(HttpStatus.BAD_REQUEST, "토큰이 없거나, 유효하지 않은 JWT 토큰입니다."),
NOT_FOUND_SECTION(HttpStatus.BAD_REQUEST, "사물함 구역 정보를 찾을 수 없습니다."),
ITEM_NOT_OWNED(HttpStatus.BAD_REQUEST, "해당 아이템을 보유하고 있지 않습니다"),
ITEM_USE_DUPLICATED(HttpStatus.FORBIDDEN, "아이템이 중복 사용되었습니다.");
ITEM_USE_DUPLICATED(HttpStatus.FORBIDDEN, "아이템이 중복 사용되었습니다."),
INVALID_AMOUNT(HttpStatus.BAD_REQUEST, "코인 지급양은 비어있을 수 없습니다.");

final private int statusCode;
final private String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ public class ItemHistory {
@Column(name = "USER_ID", nullable = false)
private Long userId;

@Column(name = "AMOUNT", nullable = true)
private Long amount;

protected ItemHistory(long userId, long itemId, LocalDateTime usedAt) {
protected ItemHistory(Long userId, Long itemId, LocalDateTime assignedAt, Long amount) {
this.userId = userId;
this.itemId = itemId;
this.usedAt = usedAt;
this.usedAt = assignedAt;
this.amount = amount;
}

/**
Expand All @@ -88,8 +91,8 @@ protected ItemHistory(long userId, long itemId, LocalDateTime usedAt) {
* @param usedAt 아이템 사용일자
* @return 아이템 히스토리 객체 {@link ItemHistory}
*/
public static ItemHistory of(long userId, long itemId, LocalDateTime usedAt) {
ItemHistory itemHistory = new ItemHistory(userId, itemId, usedAt);
public static ItemHistory of(Long userId, Long itemId, LocalDateTime usedAt, Long amount) {
ItemHistory itemHistory = new ItemHistory(userId, itemId, usedAt, amount);
if (!itemHistory.isValid()) {
throw ExceptionStatus.INVALID_ARGUMENT.asDomainException();
}
Expand Down
11 changes: 6 additions & 5 deletions backend/src/main/java/org/ftclub/cabinet/item/domain/Sku.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public enum Sku {
COIN_REWARD_1000("동전 줍기 20일 보상"),
COIN_REWARD_2000("동전 줍기 20일 보상"),

ADMIN_REWARD_100("보상"),
ADMIN_REWARD_200("보상"),
ADMIN_REWARD_500("보상"),
ADMIN_REWARD_1000("보상"),
ADMIN_REWARD_2000("보상"),
ADMIN_REWARD_100("100"),
ADMIN_REWARD_200("200"),
ADMIN_REWARD_500("500"),
ADMIN_REWARD_1000("1000"),
ADMIN_REWARD_2000("2000"),
ADMIN_REWARD_COIN("지정 보상"),
;

private final String details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public CoinCollectionRewardResponseDto collectCoinAndIssueReward(Long userId) {
// DB에 코인 저장
Item coinCollect = itemQueryService.getBySku(Sku.COIN_COLLECT);
int reward = (int) (coinCollect.getPrice().longValue());
itemHistoryCommandService.createCoinItemHistory(userId, coinCollect.getId());
itemHistoryCommandService.createCoinItemHistory(userId, coinCollect.getId(),
coinCollect.getPrice());

// 출석 일자에 따른 랜덤 리워드 지급
Long coinCollectionCountInMonth =
Expand All @@ -206,7 +207,8 @@ public CoinCollectionRewardResponseDto collectCoinAndIssueReward(Long userId) {
Sku coinSku = itemPolicyService.getRewardSku(randomPercentage);
Item coinReward = itemQueryService.getBySku(coinSku);

itemHistoryCommandService.createCoinItemHistory(userId, coinReward.getId());
itemHistoryCommandService.createCoinItemHistory(userId, coinReward.getId(),
coinReward.getPrice());
reward += coinReward.getPrice();
}

Expand Down Expand Up @@ -310,7 +312,7 @@ public void purchaseItem(Long userId, Sku sku) {
itemPolicyService.verifyIsAffordable(userCoin, price);

// 아이템 구매 처리
itemHistoryCommandService.createItemHistory(user.getId(), item.getId());
itemHistoryCommandService.createItemHistory(user.getId(), item.getId(), price);

LockUtil.lockRedisCoin(userId, () -> {
// 코인 차감
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,39 @@ public class ItemHistoryCommandService {

private final ItemHistoryRepository itemHistoryRepository;

public void createItemHistory(Long userId, Long itemId) {
ItemHistory itemHistory = ItemHistory.of(userId, itemId, null);
public void createItemHistory(Long userId, Long itemId, Long amount) {
ItemHistory itemHistory = ItemHistory.of(userId, itemId, null, amount);
itemHistoryRepository.save(itemHistory);
}

public void createItemHistories(List<Long> userIds, Long itemId, LocalDateTime usedAt) {
public void createItemHistories(List<Long> userIds, Long itemId, LocalDateTime usedAt,
Long amount) {
List<ItemHistory> itemHistories = userIds.stream()
.map(userId -> ItemHistory.of(userId, itemId, usedAt))
.map(userId -> ItemHistory.of(userId, itemId, usedAt, amount))
.collect(Collectors.toList());
itemHistoryRepository.saveAll(itemHistories);
}

public void createCoinItemHistory(Long userId, Long itemId) {
ItemHistory coinCollectItemHistory = ItemHistory.of(userId, itemId, LocalDateTime.now());
public void createCoinItemHistory(Long userId, Long itemId, Long amount) {
ItemHistory coinCollectItemHistory = ItemHistory.of(userId, itemId, LocalDateTime.now(),
amount);
itemHistoryRepository.save(coinCollectItemHistory);
}

/**
* 관리자가 코인 지급 시 ItemHistory에 기록을 남깁니다
*
* @param userIds
* @param itemId
* @param usedAt
* @param amount
*/
public void createCoinAssignHistory(List<Long> userIds, Long itemId, LocalDateTime usedAt,
Long amount) {
List<ItemHistory> itemHistories = userIds.stream()
.map(userId -> ItemHistory.of(userId, itemId, usedAt, amount))
.collect(Collectors.toList());

itemHistoryRepository.saveAll(itemHistories);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ public Sku getRewardSku(int randomPercentage) {
return Sku.COIN_REWARD_2000;
}
}

public void verifyCoinAmount(Long amount) {
if (amount == null) {
throw ExceptionStatus.INVALID_AMOUNT.asServiceException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public interface ItemMapper {
ItemMapper INSTANCE = Mappers.getMapper(ItemMapper.class);

@Mapping(target = "date", source = "itemHistory.purchaseAt")
@Mapping(target = "amount", source = "item.price")
@Mapping(target = "history", source = "item.type.name")
@Mapping(target = "itemDetails", source = "item.sku.details")
@Mapping(target = "amount", source = "itemHistory.amount")
CoinHistoryDto toCoinHistoryDto(ItemHistory itemHistory, Item item);

@Mapping(target = "itemSku", source = "item.sku")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,10 @@ public interface UserRepository extends JpaRepository<User, Long> {

@Query("SELECT u FROM User u WHERE u.deletedAt IS NULL")
List<User> findAllDeletedAtIsNull();

@Modifying(clearAutomatically = true)
@Query("UPDATE User u "
+ "SET u.coin = u.coin + :amount "
+ "WHERE u.id IN :userIds")
void updateBulkUserCoin(@Param("userIds") List<Long> userIds, @Param("amount") Long amount);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public void issueLentExtension() {
users.forEach(user -> {
Long userId = user.getId();
user.addCoin(coinRewardItem.getPrice());
itemHistoryCommandService.createCoinItemHistory(userId, coinRewardItem.getId());
itemHistoryCommandService.createCoinItemHistory(userId, coinRewardItem.getId(),
coinRewardItem.getPrice());
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ftclub.cabinet.user.service;

import java.time.LocalDateTime;
import java.util.List;
import javax.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.ftclub.cabinet.auth.domain.FtProfile;
Expand Down Expand Up @@ -115,4 +116,8 @@ public void updateCoinAmount(Long userId, Long reward) {
.orElseThrow(ExceptionStatus.NOT_FOUND_USER::asServiceException);
user.addCoin(reward);
}

public void addBulkCoin(List<Long> userIds, Long amount) {
userRepository.updateBulkUserCoin(userIds, amount);
}
}
2 changes: 1 addition & 1 deletion config
Loading
Loading