liriming
2024-08-27 c7f70933adf89a163d0049c907492a6df60cb45f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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<PageResult<HttpApiRespVO>> page(@Valid HttpApiPageReqVO reqVO) {
        PageResult<HttpApiEntity> page = httpApiService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, HttpApiRespVO.class));
    }
 
    @GetMapping("list")
    public CommonResult<List<HttpApiEntity>> list() {
        List<HttpApiEntity> list = httpApiService.list();
        return success(list);
    }
 
    /**
     * 根据id查询详情
     *
     * @param id
     */
    @GetMapping("/info/{id}")
    public CommonResult<HttpApiEntity> info(@PathVariable("id") String id){
        HttpApiEntity info= httpApiService.info(id);
        return success(info);
    }
    /**
     * 添加API
     *
     * @param httpApiEntity
     */
    @PostMapping("/add")
    public CommonResult<Boolean> 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<Boolean> update(@RequestBody HttpApiEntity httpApiEntity) {
        httpApiService.update(httpApiEntity);
        return success(true);
    }
 
    /**
     * 删除API
     *
     * @param id
     *
     */
    @DeleteMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        httpApiService.delete(id);
        return success(true);
    }
}