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 com.artfess.base.valid.AddGroup;
import com.artfess.rescue.event.model.BizEventHandle;
import com.artfess.rescue.file.model.BizRescueFileCommon;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.checkerframework.checker.units.qual.C;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.artfess.base.controller.BaseController;
import com.artfess.rescue.event.model.BizRescueAppraise;
import com.artfess.rescue.event.manager.BizRescueAppraiseManager;

import java.util.List;

/**
 * 救援评价与回访 前端控制器
 *
 * @company 阿特菲斯信息技术有限公司
 * @author 系统管理员
 * @since 2024-10-24
 */
@RestController
@RequestMapping("/event/bizRescueAppraise/v1/")
@Api(tags = "救援评价与回访")
@ApiGroup(group = {ApiGroupConsts.GROUP_BIZ_RESCUE})
public class BizRescueAppraiseController extends BaseController<BizRescueAppraiseManager, BizRescueAppraise> {

    @Override
    @PostMapping("/")
    @ApiOperation("添加实体的接口")
    public CommonResult<String> create(@ApiParam(name = "model", value = "实体信息") @Validated({AddGroup.class}) @RequestBody BizRescueAppraise t) {
        boolean b = baseService.saveInfo(t);
        return new CommonResult<>(b,b?"添加成功":"添加失败");
    }

    @Override
    @PutMapping("/")
    @ApiOperation("修改实体的接口")
    public CommonResult<String> updateById(@ApiParam(name = "model", value = "实体信息") @Validated({AddGroup.class}) @RequestBody BizRescueAppraise t) {
        boolean b = baseService.updateInfo(t);
        return new CommonResult<>(b,b?"修改成功":"修改失败");
    }

    @Override
    @GetMapping("/{id}")
    @ApiOperation("根据id查询实体")
    public BizRescueAppraise getById(@ApiParam(name = "id", value = "实体id") @PathVariable String id) {
        return baseService.getInfo(id);
    }

    @GetMapping("/rescueFiles/{rescueId}")
    @ApiOperation("根据id查询实体")
    public List<BizRescueFileCommon> getRescueFileCommons(@ApiParam(name = "id", value = "救援id") @PathVariable String rescueId) {
        return baseService.getRescueFileCommons(rescueId);
    }


    @GetMapping("/defaultRatings")
    @ApiOperation("根据时间来默认打分")
    public CommonResult bathRatings() {
        return CommonResult.success(baseService.bathRatings(),"");
    }

}
