package com.uas.platform.b2b.v2.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.uas.platform.b2b.model.Enterprise;
import com.uas.platform.b2b.temporary.model.ChangeAdminDetail;
import com.uas.platform.b2b.v2.service.ChangeAdminService;

@Controller("v2.ChangeAdminController")
@RequestMapping(value = "/public/changeadmin")
public class ChangeAdminController {

	@Autowired
	private ChangeAdminService changeAdminService;

	@RequestMapping(method = RequestMethod.POST)
	@ResponseBody
	public String save(ChangeAdminDetail detail) throws Exception {
		if (detail != null) {
			Enterprise enterprise = changeAdminService.save(detail);
			String result = null;
			try {
				changeAdminService.save(enterprise);
				result = "更新成功";
			} catch (Exception e) {
				result = "更新失败";
				e.printStackTrace();
				throw e;
			}
			return result;
		}
		return null;
	}
}
