用户徽章佩戴和发放

This commit is contained in:
zhongzb
2023-05-07 20:22:06 +08:00
parent c8369e31a1
commit b39a1bdf0c
22 changed files with 187 additions and 71 deletions

View File

@@ -18,8 +18,8 @@ import java.util.stream.Collectors;
public enum ItemEnum {
MODIFY_NAME_CARD(1L, ItemTypeEnum.MODIFY_NAME_CARD, "改名卡"),
LIKE_BADGE(2L, ItemTypeEnum.BADGE, "爆赞徽章"),
REG_TOP10_BADGE(2L, ItemTypeEnum.BADGE, "爆赞徽章"),
REG_TOP100_BADGE(2L, ItemTypeEnum.BADGE, "爆赞徽章"),
REG_TOP10_BADGE(3L, ItemTypeEnum.BADGE, "前十注册徽章"),
REG_TOP100_BADGE(4L, ItemTypeEnum.BADGE, "前100注册徽章"),
;
private final Long id;

View File

@@ -3,6 +3,7 @@ package com.abin.mallchat.common.user.service.impl;
import com.abin.mallchat.common.common.annotation.RedissonLock;
import com.abin.mallchat.common.common.domain.enums.IdempotentEnum;
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
import com.abin.mallchat.common.common.event.ItemReceiveEvent;
import com.abin.mallchat.common.user.dao.ItemConfigDao;
import com.abin.mallchat.common.user.dao.UserBackpackDao;
import com.abin.mallchat.common.user.domain.entity.ItemConfig;
@@ -11,7 +12,10 @@ import com.abin.mallchat.common.user.domain.enums.ItemTypeEnum;
import com.abin.mallchat.common.user.service.IUserBackpackService;
import com.abin.mallchat.common.user.service.cache.ItemCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
@@ -31,6 +35,8 @@ public class UserBackpackServiceImpl implements IUserBackpackService {
private ItemConfigDao itemConfigDao;
@Autowired
private ItemCache itemCache;
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
@Override
@RedissonLock(key = "#uid")
@@ -56,6 +62,8 @@ public class UserBackpackServiceImpl implements IUserBackpackService {
.idempotent(idempotent)
.build();
userBackpackDao.save(insert);
//用户收到物品的事件
applicationEventPublisher.publishEvent(new ItemReceiveEvent(this, insert));
}
private String getIdempotent(Long itemId, IdempotentEnum idempotentEnum, String businessId) {