|
|
@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.bnyer.common.core.constant.RedisKeyConstant; |
|
|
import com.bnyer.common.core.constant.RedisKeyConstant; |
|
|
import com.bnyer.common.core.domain.AiPaint; |
|
|
import com.bnyer.common.core.domain.AiPaint; |
|
|
|
|
|
import com.bnyer.common.core.domain.FhUser; |
|
|
|
|
|
import com.bnyer.common.core.domain.TiktokUser; |
|
|
|
|
|
import com.bnyer.common.core.domain.WxUser; |
|
|
import com.bnyer.common.core.dto.TextToImgDto; |
|
|
import com.bnyer.common.core.dto.TextToImgDto; |
|
|
import com.bnyer.common.core.dto.TextToImgLoveDto; |
|
|
import com.bnyer.common.core.dto.TextToImgLoveDto; |
|
|
import com.bnyer.common.core.exception.ServiceException; |
|
|
import com.bnyer.common.core.exception.ServiceException; |
|
|
@ -17,8 +20,7 @@ import com.bnyer.file.api.RemoteFileService; |
|
|
import com.bnyer.img.config.StableDiffusionConfig; |
|
|
import com.bnyer.img.config.StableDiffusionConfig; |
|
|
import com.bnyer.img.config.TencentTranslateConfig; |
|
|
import com.bnyer.img.config.TencentTranslateConfig; |
|
|
import com.bnyer.img.enums.AiPaintButtonEnum; |
|
|
import com.bnyer.img.enums.AiPaintButtonEnum; |
|
|
import com.bnyer.img.service.AiPaintService; |
|
|
import com.bnyer.img.service.*; |
|
|
import com.bnyer.img.service.StableDiffusionService; |
|
|
|
|
|
import com.tencentcloudapi.aiart.v20221229.AiartClient; |
|
|
import com.tencentcloudapi.aiart.v20221229.AiartClient; |
|
|
import com.tencentcloudapi.aiart.v20221229.models.ResultConfig; |
|
|
import com.tencentcloudapi.aiart.v20221229.models.ResultConfig; |
|
|
import com.tencentcloudapi.aiart.v20221229.models.TextToImageRequest; |
|
|
import com.tencentcloudapi.aiart.v20221229.models.TextToImageRequest; |
|
|
@ -61,6 +63,15 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private StableDiffusionConfig stableDiffusionConfig; |
|
|
private StableDiffusionConfig stableDiffusionConfig; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private TiktokUserService tiktokUserService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WxUserService wxUserService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private FhUserService fhUserService; |
|
|
|
|
|
|
|
|
private String translate(String text){ |
|
|
private String translate(String text){ |
|
|
try{ |
|
|
try{ |
|
|
Credential cred = new Credential(tencentTranslateConfig.getSecretId(), tencentTranslateConfig.getSecretKey()); |
|
|
Credential cred = new Credential(tencentTranslateConfig.getSecretId(), tencentTranslateConfig.getSecretKey()); |
|
|
@ -165,8 +176,6 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
paint.setPainterId(param.getPainterId()); |
|
|
paint.setPainterId(param.getPainterId()); |
|
|
paint.setPainterName(param.getPainterName()); |
|
|
paint.setPainterName(param.getPainterName()); |
|
|
aiPaintService.insert(paint); |
|
|
aiPaintService.insert(paint); |
|
|
//写入ai绘画次数
|
|
|
|
|
|
writePlatformUserAiPaintNum(param.getAppType(),param.getPlatform(),param.getPainterId()); |
|
|
|
|
|
} |
|
|
} |
|
|
img.setPaintId(paintId); |
|
|
img.setPaintId(paintId); |
|
|
img.setPaintTime(paintTime); |
|
|
img.setPaintTime(paintTime); |
|
|
@ -274,8 +283,6 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
paint.setPainterId(param.getPainterId()); |
|
|
paint.setPainterId(param.getPainterId()); |
|
|
paint.setPainterName(param.getPainterName()); |
|
|
paint.setPainterName(param.getPainterName()); |
|
|
aiPaintService.insert(paint); |
|
|
aiPaintService.insert(paint); |
|
|
//写入ai绘画次数
|
|
|
|
|
|
writePlatformUserAiPaintNum(param.getAppType(),param.getPlatform(),param.getPainterId()); |
|
|
|
|
|
} |
|
|
} |
|
|
img.setPaintId(paintId); |
|
|
img.setPaintId(paintId); |
|
|
img.setPaintTime(paintTime); |
|
|
img.setPaintTime(paintTime); |
|
|
@ -501,34 +508,40 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 写入ai绘画次数 |
|
|
|
|
|
* @param appType 应用 |
|
|
|
|
|
* @param platform 平台 |
|
|
|
|
|
* @param userId 用户id |
|
|
|
|
|
*/ |
|
|
|
|
|
private void writePlatformUserAiPaintNum(String appType,String platform,Long userId){ |
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
String date = df.format(new Date()); |
|
|
|
|
|
String hashKey = appType+":"+platform+":"+userId; |
|
|
|
|
|
log.info("日期【{}】应用【{}】平台【{}】用户【{}】ai绘画数+1",date,appType,platform,userId); |
|
|
|
|
|
String redisKey = RedisKeyConstant.PLATFORM_USER_AI_PAINT_KEY + date; |
|
|
|
|
|
redisService.hashIncr(redisKey, hashKey, 1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void imgToImg() { |
|
|
public void imgToImg() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void addPlatformUserAiPaintNum(String appType, String platform, Long userId, int patinNum) { |
|
|
public void addPlatformUserAiPaintNum(String platform, Long userId, int paintNum) { |
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
//判断是哪个平台的
|
|
|
String date = df.format(new Date()); |
|
|
switch (platform){ |
|
|
String hashKey = appType+":"+platform+":"+userId; |
|
|
//抖音
|
|
|
log.info("日期【{}】应用【{}】平台【{}】用户【{}】ai绘画次数+【{}】",date,appType,platform,userId,patinNum); |
|
|
case "1": |
|
|
String redisKey = RedisKeyConstant.PLATFORM_USER_AI_PAINT_KEY + date; |
|
|
//查询用户信息
|
|
|
redisService.hashIncr(redisKey, hashKey, -patinNum); |
|
|
TiktokUser tiktokUser = tiktokUserService.getUserById(userId); |
|
|
|
|
|
tiktokUser.setGoldNum(tiktokUser.getGoldNum()+paintNum); |
|
|
|
|
|
//更新用户信息
|
|
|
|
|
|
tiktokUserService.updateTiktokUser(tiktokUser); |
|
|
|
|
|
break; |
|
|
|
|
|
//快手
|
|
|
|
|
|
case "2": |
|
|
|
|
|
//查询用户信息
|
|
|
|
|
|
FhUser fhUser = fhUserService.getUserById(userId); |
|
|
|
|
|
fhUser.setGoldNum(fhUser.getGoldNum()+paintNum); |
|
|
|
|
|
//更新用户信息
|
|
|
|
|
|
fhUserService.updateFhUser(fhUser); |
|
|
|
|
|
break; |
|
|
|
|
|
//微信
|
|
|
|
|
|
case "3": |
|
|
|
|
|
//查询用户信息
|
|
|
|
|
|
WxUser wxUser = wxUserService.getUserById(userId); |
|
|
|
|
|
wxUser.setGoldNum(wxUser.getGoldNum()+paintNum); |
|
|
|
|
|
//更新用户信息
|
|
|
|
|
|
wxUserService.updateWxUser(wxUser); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|