package cn.lihongjie.coal.acDevice.controller;

import cn.lihongjie.coal.acDevice.dto.AcDeviceDto;
import cn.lihongjie.coal.acDevice.dto.CreateAcDeviceDto;
import cn.lihongjie.coal.acDevice.dto.UpdateAcDeviceDto;
import cn.lihongjie.coal.acDevice.service.AcDeviceService;
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("/acDevice")
@SysLog(module = "门禁设备")
@Slf4j
@OrgScope
public class AcDeviceController {
    @Autowired private AcDeviceService service;

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

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

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

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

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