package com.inspect.metadata.mqtt.controller;

import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.metadata.mqtt.domain.HrWarn;
import com.inspect.metadata.mqtt.enums.HrDeviceEnum;
import com.inspect.metadata.mqtt.service.IHrTaskProcessService;
import com.inspect.metadata.mqtt.service.IHrWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hr/warn")
public class HrWarnController extends BaseController {
    @Autowired
    private IHrWarnService warnService;

    @GetMapping("/list")
    public TableDataInfo list(HrWarn warn) {
        startPage();
        List<HrWarn> list = warnService.selectWarnList(warn);
        list.forEach(item -> {
            String device = item.getType().equals(HrDeviceEnum.Nest.getCode()) ? "机巢" : "无人机";
            String errMsg = device + ":" + item.getNestCode() + "," + item.getErrMsg();
            item.setErrMsg(errMsg);
        });
        return getDataTable(list);
    }
}
