package org.cs.mgr.user.ctl;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.cs.core.ctl.BaseCtl;
import org.cs.mgr.user.model.MgmUser;
import org.cs.mgr.user.model.MgmUserBank;
import org.cs.mgr.user.service.IMgmUserBankService;
import org.cs.mgr.user.service.IMgmUserService;
import org.cs.mgr.user.service.ISmsService;
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.ResponseBody;

import com.alibaba.fastjson.JSONObject;


@Controller
@RequestMapping("/rest/mgmUserBank")
public class MgmUserBankAPI extends BaseCtl{

	private Logger log = Logger.getLogger(MgmUserBankAPI.class);
	@Autowired
	public ISmsService smsService;
	
	@Autowired
	public IMgmUserBankService mgmUserBankService;
 
	@ResponseBody
	@RequestMapping("/updateUserBank")
	public JSONObject getUserinfo(String data){
		MgmUserBank userBank = getBeanFromJson(data, MgmUserBank.class);
		JSONObject json = new JSONObject();
		try {
			json=mgmUserBankService.updateUserBank(userBank);
		} catch (Exception e) {
			log.error("修改银行卡信息失败："+e.getMessage());
			json = getJson(0, "", "修改银行卡信息失败");
		}
		return json;
	}
	
	@ResponseBody
	@RequestMapping("/getUserBank")
	public String getUserBank(String data){
		Map<String, String> map = getMapFromJson(data);
		JSONObject json = new JSONObject();
		try {
			json = mgmUserBankService.getUserBank(map);
		} catch (Exception e) {
			log.error("获取银行卡信息失败："+e.getMessage());
			json = getJson(0, "","获取银行卡信息失败");
		}
		return JSONObject.toJSONString(json,features);
	}
}
