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.DeviceLocalizerEntity;
import com.njzscloud.supervisory.device.service.DeviceLocalizerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 定位器
 */
@Slf4j
@RestController
@RequestMapping("/device_localizer")
@RequiredArgsConstructor
public class DeviceLocalizerController {

    private final DeviceLocalizerService deviceLocalizerService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody DeviceLocalizerEntity deviceLocalizerEntity) {
        deviceLocalizerService.add(deviceLocalizerEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody DeviceLocalizerEntity deviceLocalizerEntity) {
        deviceLocalizerService.modify(deviceLocalizerEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<DeviceLocalizerEntity>> paging(PageParam pageParam, DeviceLocalizerEntity deviceLocalizerEntity) {
        return R.success(deviceLocalizerService.paging(pageParam, deviceLocalizerEntity));
    }

}
