package com.iailab.module.data.channel.http.controller.admin; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.data.channel.http.entity.HttpApiEntity; import com.iailab.module.data.channel.http.service.HttpApiService; import com.iailab.module.data.channel.http.vo.HttpApiPageReqVO; import com.iailab.module.data.channel.http.vo.HttpApiRespVO; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.util.List; import java.util.UUID; import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author lirm * @Description * @createTime 2024年08月27日 */ @RestController @RequestMapping("/data/http/api") public class HttpApiController { @Resource private HttpApiService httpApiService; @GetMapping("page") public CommonResult> page(@Valid HttpApiPageReqVO reqVO) { PageResult page = httpApiService.queryPage(reqVO); return success(BeanUtils.toBean(page, HttpApiRespVO.class)); } @GetMapping("list") public CommonResult> list() { List list = httpApiService.list(); return success(list); } /** * 根据id查询详情 * * @param id */ @GetMapping("/info/{id}") public CommonResult info(@PathVariable("id") String id){ HttpApiEntity info= httpApiService.info(id); return success(info); } /** * 添加API * * @param httpApiEntity */ @PostMapping("/add") public CommonResult add(@RequestBody HttpApiEntity httpApiEntity){ String id = UUID.randomUUID().toString(); httpApiEntity.setId(id); httpApiService.add(httpApiEntity); return success(true); } /** * 修改API * * @param httpApiEntity */ @PutMapping("/update") public CommonResult update(@RequestBody HttpApiEntity httpApiEntity) { httpApiService.update(httpApiEntity); return success(true); } /** * 删除API * * @param id * */ @DeleteMapping("/delete") public CommonResult delete(@RequestParam("id") String id) { httpApiService.delete(id); return success(true); } }