package com.artfess.rescue.event.controller;


import com.artfess.base.annotation.ApiGroup;
import com.artfess.base.constants.ApiGroupConsts;
import com.artfess.base.model.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.artfess.base.controller.BaseController;
import com.artfess.rescue.event.model.BizEventUpload;
import com.artfess.rescue.event.manager.BizEventUploadManager;

import java.lang.reflect.InvocationTargetException;

/**
 * 事件上报 前端控制器
 *
 * @company 阿特菲斯信息技术有限公司
 * @author 系统管理员
 * @since 2024-08-05
 */
@RestController
@RequestMapping("/event/bizEventUpload/v1/")
@Api(tags = "事件上报")
@ApiGroup(group = {ApiGroupConsts.GROUP_BIZ_RESCUE})
public class BizEventUploadController extends BaseController<BizEventUploadManager, BizEventUpload> {

    @RequestMapping(value = "isAffirm", method = RequestMethod.POST, produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "事件确认", httpMethod = "POST", notes = "事件确认接口")
    public CommonResult<String> isAffirm(@RequestParam("id")String id) throws InvocationTargetException, IllegalAccessException {
        boolean affirm = baseService.isAffirm(id);
        return new CommonResult<>(affirm,affirm?"确认成功":"确认失败");
    }

    @RequestMapping(value = "updateByStatus", method = RequestMethod.POST, produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "修改操作状态", httpMethod = "POST", notes = "修改操作状态接口")
    public CommonResult<String> updateByStatus(@RequestParam("id")String id,@RequestParam("status")Integer status){
        boolean res = baseService.updateByStatus(id, status);
        return new CommonResult<>(res,res?"修改操作状态成功":"修改操作状态失败");
    }
}
