package cn.lihongjie.coal.coalBlend.controller;

import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.controller.BaseController;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.coalBlend.dto.CoalBlendDto;
import cn.lihongjie.coal.coalBlend.dto.CreateCoalBlendDto;
import cn.lihongjie.coal.coalBlend.dto.UpdateCoalBlendDto;
import cn.lihongjie.coal.coalBlend.service.CoalBlendService;

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;

@RequestMapping("/coalBlend")
@RestController
@SysLog(module = "配煤")
@OrgScope
public class CoalBlendController extends BaseController {

    @Autowired CoalBlendService service;

    @PostMapping("/blend")
    @SysLog(action = "配煤")
    public CoalBlendDto blend(@RequestBody CreateCoalBlendDto dto) {
        return this.service.blend(dto);
    }

    @PostMapping("/create")
    @SysLog(action = "新增")
    public CoalBlendDto create(@RequestBody CreateCoalBlendDto dto) {
        return this.service.create(dto);
    }

    @PostMapping("/update")
    @SysLog(action = "编辑")
    public CoalBlendDto update(@RequestBody UpdateCoalBlendDto dto) {
        return this.service.update(dto);
    }

    @PostMapping("/delete")
    @SysLog(action = "删除")
    public Object delete(@RequestBody IdRequest dto) {
        this.service.delete(dto);
        return true;
    }

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

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