package com.prolog.rdc.tms.controller;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.BmsMergeStrategyDTO;
import com.prolog.rdc.tms.model.vo.BmsMergeStrategyQueryVO;
import com.prolog.rdc.tms.model.vo.BmsMergeStrategyVO;
import com.prolog.rdc.tms.model.vo.StatusUpdate;
import com.prolog.rdc.tms.service.MergeBillStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "策略中心-合并计费策略")
@RestController
@RequestMapping("/mergeStrategy")
public class MergeBillStrategyController {

    @Autowired
    private MergeBillStrategyService mergeBillStrategyService;

    @UserLog("合并计费策略分页查询")
    @ApiOperation(value = "合并计费策略分页查询", notes = "合并计费策略分页查询")
    @PostMapping("/findList")
    public RestMessage<Page<BmsMergeStrategyDTO>> findList(@RequestBody BmsMergeStrategyQueryVO vo) throws Exception {
        Page<BmsMergeStrategyDTO> list = mergeBillStrategyService.findList(vo);
        return RestMessage.newInstance(true, "操作成功", list);
    }

    @UserLog("合并计费策略新增")
    @ApiOperation(value = "合并计费策略新增", notes = "合并计费策略新增")
    @PostMapping("/save")
    public RestMessage<Object> save(@RequestBody BmsMergeStrategyVO vo) throws Exception {
        mergeBillStrategyService.save(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("合并计费策略查询详情")
    @ApiOperation(value = "合并计费策略查询详情", notes = "合并计费策略查询详情")
    @PostMapping("/detail")
    public RestMessage<BmsMergeStrategyDTO> detail(@RequestParam(value = "id") Long id) throws Exception {
        BmsMergeStrategyDTO dto =  mergeBillStrategyService.detail(id);
        return RestMessage.newInstance(true, "操作成功", dto);
    }

    @UserLog("合并计费策略修改")
    @ApiOperation(value = "合并计费策略修改", notes = "合并计费策略修改")
    @PostMapping("/update")
    public RestMessage<Object> update(@RequestBody BmsMergeStrategyVO vo) throws Exception {
        mergeBillStrategyService.update(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("合并计费策略状态修改")
    @ApiOperation(value = "合并计费策略状态修改", notes = "合并计费策略状态修改")
    @PostMapping("/updateStatus")
    public RestMessage<Object> updateStatus(@RequestBody List<StatusUpdate> vo) throws Exception {
        mergeBillStrategyService.updateStatus(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("审核流程配置删除")
    @ApiOperation(value = "审核流程配置删除", notes = "审核流程配置删除")
    @PostMapping("/delete")
    public RestMessage<Object> delete(@RequestBody String[] ids) {
        mergeBillStrategyService.delete(ids);
        return RestMessage.newInstance(true, "操作成功", null);
    }
}