feat(content): 新增运营分类与剧单分类管理
This commit is contained in:
1 parent
758c7521bb
commit
7b360ddccd
26 files changed
+1106
-3
No files matched your search
+115
@@ -0,0 +1,115 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.service.DramaClassificationService;
|
||||
import com.fruitshorts.content.vo.DramaBriefVO;
|
||||
import com.fruitshorts.content.vo.DramaClassificationRespVO;
|
||||
import com.fruitshorts.content.vo.DramaClassificationSaveReqVO;
|
||||
import com.fruitshorts.content.vo.DramaIdsReqVO;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 运营分类管理。分类与短剧类型(drama-categories)是两套独立概念,
|
||||
* 分类可自定义增删,并关联任意多部短剧。
|
||||
*/
|
||||
@Tag(name = "后台-运营分类")
|
||||
@RestController
|
||||
@RequestMapping("/admin/drama-classifications")
|
||||
@RequiredArgsConstructor
|
||||
public class DramaClassificationController {
|
||||
|
||||
private final DramaClassificationService classificationService;
|
||||
|
||||
@Operation(summary = "分类列表(带关联数量)")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<List<DramaClassificationRespVO>> list() {
|
||||
return Result.ok(classificationService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "新建分类")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:create')")
|
||||
@OperationLog(module = "内容管理", action = "新增分类")
|
||||
public Result<Long> create(@Valid @RequestBody DramaClassificationSaveReqVO req) {
|
||||
return Result.ok(classificationService.create(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "编辑分类")
|
||||
@PutMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "编辑分类")
|
||||
public Result<Void> update(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaClassificationSaveReqVO req) {
|
||||
classificationService.update(id, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除分类")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:delete')")
|
||||
@OperationLog(module = "内容管理", action = "删除分类")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
classificationService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分类下已关联的短剧")
|
||||
@GetMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> dramas(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(classificationService.pageDramas(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "尚未关联到该分类的短剧")
|
||||
@GetMapping("/{id}/dramas/candidates")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> candidates(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(classificationService.pageCandidates(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量关联短剧")
|
||||
@PostMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "分类关联短剧")
|
||||
public Result<Integer> bindDramas(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaIdsReqVO req) {
|
||||
return Result.ok(classificationService.bindDramas(id, req.getDramaIds()));
|
||||
}
|
||||
|
||||
@Operation(summary = "移除分类下的短剧")
|
||||
@DeleteMapping("/{id}/dramas/{dramaId}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "分类移除短剧")
|
||||
public Result<Void> unbindDrama(@PathVariable Long id, @PathVariable Long dramaId) {
|
||||
classificationService.unbindDrama(id, dramaId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.service.DramaPlaylistCategoryService;
|
||||
import com.fruitshorts.content.vo.DramaBriefVO;
|
||||
import com.fruitshorts.content.vo.DramaIdsReqVO;
|
||||
import com.fruitshorts.content.vo.DramaPlaylistCategoryRespVO;
|
||||
import com.fruitshorts.content.vo.DramaPlaylistCategorySaveReqVO;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 剧单分类管理:分类直接关联短剧,没有「剧单」这一层。
|
||||
* 与「类型」「分类管理」均无关。
|
||||
*/
|
||||
@Tag(name = "后台-剧单分类")
|
||||
@RestController
|
||||
@RequestMapping("/admin/drama-playlist-categories")
|
||||
@RequiredArgsConstructor
|
||||
public class DramaPlaylistCategoryController {
|
||||
|
||||
private final DramaPlaylistCategoryService categoryService;
|
||||
|
||||
@Operation(summary = "剧单分类列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<List<DramaPlaylistCategoryRespVO>> list() {
|
||||
return Result.ok(categoryService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "新建剧单分类")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:create')")
|
||||
@OperationLog(module = "内容管理", action = "新增剧单分类")
|
||||
public Result<Long> create(@Valid @RequestBody DramaPlaylistCategorySaveReqVO req) {
|
||||
return Result.ok(categoryService.create(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "编辑剧单分类")
|
||||
@PutMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "编辑剧单分类")
|
||||
public Result<Void> update(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaPlaylistCategorySaveReqVO req) {
|
||||
categoryService.update(id, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除剧单分类")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:delete')")
|
||||
@OperationLog(module = "内容管理", action = "删除剧单分类")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
categoryService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分类下已关联的短剧")
|
||||
@GetMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> dramas(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(categoryService.pageDramas(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "尚未关联到该分类的短剧")
|
||||
@GetMapping("/{id}/dramas/candidates")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> candidates(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(categoryService.pageCandidates(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量关联短剧")
|
||||
@PostMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "剧单分类关联短剧")
|
||||
public Result<Integer> bindDramas(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaIdsReqVO req) {
|
||||
return Result.ok(categoryService.bindDramas(id, req.getDramaIds()));
|
||||
}
|
||||
|
||||
@Operation(summary = "移除分类下的短剧")
|
||||
@DeleteMapping("/{id}/dramas/{dramaId}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "剧单分类移除短剧")
|
||||
public Result<Void> unbindDrama(@PathVariable Long id, @PathVariable Long dramaId) {
|
||||
categoryService.unbindDrama(id, dramaId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user