package com.docus.server.controller;

import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.log.annotation.TrackLogGroup;
import com.docus.server.api.scheduling.management.SchCollectorApi;
import com.docus.server.common.process.CollectorVersionProcessor;
import com.docus.server.dto.scheduling.management.schcollector.AddSchCollectorDTO;
import com.docus.server.dto.scheduling.management.schcollector.DeleteSchCollectorDTO;
import com.docus.server.dto.scheduling.management.schcollector.EditSchCollectorDTO;
import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO;
import com.docus.server.service.ISchCollectorService;
import com.docus.server.vo.scheduling.management.schcollector.LoadSchCollectorVO;
import com.docus.server.vo.scheduling.management.schcollector.SchCollectorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 采集器管理 控制器类
 *
 * @author AutoGenerator
 * @since 2023-07-15
 */
@Api(value = "采集器管理接口", tags = "采集器管理接口")
@RestController
public class SchCollectorController implements SchCollectorApi {
    @Resource
    private ISchCollectorService iSchCollectorService;

    @ApiOperation("查询全部")
    @Override
    public List<LoadSchCollectorVO> findAll() {
        return iSchCollectorService.findAll();
    }

    /**
     * 按主键查询
     *
     * @param id 主键Id
     * @return 实体
     */
    @ApiOperation("按主键查询")
    @Override
    public SchCollectorVO findById(String id) {
        return iSchCollectorService.findById(id);
    }

    /**
     * 关键字搜索
     *
     * @param searchDTO 搜索参数
     * @return 分页列表
     */
    @ApiOperation("关键字搜索")
    @Override
    public PageResult<SchCollectorVO> search(SearchDTO searchDTO) {
        return iSchCollectorService.search(searchDTO);
    }

    /**
     * 新增
     *
     * @param addSchCollectorDTO 编辑参数
     * @return 成功或失败
     */
    @ApiOperation("新增")
    @Override
    public boolean add(AddSchCollectorDTO addSchCollectorDTO) {
        return iSchCollectorService.add(addSchCollectorDTO);
    }

    /**
     * 编辑
     *
     * @param editSchCollectorDTO 编辑参数
     * @return 成功或失败
     */
    @ApiOperation("编辑")
    @Override
    public boolean edit(EditSchCollectorDTO editSchCollectorDTO) {
        return iSchCollectorService.edit(editSchCollectorDTO);
    }

    /**
     * 批量删除
     *
     * @param deleteSchCollectorDTO 删除参数
     * @return 成功或失败
     */
    @ApiOperation("批量删除")
    @Override
    public int delete(DeleteSchCollectorDTO deleteSchCollectorDTO) {
        return iSchCollectorService.delete(deleteSchCollectorDTO);
    }

    /**
     * 选为当前版本并更新
     *
     * @return 成功或失败
     */
    @ApiOperation("选为当前版本并更新")
    @TrackLogGroup(group = "采集器管理", action = "更新", desc = "更新采集器版本", processor = CollectorVersionProcessor.class)
    @Override
    public boolean updateVersion(UpdateSchCollectorDTO updateDTO) {
        return iSchCollectorService.updateVersion(updateDTO);
    }
}
