package com.ycwl.basic.controller.pc;

import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
import com.ycwl.basic.service.printer.PrinterService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/printer/v1")
public class PrinterController {
    @Autowired
    private PrinterService printerService;

    @ApiOperation("查询列表")
    @PostMapping("/list")
    public ApiResponse<List<PrinterEntity>> list(@RequestBody PrinterEntity condition) {
        return printerService.list(condition);
    }

    @ApiOperation("获取详情")
    @GetMapping("/get/{id}")
    public ApiResponse<PrinterEntity> get(@PathVariable("id") Integer id) {
        return printerService.get(id);
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public ApiResponse<Integer> add(@RequestBody PrinterEntity entity) {
        return printerService.add(entity);
    }

    @ApiOperation("更新")
    @PostMapping("/update")
    public ApiResponse<Integer> update(@RequestBody PrinterEntity entity) {
        return printerService.update(entity);
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete/{id}")
    public ApiResponse<Integer> delete(@PathVariable("id") Integer id) {
        return printerService.delete(id);
    }
}