|
|
|
@ -3,6 +3,7 @@ package com.bnyer.img.service.impl; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.bnyer.common.core.constant.RedisKeyConstant; |
|
|
|
import com.bnyer.common.core.domain.AiPaint; |
|
|
|
import com.bnyer.common.core.domain.R; |
|
|
|
import com.bnyer.common.core.dto.TextToImgDto; |
|
|
|
@ -10,6 +11,7 @@ import com.bnyer.common.core.utils.TranslateUtils; |
|
|
|
import com.bnyer.common.core.utils.file.Base64ToMultipartFileUtils; |
|
|
|
import com.bnyer.common.core.utils.file.ImageUtils; |
|
|
|
import com.bnyer.common.core.vo.TextToImgVo; |
|
|
|
import com.bnyer.common.redis.service.RedisService; |
|
|
|
import com.bnyer.file.api.RemoteFileService; |
|
|
|
import com.bnyer.img.service.AiPaintService; |
|
|
|
import com.bnyer.img.service.StableDiffusionService; |
|
|
|
@ -20,6 +22,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
@ -38,6 +41,9 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
@Autowired |
|
|
|
private RemoteFileService remoteFileService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisService redisService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public TextToImgVo textToImg(TextToImgDto param) { |
|
|
|
try{ |
|
|
|
@ -99,6 +105,8 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
paint.setPainterId(param.getPainterId()); |
|
|
|
paint.setPainterName(param.getPainterName()); |
|
|
|
aiPaintService.insert(paint); |
|
|
|
//写入ai绘画次数
|
|
|
|
writePlatformUserAiPaintNum(param.getAppType(),param.getPlatform(),param.getPainterId()); |
|
|
|
} |
|
|
|
img.setPaintId(paintId); |
|
|
|
img.setPaintTime(paintTime); |
|
|
|
@ -110,6 +118,21 @@ public class StableDiffusionServiceImpl implements StableDiffusionService { |
|
|
|
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 |
|
|
|
public void imgToImg() { |
|
|
|
|
|
|
|
|