package com.njzscloud.supervisory.endpoint.controller;

import com.njzscloud.supervisory.endpoint.pojo.SysEndpointEntity;
import com.njzscloud.supervisory.endpoint.service.SysEndpointService;
import lombok.extern.slf4j.Slf4j;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;

import java.util.List;

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

    private final SysEndpointService sysEndpointService;

    /**
     * 新增
     *
     * @param sysEndpointEntity 数据
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody SysEndpointEntity sysEndpointEntity) {
        sysEndpointService.add(sysEndpointEntity);
        return R.success();
    }

    /**
     * 修改
     *
     * @param sysEndpointEntity 数据
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody SysEndpointEntity sysEndpointEntity) {
        sysEndpointService.modify(sysEndpointEntity);
        return R.success();
    }

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

    /**
     * 详情
     *
     * @param id Id
     * @return SysEndpointEntity 结果
     */
    @GetMapping("/detail")
    public R<SysEndpointEntity> detail(@RequestParam Long id) {
        return R.success(sysEndpointService.detail(id));
    }

    /**
     * 分页查询
     *
     * @param sysEndpointEntity 筛选条件
     * @param pageParam         分页参数
     * @return PageResult&lt;SysEndpointEntity&gt; 分页结果
     */
    @GetMapping("/paging")
    public R<PageResult<SysEndpointEntity>> paging(PageParam pageParam, SysEndpointEntity sysEndpointEntity) {
        return R.success(sysEndpointService.paging(pageParam, sysEndpointEntity));
    }

}
