bug修改

This commit is contained in:
guojunjie 2025-01-23 12:07:51 +08:00
parent c8e155eaf6
commit 24a1b92fc4
10 changed files with 80 additions and 25 deletions

View File

@ -102,6 +102,12 @@ public class PaCollectionController extends BaseController {
if (userid==null){ if (userid==null){
return new Result(false, "用户不存在"); return new Result(false, "用户不存在");
} }
Integer count=entityService.lambdaQuery()
.eq(PaCollection::getUserId,userid)
.eq(PaCollection::getCreationId,entity.getCreationId()).count();
if(count>0){
return new Result(false, "请勿重复收藏作品");
}
entity.setState("t"); entity.setState("t");
entity.setUserId(userid); entity.setUserId(userid);
entity.setCreatetime(new Date()); entity.setCreatetime(new Date());

View File

@ -81,6 +81,14 @@ public class AiPictureController {
if (paServices==null) if (paServices==null)
return new Result(false, "该服务不存在", "该服务不存在"); return new Result(false, "该服务不存在", "该服务不存在");
//服务单独判断
if(aiPictureVo.getServiceId()==7 && aiPictureVo.getText().length()>6 ){
return new Result(false, "字数超过限制", "字数超过限制");
}
if(aiPictureVo.getServiceId()==8 && aiPictureVo.getText().length()>200 ){
return new Result(false, "字数超过限制", "字数超过限制");
}
//进行扣费并记录日志 //进行扣费并记录日志
Boolean pay=paVipCurrencyService.consume(userId,paServices); Boolean pay=paVipCurrencyService.consume(userId,paServices);
if (!pay){ if (!pay){

View File

@ -64,7 +64,7 @@ public class ScheduledTasks {
//每隔30秒拉取一次阿里云火山生成结果 //每隔30秒拉取一次阿里云火山生成结果
// @Scheduled(fixedRate = 30*1000) @Scheduled(fixedRate = 30*1000)
public void getCreationUrl() throws Exception { public void getCreationUrl() throws Exception {
//2阿里云3火山 //2阿里云3火山
List<PaCreation> paCreations= paCreationService.lambdaQuery() List<PaCreation> paCreations= paCreationService.lambdaQuery()
@ -155,7 +155,7 @@ public class ScheduledTasks {
aiPictureService.failureHandling(paCreation,e); aiPictureService.failureHandling(paCreation,e);
ResultVo resultVo=new ResultVo(); ResultVo resultVo=new ResultVo();
resultVo.setStatus("fail"); resultVo.setStatus("fail");
resultVo.setReason(e.getMessage()); resultVo.setReason(paCreation.getReason());
return resultVo; return resultVo;
} }
} }
@ -174,13 +174,13 @@ public class ScheduledTasks {
// }else{ // }else{
cpAttachmentService.lambdaUpdate() cpAttachmentService.lambdaUpdate()
.set(CpAttachment::getPath,ossUrl) .set(CpAttachment::getPath,ossUrl)
.set(CpAttachment::getState,state) .set(CpAttachment::getState,"t")//图片状态永远为t
.eq(CpAttachment::getId,paCreation.getPhotoId()).update(); .eq(CpAttachment::getId,paCreation.getPhotoId()).update();
// } // }
//更新收藏品状态 //更新品状态
paCreationService.lambdaUpdate() paCreationService.lambdaUpdate()
.set(PaCreation::getState,state) .set(PaCreation::getState,state)//作品状态为createtfail
.set(PaCreation::getReason,reason) // .set(PaCreation::getReason,reason)
.eq(PaCreation::getId,paCreation.getId()).update(); .eq(PaCreation::getId,paCreation.getId()).update();
return ossUrl; return ossUrl;
} }

View File

@ -33,6 +33,8 @@ import okhttp3.MediaType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -68,13 +70,19 @@ public class AiPictureServiceImpl implements AiPictureService {
@Autowired @Autowired
private PaCreationService paCreationService; private PaCreationService paCreationService;
@Autowired @Autowired
RestTemplate restTemplate;
@Autowired
private PaAiTryonService paAiTryonService; private PaAiTryonService paAiTryonService;
@Autowired @Autowired
private VolcengineExConfig volcengineExConfig; private VolcengineExConfig volcengineExConfig;
@Value("${picture.fail}") @Value("${picture.fail}")
private String fail; private String fail;
@Autowired
private RestTemplateBuilder restTemplateBuilder;
@Bean
public RestTemplate getRestTemplate() {
return restTemplateBuilder.build();
}
@Autowired
RestTemplate restTemplate;
@Override @Override
@SysLog(action = "AiPicture:ImageColoring", value = "百度:黑白图片上色") @SysLog(action = "AiPicture:ImageColoring", value = "百度:黑白图片上色")
@ -103,11 +111,14 @@ public class AiPictureServiceImpl implements AiPictureService {
cpAttachment.setPath(fail); cpAttachment.setPath(fail);
cpAttachmentService.updateById(cpAttachment); cpAttachmentService.updateById(cpAttachment);
String message=e.getMessage(); String message=e.getMessage();
JSONObject jsonObject=JSONObject.parseObject(message); if (StringUtil.isNotBlank(message) && JSONUtil.isJSON(message)){
if (jsonObject!=null) { JSONObject jsonObject=JSONObject.parseObject(message);
Integer code = Integer.valueOf(jsonObject.getString("code")); if (jsonObject!=null) {
paCreation.setReason(VolcengineUtil.getErrorMessage(code)); Integer code = Integer.valueOf(jsonObject.getString("code"));
paCreation.setReason(VolcengineUtil.getErrorMessage(code));
}
}else if(StringUtil.isNotBlank(message) && message.equals("400 Bad Request")){
paCreation.setReason("输入内容不符合规范");
} }
paCreation.setSystemCause(message); paCreation.setSystemCause(message);
paCreation.setState("fail"); paCreation.setState("fail");
@ -162,14 +173,10 @@ public class AiPictureServiceImpl implements AiPictureService {
@Override @Override
@SysLog(action = "AiPicture:textToImage", value = "阿里云:文字生成图片") @SysLog(action = "AiPicture:textToImage", value = "阿里云:文字生成图片")
public void textToImage(AiPictureVo aiPictureVo,PaCreation paCreation) throws Exception { public void textToImage(AiPictureVo aiPictureVo,PaCreation paCreation) throws Exception {
try {
//异步请求阿里云URL获取任务id //异步请求阿里云URL获取任务id
String taskId=((Map)this.text2Images(aiPictureVo,paCreation)).get("task_id").toString(); String taskId=((Map)this.text2Images(aiPictureVo,paCreation)).get("task_id").toString();
paCreation.setTaskId(taskId); paCreation.setTaskId(taskId);
paCreationService.updateById(paCreation); paCreationService.updateById(paCreation);
}catch (Exception e){
failureHandling(paCreation,e);
}
} }
@Override @Override
@ -594,14 +601,15 @@ public class AiPictureServiceImpl implements AiPictureService {
public Map text2Images(AiPictureVo aiPictureVo, PaCreation paCreation) { public Map text2Images(AiPictureVo aiPictureVo, PaCreation paCreation) {
try { try {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);//固定返回类型只有json headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);//固定返回类型只有json
headers.set("Authorization", API_KEY);//固定api密钥 headers.set("Authorization", API_KEY);//固定api密钥
headers.set("X-DashScope-Async", "enable");//只有默认异步提交任务 headers.set("X-DashScope-Async", "enable");//只有默认异步提交任务
String url="https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis";//文生图url String url="https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis";//文生图url
Map<String, Object> input = new HashMap<>();//放到request中 Map<String, Object> input = new HashMap<>();//放到request中
input.put("prompt", aiPictureVo.getPromt());//////////文本描述 input.put("prompt", aiPictureVo.getText());//////////文本描述
input.put("size", 1024*1024);//////////尺寸 input.put("size", aiPictureVo.getSize());//////////尺寸
Map<String, Object> parameters = new HashMap<>();//放到request中 Map<String, Object> parameters = new HashMap<>();//放到request中
parameters.put("style", aiPictureVo.getOption());//////////类型 parameters.put("style", aiPictureVo.getOption());//////////类型
parameters.put("n", 1);//////////数量 parameters.put("n", 1);//////////数量

View File

@ -0,0 +1,26 @@
package com.pixelai.api.picture.util;
import com.alibaba.fastjson.JSON;
/**
* @ClassName JSONUtils
* @Description json验证工具
* @Author zhangxin
* @Date 2020-08-19
**/
public class JSONUtil {
public static boolean isJSON(String str) {
boolean result = false;
try {
Object obj= JSON.parse(str);
result = true;
} catch (Exception e) {
result=false;
}
return result;
}
}

View File

@ -84,7 +84,7 @@ public class VolcengineUtil {
errorMessage="输出文本后审核未通过"; errorMessage="输出文本后审核未通过";
break; break;
case 50413: case 50413:
errorMessage="文本不符规范,请调整文本内容"; errorMessage="文本不符合安全规范,请调整文本内容";
break; break;
case 60101: case 60101:
errorMessage="图像解析错误"; errorMessage="图像解析错误";
@ -105,10 +105,13 @@ public class VolcengineUtil {
errorMessage="图像尺寸超过限制"; errorMessage="图像尺寸超过限制";
break; break;
case 50429: case 50429:
errorMessage="当前使用人数过多,请"; errorMessage="当前使用人数过多,请稍后再";
break; break;
case 50501: case 50501:
errorMessage="服务器内部RPC错误,正在重试"; errorMessage="服务器内部RPC错误,请稍后再试";
break;
case 50400:
errorMessage="权限校验失败,请联系管理员";
break; break;
} }
return errorMessage; return errorMessage;

View File

@ -28,4 +28,7 @@ public class AiPictureVo {
@ApiModelProperty(value = "换衣-下衣url") @ApiModelProperty(value = "换衣-下衣url")
private String bottomImageUrl; private String bottomImageUrl;
@ApiModelProperty(value = "图片大小")
private String size;
} }

View File

@ -76,7 +76,7 @@
show, edit, createtime, pwdupdatetime, state,salt show, edit, createtime, pwdupdatetime, state,salt
</sql> </sql>
<select id="findByUsername" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="findByUsername" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM ac_user where username = #{username} and usertype = #{usertype} and state = 't' FROM ac_user where username = #{username} and usertype = #{usertype} and state = 't'

View File

@ -28,7 +28,7 @@
type, type,
review_status review_status
from (select from (select
pa_creation."id", pa_collection."id",
pa_creation."name", pa_creation."name",
pa_creation.photo_id, pa_creation.photo_id,
pa_creation.user_id, pa_creation.user_id,

View File

@ -70,7 +70,8 @@
ac_user.realname as upload_name, ac_user.realname as upload_name,
cp_label.name as label_name, cp_label.name as label_name,
pa_picture_wall.price as price, pa_picture_wall.price as price,
pa_services.name as service_name pa_services.name as service_name,
pa_services.id as serviceId
from pa_picture_wall from pa_picture_wall
left join ac_user on pa_picture_wall.userid=ac_user.id left join ac_user on pa_picture_wall.userid=ac_user.id
left join cp_label on pa_picture_wall.cp_label_id =cp_label.id left join cp_label on pa_picture_wall.cp_label_id =cp_label.id