package com.cpp.web.controller.configManager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpp.common.core.domain.R;
import com.cpp.web.domain.datafactory.ParsingType;
import com.cpp.web.service.datafactory.ParsingTypeService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/parsingType")
@AllArgsConstructor
public class ParsingTypeController {

    private final ParsingTypeService parsingTypeService;


    @ApiOperation(value = "添加ftp通道", notes = "添加ftp通道")
    @PostMapping()
    public Boolean add(@RequestBody ParsingType parsingType) {
        return parsingTypeService.save(parsingType);
    }

    @ApiOperation(value = "修改ftp通道", notes = "修改ftp通道")
    @PutMapping()
    public Boolean update(@RequestBody ParsingType ftpChannel) {
        return parsingTypeService.updateById(ftpChannel);

    }


    @ApiOperation(value = "根据id删除ftp通道", notes = "根据id删除ftp通道")
    @DeleteMapping("/{id}")
    public Boolean delete(@PathVariable String id) {
        return parsingTypeService.removeById(id);

    }

    @ApiOperation(value = "查询所有ftp通道", notes = "查询所有ftp通道")
    @GetMapping()
    public List<ParsingType> getAll() {
         return parsingTypeService.list();
    }

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public R page(Long currentPage,Long pageSize) {
        Page page = new Page(currentPage, pageSize);
        page.setMaxLimit((long) -1);
        return R.ok(parsingTypeService.page(page));
    }


}
