|
@@ -1,5 +1,9 @@
|
|
|
package com.backendsys.modules.crt.service.impl;
|
|
|
|
|
|
+import com.backendsys.exception.CustException;
|
|
|
+import com.backendsys.modules.common.config.security.enums.SecurityEnum;
|
|
|
+import com.backendsys.modules.common.config.security.utils.SecurityUtil;
|
|
|
+import com.backendsys.modules.common.enums.MatchType;
|
|
|
import com.backendsys.modules.crt.dao.CrtDramaProjectDao;
|
|
|
import com.backendsys.modules.crt.dao.CrtDramaProjectSettingsDao;
|
|
|
import com.backendsys.modules.crt.dao.CrtDramaProjectStoryboardDao;
|
|
@@ -9,7 +13,6 @@ import com.backendsys.modules.crt.entity.CrtDramaProjectStoryboard;
|
|
|
import com.backendsys.modules.crt.enums.AspectRatioEnums;
|
|
|
import com.backendsys.modules.crt.enums.ProjectSettingTypeEnums;
|
|
|
import com.backendsys.modules.crt.service.CrtDramaProjectService;
|
|
|
-import com.backendsys.modules.crt.utils.CrtUtil;
|
|
|
import com.backendsys.utils.response.PageEntity;
|
|
|
import com.backendsys.utils.response.PageInfoResult;
|
|
|
import com.backendsys.utils.v2.PageUtils;
|
|
@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -25,7 +29,7 @@ import java.util.Map;
|
|
|
public class CrtDramaProjectServiceImpl implements CrtDramaProjectService {
|
|
|
|
|
|
@Autowired
|
|
|
- private CrtUtil crtUtil;
|
|
|
+ private SecurityUtil securityUtil;
|
|
|
@Autowired
|
|
|
private CrtDramaProjectDao crtDramaProjectDao;
|
|
|
@Autowired
|
|
@@ -72,43 +76,108 @@ public class CrtDramaProjectServiceImpl implements CrtDramaProjectService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 编辑短剧创作-项目
|
|
|
+ * 编辑项目
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Object> updateCrtDramaProject(CrtDramaProject crtDramaProject) {
|
|
|
|
|
|
+ Long project_id = crtDramaProject.getDrama_project_id();
|
|
|
+ CrtDramaProject projectDetail = crtDramaProjectDao.selectById(project_id);
|
|
|
+ if (projectDetail == null) throw new CustException("项目不存在");
|
|
|
+
|
|
|
+ // 是否 [项目] 拥有者,权限:
|
|
|
+ // - 编辑自己的 (需 36.1.4.1 权限)
|
|
|
+ // - 编辑自己及他人的 (需要 36.1.4 权限或超级管理员)
|
|
|
+ Boolean isOwner = projectDetail.getUser_id() == SecurityUtil.getUserId();
|
|
|
+ if (isOwner && !securityUtil.hasPermissions(Arrays.asList("36.1.4", "36.1.4.1"), MatchType.OR)) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ if (!isOwner && !securityUtil.hasPermission("36.1.4")) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ // ---------------------------------------------------------------------------
|
|
|
|
|
|
+ // [DB] 更新项目
|
|
|
+ crtDramaProjectDao.update(crtDramaProject, new LambdaQueryWrapper<CrtDramaProject>()
|
|
|
+ .eq(CrtDramaProject::getId, crtDramaProject.getDrama_project_id()));
|
|
|
+ return Map.of("drama_project_id", crtDramaProject.getDrama_project_id());
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // 有问题,还要判断自己是否具备 36.1.4.1 权限呢
|
|
|
-
|
|
|
- // 判断项目是否存在,并且是否具备操作权限
|
|
|
- crtUtil.checkProject(crtDramaProject.getDrama_project_id(), "36.1.4");
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- // [DB] 更新项目
|
|
|
- crtDramaProjectDao.update(crtDramaProject, new LambdaQueryWrapper<CrtDramaProject>()
|
|
|
- .eq(CrtDramaProject::getId, crtDramaProject.getDrama_project_id()));
|
|
|
- return Map.of("drama_project_id", crtDramaProject.getDrama_project_id());
|
|
|
+ /**
|
|
|
+ * 编辑项目生图/生视频配置
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> updateDramaProjectSettings(CrtDramaProjectSettings crtDramaProjectSettings) {
|
|
|
+
|
|
|
+ Long project_id = crtDramaProjectSettings.getDrama_project_id();
|
|
|
+ CrtDramaProject projectDetail = crtDramaProjectDao.selectById(project_id);
|
|
|
+ if (projectDetail == null) throw new CustException("项目不存在");
|
|
|
+
|
|
|
+ // 是否 [项目] 拥有者,权限:
|
|
|
+ // - 编辑自己的 (需 36.2.3.1 权限)
|
|
|
+ // - 编辑自己及他人的 (需要 36.2.3 权限或超级管理员)
|
|
|
+ Boolean isOwner = projectDetail.getUser_id() == SecurityUtil.getUserId();
|
|
|
+ if (isOwner && !securityUtil.hasPermissions(Arrays.asList("36.2.3", "36.2.3.1"), MatchType.OR)) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ if (!isOwner && !securityUtil.hasPermission("36.2.3")) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ // ---------------------------------------------------------------------------
|
|
|
+
|
|
|
+ // 项目配置类型 (1: 生图配置, 2: 生视频配置)
|
|
|
+ Integer setting_type = crtDramaProjectSettings.getDrama_project_setting_type();
|
|
|
+
|
|
|
+ // 查询条件
|
|
|
+ LambdaQueryWrapper<CrtDramaProjectSettings> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CrtDramaProjectSettings::getDrama_project_id, crtDramaProjectSettings.getDrama_project_id());
|
|
|
+ wrapper.eq(CrtDramaProjectSettings::getDrama_project_setting_type, setting_type);
|
|
|
+
|
|
|
+ // 更新字段
|
|
|
+ CrtDramaProjectSettings entity = new CrtDramaProjectSettings();
|
|
|
+ entity.setAspect_ratio(crtDramaProjectSettings.getAspect_ratio());
|
|
|
+
|
|
|
+ // 生图配置:基础模型、风格LoRA、风格LoRA强度
|
|
|
+ if (setting_type == 1) {
|
|
|
+ entity.setModel_id(crtDramaProjectSettings.getModel_id());
|
|
|
+ entity.setLora_style_id(crtDramaProjectSettings.getLora_style_id());
|
|
|
+ entity.setLora_style_strength(crtDramaProjectSettings.getLora_style_strength());
|
|
|
+ }
|
|
|
+
|
|
|
+ crtDramaProjectSettingsDao.update(entity, wrapper);
|
|
|
+ return Map.of("drama_project_id", crtDramaProjectSettings.getDrama_project_id());
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 删除短剧创作-项目
|
|
|
+ * 删除项目
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String, Object> deleteCrtDramaProject(CrtDramaProject crtDramaProject) {
|
|
|
|
|
|
- // 判断项目是否存在,并且是否具备操作权限
|
|
|
- crtUtil.checkProject(crtDramaProject.getDrama_project_id(), "36.1.6");
|
|
|
+ Long project_id = crtDramaProject.getDrama_project_id();
|
|
|
+ CrtDramaProject projectDetail = crtDramaProjectDao.selectById(project_id);
|
|
|
+ if (projectDetail == null) throw new CustException("项目不存在");
|
|
|
+
|
|
|
+ // 是否 [项目] 拥有者,权限:
|
|
|
+ // - 编辑自己的 (需 36.1.6.1 权限)
|
|
|
+ // - 编辑自己及他人的 (需要 36.1.6 权限或超级管理员)
|
|
|
+ Boolean isOwner = projectDetail.getUser_id() == SecurityUtil.getUserId();
|
|
|
+ if (isOwner && !securityUtil.hasPermissions(Arrays.asList("36.1.6", "36.1.6.1"), MatchType.OR)) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ if (!isOwner && !securityUtil.hasPermission("36.1.6")) {
|
|
|
+ throw new CustException(SecurityEnum.NOAUTH);
|
|
|
+ }
|
|
|
+ // ---------------------------------------------------------------------------
|
|
|
|
|
|
// [DB] 删除 [项目],同时删除 [项目配置]、[项目分集/分镜]
|
|
|
- Long project_id = crtDramaProject.getDrama_project_id();
|
|
|
crtDramaProjectDao.delete(new LambdaQueryWrapper<CrtDramaProject>().eq(CrtDramaProject::getId, project_id));
|
|
|
crtDramaProjectSettingsDao.delete(new LambdaQueryWrapper<CrtDramaProjectSettings>()
|
|
|
.eq(CrtDramaProjectSettings::getDrama_project_id, project_id));
|