package com.njzscloud.supervisory.device.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.device.pojo.entity.DeviceInfoEntity;
import com.njzscloud.supervisory.device.service.DeviceInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备信息表
 */
@Slf4j
@RestController
@RequestMapping("/device_info")
@RequiredArgsConstructor
public class DeviceInfoController {

    private final DeviceInfoService deviceInfoService;

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

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

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

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

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

}
