package com.sptg.device.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.device.api.dto.DeviceTemplateDto;
import com.sptg.device.api.entity.DeviceTemplate;
import com.sptg.device.api.feigns.DeviceTemplateFeign;
import com.sptg.device.biz.service.DeviceTemplateServiceInterface;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class DeviceTemplateController implements DeviceTemplateFeign {
    private final DeviceTemplateServiceInterface deviceTemplateServiceInterface;

    @Override
    @PostMapping(value = "/deviceTemplate/pagingQuery")
    public ResultBean<Page<DeviceTemplate>> pagingQuery(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.pagingQuery(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/addDeviceTemplate")
    public ResultBean<Boolean> addDeviceTemplate(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.addDeviceTemplate(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/updateDeviceTemplate")
    public ResultBean<Boolean> updateDeviceTemplate(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.updateDeviceTemplate(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/deleteDeviceTemplate")
    public ResultBean<Boolean> deleteDeviceTemplate(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.deleteDeviceTemplate(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/getOne")
    public DeviceTemplate getOne(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.getOne(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/getListByCondition")
    public List<DeviceTemplate> getListByCondition(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.getListByCondition(deviceTemplateDto);
    }

    @Override
    @PostMapping(value = "/deviceTemplate/getOneById/{id}")
    public DeviceTemplate getOneById(@PathVariable(value = "id") Long id) {
        return this.deviceTemplateServiceInterface.selectById(id);
    }

    @Override
    public List<DeviceTemplate> getListByLikeTypeCode(@RequestBody DeviceTemplateDto deviceTemplateDto) {
        return this.deviceTemplateServiceInterface.getListByLikeTypeCode(deviceTemplateDto);
    }
}
