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.PartnerServingStationDTO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerServingStationAddVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerServingStationCancelVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerServingStationPopVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerServingStationQueryVO;
import com.prolog.rdc.tms.model.vo.fleetManagement.PartnerServingStationUpdateVO;
import com.prolog.rdc.tms.service.fleetManagement.PartnerServingStationService;

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

/**
 * 
 *
 * 车队管理-维修厂管理控制层
 *
 * @className :PartnerServingStationController
 * @author :fanzw
 * @creationTime :2021/08/31
 * @description :
 * @modifier :fanzw
 * @modifyTime :2021/08/31
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "车队管理-维修厂管理控制层")
@RestController
@RequestMapping("/partnerServingStation")
public class PartnerServingStationController {

	@Autowired
	private PartnerServingStationService partnerServingStationService;

	@UserLog("维修厂弹窗")
	@ApiOperation(value = "维修厂弹窗", notes = "维修厂弹窗")
	@PostMapping("/pop")
	public RestMessage<Page<PartnerServingStationDTO>> listPartnerServingStationPopExecute(@RequestBody PartnerServingStationPopVO partnerServingStationPopVO) {
		try {
			Page<PartnerServingStationDTO> partnerServingStationDTOs = partnerServingStationService.listPartnerServingStationPopData(partnerServingStationPopVO);
			return RestMessage.newInstance(true, "维修厂弹窗查询成功", partnerServingStationDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("维修厂查询")
	@ApiOperation(value = "维修厂查询", notes = "维修厂查询")
	@PostMapping("/query")
	public RestMessage<Page<PartnerServingStationDTO>> listPartnerServingStationExecute(@RequestBody PartnerServingStationQueryVO partnerServingStationQueryVO) {
		try {
			Page<PartnerServingStationDTO> partnerServingStationDTOs = partnerServingStationService.listPartnerServingStationData(partnerServingStationQueryVO);
			return RestMessage.newInstance(true, "维修厂查询成功", partnerServingStationDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("维修厂新增")
	@ApiOperation(value = "维修厂新增", notes = "维修厂新增")
	@PostMapping("/add")
	public RestMessage<String> addPartnerServingStationExecute(@RequestBody PartnerServingStationAddVO partnerServingStationAddVO) {
		try {
			partnerServingStationService.addPartnerServingStationData(partnerServingStationAddVO);
			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> updatePartnerServingStationExecute(@RequestBody PartnerServingStationUpdateVO partnerServingStationUpdateVO) {
		try {
			partnerServingStationService.updatePartnerServingStationData(partnerServingStationUpdateVO);
			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> cancelPartnerServingStationExecute(@RequestBody List<PartnerServingStationCancelVO> partnerServingStationCancelVOs) {
		try {
			partnerServingStationService.cancelPartnerServingStationData(partnerServingStationCancelVOs);
			return RestMessage.newInstance(true, "维修厂作废成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

}
