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.entity.ApiGroupEntity;
|
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:16:00
|
*/
|
@RestController
|
@RequestMapping("/api-gateway/group")
|
public class ApiGroupController {
|
@Resource
|
private ApiGroupService apiGroupService;
|
|
/**
|
* API分组列表
|
*
|
* @param params
|
* @return
|
*/
|
@GetMapping("/list")
|
public R list(@RequestParam Map<String, Object> params) {
|
PageUtils page = apiGroupService.queryPage(params);
|
return R.ok().put("page", page);
|
}
|
|
/**
|
* 新增API分组
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/add")
|
public R add(@RequestBody ApiGroupEntity apiAppEntity) {
|
int count = apiGroupService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiAppEntity.setCreateTime(new Date());
|
apiGroupService.add(apiAppEntity);
|
return R.ok();
|
}
|
|
/**
|
* 更新API分组
|
*
|
* @param apiAppEntity
|
* @return
|
*/
|
@PostMapping("/update")
|
public R update(@RequestBody ApiGroupEntity apiAppEntity) {
|
int count = apiGroupService.cheack(apiAppEntity);
|
if (count > 0) {
|
return R.error("名称或数据值重复");
|
}
|
apiGroupService.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");
|
apiGroupService.deleteById(id);
|
return R.ok();
|
}
|
|
/**
|
* API分组详情
|
*
|
* @param id
|
* @return
|
*/
|
@RequestMapping("/info/{id}")
|
public R info(@PathVariable("id") String id){
|
ApiGroupEntity sysDictItemEntity = apiGroupService.getInfoById(id);
|
|
return R.ok().put("data", sysDictItemEntity);
|
}
|
}
|