Bladeren bron

枚举接口

master
chenchaod 3 maanden geleden
bovenliggende
commit
47964878ad
1 gewijzigde bestanden met toevoegingen van 42 en 0 verwijderingen
  1. 42
    0
      zhywpt-app-managew/src/main/java/cn/com/taiji/managew/api/EnumController.java

+ 42
- 0
zhywpt-app-managew/src/main/java/cn/com/taiji/managew/api/EnumController.java Bestand weergeven

@@ -0,0 +1,42 @@
package cn.com.taiji.managew.api;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.common.model.KeyValue;
import cn.com.taiji.common.web.ApiResponse;
import cn.com.taiji.core.entity.dict.AllEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

/**
* @Author:ChenChao
* @Date:2025/5/28 9:13
* @Filename:EnumController
* @description:
*/
@Api(tags = {"106.枚举"})
@RestController
@RequestMapping("/api/enum")
public class EnumController extends MyValidController {

private static final String all = "ALL_ENUM";
@ApiOperation("获取枚举")
@GetMapping("/getEnum")
public ApiResponse<List<KeyValue>> agreementInsert(String em) throws ManagerException {
List<KeyValue> keyValues = new ArrayList<>();
if (all.equals(em)){
keyValues = AllEnum.keyValues();
}else {
try {
AllEnum allEnum = AllEnum.valueOf(em);
keyValues = allEnum.getKeyValues();
}catch (IllegalArgumentException e){
throw new ManagerException("枚举不存在");
}
}
return ApiResponse.of(keyValues);
}

}

Laden…
Annuleren
Opslaan