package com.docus.server.service.impl;

import com.docus.infrastructure.redis.service.IdService;
import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.convert.SchVirtualLogConvert;
import com.docus.server.dto.scheduling.management.schvirtuallog.AddSchVirtualLogDTO;
import com.docus.server.dto.scheduling.management.schvirtuallog.DeleteSchVirtualLogDTO;
import com.docus.server.dto.scheduling.management.schvirtuallog.EditSchVirtualLogDTO;
import com.docus.server.entity.scheduling.management.SchVirtualLog;
import com.docus.server.infrastructure.dao.ISchVirtualLogDao;
import com.docus.server.service.ISchVirtualLogService;
import com.docus.server.vo.scheduling.management.schvirtuallog.SchVirtualLogVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 虚拟机使用情况 服务实现类
 *
 * @author AutoGenerator
 * @since 2023-07-15
 */
@Service
public class SchVirtualLogServiceImpl implements ISchVirtualLogService {
    @Resource
    private ISchVirtualLogDao iSchVirtualLogDao;
    @Resource
    private IdService idService;

    /**
     * 按主键查询
     *
     * @param id 主键Id
     * @return 实体
     */
    @Override
    public SchVirtualLogVO findById(String id) {
        return SchVirtualLogConvert.INSTANCE.convertVO(iSchVirtualLogDao.findById(id));
    }

    /**
     * 关键字搜索
     *
     * @param searchDTO 搜索参数
     * @return 分页列表
     */
    @Override
    public PageResult<SchVirtualLogVO> search(SearchDTO searchDTO) {
        return SchVirtualLogConvert.INSTANCE.convertVO(iSchVirtualLogDao.search(searchDTO));
    }

    /**
     * 新增
     *
     * @param addSchVirtualLogDTO 编辑参数
     * @return 成功或失败
     */
    @Override
    public boolean add(AddSchVirtualLogDTO addSchVirtualLogDTO) {
        SchVirtualLog schVirtualLog = SchVirtualLogConvert.INSTANCE.convertDO(addSchVirtualLogDTO);
        schVirtualLog.setId(idService.getDateSeq());
        return iSchVirtualLogDao.add(schVirtualLog);
    }

    /**
     * 编辑
     *
     * @param editSchVirtualLogDTO 编辑参数
     * @return 成功或失败
     */
    @Override
    public boolean edit(EditSchVirtualLogDTO editSchVirtualLogDTO) {
        SchVirtualLog schVirtualLog = SchVirtualLogConvert.INSTANCE.convertDO(editSchVirtualLogDTO);
        return iSchVirtualLogDao.edit(schVirtualLog);
    }

    /**
     * 批量删除
     *
     * @param deleteSchVirtualLogDTO 删除参数
     * @return 成功或失败
     */
    @Override
    public int delete(DeleteSchVirtualLogDTO deleteSchVirtualLogDTO) {
        return iSchVirtualLogDao.delete(deleteSchVirtualLogDTO.getIds());
    }
}

