/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 运维系统
 * 创建日期:2022/8/28
 */
package org.springblade.modules.business.monitor.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.baseinfo.monitorpoint.entity.MonitorPointInfoEntity;
import org.springblade.modules.baseinfo.monitorpoint.vo.MonitorPointInfoVO;
import org.springblade.modules.baseinfo.monitorpoint.wrapper.MonitorPointWrapper;
import org.springblade.modules.baseinfo.wateruseconsumer.entity.WaterUseConsumerInfoEntity;
import org.springblade.modules.baseinfo.wateruseconsumer.vo.WaterUseConsumerInfoVO;
import org.springblade.modules.baseinfo.wateruseconsumer.wrapper.WaterUseConsumerWrapper;
import org.springblade.modules.business.monitor.dto.WaterFlowRateInfoDTO;
import org.springblade.modules.business.monitor.entity.WaterFlowRateInfoEntity;
import org.springblade.modules.business.monitor.service.IWaterFlowRateService;
import org.springblade.modules.business.monitor.vo.WaterFlowRateInfoVO;
import org.springblade.modules.business.monitor.wrapper.WaterFlowRateWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;


/***
 * Date:2022/8/28
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@RestController
@RequestMapping("galaxy-business/monitor/waterflowrate")
@AllArgsConstructor
@Api(value = "降水实时数据管理", tags = "测站实时数据管理")
public class WaterFlowRateMonitorController extends BladeController {
    private final IWaterFlowRateService waterFlowRateService;


    /**
     * 分页
     */
    @GetMapping("/page")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wiuNm", value = "取用水户", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "mpnm", value = "测点名称", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "mpcd", value = "测点编码", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "orgId", value = "机构ID", paramType = "query", dataType = "long"),
    })
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页")
    public R<IPage<WaterFlowRateInfoVO>> page(@ApiIgnore WaterFlowRateInfoDTO dto, Query query) {
        IPage<WaterFlowRateInfoVO> pages = waterFlowRateService.selectPage(Condition.getPage(query), dto);
        List<WaterFlowRateInfoVO> list = pages.getRecords();
        for (WaterFlowRateInfoVO v : list) {
            WaterFlowRateWrapper.build().entityVO(v);
        }
        return R.data(pages);
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "")
    public R<WaterFlowRateInfoVO> detail(WaterFlowRateInfoEntity entity) {
        WaterFlowRateInfoEntity detail = waterFlowRateService.getOne(Condition.getQueryWrapper(entity));
        return R.data(WaterFlowRateWrapper.build().entityVO(detail));
    }
}
