package com.vincent.rsf.openApi.controller.platform; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.vincent.rsf.openApi.entity.app.App; import com.vincent.rsf.openApi.entity.dto.CommonResponse; import com.vincent.rsf.openApi.service.AppService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * App管理Controller * * @author vincent * @since 2026-01-04 */ @RestController @RequestMapping("/api/app") @Api(tags = "应用管理") public class AppController { @Autowired private AppService appService; @ApiOperation("分页查询应用列表") @GetMapping("/page") public CommonResponse page(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size) { Page page = appService.page(new Page<>(current, size)); return CommonResponse.ok().setData(page); } @ApiOperation("查询所有应用") @GetMapping("/list") public CommonResponse list() { List list = appService.list(); return CommonResponse.ok().setData(list); } @ApiOperation("根据ID查询应用") @GetMapping("/{id}") public CommonResponse getById(@PathVariable String id) { App app = appService.getById(id); return CommonResponse.ok().setData(app); } @ApiOperation("新增应用") @PostMapping public CommonResponse save(@RequestBody App app) { boolean result = appService.save(app); if (result) { appService.refreshCache(); return CommonResponse.ok().setMsg("新增成功"); } return CommonResponse.error("新增失败"); } @ApiOperation("更新应用") @PutMapping public CommonResponse update(@RequestBody App app) { boolean result = appService.updateById(app); if (result) { appService.refreshCache(); return CommonResponse.ok().setMsg("更新成功"); } return CommonResponse.error("更新失败"); } @ApiOperation("删除应用") @DeleteMapping("/{id}") public CommonResponse delete(@PathVariable String id) { boolean result = appService.removeById(id); if (result) { appService.refreshCache(); return CommonResponse.ok().setMsg("删除成功"); } return CommonResponse.error("删除失败"); } @ApiOperation("批量删除应用") @DeleteMapping("/batch") public CommonResponse deleteBatch(@RequestBody List ids) { boolean result = appService.removeByIds(ids); if (result) { appService.refreshCache(); return CommonResponse.ok().setMsg("批量删除成功"); } return CommonResponse.error("批量删除失败"); } @ApiOperation("刷新应用缓存") @PostMapping("/refresh") public CommonResponse refresh() { appService.refreshCache(); return CommonResponse.ok().setMsg("缓存刷新成功"); } }