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.HttpTokenEntity; import com.iailab.module.data.http.service.HttpTokenService; import javax.annotation.Resource; import org.springframework.web.bind.annotation.*; import java.util.Map; import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2023年12月22日 10:52:00 */ @RestController @RequestMapping("/data/http/token") public class HttpTokenController { @Resource private HttpTokenService httpTokenService; /** * 分页 * * @param params * @return */ @GetMapping("page") public CommonResult> page(@RequestParam Map params) { PageData page = httpTokenService.page(params); return new CommonResult>().setData(page); } /** * 详情 * * @param id */ @GetMapping("/info/{id}") public R info(@PathVariable("id") String id) { HttpTokenEntity info = httpTokenService.selectById(id); return R.ok().put("data", info); } /** * 详情 * * @param apiId */ @GetMapping("/api-id/{apiId}") public R apiId(@PathVariable("apiId") String apiId) { HttpTokenEntity info = httpTokenService.getByApiId(apiId); return R.ok().put("data", info); } /** * 添加 * * @param httpApiEntity */ @PostMapping("/add") public R add(@RequestBody HttpTokenEntity httpApiEntity) { String id = UUID.randomUUID().toString(); httpApiEntity.setId(id); httpTokenService.insert(httpApiEntity); return R.ok(); } /** * 修改 * * @param httpApiEntity */ @PostMapping("/update") public R update(@RequestBody HttpTokenEntity httpApiEntity) { httpTokenService.updateById(httpApiEntity); return R.ok(); } /** * 删除 * * @param params */ @PostMapping("/delete") public R delete(@RequestBody Map params) { String id = (String) params.get("id"); httpTokenService.deleteById(id); return R.ok(); } }