package com.ho.business.controller;

import com.ho.business.entity.Convert;
import com.ho.business.service.ConvertService;
import com.ho.business.vo.req.colCount.ColCountReq;
import com.ho.common.tools.annotation.LogAnnotation;
import com.ho.common.tools.constant.ContextConstant;
import com.ho.common.tools.exception.DataResult;
import com.ho.common.tools.util.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;


/**
 * @author gyan
 * @desc: 遥测转遥信控制页面
 * @DateTime: 2023/7/11 14:33
 */
@RestController
@RequestMapping(ContextConstant.BUSINESS + "convert")
@Api(tags = "遥测转遥信配置页面")
@Slf4j
public class ConvertController {
    @Autowired
    ConvertService convertService;
    //新增
    @PostMapping("add")
    @ApiOperation(value = "新增遥测转遥信")
    @LogAnnotation(title = "遥测转遥信", action = "新增遥测转遥信值")
    public DataResult add(@RequestBody Convert vo) {
        convertService.add(vo);
        return DataResult.success();
    }


    @PostMapping("delete")
    @ApiOperation(value = "删除遥测转遥信")
    @LogAnnotation(title = "遥测转遥信", action = "删除遥测转遥信值")
    public DataResult delete(@RequestBody Convert vo) {
        convertService.delete(vo.getId());
        return DataResult.success();
    }
    //删除

    //分页查询
    //根据colName进行查询
    @PostMapping("pageList")
    @ApiOperation(value = "查询遥测转遥信值")
    public DataResult<Convert> pageList(@RequestBody ColCountReq vo) {
        PageResult<Convert> pageList = convertService.getPageList(vo);
        return DataResult.success(pageList);
    }
}
