fix(education): tighten entitlement integration contracts
This commit is contained in:
@@ -9,6 +9,9 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Mapper
|
||||
public interface EducationEntitlementMapper extends BaseMapperX<EducationEntitlementDO> {
|
||||
@Select("SELECT 1 FROM pg_advisory_xact_lock(hashtextextended(#{subjectKey}, 0))")
|
||||
Integer lockSubject(@Param("subjectKey") String subjectKey);
|
||||
|
||||
@Select("""
|
||||
SELECT * FROM education_entitlement
|
||||
WHERE tenant_id=#{tenantId} AND user_id=#{userId} AND resource_type=#{resourceType} AND resource_id=#{resourceId}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.education.integration.member;
|
||||
|
||||
import cn.iocoder.yudao.module.member.api.point.MemberPointApi;
|
||||
import cn.iocoder.yudao.module.member.api.point.MemberPointBizType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,8 @@ public class MemberPointAwardPort {
|
||||
}
|
||||
|
||||
public void addLearningPoints(Long userId, Integer points, Long awardId) {
|
||||
memberPointApi.addPoint(userId, points, 31, "education-learning-award:" + awardId);
|
||||
memberPointApi.addPoint(userId, points, MemberPointBizType.EDUCATION_LEARNING,
|
||||
"education-learning-award:" + awardId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ public class EducationEntitlementServiceImpl implements EducationEntitlementServ
|
||||
}
|
||||
return existing.getEntitlementId();
|
||||
}
|
||||
entitlementMapper.lockSubject(tenantId + ":" + command.userId() + ":" + command.resourceType()
|
||||
+ ":" + command.resourceId());
|
||||
EducationEntitlementDO aggregate = entitlementMapper.selectForUpdate(tenantId, command.userId(), command.resourceType(), command.resourceId());
|
||||
boolean applied;
|
||||
if ("GRANT".equals(command.eventType())) {
|
||||
|
||||
@@ -38,10 +38,11 @@ public class ResourceProductBindingService {
|
||||
throw exception(PRODUCT_BINDING_CONFLICT);
|
||||
} else if (!"ACTIVE".equals(existing.getStatus())) {
|
||||
int version = existing.getVersion();
|
||||
bindingMapper.update(null, new LambdaUpdateWrapper<EducationResourceProductBindingDO>()
|
||||
int updated = bindingMapper.update(null, new LambdaUpdateWrapper<EducationResourceProductBindingDO>()
|
||||
.eq(EducationResourceProductBindingDO::getId, existing.getId()).eq(EducationResourceProductBindingDO::getTenantId, tenantId)
|
||||
.eq(EducationResourceProductBindingDO::getVersion, version).set(EducationResourceProductBindingDO::getStatus, "ACTIVE")
|
||||
.set(EducationResourceProductBindingDO::getVersion, version + 1));
|
||||
if (updated != 1) throw exception(PRODUCT_BINDING_CONFLICT);
|
||||
existing.setStatus("ACTIVE"); existing.setVersion(version + 1);
|
||||
}
|
||||
return toResult(existing);
|
||||
|
||||
Reference in New Issue
Block a user