package com.prolog.rdc.tms.controller;

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.alibaba.fastjson.JSONObject;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.vo.IntfCargoOwnerSaveVO;
import com.prolog.rdc.tms.service.CargoOwnerService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 
 *
 * 货主资料接口控制层
 *
 * @className :CargoOwnerController
 * @author :fanzw
 * @creationTime :2022/11/28
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/11/28
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Slf4j
@Api(tags = "货主资料接口控制层")
@RestController
@RequestMapping("/cargoOwner")
public class CargoOwnerController {

	@Autowired
	private CargoOwnerService cargoOwnerService;

	@UserLog("货主资料接口保存")
	@ApiOperation(value = "货主资料接口保存", notes = "货主资料接口保存")
	@PostMapping("/save")
	public RestMessage<Object> saveCargoOwnerExecute(@RequestBody IntfCargoOwnerSaveVO intfCargoOwnerSaveVO) {
		try {
			log.info("======货主资料接口保存开始:{}", JSONObject.toJSONString(intfCargoOwnerSaveVO));
			String results = cargoOwnerService.saveCargoOwnerData(intfCargoOwnerSaveVO);
			log.info("======货主资料接口保存结束======");

			if (results == null) {
				return RestMessage.newInstance(true, "货主资料保存成功", null);
			} else {
				return RestMessage.newInstance(false, results, null);
			}
		} catch (Exception e) {
			e.printStackTrace();

			log.info("======货主资料接口保存异常:{}", e.getMessage());

			return RestMessage.newInstance(false, "货主资料保存失败:" + e.getMessage(), null);
		}
	}

}
