|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.yusys.yusp.controller;
|
|
|
|
|
|
+import cn.com.yusys.yusp.model.Result;
|
|
|
import cn.com.yusys.yusp.domain.dto.TabAppCreateDTO;
|
|
|
import cn.com.yusys.yusp.domain.entity.TabApp;
|
|
|
import cn.com.yusys.yusp.service.TabAppService;
|
|
|
@@ -18,29 +19,60 @@ public class TabAppController {
|
|
|
private TabAppService tabAppService;
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
- public Page<TabApp> listApps(
|
|
|
+ public Result<Page<TabApp>> listApps(
|
|
|
@RequestParam(defaultValue = "1") int page,
|
|
|
@RequestParam(defaultValue = "10") int size) {
|
|
|
- return tabAppService.listApps(page, size);
|
|
|
+ try {
|
|
|
+ Page<TabApp> pageResult = tabAppService.listApps(page, size);
|
|
|
+ // 封装为 Result 对象
|
|
|
+ return Result.success(pageResult, pageResult.getTotal());
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("500", "分页查询失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping("/add")
|
|
|
- public TabApp addApp(@Validated @RequestBody TabAppCreateDTO dto) {
|
|
|
- return tabAppService.addApp(dto);
|
|
|
+ public Result<TabApp> addApp(@Validated @RequestBody TabAppCreateDTO dto) {
|
|
|
+ try {
|
|
|
+ TabApp app = tabAppService.addApp(dto);
|
|
|
+ return Result.success(app); // 成功时返回封装后的数据
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("500", "应用新增失败:" + e.getMessage()); // 异常时返回错误信息
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@GetMapping("/query")
|
|
|
- public List<TabApp> queryByName(@RequestParam String appName) {
|
|
|
- return tabAppService.queryByName(appName);
|
|
|
+ public Result<List<TabApp>> queryByName(@RequestParam String appName) {
|
|
|
+ try {
|
|
|
+ List<TabApp> apps = tabAppService.queryByAppNameLike(appName);
|
|
|
+ return Result.success(apps); // 成功时返回封装后的数据
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("500", "应用查询失败:" + e.getMessage()); // 异常时返回错误信息
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @PutMapping("/reset-secret/{id}")
|
|
|
- public String resetSecret(@PathVariable String id) {
|
|
|
- return tabAppService.resetSecret(id);
|
|
|
+
|
|
|
+ @PostMapping("/reset-secret")
|
|
|
+ public Result<String> resetSecret(@RequestParam String id) {
|
|
|
+ try {
|
|
|
+ String newSecret = tabAppService.resetSecret(id);
|
|
|
+ return Result.success(newSecret);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("500", "密钥重置失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @PutMapping("/disable/{id}")
|
|
|
- public void disableApp(@PathVariable String id) {
|
|
|
- tabAppService.disableApp(id);
|
|
|
+
|
|
|
+ @PostMapping("/disable")
|
|
|
+ public Result<Void> disableApp(@RequestParam String id) {
|
|
|
+ try {
|
|
|
+ tabAppService.disableApp(id);
|
|
|
+ return Result.success();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error("500", "应用禁用失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|