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.HttpTokenEntity; import com.iailab.module.data.channel.http.service.HttpTokenService; import com.iailab.module.data.channel.http.vo.HttpTokenPageReqVO; import com.iailab.module.data.channel.http.vo.HttpTokenRespVO; 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/token") public class HttpTokenController { @Resource private HttpTokenService httpTokenService; @GetMapping("page") public CommonResult<PageResult<HttpTokenRespVO>> page(@Valid HttpTokenPageReqVO reqVO) { PageResult<HttpTokenEntity> page = httpTokenService.queryPage(reqVO); return success(BeanUtils.toBean(page, HttpTokenRespVO.class)); } @GetMapping("list") public CommonResult<List<HttpTokenEntity>> list(){ List<HttpTokenEntity> list = httpTokenService.list(); return new CommonResult<List<HttpTokenEntity>>().setData(list); } @GetMapping("/info/{id}") public CommonResult<HttpTokenEntity> info(@PathVariable("id") String id){ HttpTokenEntity info= httpTokenService.info(id); return success(info); } @PostMapping("/add") public CommonResult<Boolean> add(@RequestBody HttpTokenEntity HttpTokenEntity){ String id = UUID.randomUUID().toString(); HttpTokenEntity.setId(id); httpTokenService.add(HttpTokenEntity); return success(true); } @PutMapping("/update") public CommonResult<Boolean> update(@RequestBody HttpTokenEntity HttpTokenEntity) { httpTokenService.update(HttpTokenEntity); return success(true); } @DeleteMapping("/delete") public CommonResult<Boolean> delete(@RequestParam("id") String id) { httpTokenService.delete(id); return success(true); } @GetMapping("/api-id/{apiId}") public CommonResult<HttpTokenEntity> apiId(@PathVariable("apiId") String apiId) { HttpTokenEntity info = httpTokenService.getByApiId(apiId); return success(info); } }