package com.pqs9300.controller.report;

import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.pointInfo.PointInfo;
import com.njcn.service.point.PointBaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Sunwei 【sunW2016@163.com】
 * @Description:
 * @Date: Create in 13:22 2018/5/28
 * @Modified By:
 */
@RestController
public class PointBaseInfoController {
    @Autowired
    private PointBaseInfoService pointBaseInfoService;

    @PostMapping(value = "/getPointInfo")
    public HttpResult getPointInfo(Integer pointIndex) {
        HttpResult httpResult = new HttpResult();
        PointInfo pointInfo;

        try {
            pointInfo = pointBaseInfoService.getPointInfo(pointIndex);
        } catch (Exception e) {
            httpResult.setCode(500);
            httpResult.setMessage("监测点详情获取失败.");
            return httpResult;
        }

        if (pointInfo != null) {
            httpResult.setCode(200);
            httpResult.setBody(pointInfo);
            httpResult.setMessage("监测点详情获取成功.");
        } else {
            httpResult.setCode(500);
            httpResult.setMessage("监测点详情获取失败.");
        }

        return httpResult;
    }
}
