package com.yihu.jw.base.endpoint.equipment;

import com.yihu.jw.base.service.equipment.JuMiAiService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by wangzhinan on 2021/09/16.
 * 设备管理
 */
@RestController
@RequestMapping(value = BaseRequestMapping.JumiApi.PREFIX)
@Api(value = "巨米api管理", description = "巨米api管理接口", tags = {"巨米api管理接口"})
public class JuMiApiEndpoint extends EnvelopRestEndpoint {

    @Autowired
    private JuMiAiService juMiAiService;


    @PostMapping(value = BaseRequestMapping.JumiApi.getEquipmentList)
    @ApiOperation(value = "获取设备列表")
    public Envelop selectByHospitalOrTown (
            @ApiParam(name = "pageIndex", value = "当前页数", required = false)
            @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
            @ApiParam(name = "page_size", value = "每页数量", required = false)
            @RequestParam(value = "page_size", required = false) Integer page_size) throws Exception {
        String  result =  juMiAiService.getEquipmentList(pageIndex,page_size);
        Envelop envelop = new Envelop();
        envelop.setMessage(result);
        return envelop;
    }

    @PostMapping(value = BaseRequestMapping.JumiApi.getEquipmentInfo)
    @ApiOperation(value = "获取设备详情")
    public Envelop selectByHospitalOrTown (
            @ApiParam(name = "deviceNo", value = "设备编号", required = false)
            @RequestParam(value = "deviceNo", required = false) String deviceNo) throws Exception {
        String  result =  juMiAiService.getEquipmentInfo(deviceNo);
        Envelop envelop = new Envelop();
        envelop.setMessage(result);
        return envelop;
    }
}
