package com.prolog.rdc.tms.controller.basicConfigure;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

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.basicConfigure.StrategySplitMatchingDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategySplitPageDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategySplitViewDTO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategySplitMatchingVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategySplitPageVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategySplitSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategySplitUpdateVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategySplitViewVO;
import com.prolog.rdc.tms.service.basicConfigure.StrategySplitService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 策略中心-拆分策略
 *
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author zhangsj
 * @since 2022/7/16 9:39
 */
@RestController
@Api(tags = "策略中心-拆分策略")
@RequestMapping("strategySplit")
public class StrategySplitController {

    @Autowired
    private StrategySplitService strategySplitService;

    @UserLog("分页查询")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public RestMessage<Page<StrategySplitPageDTO>> queryPageExecute(@RequestBody @Valid StrategySplitPageVO strategySplitPageVO){
        Page<StrategySplitPageDTO> page = strategySplitService.queryPageData(strategySplitPageVO);
        return RestMessage.newInstance(true, "查询成功！", page);
    }

    @UserLog("查看")
    @ApiOperation(value = "查看", notes = "查看")
    @PostMapping("/view")
    public RestMessage<StrategySplitViewDTO> viewExecute(@RequestBody @Valid StrategySplitViewVO strategySplitViewVO){
        StrategySplitViewDTO dto = strategySplitService.viewData(strategySplitViewVO);
        return RestMessage.newInstance(true, "查询成功！", dto);
    }

    @UserLog("删除")
    @ApiOperation(value = "删除", notes = "删除")
    @PostMapping("/remove")
    public RestMessage<Object> removeExecute(@RequestBody List<Long> ids){
        strategySplitService.removeData(ids);
        return RestMessage.newInstance(true, "删除成功！", null);
    }

    @UserLog("新增")
    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("/save")
    public RestMessage<Object> saveExecute(@RequestBody StrategySplitSaveVO strategySplitSaveVO){
        strategySplitService.saveData(strategySplitSaveVO);
        return RestMessage.newInstance(true, "新增成功！", null);
    }

    @UserLog("修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/update")
    public RestMessage<Object> updateExecute(@RequestBody StrategySplitUpdateVO strategySplitUpdateVO){
        strategySplitService.updateData(strategySplitUpdateVO);
        return RestMessage.newInstance(true, "修改成功！", null);
    }

    @UserLog("停用")
    @ApiOperation(value = "停用", notes = "停用")
    @PostMapping("/disable")
    public RestMessage<Object> disableExecute(@RequestBody List<Long> ids){
        strategySplitService.disableData(ids);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("启用")
    @ApiOperation(value = "启用", notes = "启用")
    @PostMapping("/active")
    public RestMessage<Object> activeExecute(@RequestBody List<Long> ids){
        strategySplitService.activeData(ids);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("匹配")
    @ApiOperation(value = "匹配", notes = "匹配")
    @PostMapping("/matching")
    public RestMessage<List<StrategySplitMatchingDTO>> matchingExecute(@RequestBody StrategySplitMatchingVO strategySplitMatchingVO){
        List<StrategySplitMatchingDTO> list = strategySplitService.matchingData(strategySplitMatchingVO);
        return RestMessage.newInstance(true, "查询成功！", list);
    }
}
