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

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

/**
 *
 *
 * 客户资料接口控制层
 *
 * @className :CustomerController
 * @author :xiaoyf
 * @creationTime :2022/08/12
 * @description :
 *
 * 
 * @version :1.0.0
 *
 */
@Slf4j
@Api(tags = "客户资料接口控制层")
@RestController
@RequestMapping("/customer")
public class CustomerController {

	@Autowired
	private CustomerService customerService;

	@UserLog("客户资料接口保存")
	@ApiOperation(value = "客户资料接口保存", notes = "客户资料接口保存")
	@PostMapping("/save")
	public RestMessage<Object> saveCustomerExecute(@RequestBody IntfCustomerSaveVO intfCustomerSaveVO) {
		try {
			log.info("======客户资料接口保存开始:{}", JSONObject.toJSONString(intfCustomerSaveVO));
			String results = customerService.saveCustomerData(intfCustomerSaveVO);
			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);
		}
	}

}
