package cn.lihongjie.coal.acDeviceSupplier.controller;

import cn.lihongjie.coal.acDeviceSupplier.dto.AcDeviceSupplierDto;
import cn.lihongjie.coal.acDeviceSupplier.dto.CreateAcDeviceSupplierDto;
import cn.lihongjie.coal.acDeviceSupplier.dto.UpdateAcDeviceSupplierDto;
import cn.lihongjie.coal.acDeviceSupplier.service.AcDeviceSupplierService;
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 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("/acDeviceSupplier")
@SysLog(module = "门禁设备厂商")
@Slf4j
@OrgScope
public class AcDeviceSupplierController {
    @Autowired private AcDeviceSupplierService service;

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

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

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

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

    @PostMapping("/list")
    public Page<AcDeviceSupplierDto> 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;
    }
}
