package com.bonus.material.devchange.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devchange.domain.DeviceCountBean;
import com.bonus.material.devchange.domain.DeviceTreeBean;
import com.bonus.material.devchange.domain.MaDevInfo;
import com.bonus.material.devchange.service.MaDevInfoService;
import com.bonus.material.devchange.service.MaDevRetireWarningService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 设备退役预警-总览表
*
* @author xxxxx
*/
@RestController
@RequestMapping("/deviceRetireWarning")
public class MaDevRetireWarningController extends BaseController{
/**
* 服务对象
*/
    @Autowired
    private MaDevRetireWarningService service;

    /**
     * cha
     * @param o
     * @return
     */
    @ApiOperation(value = "设备退役预警-列表")
    @GetMapping("/list")
    public AjaxResult list(MaDevInfo o) {
        try {
            startPage();
            List<MaDevInfo> list = service.list(o);
            return AjaxResult.success(getDataTable(list));
        }catch (Exception e){
            logger.error("报错啦",e);
            return AjaxResult.error("调用异常，请联系管理员");
        }
    }

    @ApiOperation(value = "设备退役-退役")
    @PostMapping("/updateDeviceStatus")
    public AjaxResult updateDeviceStatus(String ids, String status){
        try {
        Integer i = service.updateDeviceStatus(ids,status);
        if (i > 0){
            return AjaxResult.success("修改成功");
        }else {
            return AjaxResult.error("修改失败");
        }
        }catch (Exception e){
            logger.error("报错啦",e);
            return AjaxResult.error("调用异常，请联系管理员");
        }
    }



}
