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.ApiServerService;
|
import com.iailab.module.data.gateway.entity.ApiServerEntity;
|
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/server")
|
public class ApiServerController {
|
@Resource
|
private ApiServerService apiServerService;
|
|
/**
|
* API提供方列表
|
*
|
* @param params
|
* @return
|
*/
|
@GetMapping("/list")
|
public R list(@RequestParam Map<String, Object> params) {
|
PageUtils page = apiServerService.queryPage(params);
|
return R.ok().put("page", page);
|
}
|
|
/**
|
* 新增API提供方
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/add")
|
public R add(@RequestBody ApiServerEntity apiAppEntity) {
|
int count = apiServerService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiAppEntity.setCreateTime(new Date());
|
apiServerService.add(apiAppEntity);
|
return R.ok();
|
}
|
|
/**
|
* 更新API提供方
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody ApiServerEntity apiAppEntity) {
|
int count = apiServerService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiServerService.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");
|
apiServerService.deleteById(id);
|
return R.ok();
|
}
|
|
/**
|
* API提供方详情
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/info/{id}")
|
public R info(@PathVariable("id") String id){
|
ApiServerEntity sysDictItemEntity = apiServerService.getInfoById(id);
|
|
return R.ok().put("data", sysDictItemEntity);
|
}
|
}
|