package cn.lihongjie.coal.excelTemplate.controller;

import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.excelTemplate.dto.CreateExcelTemplateDto;
import cn.lihongjie.coal.excelTemplate.dto.ExcelTemplateDto;
import cn.lihongjie.coal.excelTemplate.dto.UpdateExcelTemplateDto;
import cn.lihongjie.coal.excelTemplate.service.ExcelTemplateService;

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("/excelTemplate")
@SysLog(module = "Excel模板生成服务")
@Slf4j
public class ExcelTemplateController {
    @Autowired private ExcelTemplateService service;

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

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

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

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

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