package com.njzscloud.supervisory.sys.endpoint.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.supervisory.sys.endpoint.pojo.entity.EndpointEntity;
import com.njzscloud.supervisory.sys.endpoint.pojo.param.EndpointSearchParam;
import com.njzscloud.supervisory.sys.endpoint.pojo.result.EndpointDetailResult;
import com.njzscloud.supervisory.sys.endpoint.service.EndpointService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 端点信息表
 */
@Slf4j
@RestController
@RequestMapping("/endpoint")
@RequiredArgsConstructor
public class EndpointController {

    private final EndpointService endpointService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody EndpointEntity endpointEntity) {
        endpointService.add(endpointEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody EndpointEntity endpointEntity) {
        endpointService.modify(endpointEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        endpointService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<EndpointEntity> detail(@RequestParam Long id) {
        return R.success(endpointService.detail(id));
    }

    /**
     * 查询
     */
    @GetMapping("/list_all")
    public R<List<EndpointDetailResult>> listAll(EndpointSearchParam endpointSearchParam) {
        return R.success(endpointService.listAll(endpointSearchParam));
    }

}
