diff --git a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentCategoryController.java b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentCategoryController.java index e09585005..62ead985c 100644 --- a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentCategoryController.java +++ b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentCategoryController.java @@ -5,7 +5,6 @@ import com.luban.api.dto.H5ComponentCategoryQueryDTO; import com.luban.api.entity.H5ComponentCategory; import com.luban.api.service.H5ComponentCategoryService; import com.luban.api.vo.H5ComponentCategoryTreeVO; -import com.luban.api.vo.Result; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -31,53 +30,51 @@ public class H5ComponentCategoryController { @Operation(summary = "分页查询分类", description = "支持查询一级分类和子分类。不传 parentId 时查询一级分类,传入 parentId 时查询对应子分类") @GetMapping("/page") - public Result> pageCategories( + public Page pageCategories( @Parameter(description = "查询参数") @ModelAttribute H5ComponentCategoryQueryDTO queryDTO) { Page result = h5ComponentCategoryService.pageCategories(queryDTO); - return new Result<>(result); + return result; } @Operation(summary = "根据类型查询分类") @GetMapping("/by-type") - public Result> getCategoriesByType( + public List getCategoriesByType( @Parameter(description = "组件类型", required = true) @RequestParam String type) { List result = h5ComponentCategoryService.getCategoriesByType(type); - return new Result<>(result); + return result; } @Operation(summary = "获取分类树形结构") @GetMapping("/tree") - public Result> getCategoryTree() { + public List getCategoryTree() { List result = h5ComponentCategoryService.getCategoryTree(); - return new Result<>(result); + return result; } @Operation(summary = "创建分类") @PostMapping - public Result create( + public Long create( @Parameter(description = "分类信息", required = true) @RequestBody @Validated H5ComponentCategory category) { Long id = h5ComponentCategoryService.create(category); - return new Result<>(id); + return id; } @Operation(summary = "更新分类") @PostMapping("/update/{id}") - public Result update( + public void update( @Parameter(description = "分类 ID", required = true) @PathVariable Long id, @Parameter(description = "分类信息", required = true) @RequestBody @Validated H5ComponentCategory category) { - category.setId(id); h5ComponentCategoryService.update(category); - return new Result<>(); } @Operation(summary = "删除分类") @PostMapping("/delete/{id}") - public Result deleteById( + public void deleteById( @Parameter(description = "分类 ID", required = true) @PathVariable Long id) { h5ComponentCategoryService.deleteById(id); - return new Result<>(); } + } diff --git a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentController.java b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentController.java index 23056bcc2..0318806f8 100644 --- a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentController.java +++ b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/controller/H5ComponentController.java @@ -1,12 +1,10 @@ package com.luban.api.controller; -import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.luban.api.entity.H5Component; import com.luban.api.service.H5ComponentService; import com.luban.api.vo.H5ComponentVO; -import com.luban.api.vo.Result; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -32,15 +30,14 @@ public class H5ComponentController { @Operation(summary = "根据 ID 查询组件") @GetMapping("/{id}") - public Result getById( + public H5ComponentVO getById( @Parameter(description = "组件 ID") @PathVariable Long id) { - H5ComponentVO vo = h5ComponentService.getById(id); - return new Result<>(vo); + return h5ComponentService.getById(id); } @Operation(summary = "分页查询组件列表") @GetMapping("/page") - public Result> getPage( + public Page getPage( @Parameter(description = "页码", required = true) @RequestParam Integer page, @Parameter(description = "每页大小", required = true) @RequestParam Integer pageSize, @Parameter(description = "组件类型") @RequestParam(required = false) String type, @@ -48,24 +45,22 @@ public class H5ComponentController { @Parameter(description = "分类 ID") @RequestParam(required = false) Long categoryId, @Parameter(description = "标签 ID") @RequestParam(required = false) Long tagId) { - Page result = h5ComponentService.getPage(page, pageSize, type, keyword, categoryId, tagId); - return new Result<>(result); + return h5ComponentService.getPage(page, pageSize, type, keyword, categoryId, tagId); } @Operation(summary = "创建组件") @PostMapping - public Result create( + public Long create( @Parameter(description = "组件信息", required = true) @RequestBody @Validated H5Component component, @Parameter(description = "分类 ID 列表") @RequestBody(required = false) List categoryIds, @Parameter(description = "标签 ID 列表") @RequestBody(required = false) List tagIds) { - Long id = h5ComponentService.create(component, categoryIds, tagIds); - return new Result<>(id); + return h5ComponentService.create(component, categoryIds, tagIds); } @Operation(summary = "更新组件") @PostMapping("/update/{id}") - public Result update( + public void update( @Parameter(description = "组件 ID", required = true) @PathVariable Long id, @Parameter(description = "组件信息", required = true) @RequestBody @Validated H5Component component, @Parameter(description = "分类 ID 列表") @RequestBody(required = false) List categoryIds, @@ -73,48 +68,42 @@ public class H5ComponentController { component.setId(id); h5ComponentService.update(component, categoryIds, tagIds); - return new Result<>(); } @Operation(summary = "删除组件") @PostMapping("/delete/{id}") - public Result deleteById( + public void deleteById( @Parameter(description = "组件 ID", required = true) @PathVariable Long id) { h5ComponentService.deleteById(id); - return new Result<>(); } @Operation(summary = "批量删除组件") @PostMapping("/batch") - public Result deleteBatch( + public void deleteBatch( @Parameter(description = "组件 ID 列表", required = true) @RequestBody List ids) { h5ComponentService.deleteBatch(ids); - return new Result<>(); } @Operation(summary = "增加使用次数") @PostMapping("/{id}/usage") - public Result incrementUsageCount( + public void incrementUsageCount( @Parameter(description = "组件 ID", required = true) @PathVariable Long id) { h5ComponentService.incrementUsageCount(id); - return new Result<>(); } @Operation(summary = "增加点赞数") @PostMapping("/{id}/like") - public Result incrementLikeCount( + public void incrementLikeCount( @Parameter(description = "组件 ID", required = true) @PathVariable Long id) { h5ComponentService.incrementLikeCount(id); - return new Result<>(); } @Operation(summary = "获取热门组件") @GetMapping("/hot") - public Result> getHotComponents( + public List getHotComponents( @Parameter(description = "组件类型") @RequestParam(required = false) String type, @Parameter(description = "数量限制", required = true) @RequestParam Integer limit) { - List result = h5ComponentService.getHotComponents(type, limit); - return new Result<>(result); + return h5ComponentService.getHotComponents(type, limit); } } diff --git a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/vo/H5ComponentCategoryPageVO.java b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/vo/H5ComponentCategoryPageVO.java index 0d0d31713..d38d3754e 100644 --- a/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/vo/H5ComponentCategoryPageVO.java +++ b/ruoyi-site/ruoyi-h5/src/main/java/com/luban/api/vo/H5ComponentCategoryPageVO.java @@ -39,16 +39,4 @@ public class H5ComponentCategoryPageVO { */ private Integer pages; - /** - * 从 MyBatis-Plus Page 构建分页 VO - */ - public static H5ComponentCategoryPageVO from(Page page) { - H5ComponentCategoryPageVO vo = new H5ComponentCategoryPageVO(); - vo.setList(page.getRecords()); - vo.setTotal(page.getTotal()); - vo.setPageNum((int) page.getCurrent()); - vo.setPageSize((int) page.getSize()); - vo.setPages((int) ((page.getTotal() + page.getSize() - 1) / page.getSize())); - return vo; - } }