package net.srt.controller; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import net.srt.convert.ApiGroupConvert; import net.srt.entity.ApiGroupEntity; import net.srt.framework.common.utils.Result; import net.srt.framework.common.utils.TreeNodeVo; import net.srt.service.ApiGroupService; import net.srt.vo.ApiGroup; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; /** * 数据服务-api分组 * * @author zrx 985134801@qq.com * @since 1.0.0 2023-01-28 */ @RestController @RequestMapping("/api-group") @AllArgsConstructor public class ApiGroupController { private final ApiGroupService apiGroupService; @GetMapping @Operation(summary = "查询文件分组树") public Result> listTree() { return Result.ok(apiGroupService.listTree()); } @GetMapping("{id}") @Operation(summary = "信息") @PreAuthorize("hasAuthority('data-service:api-group:info')") public Result get(@PathVariable("id") Long id){ ApiGroupEntity entity = apiGroupService.getById(id); return Result.ok(ApiGroupConvert.INSTANCE.convert(entity)); } @PostMapping @Operation(summary = "保存") @PreAuthorize("hasAuthority('data-service:api-group:save')") public Result save(@RequestBody ApiGroup vo) { apiGroupService.save(vo); return Result.ok(); } @PutMapping @Operation(summary = "修改") @PreAuthorize("hasAuthority('data-service:api-group:update')") public Result update(@RequestBody @Valid ApiGroup vo) { apiGroupService.update(vo); return Result.ok(); } @DeleteMapping("/{id}") @Operation(summary = "删除") @PreAuthorize("hasAuthority('data-service:api-group:delete')") public Result delete(@PathVariable Long id) { apiGroupService.delete(id); return Result.ok(); } }