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

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 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.fleetManagement.PartnerGasStationDTO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerGasStationAddVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerGasStationCancelVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerGasStationPopVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerGasStationQueryVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerGasStationUpdateVO;
import com.prolog.rdc.tms.service.fleetManagement.PartnerGasStationService;

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

/**
 * 
 *
 * 车队管理-加油站管理控制层
 *
 * @className :PartnerGasStationController
 * @author :fanzw
 * @creationTime :2021/08/31
 * @description :
 * @modifier :fanzw
 * @modifyTime :2021/08/31
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "车队管理-加油站管理控制层")
@RestController
@RequestMapping("/partnerGasStation")
public class PartnerGasStationController {

	@Autowired
	private PartnerGasStationService partnerGasStationService;

	@UserLog("加油站弹窗")
	@ApiOperation(value = "加油站弹窗", notes = "加油站弹窗")
	@PostMapping("/pop")
	public RestMessage<Page<PartnerGasStationDTO>> listPartnerGasStationPopExecute(@RequestBody PartnerGasStationPopVO partnerGasStationPopVO) {
		try {
			Page<PartnerGasStationDTO> partnerGasStationDTOs = partnerGasStationService.listPartnerGasStationPopData(partnerGasStationPopVO);
			return RestMessage.newInstance(true, "加油站弹窗查询成功", partnerGasStationDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("加油站查询")
	@ApiOperation(value = "加油站查询", notes = "加油站查询")
	@PostMapping("/query")
	public RestMessage<Page<PartnerGasStationDTO>> listPartnerGasStationExecute(@RequestBody PartnerGasStationQueryVO partnerGasStationQueryVO) {
		try {
			Page<PartnerGasStationDTO> partnerGasStationDTOs = partnerGasStationService.listPartnerGasStationData(partnerGasStationQueryVO);
			return RestMessage.newInstance(true, "加油站查询成功", partnerGasStationDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("加油站新增")
	@ApiOperation(value = "加油站新增", notes = "加油站新增")
	@PostMapping("/add")
	public RestMessage<String> addPartnerGasStationExecute(@RequestBody PartnerGasStationAddVO partnerGasStationAddVO) {
		try {
			partnerGasStationService.addPartnerGasStationData(partnerGasStationAddVO);
			return RestMessage.newInstance(true, "加油站新增成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("加油站修改")
	@ApiOperation(value = "加油站修改", notes = "加油站修改")
	@PostMapping("/update")
	public RestMessage<String> updatePartnerGasStationExecute(@RequestBody PartnerGasStationUpdateVO partnerGasStationUpdateVO) {
		try {
			partnerGasStationService.updatePartnerGasStationData(partnerGasStationUpdateVO);
			return RestMessage.newInstance(true, "加油站修改成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("加油站作废")
	@ApiOperation(value = "加油站作废", notes = "加油站作废")
	@PostMapping("/cancel")
	public RestMessage<String> cancelPartnerGasStationExecute(@RequestBody List<PartnerGasStationCancelVO> partnerGasStationCancelVOs) {
		try {
			partnerGasStationService.cancelPartnerGasStationData(partnerGasStationCancelVOs);
			return RestMessage.newInstance(true, "加油站作废成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

}
