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.IntfShipbillPackageVO;
import com.prolog.rdc.tms.service.ShipbillPackageService;

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

/**
 * 
 *
 * 运单包裹接口控制层
 *
 * @className :ShipbillPackageController
 * @author :fanzw
 * @creationTime :2022/11/17
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/11/17
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Slf4j
@Api(tags = "运单包裹接口控制层")
@RestController
@RequestMapping("/shipbillPackage")
public class ShipbillPackageController {

	@Autowired
	private ShipbillPackageService shipbillPackageService;

	@UserLog("运单包裹接口保存")
	@ApiOperation(value = "运单包裹接口保存", notes = "运单包裹接口保存")
	@PostMapping("/save")
	public RestMessage<Object> saveShipbillPackageExecute(@RequestBody IntfShipbillPackageVO intfShipbillPackageVO) {
		try {
			log.info("======运单包裹接口保存开始:{}", JSONObject.toJSONString(intfShipbillPackageVO));
			String results = shipbillPackageService.saveShipbillPackageData(intfShipbillPackageVO);
			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);
		}
	}

}
