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

import java.util.List;

import javax.validation.Valid;

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 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.StrategyTransferMatchingDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferPageDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.StrategyTransferViewDTO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferMatchingVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferPageVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferUpdateVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.StrategyTransferViewVO;
import com.prolog.rdc.tms.service.basicConfigure.StrategyTransferService;

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

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

	@Autowired
	private StrategyTransferService strategyTransferService;

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

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

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

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

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

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

	@UserLog("中转策略匹配")
	@ApiOperation(value = "中转策略匹配", notes = "中转策略匹配")
	@PostMapping("/matching")
	public RestMessage<List<StrategyTransferMatchingDTO>> matchingTransferExecute(@RequestBody StrategyTransferMatchingVO transferMatchingVO) {
		List<StrategyTransferMatchingDTO> list = strategyTransferService.matchingData(transferMatchingVO);
		return RestMessage.newInstance(true, "查询成功！", list);
	}
}
