package com.artfess.rescue.patrol.controller;


import com.artfess.base.annotation.ApiGroup;
import com.artfess.base.constants.ApiGroupConsts;
import com.artfess.base.controller.BaseController;
import com.artfess.base.model.CommonResult;
import com.artfess.base.query.PageList;
import com.artfess.base.query.QueryFilter;
import com.artfess.base.util.StringUtil;
import com.artfess.rescue.monitor.manager.BizRankInfoManager;
import com.artfess.rescue.monitor.model.BizRankInfo;
import com.artfess.rescue.patrol.manager.BizInspectRankInfoManager;
import com.artfess.rescue.patrol.model.BizInspectRankInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 班组信息 前端控制器
 *
 * @company 阿特菲斯信息技术有限公司
 * @author 管理员
 * @since 2023-11-30
 */

@RestController
@RequestMapping("/bizInspectRankInfo/v1/")
@Api(tags = "班组信息")
@ApiGroup(group = {ApiGroupConsts.GROUP_BIZ_RESCUE})
public class BizInspectRankInfoController extends BaseController<BizInspectRankInfoManager, BizInspectRankInfo> {

    @PostMapping("/page")
    @ApiOperation(value = "S-分页查询所有数据")
    public CommonResult<PageList<BizInspectRankInfo>> pageAll(@ApiParam(name = "queryfilter", value = "通用查询器") @RequestBody QueryFilter<BizInspectRankInfo> queryFilter) {
        return baseService.pageAll(queryFilter);
    }


    @PostMapping(value = "/get/{id}")
    @ApiOperation(value = "S-监调中心班组信息详情", httpMethod = "POST", notes = "监调中心班组信息详情")
    public BizInspectRankInfo get(@ApiParam(name = "id", value = "业务对象主键", required = true) @PathVariable String id) throws Exception {
        return baseService.get(id);
    }


    @PostMapping(value = "/save")
    @ApiOperation(value = "S-新增,更新班组信息", httpMethod = "POST", notes = "新增,更新班组信息")
    public CommonResult<String> save(@ApiParam(name = "BizRankInfo", value = "收费站班组信息对象", required = true) @RequestBody BizInspectRankInfo rankInfo) throws Exception {
        String msg = "添加成功";
        if (StringUtil.isEmpty(String.valueOf(rankInfo.getId()))) {
            rankInfo.setIsDele("0");
            baseService.save(rankInfo);
        } else {
            baseService.update(rankInfo);
            rankInfo.setIsDele("0");
            msg = "更新成功";
        }
        return new CommonResult<>(msg);
    }


    @PostMapping(value = "/removes")
    @ApiOperation(value = "S-批量删除", httpMethod = "POST", notes = "批量删除")
    public CommonResult<String> removes(@ApiParam(name = "ids", value = "多个主键之间用逗号分隔", required = true) @RequestParam String ids) throws Exception {
        List<String> rankIds = Arrays.asList(ids.split(","));
        baseService.removeByIds(rankIds);
        return new CommonResult<String>(true, "删除成功");
    }

}
