package cn.lihongjie.coal.meterDayLog.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.meterDayLog.dto.CreateMeterDayLogDto;
import cn.lihongjie.coal.meterDayLog.dto.MeterDayLogDto;
import cn.lihongjie.coal.meterDayLog.dto.UpdateMeterDayLogDto;
import cn.lihongjie.coal.meterDayLog.service.MeterDayLogService;

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("/meterDayLog")
@SysLog(
    module = "水电表抄表记录按天统计"
)
@Slf4j
@OrgScope
public class MeterDayLogController {
  @Autowired
  private MeterDayLogService service;

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

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

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

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

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