package com.iailab.module.data.http.controller.admin; import com.iailab.framework.common.page.PageData; import com.iailab.module.data.common.utils.R; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.data.http.entity.HttpApiEntity; import com.iailab.module.data.http.service.HttpApiService; import javax.annotation.Resource; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; import java.util.UUID; import static com.iailab.framework.common.pojo.CommonResult.success; @RestController @RequestMapping("/data/http/api") public class HttpApiController { @Resource private HttpApiService httpApiService; @GetMapping("page") public CommonResult> page(@RequestParam Map params) { PageData page = httpApiService.page(params); return success(page); } @GetMapping("list") public CommonResult> list() { List list = httpApiService.list(); return new CommonResult>().setData(list); } /** * 根据id查询详情 * * @param id */ @GetMapping("/info/{id}") public R info(@PathVariable("id") String id){ HttpApiEntity info= httpApiService.selectById(id); return R.ok().put("data", info); } /** * 添加API * * @param httpApiEntity */ @PostMapping("/add") public R add(@RequestBody HttpApiEntity httpApiEntity){ String id = UUID.randomUUID().toString(); httpApiEntity.setId(id); httpApiService.insert(httpApiEntity); return R.ok(); } /** * 修改API * * @param httpApiEntity */ @PostMapping("/update") public R update(@RequestBody HttpApiEntity httpApiEntity) { httpApiService.updateById(httpApiEntity); return R.ok(); } /** * 删除API * * @param params * */ @PostMapping("/delete") public R delete(@RequestBody Map params) { String id = (String)params.get("id"); httpApiService.deleteById(id); return R.ok(); } }