package org.cs.web.user;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;


/**
 * 
 * @ClassName: MgmUserBank
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:28:55
 */
@Controller
@RequestMapping("web/mgmUserBankCtl")
public class MgmUserBankWebCtl extends BaseCtl {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private IMgmUserBankService mgmUserBankService;
	
	/**
	 * 
	 * <p>银行卡信息</p>
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("me_card")
	public String mepeo_info(HttpServletRequest request,@RequestParam("userId") String userId,ModelMap mm){
		Map<String, String> map=new HashMap<String, String>();
		map.put("userId", userId);
		JSONObject json=mgmUserBankService.getUserBank(map);
		Map<String, String> userBank = getMapFromJson(json.getJSONObject("data").toString());
		mm.put("USER_ID", userId);
		mm.put("USER_BANK", userBank);
		return "app/me/me_card";	
	}
	
	@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) {
			json = getJson(0, "", "修改银行卡信息失败");
		}
		return json;
	}
	 
}

