package com.test.test.controller;

import java.util.List;

import com.test.test.domain.qo.IDQO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.test.common.annotation.Log;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.common.enums.BusinessType;
import com.test.test.domain.TestHttp;
import com.test.test.service.ITestHttpService;

/**
 * http服务Controller
 */
@RestController
@RequestMapping("/test/http")
public class TestHttpController extends BaseController {
    @Resource
    private ITestHttpService testHttpService;

    /**
     * 查询http服务列表
     */
    @GetMapping("/list")
    public AjaxResult list() {
        return success(testHttpService.selectTestHttpList());
    }

    /**
     * 获取http服务详细信息
     */
    @PostMapping(value = "/detail")
    public AjaxResult getInfo(@RequestBody IDQO qo) {
        return success(testHttpService.selectTestHttpById(qo.getId()));
    }

    /**
     * 新增http服务
     */
    @Log(title = "http服务", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TestHttp testHttp) {
        return success(testHttpService.insertTestHttp(testHttp));
    }

    /**
     * 修改http服务
     */
    @Log(title = "http服务", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody TestHttp testHttp) {
        return toAjax(testHttpService.updateTestHttp(testHttp));
    }

    /**
     * 删除http服务
     */
    @Log(title = "http服务", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult remove(@RequestBody IDQO qo) {
        return toAjax(testHttpService.deleteTestHttpById(qo.getId()));
    }
}
