package com.docus.server.controller;

import com.docus.core.util.json.JSON;
import com.docus.infrastructure.web.request.SearchDTO;
import com.docus.infrastructure.web.response.PageResult;
import com.docus.server.api.scheduling.management.SchCollectorConfigApi;
import com.docus.server.dto.scheduling.management.schcollectorconfig.AddSchCollectorConfigDTO;
import com.docus.server.dto.scheduling.management.schcollectorconfig.DeleteSchCollectorConfigDTO;
import com.docus.server.dto.scheduling.management.schcollectorconfig.EditSchCollectorConfigDTO;
import com.docus.server.service.ISchCollectorConfigService;
import com.docus.server.vo.scheduling.management.schcollectorconfig.SchCollectorConfigVO;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 采集器配置 控制器类
 *
 * @author AutoGenerator
 * @since 2023-07-15
 */
@Api(value = "采集器配置管理接口", tags = "采集器配置管理接口")
@RestController
public class SchCollectorConfigController implements SchCollectorConfigApi {
    @Resource
    private ISchCollectorConfigService iSchCollectorConfigService;

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

    @ApiOperation("查询所有")
    @Override
    public List<SchCollectorConfigVO> findAll() {
        return iSchCollectorConfigService.findAll();
    }

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

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

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

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


    public static void main(String[] args) {

        HashMap<Object, Object> objectObjectHashMap = Maps.newHashMap();
        objectObjectHashMap.put("ocr.url", "http://192.168.2.13/ocr");
        objectObjectHashMap.put("ocr.name", "lin");
        objectObjectHashMap.put("ocr.pwd", "123");
        System.out.println(JSON.toJSON(objectObjectHashMap));

    }
}
