fix: nanobanana回调和日志输出
This commit is contained in:
parent
48d4affe3a
commit
4465eca8d7
|
|
@ -112,7 +112,7 @@ public class ByteApiController extends BaseController {
|
||||||
|
|
||||||
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
||||||
aiOrderService.orderFailure(aiOrder);
|
aiOrderService.orderFailure(aiOrder);
|
||||||
return AjaxResult.error(-2, "generation failed, balance has been refunded");
|
return buildNanoGenerateFailureResult(nanoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskId = nanoResponse.getData().getTaskId();
|
String taskId = nanoResponse.getData().getTaskId();
|
||||||
|
|
@ -135,6 +135,7 @@ public class ByteApiController extends BaseController {
|
||||||
@ApiOperation("Portal 图生图:functionType=11调用v2,functionType=12调用pro")
|
@ApiOperation("Portal 图生图:functionType=11调用v2,functionType=12调用pro")
|
||||||
@Transactional
|
@Transactional
|
||||||
public AjaxResult nanoImgToImg(@RequestBody NanoBananaPortalImgRequest request) {
|
public AjaxResult nanoImgToImg(@RequestBody NanoBananaPortalImgRequest request) {
|
||||||
|
logger.info("[NanoImgToImg] 前端请求入参: {}", request);
|
||||||
String functionType = request.getFunctionType();
|
String functionType = request.getFunctionType();
|
||||||
if (StringUtils.isEmpty(functionType)) {
|
if (StringUtils.isEmpty(functionType)) {
|
||||||
return AjaxResult.error("functionType is null");
|
return AjaxResult.error("functionType is null");
|
||||||
|
|
@ -209,11 +210,13 @@ public class ByteApiController extends BaseController {
|
||||||
nanoRequest.setOutputFormat(request.getOutputFormat());
|
nanoRequest.setOutputFormat(request.getOutputFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("[NanoImgToImg] 上游请求参数: nanoApiType={}, requestBody={}", nanoApiType, nanoRequest);
|
||||||
NanoBananaResponse nanoResponse = byteService.generateNanoBanana(nanoApiType, nanoRequest);
|
NanoBananaResponse nanoResponse = byteService.generateNanoBanana(nanoApiType, nanoRequest);
|
||||||
|
logger.info("[NanoImgToImg] 上游响应结果: nanoApiType={}, response={}", nanoApiType, nanoResponse);
|
||||||
|
|
||||||
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
||||||
aiOrderService.orderFailure(aiOrder);
|
aiOrderService.orderFailure(aiOrder);
|
||||||
return AjaxResult.error(-2, "generation failed, balance has been refunded");
|
return buildNanoGenerateFailureResult(nanoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskId = nanoResponse.getData().getTaskId();
|
String taskId = nanoResponse.getData().getTaskId();
|
||||||
|
|
@ -233,13 +236,14 @@ public class ByteApiController extends BaseController {
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[NanoImgToImg] 调用上游异常并退款: functionType={}, nanoApiType={}, resolution={}, aspectRatio={}, numImages={}, imageUrlsSize={}, message={}",
|
logger.error("[NanoImgToImg] 调用上游异常并退款: functionType={}, nanoApiType={}, resolution={}, aspectRatio={}, numImages={}, imageUrlsSize={}, frontRequest={}, message={}",
|
||||||
functionType,
|
functionType,
|
||||||
nanoApiType,
|
nanoApiType,
|
||||||
request.getResolution(),
|
request.getResolution(),
|
||||||
request.getAspectRatio(),
|
request.getAspectRatio(),
|
||||||
request.getNumImages(),
|
request.getNumImages(),
|
||||||
imageUrls.size(),
|
imageUrls.size(),
|
||||||
|
request,
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
if (aiOrder != null) {
|
if (aiOrder != null) {
|
||||||
aiOrderService.orderFailure(aiOrder);
|
aiOrderService.orderFailure(aiOrder);
|
||||||
|
|
@ -311,7 +315,7 @@ public class ByteApiController extends BaseController {
|
||||||
nanoResponse == null ? "NULL_RESPONSE" : nanoResponse.getMessage(),
|
nanoResponse == null ? "NULL_RESPONSE" : nanoResponse.getMessage(),
|
||||||
nanoResponse == null || nanoResponse.getData() == null);
|
nanoResponse == null || nanoResponse.getData() == null);
|
||||||
aiOrderService.orderFailure(aiOrder);
|
aiOrderService.orderFailure(aiOrder);
|
||||||
return AjaxResult.error(-2, "generation failed, balance has been refunded");
|
return buildNanoGenerateFailureResult(nanoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskId = nanoResponse.getData().getTaskId();
|
String taskId = nanoResponse.getData().getTaskId();
|
||||||
|
|
@ -405,7 +409,7 @@ public class ByteApiController extends BaseController {
|
||||||
|
|
||||||
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
if (nanoResponse == null || nanoResponse.getCode() != 200 || nanoResponse.getData() == null) {
|
||||||
aiOrderService.orderFailure(aiOrder);
|
aiOrderService.orderFailure(aiOrder);
|
||||||
return AjaxResult.error(-2, "generation failed, balance has been refunded");
|
return buildNanoGenerateFailureResult(nanoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskId = nanoResponse.getData().getTaskId();
|
String taskId = nanoResponse.getData().getTaskId();
|
||||||
|
|
@ -681,6 +685,21 @@ public class ByteApiController extends BaseController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一处理 NanoBanana 提交任务失败场景,便于前端展示明确错误信息。
|
||||||
|
*/
|
||||||
|
private AjaxResult buildNanoGenerateFailureResult(NanoBananaResponse nanoResponse) {
|
||||||
|
if (nanoResponse != null && Integer.valueOf(402).equals(nanoResponse.getCode())) {
|
||||||
|
return AjaxResult.error(-4, "上游服务额度不足,请联系管理员充值");
|
||||||
|
}
|
||||||
|
if (nanoResponse != null
|
||||||
|
&& StringUtils.isNotBlank(nanoResponse.getMessage())
|
||||||
|
&& nanoResponse.getMessage().toLowerCase().contains("insufficient")) {
|
||||||
|
return AjaxResult.error(-4, "上游服务额度不足,请联系管理员充值");
|
||||||
|
}
|
||||||
|
return AjaxResult.error(-2, "generation failed, balance has been refunded");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保留原有视频回调(GET转POST兼容)
|
* 保留原有视频回调(GET转POST兼容)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- NanoBanana 异步任务:订单表需存储 taskId 供回调按任务匹配
|
||||||
|
-- 若库中已存在该列,执行会报错,可先执行:SHOW COLUMNS FROM ai_order LIKE 'task_id';
|
||||||
|
|
||||||
|
ALTER TABLE `ai_order`
|
||||||
|
ADD COLUMN `task_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'NanoBanana任务ID(回调匹配)' AFTER `img2`;
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,202 @@
|
||||||
|
-- NanoBanana 标签测试数据(幂等脚本)
|
||||||
|
-- 适用场景:portal-ui 快捷生图(functionType=1)
|
||||||
|
-- 执行方式:在目标库执行本脚本,可重复执行,不会产生重复标签
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
-- 1) 获取快捷生图 ai_id(优先 type=1,兜底标题=快捷生图)
|
||||||
|
SET @ai_id := (
|
||||||
|
SELECT id
|
||||||
|
FROM ai_manager
|
||||||
|
WHERE del_flag = '0'
|
||||||
|
AND (type = '1' OR title = '快捷生图')
|
||||||
|
ORDER BY CASE WHEN type = '1' THEN 0 ELSE 1 END, id
|
||||||
|
LIMIT 1
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 如果没有查到 ai_id,下面语句会因为 @ai_id 为 NULL 不插入数据
|
||||||
|
-- 可先检查:SELECT @ai_id;
|
||||||
|
|
||||||
|
-- 2) 创建父级标签(与 prompt 占位符一一对应)
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '发型', 0, NULL, '髮型', 'hairstyle'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '发型');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '眼睛颜色', 0, NULL, '眼睛顏色', 'eye color'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '眼睛颜色');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '配饰', 0, NULL, '配飾', 'accessory'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '配饰');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '表情', 0, NULL, '表情', 'expression'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '表情');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '姿势', 0, NULL, '姿勢', 'pose'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '姿势');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '背景', 0, NULL, '背景', 'background'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '背景');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '服装描述', 0, NULL, '服裝描述', 'outfit'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '服装描述');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '胸部大小', 0, NULL, '胸部大小', 'breast size'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '胸部大小');
|
||||||
|
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), 0, @ai_id, '多人描述', 0, NULL, '多人描述', 'multi person'
|
||||||
|
FROM dual
|
||||||
|
WHERE @ai_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '多人描述');
|
||||||
|
|
||||||
|
-- 3) 读取父级标签 ID
|
||||||
|
SET @p_hair := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '发型' LIMIT 1);
|
||||||
|
SET @p_eye := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '眼睛颜色' LIMIT 1);
|
||||||
|
SET @p_acc := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '配饰' LIMIT 1);
|
||||||
|
SET @p_exp := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '表情' LIMIT 1);
|
||||||
|
SET @p_pose := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '姿势' LIMIT 1);
|
||||||
|
SET @p_bg := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '背景' LIMIT 1);
|
||||||
|
SET @p_outfit := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '服装描述' LIMIT 1);
|
||||||
|
SET @p_breast := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '胸部大小' LIMIT 1);
|
||||||
|
SET @p_multi := (SELECT id FROM ai_tag WHERE ai_id = @ai_id AND parent_id = 0 AND title = '多人描述' LIMIT 1);
|
||||||
|
|
||||||
|
-- 4) 子标签(prompt 字段建议使用英文短语,避免模板替换后的语言混杂)
|
||||||
|
-- 发型
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), @p_hair, @ai_id, '黑长直', 0, 'long straight black hair', '黑長直', 'long straight black hair'
|
||||||
|
FROM dual WHERE @p_hair IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = @p_hair AND title = '黑长直');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), @p_hair, @ai_id, '浅金波浪长发', 0, 'long wavy blonde hair', '淺金波浪長髮', 'long wavy blonde hair'
|
||||||
|
FROM dual WHERE @p_hair IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = @p_hair AND title = '浅金波浪长发');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), @p_hair, @ai_id, '银白短发', 0, 'short silver hair', '銀白短髮', 'short silver hair'
|
||||||
|
FROM dual WHERE @p_hair IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = @p_hair AND title = '银白短发');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US)
|
||||||
|
SELECT '0', 'seed', NOW(), 'seed', NOW(), @p_hair, @ai_id, '双马尾', 0, 'twin tails hairstyle', '雙馬尾', 'twin tails hairstyle'
|
||||||
|
FROM dual WHERE @p_hair IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id = @ai_id AND parent_id = @p_hair AND title = '双马尾');
|
||||||
|
|
||||||
|
-- 眼睛颜色
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_eye,@ai_id,'琥珀色',0,'amber eyes','琥珀色','amber eyes' FROM dual
|
||||||
|
WHERE @p_eye IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_eye AND title='琥珀色');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_eye,@ai_id,'蓝色',0,'deep blue eyes','藍色','deep blue eyes' FROM dual
|
||||||
|
WHERE @p_eye IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_eye AND title='蓝色');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_eye,@ai_id,'绿色',0,'emerald green eyes','綠色','emerald green eyes' FROM dual
|
||||||
|
WHERE @p_eye IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_eye AND title='绿色');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_eye,@ai_id,'紫色',0,'violet eyes','紫色','violet eyes' FROM dual
|
||||||
|
WHERE @p_eye IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_eye AND title='紫色');
|
||||||
|
|
||||||
|
-- 配饰
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_acc,@ai_id,'无配饰',0,'no accessories','無配飾','no accessories' FROM dual
|
||||||
|
WHERE @p_acc IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_acc AND title='无配饰');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_acc,@ai_id,'银框眼镜',0,'silver frame glasses','銀框眼鏡','silver frame glasses' FROM dual
|
||||||
|
WHERE @p_acc IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_acc AND title='银框眼镜');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_acc,@ai_id,'珍珠耳环',0,'pearl earrings','珍珠耳環','pearl earrings' FROM dual
|
||||||
|
WHERE @p_acc IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_acc AND title='珍珠耳环');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_acc,@ai_id,'发光项链',0,'glowing necklace','發光項鍊','glowing necklace' FROM dual
|
||||||
|
WHERE @p_acc IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_acc AND title='发光项链');
|
||||||
|
|
||||||
|
-- 表情
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_exp,@ai_id,'微笑',0,'gentle smile','微笑','gentle smile' FROM dual
|
||||||
|
WHERE @p_exp IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_exp AND title='微笑');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_exp,@ai_id,'冷艳',0,'cool confident expression','冷豔','cool confident expression' FROM dual
|
||||||
|
WHERE @p_exp IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_exp AND title='冷艳');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_exp,@ai_id,'害羞',0,'shy expression','害羞','shy expression' FROM dual
|
||||||
|
WHERE @p_exp IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_exp AND title='害羞');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_exp,@ai_id,'俏皮眨眼',0,'playful wink','俏皮眨眼','playful wink' FROM dual
|
||||||
|
WHERE @p_exp IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_exp AND title='俏皮眨眼');
|
||||||
|
|
||||||
|
-- 姿势
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_pose,@ai_id,'站立回眸',0,'standing and looking back','站立回眸','standing and looking back' FROM dual
|
||||||
|
WHERE @p_pose IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_pose AND title='站立回眸');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_pose,@ai_id,'双手叉腰',0,'standing hands on hips','雙手叉腰','standing hands on hips' FROM dual
|
||||||
|
WHERE @p_pose IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_pose AND title='双手叉腰');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_pose,@ai_id,'坐姿侧身',0,'sitting side pose','坐姿側身','sitting side pose' FROM dual
|
||||||
|
WHERE @p_pose IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_pose AND title='坐姿侧身');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_pose,@ai_id,'单手撩发',0,'one hand touching hair','單手撩髮','one hand touching hair' FROM dual
|
||||||
|
WHERE @p_pose IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_pose AND title='单手撩发');
|
||||||
|
|
||||||
|
-- 背景
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_bg,@ai_id,'海边日落',0,'sunset beach background','海邊日落','sunset beach background' FROM dual
|
||||||
|
WHERE @p_bg IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_bg AND title='海边日落');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_bg,@ai_id,'赛博都市夜景',0,'cyberpunk city at night','賽博都市夜景','cyberpunk city at night' FROM dual
|
||||||
|
WHERE @p_bg IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_bg AND title='赛博都市夜景');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_bg,@ai_id,'古典室内',0,'classic indoor background','古典室內','classic indoor background' FROM dual
|
||||||
|
WHERE @p_bg IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_bg AND title='古典室内');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_bg,@ai_id,'樱花街道',0,'sakura street background','櫻花街道','sakura street background' FROM dual
|
||||||
|
WHERE @p_bg IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_bg AND title='樱花街道');
|
||||||
|
|
||||||
|
-- 服装描述
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_outfit,@ai_id,'白色连衣裙',0,'white dress','白色連衣裙','white dress' FROM dual
|
||||||
|
WHERE @p_outfit IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_outfit AND title='白色连衣裙');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_outfit,@ai_id,'黑色皮衣',0,'black leather jacket outfit','黑色皮衣','black leather jacket outfit' FROM dual
|
||||||
|
WHERE @p_outfit IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_outfit AND title='黑色皮衣');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_outfit,@ai_id,'运动风套装',0,'sporty outfit','運動風套裝','sporty outfit' FROM dual
|
||||||
|
WHERE @p_outfit IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_outfit AND title='运动风套装');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_outfit,@ai_id,'旗袍',0,'elegant cheongsam','旗袍','elegant cheongsam' FROM dual
|
||||||
|
WHERE @p_outfit IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_outfit AND title='旗袍');
|
||||||
|
|
||||||
|
-- 胸部大小
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_breast,@ai_id,'小',0,'small bust','小','small bust' FROM dual
|
||||||
|
WHERE @p_breast IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_breast AND title='小');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_breast,@ai_id,'中',0,'medium bust','中','medium bust' FROM dual
|
||||||
|
WHERE @p_breast IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_breast AND title='中');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_breast,@ai_id,'大',0,'large bust','大','large bust' FROM dual
|
||||||
|
WHERE @p_breast IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_breast AND title='大');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_breast,@ai_id,'超大',0,'very large bust','超大','very large bust' FROM dual
|
||||||
|
WHERE @p_breast IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_breast AND title='超大');
|
||||||
|
|
||||||
|
-- 多人描述
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_multi,@ai_id,'单人',0,'single person only','單人','single person only' FROM dual
|
||||||
|
WHERE @p_multi IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_multi AND title='单人');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_multi,@ai_id,'双人同框',0,'two persons in frame','雙人同框','two persons in frame' FROM dual
|
||||||
|
WHERE @p_multi IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_multi AND title='双人同框');
|
||||||
|
INSERT INTO ai_tag (del_flag, create_by, create_time, update_by, update_time, parent_id, ai_id, title, status, prompt, title_HK, title_US) SELECT '0','seed',NOW(),'seed',NOW(),@p_multi,@ai_id,'三人构图',0,'three persons composition','三人構圖','three persons composition' FROM dual
|
||||||
|
WHERE @p_multi IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ai_tag WHERE ai_id=@ai_id AND parent_id=@p_multi AND title='三人构图');
|
||||||
|
|
||||||
|
-- 5) 同步图生图(type=11)模版,避免与测试标签占位符不一致
|
||||||
|
UPDATE ai_manager
|
||||||
|
SET title = '图生图',
|
||||||
|
status = 1,
|
||||||
|
prompt = '1girl, solo, exact same character as reference image, (completely nude:1.2), naked, no clothes, breasts fully exposed, {胸部大小}, perfect anatomy, masterpiece, best quality',
|
||||||
|
parent_id_sort = NULL
|
||||||
|
WHERE type = '11'
|
||||||
|
AND del_flag = '0';
|
||||||
|
|
||||||
|
-- 6) 对齐快捷生图(type=1) parentIdSort(按当前 prompt 的占位符顺序)
|
||||||
|
UPDATE ai_manager
|
||||||
|
SET parent_id_sort = CONCAT_WS(',',
|
||||||
|
@p_hair, @p_eye, @p_acc, @p_exp, @p_pose, @p_bg, @p_outfit, @p_breast, @p_multi
|
||||||
|
)
|
||||||
|
WHERE id = @ai_id
|
||||||
|
AND @ai_id IS NOT NULL;
|
||||||
|
|
||||||
|
-- 7) 快速校验
|
||||||
|
-- SELECT id, parent_id, ai_id, title, prompt FROM ai_tag WHERE ai_id = @ai_id ORDER BY parent_id, id;
|
||||||
|
-- SELECT id, title, type, parent_id_sort FROM ai_manager WHERE id = @ai_id;
|
||||||
Loading…
Reference in New Issue