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.ApiInfoService;
|
import com.iailab.module.data.gateway.entity.ApiInfoEntity;
|
import com.iailab.module.data.gateway.service.ApiGroupService;
|
import javax.annotation.Resource;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Date;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2022年07月15日 14:17:00
|
*/
|
@RestController
|
@RequestMapping("/api-gateway/info")
|
public class ApiInfoController {
|
@Resource
|
private ApiInfoService apiInfoService;
|
|
@Resource
|
private ApiGroupService apiGroupService;
|
|
/**
|
* API信息列表
|
*
|
* @param params
|
* @return
|
*/
|
@GetMapping("/list")
|
public R list(@RequestParam Map<String, Object> params) {
|
PageUtils page = apiInfoService.queryPage(params);
|
return R.ok().put("page", page);
|
}
|
|
/**
|
* 新增API信息
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/add")
|
public R add(@RequestBody ApiInfoEntity apiAppEntity) {
|
int count = apiInfoService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiAppEntity.setCreateTime(new Date());
|
apiInfoService.add(apiAppEntity);
|
return R.ok();
|
}
|
|
/**
|
* 更新API信息
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody ApiInfoEntity apiAppEntity) {
|
int count = apiInfoService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiInfoService.update(apiAppEntity);
|
return R.ok();
|
}
|
|
/**
|
* 删除API信息
|
*
|
* @param params
|
* @return
|
*/
|
@PostMapping("/delete")
|
public R delete(@RequestBody Map<String, Object> params) {
|
String id = (String)params.get("id");
|
apiInfoService.deleteById(id);
|
return R.ok();
|
}
|
|
/**
|
* API信息详情
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/info/{id}")
|
public R info(@PathVariable("id") String id){
|
ApiInfoEntity sysDictItemEntity = apiInfoService.getInfoById(id);
|
|
return R.ok().put("data", sysDictItemEntity);
|
}
|
}
|