parent
f6f33a07d0
commit
02abe86253
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.api.point;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户积分的 API 接口
|
||||||
|
*
|
||||||
|
* @author owen
|
||||||
|
*/
|
||||||
|
public interface MemberPointApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加用户积分
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param point 积分
|
||||||
|
* @param bizType 业务类型 {@link MemberPointBizTypeEnum}
|
||||||
|
* @param bizId 业务编号
|
||||||
|
*/
|
||||||
|
void addPoint(Long userId, Integer point, Integer bizType, String bizId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.api.point;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECORD_BIZ_NOT_SUPPORT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户积分的 API 实现类
|
||||||
|
*
|
||||||
|
* @author owen
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class MemberPointApiImpl implements MemberPointApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberPointRecordService memberPointRecordService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPoint(Long userId, Integer point, Integer bizType, String bizId) {
|
||||||
|
MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType);
|
||||||
|
if (bizTypeEnum == null) {
|
||||||
|
throw exception(POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||||
|
}
|
||||||
|
memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue