|
|
@@ -263,9 +263,10 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
public function chatList($data) {
|
|
|
+ $uid = Site::getUid();
|
|
|
$anime_name = getProp($data, 'anime_name');
|
|
|
|
|
|
- $query = DB::table('mp_animes')->where('is_deleted', 0);
|
|
|
+ $query = DB::table('mp_animes')->where('is_deleted', 0)->where('user_id', $uid);
|
|
|
if ($anime_name) {
|
|
|
$query->where('anime_name', 'like', "%$anime_name%");
|
|
|
}
|
|
|
@@ -539,10 +540,11 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
public function animeDetail($data) {
|
|
|
+ $uid = Site::getUid();
|
|
|
$anime_id = getProp($data, 'anime_id');
|
|
|
- $anime = DB::table('mp_animes')->where('id', $anime_id)->where('is_deleted', 0)
|
|
|
+ $anime = DB::table('mp_animes')->where('id', $anime_id)->where('is_deleted', 0)->where('user_id', $uid)
|
|
|
->selectRaw('id as anime_id, anime_name, intro, highlights, roles, role_relationship, core_contradiction, art_style, scenes, status, remark, generate_status, created_at, ace_mode')->first();
|
|
|
- if (!$anime) Utils::throwError('20003:该剧本不存在!');
|
|
|
+ if (!$anime) Utils::throwError('20003:权限不足');
|
|
|
$anime = (array)$anime;
|
|
|
$anime['roles'] = json_decode($anime['roles']);
|
|
|
$anime['scenes'] = json_decode($anime['scenes']);
|
|
|
@@ -560,12 +562,17 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
public function episodeInfo($data) {
|
|
|
+ $uid = Site::getUid();
|
|
|
$anime_id = getProp($data, 'anime_id');
|
|
|
$episode_id = getProp($data, 'episode_id');
|
|
|
if (!$anime_id || !$episode_id) {
|
|
|
Utils::throwError('1002:请选择剧集');
|
|
|
}
|
|
|
|
|
|
+ // 验证用户权限
|
|
|
+ $anime = DB::table('mp_animes')->where('id', $anime_id)->where('user_id', $uid)->where('is_deleted', 0)->first();
|
|
|
+ if (!$anime) Utils::throwError('20003:权限不足');
|
|
|
+
|
|
|
$episode = DB::table('mp_anime_episodes')->where('anime_id', $anime_id)->where('id', $episode_id)->select('id as episode_id', 'anime_id', 'episode_number', 'title', 'intro', 'art_style', 'roles', 'scenes', 'is_generated')->first();
|
|
|
if (!$episode) Utils::throwError('20003:该剧集不存在!');
|
|
|
$episode = (array)$episode;
|
|
|
@@ -625,6 +632,7 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
public function segmentInfo($data) {
|
|
|
+ $uid = Site::getUid();
|
|
|
$segment_id = getProp($data, 'segment_id');
|
|
|
if (!$segment_id) {
|
|
|
Utils::throwError('1002:请选择分镜');
|
|
|
@@ -633,6 +641,12 @@ class AnimeService
|
|
|
// 获取分镜信息
|
|
|
$segment = DB::table('mp_episode_segments')->where('segment_id', $segment_id)->first();
|
|
|
|
|
|
+ // 验证用户权限
|
|
|
+ if ($segment) {
|
|
|
+ $anime = DB::table('mp_animes')->where('id', getProp($segment, 'anime_id'))->where('user_id', $uid)->where('is_deleted', 0)->first();
|
|
|
+ if (!$anime) Utils::throwError('20003:权限不足');
|
|
|
+ }
|
|
|
+
|
|
|
$result = [
|
|
|
'segment_id' => getProp($segment, 'segment_id'),
|
|
|
'segment_number' => getProp($segment, 'segment_number'),
|
|
|
@@ -5409,6 +5423,7 @@ class AnimeService
|
|
|
* @return array 返回当前目录下的所有子目录和角色列表(递归)
|
|
|
*/
|
|
|
public function globalProducts($data) {
|
|
|
+ $uid = Site::getUid();
|
|
|
$cpid = Site::getCpid();
|
|
|
$id = getProp($data, 'id', 0);
|
|
|
$parent_id = getProp($data, 'parent_id', 0);
|
|
|
@@ -5422,6 +5437,7 @@ class AnimeService
|
|
|
if ($id || $product_name) {
|
|
|
$query = DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
+ ->where('user_id', $uid)
|
|
|
->where('is_deleted', 0);
|
|
|
|
|
|
// 如果指定了 id,按 id 精确查询
|
|
|
@@ -5458,7 +5474,7 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
// 递归获取所有子目录和角色
|
|
|
- return $this->getChildrenRecursive($cpid, $parent_id, $product);
|
|
|
+ return $this->getChildrenRecursive($cpid, $parent_id, $product, $uid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -5466,15 +5482,21 @@ class AnimeService
|
|
|
* @param int $cpid 公司ID
|
|
|
* @param int $parent_id 父目录ID
|
|
|
* @param int|null $product 产品类型筛选 1.角色 2.场景 3.道具
|
|
|
+ * @param int $uid 用户ID
|
|
|
* @return array
|
|
|
*/
|
|
|
- private function getChildrenRecursive($cpid, $parent_id, $product = null) {
|
|
|
+ private function getChildrenRecursive($cpid, $parent_id, $product = null, $uid = null) {
|
|
|
// 查询当前层级的所有项(文件夹和角色)
|
|
|
$query = DB::table('mp_products')
|
|
|
->where('cpid', $cpid)
|
|
|
->where('is_deleted', 0)
|
|
|
->where('parent_id', $parent_id);
|
|
|
|
|
|
+ // 添加用户ID验证
|
|
|
+ if ($uid) {
|
|
|
+ $query->where('user_id', $uid);
|
|
|
+ }
|
|
|
+
|
|
|
// 如果指定了 product,添加筛选条件(文件夹和角色都需要筛选)
|
|
|
if ($product) {
|
|
|
$query->where('product', $product);
|
|
|
@@ -5503,7 +5525,7 @@ class AnimeService
|
|
|
|
|
|
// 如果是文件夹,递归获取其子项
|
|
|
if ($item->type == 2) {
|
|
|
- $children = $this->getChildrenRecursive($cpid, $item->id, $product);
|
|
|
+ $children = $this->getChildrenRecursive($cpid, $item->id, $product, $uid);
|
|
|
if (!empty($children)) {
|
|
|
$itemArray['children'] = $children;
|
|
|
}
|