package com.njcn.csdevice.controller.project;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.param.CsLineTopologyTemplateParm;
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
import com.njcn.csdevice.pojo.vo.CsTopologyDiagramTemplateVO;
import com.njcn.csdevice.service.CsLineTopologyTemplateService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* (cs_line_topology_template)表控制层
*
* @author xxxxx
*/
@RestController
@Slf4j
@RequestMapping("/lineTemplate")
@Api(tags = " 监测点位置模板")
@AllArgsConstructor
public class CsLineTopologyTemplateController extends BaseController {

    private final CsLineTopologyTemplateService csLineTopologyTemplateService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
    @PostMapping("/addLineTemplate")
    @ApiOperation("上传拓扑图模板监测点位置")
    @ApiImplicitParam(name = "csLineTopologyTemplateParms", value = "扑图模板监测点位置", required = true)
    public HttpResult<Boolean> addLineTemplate(@RequestBody List<CsLineTopologyTemplateParm> csLineTopologyTemplateParms){
        String methodDescribe = getMethodDescribe("addLineTemplate");
        Boolean flag = csLineTopologyTemplateService.add(csLineTopologyTemplateParms);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
    @PostMapping("/queryByTopoId")
    @ApiOperation("根据拓扑图id查询监测点位置")
    public HttpResult<List<CsLineTopologyTemplateVO>> queryByTopoId(@RequestParam("topoId") String topoId){
        String methodDescribe = getMethodDescribe("queryByTopoId");
        List<CsLineTopologyTemplateVO> csLineTopologyTemplateVOS = csLineTopologyTemplateService.queryByTopoId(topoId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,csLineTopologyTemplateVOS, methodDescribe);
    }


}
