package cn.lihongjie.coal.empSalaryBatch.controller;

import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.AuditDto;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.empSalaryBatch.dto.BatchInitRequest;
import cn.lihongjie.coal.empSalaryBatch.dto.CreateEmpSalaryBatchDto;
import cn.lihongjie.coal.empSalaryBatch.dto.EmpSalaryBatchDto;
import cn.lihongjie.coal.empSalaryBatch.dto.UpdateEmpSalaryBatchDto;
import cn.lihongjie.coal.empSalaryBatch.service.EmpSalaryBatchService;

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("/empSalaryBatch")
@SysLog(module = "员工工资批次")
@Slf4j
@OrgScope
public class EmpSalaryBatchController {
    @Autowired private EmpSalaryBatchService service;

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

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

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

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

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

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

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

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

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

}
