package cn.lihongjie.coal.coalPrice.controller;

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 cn.lihongjie.coal.coalPrice.dto.CoalPriceDto;
import cn.lihongjie.coal.coalPrice.dto.CreateCoalPriceDto;
import cn.lihongjie.coal.coalPrice.dto.UpdateCoalPriceDto;
import cn.lihongjie.coal.coalPrice.service.CoalPriceService;

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("/coalPrice")
@SysLog(module = "煤源价格记录")
@Slf4j
@OrgScope
public class CoalPriceController {
    @Autowired private CoalPriceService service;

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

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

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

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

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