package com.iailab.module.data.gateway.controller;
|
|
import com.iailab.module.data.common.utils.PageUtils;
|
import com.iailab.module.data.common.utils.R;
|
import com.iailab.module.data.gateway.service.ApiAuthorizedService;
|
import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity;
|
import javax.annotation.Resource;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2022年07月15日 14:16:00
|
*/
|
@RestController
|
@RequestMapping("/api-gateway/authorized")
|
public class ApiAuthorizedController {
|
@Resource
|
private ApiAuthorizedService apiAuthorizedService;
|
|
/**
|
* 已授权API列表
|
*
|
* @param params
|
* @return
|
*/
|
@GetMapping("/list")
|
public R list(@RequestParam Map<String, Object> params) {
|
PageUtils page = apiAuthorizedService.queryPage(params);
|
return R.ok().put("page", page);
|
}
|
|
/**
|
* 已授权API更新
|
*
|
* @param apiAuthorizedEntity
|
* @return
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody ApiAuthorizedEntity apiAuthorizedEntity) {
|
apiAuthorizedService.update(apiAuthorizedEntity);
|
return R.ok();
|
}
|
|
/**
|
* API授权
|
*
|
* @param appId
|
* @param apiIdList
|
* @return
|
*/
|
@PostMapping("/grant-api/{appId}")
|
public R grantApi(@PathVariable("appId") String appId, @RequestBody List<String> apiIdList) {
|
apiAuthorizedService.grantApi(appId, apiIdList);
|
return R.ok();
|
}
|
|
/**
|
* 删除已授权API
|
*
|
* @param params
|
* @return
|
*/
|
@PostMapping("/delete")
|
public R delete(@RequestBody Map<String, Object> params) {
|
String id = (String)params.get("id");
|
apiAuthorizedService.deleteById(id);
|
return R.ok();
|
}
|
|
/**
|
* 已授权API详情
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/info/{id}")
|
public R info(@PathVariable("id") String id){
|
ApiAuthorizedEntity sysDictItemEntity = apiAuthorizedService.getInfoById(id);
|
|
return R.ok().put("dictItem", sysDictItemEntity);
|
}
|
}
|