|
|
|
@ -5,25 +5,20 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.bnyer.common.core.constant.RedisKeyConstant; |
|
|
|
import com.bnyer.common.core.constant.TiktokConstant; |
|
|
|
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.domain.*; |
|
|
|
import com.bnyer.common.core.dto.TextToImgDto; |
|
|
|
import com.bnyer.common.core.dto.TextToImgLoveDto; |
|
|
|
import com.bnyer.common.core.enums.EnumUserClientType; |
|
|
|
import com.bnyer.common.core.exception.ServiceException; |
|
|
|
import com.bnyer.common.core.utils.StringUtils; |
|
|
|
import com.bnyer.common.core.utils.TranslateUtils; |
|
|
|
import com.bnyer.common.core.utils.file.Base64ToMultipartFileUtils; |
|
|
|
import com.bnyer.common.core.vo.TextToImgVo; |
|
|
|
import com.bnyer.common.core.vo.UserInfoVo; |
|
|
|
import com.bnyer.common.redis.service.RedisService; |
|
|
|
import com.bnyer.common.security.utils.SecurityUtils; |
|
|
|
import com.bnyer.file.api.RemoteFileService; |
|
|
|
import com.bnyer.img.config.StableDiffusionConfig; |
|
|
|
import com.bnyer.img.config.TencentTranslateConfig; |
|
|
|
import com.bnyer.img.enums.AiPaintButtonEnum; |
|
|
|
import com.bnyer.img.enums.GoldEnum; |
|
|
|
import com.bnyer.img.service.*; |
|
|
|
import com.tencentcloudapi.aiart.v20221229.AiartClient; |
|
|
|
import com.tencentcloudapi.aiart.v20221229.models.ResultConfig; |
|
|
|
@ -42,7 +37,6 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
@ -76,6 +70,9 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
@Autowired |
|
|
|
private FhUserService fhUserService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GoldLogService goldLogService; |
|
|
|
|
|
|
|
private String translate(String text){ |
|
|
|
try{ |
|
|
|
Credential cred = new Credential(tencentTranslateConfig.getSecretId(), tencentTranslateConfig.getSecretKey()); |
|
|
|
@ -218,6 +215,13 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
paint.setPainterId(param.getPainterId()); |
|
|
|
paint.setPainterName(param.getPainterName()); |
|
|
|
aiPaintService.insert(paint); |
|
|
|
//写入画意值消耗记录
|
|
|
|
GoldLog goldLog = new GoldLog(); |
|
|
|
goldLog.setGoldNum(param.getGoldNum()); |
|
|
|
goldLog.setUserId(param.getPainterId()); |
|
|
|
goldLog.setSource(param.getPlatform()); |
|
|
|
goldLog.setReason(GoldEnum.PAINT.getValue()); |
|
|
|
goldLogService.insert(goldLog); |
|
|
|
} |
|
|
|
img.setPaintId(paintId); |
|
|
|
img.setPaintTime(paintTime); |
|
|
|
@ -302,7 +306,6 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
String imgStr = remoteFileService.uploadQiNiu(file,7).getData(); |
|
|
|
//保存生辰该图片到ai绘画表
|
|
|
|
AiPaint paint = new AiPaint(); |
|
|
|
//paint.setId(); 主键改成雪花算法后启用
|
|
|
|
paintId = IdUtil.getSnowflakeNextIdStr(); |
|
|
|
paintTime = new Date(); |
|
|
|
paint.setPaintId(paintId); |
|
|
|
@ -325,6 +328,13 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
paint.setPainterId(param.getPainterId()); |
|
|
|
paint.setPainterName(param.getPainterName()); |
|
|
|
aiPaintService.insert(paint); |
|
|
|
//写入画意值消耗记录
|
|
|
|
GoldLog goldLog = new GoldLog(); |
|
|
|
goldLog.setGoldNum(param.getGoldNum()); |
|
|
|
goldLog.setUserId(param.getPainterId()); |
|
|
|
goldLog.setSource(param.getPlatform()); |
|
|
|
goldLog.setReason(GoldEnum.PAINT.getValue()); |
|
|
|
goldLogService.insert(goldLog); |
|
|
|
} |
|
|
|
img.setPaintId(paintId); |
|
|
|
img.setPaintTime(paintTime); |
|
|
|
@ -377,6 +387,14 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
default: |
|
|
|
throw new ServiceException("用户类型错误!", TiktokConstant.USER_TYPE_ERROR); |
|
|
|
} |
|
|
|
//写入画意值消耗记录
|
|
|
|
GoldLog goldLog = new GoldLog(); |
|
|
|
goldLog.setGoldNum(param.getGoldNum()); |
|
|
|
goldLog.setUserId(param.getPainterId()); |
|
|
|
goldLog.setSource(param.getPlatform()); |
|
|
|
goldLog.setReason(GoldEnum.COUPLE_HEAD.getValue()); |
|
|
|
goldLogService.insert(goldLog); |
|
|
|
|
|
|
|
//描述词处理
|
|
|
|
//内容提示词
|
|
|
|
String contentPrompt = param.getPrompt(); |
|
|
|
|