package com.docus.server.service.impl;

import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.convert.SchOperationLogConvert;
import com.docus.server.dto.scheduling.management.schoperationlog.AddSchOperationLogDTO;
import com.docus.server.dto.scheduling.management.schoperationlog.DeleteSchOperationLogDTO;
import com.docus.server.dto.scheduling.management.schoperationlog.EditSchOperationLogDTO;
import com.docus.server.entity.scheduling.management.SchOperationLog;
import com.docus.server.infrastructure.dao.ISchOperationLogDao;
import com.docus.server.service.ISchOperationLogService;
import com.docus.server.vo.scheduling.management.schoperationlog.SchOperationLogVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 采集调度器操作日志 服务实现类
 *
 * @author AutoGenerator
 * @since 2023-07-15
 */
@Service
public class SchOperationLogServiceImpl implements ISchOperationLogService {
    @Resource
    private ISchOperationLogDao iSchOperationLogDao;

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

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

    /**
     * 新增
     *
     * @param addSchOperationLogDTO 编辑参数
     * @return 成功或失败
     */
    @Override
    public boolean add(AddSchOperationLogDTO addSchOperationLogDTO) {
        SchOperationLog schOperationLog = SchOperationLogConvert.INSTANCE.convertDO(addSchOperationLogDTO);
        return iSchOperationLogDao.add(schOperationLog);
    }

    /**
     * 编辑
     *
     * @param editSchOperationLogDTO 编辑参数
     * @return 成功或失败
     */
    @Override
    public boolean edit(EditSchOperationLogDTO editSchOperationLogDTO) {
        SchOperationLog schOperationLog = SchOperationLogConvert.INSTANCE.convertDO(editSchOperationLogDTO);
        return iSchOperationLogDao.edit(schOperationLog);
    }

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

