|
@@ -81,6 +81,13 @@ public class SceneController extends BaseController {
|
|
|
return sceneService.saves(param);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "查询该作品是否存在场景")
|
|
|
+ @GetMapping("findByWork/{workId}")
|
|
|
+ public Result findByWorkId(@PathVariable Long workId) {
|
|
|
+ List<SceneEntity> list = sceneService.findByWorkId(workId);
|
|
|
+ return Result.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@ApiOperation(value = "上传-图标", position = 2)
|
|
|
@PostMapping(value = "upload")
|
|
@@ -109,7 +116,7 @@ public class SceneController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "初始场景-设置", position = 3)
|
|
|
@PostMapping("setIndex/{id}/{workId}")
|
|
|
- public Result setIndex(@PathVariable Long id, @PathVariable Long workId) {
|
|
|
+ public Result setIndex(@PathVariable String id, @PathVariable Long workId) {
|
|
|
return sceneService.setIndex(id, workId);
|
|
|
}
|
|
|
|
|
@@ -123,7 +130,7 @@ public class SceneController extends BaseController {
|
|
|
@GetMapping("removeIndex/{workId}")
|
|
|
public Result removeIndex(@PathVariable Long workId) {
|
|
|
WorkEntity entity = workService.findById(workId);
|
|
|
- entity.setSceneIndex(null);
|
|
|
+ entity.setSceneIndex("");
|
|
|
entity.setUpdateTime(new Date());
|
|
|
workService.update(entity);
|
|
|
return Result.success();
|
|
@@ -167,7 +174,14 @@ public class SceneController extends BaseController {
|
|
|
@GetMapping("remove/{id}")
|
|
|
public Result remove(@PathVariable Long id) {
|
|
|
log.info("场景删除");
|
|
|
+
|
|
|
+ // 最后一个场景不能删除
|
|
|
SceneEntity entity = sceneService.findById(id);
|
|
|
+ List<SceneEntity> list = sceneService.findByWorkId(entity.getWorkId());
|
|
|
+ if (list.size() == 1) {
|
|
|
+ return Result.failure(3003,"请至少保留一个场景");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Long workId = entity.getWorkId();
|
|
|
entity.setIsDelete(1);
|
|
@@ -178,7 +192,7 @@ public class SceneController extends BaseController {
|
|
|
WorkEntity workEntity = workService.findById(workId);
|
|
|
|
|
|
if (workEntity != null || workEntity.getSceneIndex().equals(id) ) {
|
|
|
- workEntity.setSceneIndex(null);
|
|
|
+ workEntity.setSceneIndex("");
|
|
|
workEntity.setUpdateTime(new Date());
|
|
|
workService.update(workEntity);
|
|
|
}
|