Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -4,6 +4,7 @@ import com.ai.da.common.config.exception.BusinessException;
|
|||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.enums.*;
|
import com.ai.da.common.enums.*;
|
||||||
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
@@ -560,7 +561,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
// 2、判断用户当前积分是否够本次生成消耗
|
// 2、判断用户当前积分是否够本次生成消耗
|
||||||
Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, 1);
|
Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, 1);
|
||||||
if (!preDeduction) {
|
if (!preDeduction) {
|
||||||
throw new BusinessException("Not enough Credits");
|
throw new BusinessException("remaining.credits.insufficient");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、生成唯一id 使用uuid,由于uuid重复的几率很小,故取消对uuid重复性的校验
|
// 3、生成唯一id 使用uuid,由于uuid重复的几率很小,故取消对uuid重复性的校验
|
||||||
@@ -779,6 +780,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
Long accountId = UserContext.getUserHolder().getId();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
log.info("imageToSketch parameter : {}", imageToSketchDTO);
|
log.info("imageToSketch parameter : {}", imageToSketchDTO);
|
||||||
|
|
||||||
|
// 检查积分是否够本次扣除
|
||||||
|
CreditsEventsEnum event = CreditsEventsEnum.IMAGE_TO_SKETCH;
|
||||||
|
Boolean b = creditsService.checkCredits(accountId, event, 1);
|
||||||
|
if (!b){
|
||||||
|
throw new BusinessException("remaining.credits.insufficient", ResultEnum.PROMPT.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
CollectionElement collectionElement = collectionElementService.getById(imageToSketchDTO.getElementId());
|
CollectionElement collectionElement = collectionElementService.getById(imageToSketchDTO.getElementId());
|
||||||
String imagePath = collectionElement.getUrl();
|
String imagePath = collectionElement.getUrl();
|
||||||
|
|
||||||
@@ -823,7 +831,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
String clothCategory = pythonService.getClothCategory(sketchPath, imageToSketchDTO.getGender());
|
String clothCategory = pythonService.getClothCategory(sketchPath, imageToSketchDTO.getGender());
|
||||||
|
|
||||||
CreditsEventsEnum event = CreditsEventsEnum.IMAGE_TO_SKETCH;
|
|
||||||
BigDecimal existingCredits = accountService.getById(accountId).getCredits();
|
BigDecimal existingCredits = accountService.getById(accountId).getCredits();
|
||||||
BigDecimal subtract = existingCredits.subtract(new BigDecimal(event.getValue()));
|
BigDecimal subtract = existingCredits.subtract(new BigDecimal(event.getValue()));
|
||||||
accountService.updateCreditsAndEndTime(accountId, subtract.toString(), null);
|
accountService.updateCreditsAndEndTime(accountId, subtract.toString(), null);
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ you.have.not.followed.the.current.user=You have not followed the current user
|
|||||||
remaining.modifications=Remaining modifications are 0
|
remaining.modifications=Remaining modifications are 0
|
||||||
you.have.participated.in.the.event=You have participated in the event.
|
you.have.participated.in.the.event=You have participated in the event.
|
||||||
only.original.works.can.participate.in.the.event=Sorry, only original works can participate in the event.
|
only.original.works.can.participate.in.the.event=Sorry, only original works can participate in the event.
|
||||||
|
remaining.credits.insufficient=Your remaining credits are insufficient for this generation. Please recharge.
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ you.have.not.followed.the.current.user=您还未关注当前用户
|
|||||||
remaining.modifications=剩余修改次数为0
|
remaining.modifications=剩余修改次数为0
|
||||||
you.have.participated.in.the.event=您已经参与活动。
|
you.have.participated.in.the.event=您已经参与活动。
|
||||||
only.original.works.can.participate.in.the.event=抱歉,只有原创作品能参与活动。
|
only.original.works.can.participate.in.the.event=抱歉,只有原创作品能参与活动。
|
||||||
|
remaining.credits.insufficient=您的剩余积分不够本次生成消耗,请充值
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
Reference in New Issue
Block a user