|
|
@@ -4324,19 +4324,29 @@ class AnimeService
|
|
|
* @param array $data 包含 parent_id(父文件夹ID,默认0表示最外层)、role(搜索关键词)
|
|
|
* @return array 返回当前目录下的所有子目录和角色列表(递归)
|
|
|
*/
|
|
|
- public function globalRoles($data) {
|
|
|
+ public function globalProducts($data) {
|
|
|
$cpid = Site::getCpid();
|
|
|
$parent_id = getProp($data, 'parent_id', 0);
|
|
|
- $role = getProp($data, 'role');
|
|
|
+ $product_name = getProp($data, 'product_name');
|
|
|
+ $product = getProp($data, 'product'); // 1.角色 2.场景 3.道具
|
|
|
+ if (!$product) {
|
|
|
+ Utils::throwError('20003:请选择产品类型');
|
|
|
+ }
|
|
|
|
|
|
// 如果有搜索关键词,只搜索角色图片
|
|
|
- if ($role) {
|
|
|
- $result = DB::table('mp_roles')
|
|
|
+ if ($product_name) {
|
|
|
+ $query = DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
->where('is_deleted', 0)
|
|
|
->where('type', 1)
|
|
|
- ->where('role', 'like', "%{$role}%")
|
|
|
- ->select('id', 'type', 'parent_id', 'level', 'role', 'url', 'pic_prompt', 'three_view_image_url', 'versions', 'created_at')
|
|
|
+ ->where('product_name', 'like', "%{$product_name}%");
|
|
|
+
|
|
|
+ // 如果指定了 product,添加筛选条件
|
|
|
+ if ($product) {
|
|
|
+ $query->where('product', $product);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = $query->select('id', 'type', 'parent_id', 'level', 'product_name', 'url', 'pic_prompt', 'three_view_image_url', 'versions', 'product', 'created_at')
|
|
|
->orderByRaw('sort_order DESC, created_at DESC')
|
|
|
->get()
|
|
|
->map(function($value) {
|
|
|
@@ -4345,6 +4355,7 @@ class AnimeService
|
|
|
$value['type'] = (int)$value['type'];
|
|
|
$value['parent_id'] = (int)$value['parent_id'];
|
|
|
$value['level'] = (int)$value['level'];
|
|
|
+ $value['product'] = (int)($value['product'] ?? 1);
|
|
|
$value['versions'] = json_decode($value['versions'], true) ?: [];
|
|
|
return $value;
|
|
|
})
|
|
|
@@ -4354,22 +4365,29 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
// 递归获取所有子目录和角色
|
|
|
- return $this->getChildrenRecursive($cpid, $parent_id);
|
|
|
+ return $this->getChildrenRecursive($cpid, $parent_id, $product);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 递归获取指定目录下的所有子目录和角色
|
|
|
* @param int $cpid 公司ID
|
|
|
* @param int $parent_id 父目录ID
|
|
|
+ * @param int|null $product 产品类型筛选 1.角色 2.场景 3.道具
|
|
|
* @return array
|
|
|
*/
|
|
|
- private function getChildrenRecursive($cpid, $parent_id) {
|
|
|
+ private function getChildrenRecursive($cpid, $parent_id, $product = null) {
|
|
|
// 查询当前层级的所有项(文件夹和角色)
|
|
|
- $items = DB::table('mp_roles')
|
|
|
+ $query = DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
->where('is_deleted', 0)
|
|
|
- ->where('parent_id', $parent_id)
|
|
|
- ->select('id', 'type', 'parent_id', 'level', 'role', 'url', 'pic_prompt', 'three_view_image_url', 'versions', 'created_at')
|
|
|
+ ->where('parent_id', $parent_id);
|
|
|
+
|
|
|
+ // 如果指定了 product,添加筛选条件(文件夹和角色都需要筛选)
|
|
|
+ if ($product) {
|
|
|
+ $query->where('product', $product);
|
|
|
+ }
|
|
|
+
|
|
|
+ $items = $query->select('id', 'type', 'parent_id', 'level', 'product_name', 'url', 'pic_prompt', 'three_view_image_url', 'versions', 'product', 'created_at')
|
|
|
->orderByRaw('type DESC, sort_order DESC, created_at DESC')
|
|
|
->get();
|
|
|
|
|
|
@@ -4381,17 +4399,18 @@ class AnimeService
|
|
|
'type' => (int)$item->type,
|
|
|
'parent_id' => (int)$item->parent_id,
|
|
|
'level' => (int)$item->level,
|
|
|
- 'role' => $item->role,
|
|
|
+ 'product_name' => $item->product_name,
|
|
|
'url' => $item->url,
|
|
|
- 'pic_prompt' => $item->pic_prompt,
|
|
|
+ 'pic_prompt' => $item->pic_prompt ?? '',
|
|
|
'three_view_image_url' => $item->three_view_image_url,
|
|
|
+ 'product' => (int)($item->product ?? 1),
|
|
|
'created_at' => transDate($item->created_at, 'Y-m-d')
|
|
|
];
|
|
|
$itemArray['versions'] = json_decode($item->versions, true) ?: [];
|
|
|
|
|
|
// 如果是文件夹,递归获取其子项
|
|
|
if ($item->type == 2) {
|
|
|
- $children = $this->getChildrenRecursive($cpid, $item->id);
|
|
|
+ $children = $this->getChildrenRecursive($cpid, $item->id, $product);
|
|
|
if (!empty($children)) {
|
|
|
$itemArray['children'] = $children;
|
|
|
}
|
|
|
@@ -4405,19 +4424,25 @@ class AnimeService
|
|
|
|
|
|
/**
|
|
|
* 创建文件夹
|
|
|
- * @param array $data 包含 parent_id(父文件夹ID)、role(文件夹名称
|
|
|
+ * @param array $data 包含 parent_id(父文件夹ID)、product_name(文件夹名称)、product(产品类型
|
|
|
* @return int 返回新建文件夹ID
|
|
|
*/
|
|
|
public function createFolder($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$parent_id = getProp($data, 'parent_id', 0);
|
|
|
- $folder_name = getProp($data, 'role', '新建文件夹');
|
|
|
+ $folder_name = getProp($data, 'product_name', '新建文件夹');
|
|
|
+
|
|
|
+ // 获取 product 字段:1.角色 2.场景 3.道具,默认为1
|
|
|
+ $product = getProp($data, 'product');
|
|
|
+ if (!in_array($product, [1, 2, 3])) {
|
|
|
+ Utils::throwError('20003:product 参数错误,只能是 1(角色)、2(场景) 或 3(道具)');
|
|
|
+ }
|
|
|
|
|
|
// 验证父文件夹
|
|
|
$parent_level = 0;
|
|
|
if ($parent_id > 0) {
|
|
|
- $parent = DB::table('mp_roles')
|
|
|
+ $parent = DB::table('mp_products')
|
|
|
->where('id', $parent_id)
|
|
|
->where('type', 2)
|
|
|
->where('is_deleted', 0)
|
|
|
@@ -4427,60 +4452,74 @@ class AnimeService
|
|
|
Utils::throwError('20003:父文件夹不存在');
|
|
|
}
|
|
|
|
|
|
+ // 检查父文件夹的 product 类型是否一致
|
|
|
+ if ($parent->product != $product) {
|
|
|
+ Utils::throwError('20003:文件夹类型必须与父文件夹一致');
|
|
|
+ }
|
|
|
+
|
|
|
$parent_level = $parent->level;
|
|
|
|
|
|
// 检查层级限制(最多3层)
|
|
|
if ($parent_level >= 3) {
|
|
|
- // Utils::throwError('20003:文件夹层级不能超过3层');
|
|
|
+ Utils::throwError('20003:文件夹层级不能超过3层');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 检查当前目录下是否已存在空白文件夹
|
|
|
- $empty_folder_exists = DB::table('mp_roles')
|
|
|
+ $empty_folder_exists = DB::table('mp_products')
|
|
|
->where('parent_id', $parent_id)
|
|
|
->where('type', 2)
|
|
|
- ->where('role', '新建文件夹')
|
|
|
+ ->where('product', $product)
|
|
|
+ ->where('product_name', '新建文件夹')
|
|
|
->where('is_deleted', 0)
|
|
|
->exists();
|
|
|
|
|
|
- if ($empty_folder_exists) {
|
|
|
+ if ($empty_folder_exists && $folder_name == '新建文件夹') {
|
|
|
Utils::throwError('20003:不允许创建多个空白文件夹,请先重命名现有文件夹');
|
|
|
}
|
|
|
|
|
|
// 创建文件夹
|
|
|
- $folder_id = DB::table('mp_roles')->insertGetId([
|
|
|
+ $folder_id = DB::table('mp_products')->insertGetId([
|
|
|
'user_id' => $uid,
|
|
|
'cpid' => $cpid,
|
|
|
'type' => 2,
|
|
|
'parent_id' => $parent_id,
|
|
|
'level' => $parent_level + 1,
|
|
|
- 'role' => $folder_name,
|
|
|
+ 'product_name' => $folder_name,
|
|
|
+ 'product' => $product,
|
|
|
'sort_order' => time(), // 使用时间戳作为排序权重
|
|
|
'is_deleted' => 0,
|
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
]);
|
|
|
|
|
|
- return $folder_id;
|
|
|
+ return [
|
|
|
+ 'id' => $folder_id,
|
|
|
+ 'type' => 2,
|
|
|
+ 'parent_id' => $parent_id,
|
|
|
+ 'level' => $parent_level + 1,
|
|
|
+ 'product_name' => $folder_name,
|
|
|
+ 'product' => $product,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 重命名文件夹或角色
|
|
|
- * @param array $data 包含 id、role(新名称)
|
|
|
+ * @param array $data 包含 id、product_name(新名称)
|
|
|
* @return bool
|
|
|
*/
|
|
|
public function renameFolder($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
- $new_name = getProp($data, 'role');
|
|
|
+ $new_name = getProp($data, 'product_name');
|
|
|
|
|
|
if (!$id || !$new_name) {
|
|
|
Utils::throwError('20003:参数不完整');
|
|
|
}
|
|
|
|
|
|
// 检查是否存在
|
|
|
- $item = DB::table('mp_roles')
|
|
|
+ $item = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('is_deleted', 0)
|
|
|
@@ -4490,11 +4529,11 @@ class AnimeService
|
|
|
Utils::throwError('20003:项目不存在');
|
|
|
}
|
|
|
|
|
|
- return DB::table('mp_roles')
|
|
|
+ return DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->update([
|
|
|
- 'role' => $new_name,
|
|
|
+ 'product_name' => $new_name,
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
]);
|
|
|
}
|
|
|
@@ -4504,7 +4543,7 @@ class AnimeService
|
|
|
* @param array $data 包含 id(要移动的项目ID)、target_parent_id(目标父文件夹ID)
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function moveRoleOrFolder($data) {
|
|
|
+ public function moveProductOrFolder($data) {
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
$target_parent_id = getProp($data, 'target_parent_id', 0);
|
|
|
@@ -4514,7 +4553,7 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
// 检查要移动的项目
|
|
|
- $item = DB::table('mp_roles')
|
|
|
+ $item = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('is_deleted', 0)
|
|
|
@@ -4526,8 +4565,10 @@ class AnimeService
|
|
|
|
|
|
// 验证目标文件夹
|
|
|
$target_level = 0;
|
|
|
+ $target_product = $item->product; // 默认使用当前项目的 product
|
|
|
+
|
|
|
if ($target_parent_id > 0) {
|
|
|
- $target_parent = DB::table('mp_roles')
|
|
|
+ $target_parent = DB::table('mp_products')
|
|
|
->where('id', $target_parent_id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 2)
|
|
|
@@ -4538,7 +4579,13 @@ class AnimeService
|
|
|
Utils::throwError('20003:目标文件夹不存在');
|
|
|
}
|
|
|
|
|
|
+ // 检查 product 类型是否一致
|
|
|
+ if ($target_parent->product != $item->product) {
|
|
|
+ Utils::throwError('20003:不能移动到不同类型的文件夹下');
|
|
|
+ }
|
|
|
+
|
|
|
$target_level = $target_parent->level;
|
|
|
+ $target_product = $target_parent->product;
|
|
|
|
|
|
// 如果移动的是文件夹,需要检查层级
|
|
|
if ($item->type == 2) {
|
|
|
@@ -4547,7 +4594,7 @@ class AnimeService
|
|
|
$depth = $max_child_level - $item->level;
|
|
|
|
|
|
if ($target_level + 1 + $depth > 3) {
|
|
|
- // Utils::throwError('20003:移动后文件夹层级将超过3层限制');
|
|
|
+ Utils::throwError('20003:移动后文件夹层级将超过3层限制');
|
|
|
}
|
|
|
|
|
|
// 不能移动到自己或自己的子文件夹下
|
|
|
@@ -4559,7 +4606,7 @@ class AnimeService
|
|
|
|
|
|
// 更新父文件夹和层级
|
|
|
$new_level = $target_level + 1;
|
|
|
- DB::table('mp_roles')
|
|
|
+ DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->update([
|
|
|
'parent_id' => $target_parent_id,
|
|
|
@@ -4581,17 +4628,17 @@ class AnimeService
|
|
|
* @return int
|
|
|
*/
|
|
|
private function getMaxChildLevel($folder_id) {
|
|
|
- $max_level = DB::table('mp_roles')
|
|
|
+ $max_level = DB::table('mp_products')
|
|
|
->where('parent_id', $folder_id)
|
|
|
->where('is_deleted', 0)
|
|
|
->max('level');
|
|
|
|
|
|
if (!$max_level) {
|
|
|
- return DB::table('mp_roles')->where('id', $folder_id)->value('level');
|
|
|
+ return DB::table('mp_products')->where('id', $folder_id)->value('level');
|
|
|
}
|
|
|
|
|
|
// 递归查找子文件夹
|
|
|
- $children = DB::table('mp_roles')
|
|
|
+ $children = DB::table('mp_products')
|
|
|
->where('parent_id', $folder_id)
|
|
|
->where('type', 2)
|
|
|
->where('is_deleted', 0)
|
|
|
@@ -4618,7 +4665,7 @@ class AnimeService
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- $parent = DB::table('mp_roles')
|
|
|
+ $parent = DB::table('mp_products')
|
|
|
->where('id', $target_id)
|
|
|
->where('is_deleted', 0)
|
|
|
->first();
|
|
|
@@ -4636,14 +4683,14 @@ class AnimeService
|
|
|
* @param int $parent_level
|
|
|
*/
|
|
|
private function updateChildrenLevel($parent_id, $parent_level) {
|
|
|
- $children = DB::table('mp_roles')
|
|
|
+ $children = DB::table('mp_products')
|
|
|
->where('parent_id', $parent_id)
|
|
|
->where('is_deleted', 0)
|
|
|
->get();
|
|
|
|
|
|
foreach ($children as $child) {
|
|
|
$new_level = $parent_level + 1;
|
|
|
- DB::table('mp_roles')
|
|
|
+ DB::table('mp_products')
|
|
|
->where('id', $child->id)
|
|
|
->update([
|
|
|
'level' => $new_level,
|
|
|
@@ -4676,7 +4723,7 @@ class AnimeService
|
|
|
|
|
|
|
|
|
while ($current_id > 0) {
|
|
|
- $folder = DB::table('mp_roles')
|
|
|
+ $folder = DB::table('mp_products')
|
|
|
->where('id', $current_id)
|
|
|
->where('type', 2)
|
|
|
->where('is_deleted', 0)
|
|
|
@@ -4688,7 +4735,7 @@ class AnimeService
|
|
|
|
|
|
array_unshift($path, [
|
|
|
'id' => $folder->id,
|
|
|
- 'name' => $folder->role
|
|
|
+ 'name' => $folder->product_name
|
|
|
]);
|
|
|
|
|
|
$current_id = $folder->parent_id;
|
|
|
@@ -4700,11 +4747,11 @@ class AnimeService
|
|
|
return $path;
|
|
|
}
|
|
|
|
|
|
- public function createRole($data) {
|
|
|
+ public function createProduct($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
- $role = trim(getProp($data, 'role'));
|
|
|
- if (!$role) Utils::throwError('20003:角色名不能为空');
|
|
|
+ $product_name = trim(getProp($data, 'product_name'));
|
|
|
+ if (!$product_name) Utils::throwError('20003:名称不能为空');
|
|
|
$url = trim(getProp($data, 'url'));
|
|
|
if (!$url) Utils::throwError('20003:图片地址不能为空');
|
|
|
|
|
|
@@ -4717,14 +4764,20 @@ class AnimeService
|
|
|
Utils::throwError('20003:图片格式不正确,仅支持 jpg、jpeg、png、gif、webp、bmp 格式');
|
|
|
}
|
|
|
$pic_prompt = trim(getProp($data, 'pic_prompt'));
|
|
|
- if (!$pic_prompt) Utils::throwError('20003:角色提示词不能为空');
|
|
|
+ if (!$pic_prompt) Utils::throwError('20003:提示词不能为空');
|
|
|
+
|
|
|
+ // 获取 product 字段:1.角色 2.场景 3.道具,默认为1
|
|
|
+ $product = getProp($data, 'product');
|
|
|
+ if (!in_array($product, [1, 2, 3])) {
|
|
|
+ Utils::throwError('20003:产品类型只能是 1(角色)、2(场景) 或 3(道具)');
|
|
|
+ }
|
|
|
|
|
|
// 获取父文件夹ID和层级
|
|
|
$parent_id = getProp($data, 'parent_id', 0);
|
|
|
$parent_level = 0;
|
|
|
|
|
|
if ($parent_id > 0) {
|
|
|
- $parent = DB::table('mp_roles')
|
|
|
+ $parent = DB::table('mp_products')
|
|
|
->where('id', $parent_id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 2)
|
|
|
@@ -4738,52 +4791,54 @@ class AnimeService
|
|
|
$parent_level = $parent->level;
|
|
|
}
|
|
|
|
|
|
- $id = DB::table('mp_roles')->insertGetId([
|
|
|
+ $id = DB::table('mp_products')->insertGetId([
|
|
|
'user_id' => $uid,
|
|
|
'cpid' => $cpid,
|
|
|
'type' => 1, // 1=角色图片
|
|
|
'parent_id' => $parent_id,
|
|
|
'level' => $parent_level + 1,
|
|
|
- 'role' => $role,
|
|
|
+ 'product_name' => $product_name,
|
|
|
'url' => $url,
|
|
|
'pic_prompt' => $pic_prompt,
|
|
|
+ 'product' => $product,
|
|
|
'sort_order' => time(), // 使用时间戳作为排序权重
|
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
]);
|
|
|
|
|
|
- if (!$id) Utils::throwError('20003:创建角色失败');
|
|
|
+ if (!$id) Utils::throwError('20003:创建失败');
|
|
|
return [
|
|
|
'id' => $id,
|
|
|
'type' => 1,
|
|
|
'parent_id' => $parent_id,
|
|
|
'level' => $parent_level + 1,
|
|
|
- 'role' => $role,
|
|
|
+ 'product_name' => $product_name,
|
|
|
'url' => $url,
|
|
|
- 'pic_prompt' => $pic_prompt
|
|
|
+ 'pic_prompt' => $pic_prompt,
|
|
|
+ 'product' => $product
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- public function editRole($data) {
|
|
|
+ public function editProduct($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
- if (!$id) Utils::throwError('20003:角色ID不能为空');
|
|
|
+ if (!$id) Utils::throwError('20003:ID不能为空');
|
|
|
|
|
|
- // 检查角色是否存在且属于当前用户
|
|
|
- $role = DB::table('mp_roles')
|
|
|
+ // 检查是否存在且属于当前用户
|
|
|
+ $role = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 1)->first();
|
|
|
- if (!$role) Utils::throwError('20003:角色不存在');
|
|
|
+ if (!$role) Utils::throwError('20003:记录不存在');
|
|
|
|
|
|
$updateData = [];
|
|
|
$needVersionRecord = false; // 是否需要记录版本
|
|
|
|
|
|
- // 角色名
|
|
|
- $roleName = trim(getProp($data, 'role'));
|
|
|
- if ($roleName) {
|
|
|
- $updateData['role'] = $roleName;
|
|
|
+ // 名称
|
|
|
+ $product_name = trim(getProp($data, 'product_name'));
|
|
|
+ if ($product_name) {
|
|
|
+ $updateData['product_name'] = $product_name;
|
|
|
}
|
|
|
|
|
|
// 图片地址
|
|
|
@@ -4806,7 +4861,7 @@ class AnimeService
|
|
|
$updateData['url'] = $url;
|
|
|
}
|
|
|
|
|
|
- // 角色提示词
|
|
|
+ // 提示词
|
|
|
$pic_prompt = trim(getProp($data, 'pic_prompt'));
|
|
|
if ($pic_prompt) {
|
|
|
// 如果 pic_prompt 有变更,记录版本
|
|
|
@@ -4870,7 +4925,7 @@ class AnimeService
|
|
|
|
|
|
$updateData['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
|
|
- return DB::table('mp_roles')
|
|
|
+ return DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
->where('id', $id)->update($updateData);
|
|
|
}
|
|
|
@@ -4880,12 +4935,12 @@ class AnimeService
|
|
|
* @param array $data 包含 id(角色ID)
|
|
|
* @return array 返回版本历史列表
|
|
|
*/
|
|
|
- public function getRoleVersions($data) {
|
|
|
+ public function getProductVersions($data) {
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
if (!$id) Utils::throwError('20003:角色ID不能为空');
|
|
|
|
|
|
- $role = DB::table('mp_roles')
|
|
|
+ $role = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 1)
|
|
|
@@ -4915,7 +4970,7 @@ class AnimeService
|
|
|
* @param array $data 包含 id(角色ID)、version(版本号)
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function restoreRoleVersion($data) {
|
|
|
+ public function restoreProductVersion($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
@@ -4924,7 +4979,7 @@ class AnimeService
|
|
|
if (!$id) Utils::throwError('20003:角色ID不能为空');
|
|
|
if (!$version) Utils::throwError('20003:版本号不能为空');
|
|
|
|
|
|
- $role = DB::table('mp_roles')
|
|
|
+ $role = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 1)
|
|
|
@@ -4963,7 +5018,7 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
// 恢复到指定版本
|
|
|
- return DB::table('mp_roles')
|
|
|
+ return DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->update([
|
|
|
@@ -4974,36 +5029,38 @@ class AnimeService
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- public function deleteRole($data) {
|
|
|
+ public function deleteProduct($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
- if (!$id) Utils::throwError('20003:角色ID不能为空');
|
|
|
+ if (!$id) Utils::throwError('20003:ID不能为空');
|
|
|
|
|
|
- // 检查角色是否存在且属于当前用户
|
|
|
- $role = DB::table('mp_roles')
|
|
|
+ // 检查是否存在且属于当前用户
|
|
|
+ $role = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
- ->where('type', 1)->first();
|
|
|
- if (!$role) Utils::throwError('20003:角色不存在');
|
|
|
+ ->where('type', 1)
|
|
|
+ ->first();
|
|
|
+ if (!$role) Utils::throwError('20003:记录不存在');
|
|
|
|
|
|
- return DB::table('mp_roles')
|
|
|
+ return DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
- ->where('id', $id)->delete();
|
|
|
+ ->where('id', $id)
|
|
|
+ ->delete();
|
|
|
}
|
|
|
|
|
|
public function generateThreeView($data) {
|
|
|
$uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id');
|
|
|
- if (!$id) Utils::throwError('20003:角色ID不能为空');
|
|
|
+ if (!$id) Utils::throwError('20003:ID不能为空');
|
|
|
|
|
|
- // 检查角色是否存在且属于当前用户
|
|
|
- $role = DB::table('mp_roles')
|
|
|
+ // 检查是否存在且属于当前用户
|
|
|
+ $role = DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->where('type', 1)->first();
|
|
|
- if (!$role) Utils::throwError('20003:角色不存在');
|
|
|
+ if (!$role) Utils::throwError('20003:记录不存在');
|
|
|
|
|
|
$prompt = trim(getProp($data, 'prompt', '基于参考图生成主体的标准正面、侧面、后面三视图,主体完整。在最左侧添加主体正视图的特写,主体清晰完整。背景修改成纯白色,整体保持与参考图一致的美术风格和色彩搭配。画面无说明文字'));
|
|
|
$ref_img_url = trim(getProp($data, 'ref_img_url'));
|
|
|
@@ -5106,8 +5163,8 @@ class AnimeService
|
|
|
Utils::throwError('20003:三视图生成超时,请稍后重试');
|
|
|
}
|
|
|
|
|
|
- // 保存三视图到 mp_roles 表
|
|
|
- DB::table('mp_roles')
|
|
|
+ // 保存三视图到 mp_products 表
|
|
|
+ DB::table('mp_products')
|
|
|
->where('id', $id)
|
|
|
->where('cpid', $cpid)
|
|
|
->update([
|