package cn.lihongjie.coal.deviceSupplier.controller;

import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.deviceSupplier.dto.CreateDeviceSupplierDto;
import cn.lihongjie.coal.deviceSupplier.dto.DeviceSupplierDto;
import cn.lihongjie.coal.deviceSupplier.dto.UpdateDeviceSupplierDto;
import cn.lihongjie.coal.deviceSupplier.service.DeviceSupplierService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/deviceSupplier")
@SysLog(module = "设备供应商")
@Slf4j
@OrgScope
public class DeviceSupplierController {
    @Autowired private DeviceSupplierService service;

    @PostMapping("/create")
    public DeviceSupplierDto create(@RequestBody CreateDeviceSupplierDto request) {
        return this.service.create(request);
    }

    @PostMapping("/update")
    public DeviceSupplierDto update(@RequestBody UpdateDeviceSupplierDto request) {
        return this.service.update(request);
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody IdRequest request) {
        this.service.delete(request);
        return true;
    }

    @PostMapping("/getById")
    public DeviceSupplierDto getById(@RequestBody IdRequest request) {
        return this.service.getById(request.getId());
    }

    @PostMapping("/list")
    public Page<DeviceSupplierDto> list(@RequestBody CommonQuery request) {
        return this.service.list(request);
    }

    @PostMapping("/archive")
    public Object archive(@RequestBody IdRequest request) {
        this.service.archive(request);
        return true;
    }

    @PostMapping("/unarchive")
    public Object unarchive(@RequestBody IdRequest request) {
        this.service.unarchive(request);
        return true;
    }
}
