/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.device.db.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import net.northking.cctp.common.db.DefaultPagination;
import net.northking.cctp.common.db.Pagination;
import net.northking.cctp.common.db.entity.EntityService;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.device.db.dao.CdDeviceUsageLogDao;
import net.northking.cctp.device.db.service.CdDeviceUsageLogService;
import net.northking.cctp.device.db.entity.CdDeviceUsageLog;

import net.northking.cctp.common.db.BasicDao;

import net.northking.cctp.device.dto.device.DeviceLogDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 设备使用记录
 *
 * <p>文件内容由代码生成器产生，请不要手动修改！ <br>
 * createdate:  2022-09-22 16:34:55  <br>
 * @author:  maven-cctp-plugin  <br>
 * @since:  1.0 <br>
 */
@Service
@ConditionalOnMissingBean(name = "CdDeviceUsageLogServiceImpl")
public class CdDeviceUsageLogServiceImpl extends EntityService<CdDeviceUsageLog> implements CdDeviceUsageLogService
{
private static final Logger logger = LoggerFactory.getLogger(CdDeviceUsageLogServiceImpl.class);

  private final CdDeviceUsageLogDao cdDeviceUsageLogDao;

  public CdDeviceUsageLogServiceImpl(CdDeviceUsageLogDao cdDeviceUsageLogDao) {this.cdDeviceUsageLogDao = cdDeviceUsageLogDao;}

  public BasicDao<CdDeviceUsageLog> getDao() {return cdDeviceUsageLogDao;}

  public CdDeviceUsageLog createEntity() { return new CdDeviceUsageLog();}

  @Override
  public Pagination<CdDeviceUsageLog> pageQuery(QueryByPage<DeviceLogDto> dto) {
    DefaultPagination<CdDeviceUsageLog> pagination = new DefaultPagination<>();
    Page<List<CdDeviceUsageLog>> page = PageMethod.startPage(dto.getPageNo(),dto.getPageSize());
    List<CdDeviceUsageLog> logs = this.cdDeviceUsageLogDao.queryPages(dto.getQuery());
    pagination.setRecords(logs);
    pagination.setPageNo(dto.getPageNo());
    pagination.setPageSize(dto.getPageSize());
    pagination.setRecordCount(page.getTotal());
    return pagination;
  }

  @Override
  public String queryCreatedBy(String deviceId) {
    return  this.cdDeviceUsageLogDao.queryCreatedBy(deviceId);
  }

  @Override
  public void deleteUsageLog() {
    this.cdDeviceUsageLogDao.deleteUsageLog();
  }


// ----      The End by Generator     ----//




}

