提交 | 用户 | 时间
|
c7f709
|
1 |
package com.iailab.module.data.channel.http.controller.admin; |
L |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.data.channel.http.entity.HttpApiEntity; |
|
7 |
import com.iailab.module.data.channel.http.service.HttpApiService; |
|
8 |
import com.iailab.module.data.channel.http.vo.HttpApiPageReqVO; |
|
9 |
import com.iailab.module.data.channel.http.vo.HttpApiRespVO; |
|
10 |
import org.springframework.web.bind.annotation.*; |
|
11 |
|
|
12 |
import javax.annotation.Resource; |
|
13 |
import javax.validation.Valid; |
|
14 |
import java.util.List; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author lirm |
|
21 |
* @Description |
|
22 |
* @createTime 2024年08月27日 |
|
23 |
*/ |
|
24 |
@RestController |
6bf63b
|
25 |
@RequestMapping("/data/channel/http/api") |
c7f709
|
26 |
public class HttpApiController { |
L |
27 |
|
|
28 |
@Resource |
|
29 |
private HttpApiService httpApiService; |
|
30 |
|
|
31 |
@GetMapping("page") |
|
32 |
public CommonResult<PageResult<HttpApiRespVO>> page(@Valid HttpApiPageReqVO reqVO) { |
|
33 |
PageResult<HttpApiEntity> page = httpApiService.queryPage(reqVO); |
|
34 |
return success(BeanUtils.toBean(page, HttpApiRespVO.class)); |
|
35 |
} |
|
36 |
|
|
37 |
@GetMapping("list") |
|
38 |
public CommonResult<List<HttpApiEntity>> list() { |
|
39 |
List<HttpApiEntity> list = httpApiService.list(); |
|
40 |
return success(list); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* 根据id查询详情 |
|
45 |
* |
|
46 |
* @param id |
|
47 |
*/ |
|
48 |
@GetMapping("/info/{id}") |
|
49 |
public CommonResult<HttpApiEntity> info(@PathVariable("id") String id){ |
|
50 |
HttpApiEntity info= httpApiService.info(id); |
|
51 |
return success(info); |
|
52 |
} |
|
53 |
/** |
|
54 |
* 添加API |
|
55 |
* |
|
56 |
* @param httpApiEntity |
|
57 |
*/ |
|
58 |
@PostMapping("/add") |
|
59 |
public CommonResult<Boolean> add(@RequestBody HttpApiEntity httpApiEntity){ |
|
60 |
String id = UUID.randomUUID().toString(); |
|
61 |
httpApiEntity.setId(id); |
|
62 |
httpApiService.add(httpApiEntity); |
|
63 |
return success(true); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* 修改API |
|
68 |
* |
|
69 |
* @param httpApiEntity |
|
70 |
*/ |
|
71 |
@PutMapping("/update") |
|
72 |
public CommonResult<Boolean> update(@RequestBody HttpApiEntity httpApiEntity) { |
|
73 |
httpApiService.update(httpApiEntity); |
|
74 |
return success(true); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* 删除API |
|
79 |
* |
|
80 |
* @param id |
|
81 |
* |
|
82 |
*/ |
|
83 |
@DeleteMapping("/delete") |
|
84 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
|
85 |
httpApiService.delete(id); |
|
86 |
return success(true); |
|
87 |
} |
|
88 |
} |