Java tutorial
/** *Copyright (c) 1997, 2015,BEST WONDER CO.,LTD. All rights reserved. */ package com.baiwang.banktax.controller; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.baiwang.banktax.beans.AreaBean; import com.baiwang.banktax.beans.User; import com.baiwang.banktax.services.iface.IidentifyService; import com.baiwang.banktax.utils.ConfigUtil; import com.baiwang.banktax.utils.StringUtils; /** * @ClassName: IdentyController * @Description: ? * @author gkm * @date 20151127 ?2:56:59 */ @Controller @RequestMapping("users/identify") public class IdentifyController { private static final Log logger = LogFactory.getLog(IdentifyController.class); @Resource private IidentifyService service; /** * * @author gkm * @Description: ? ?? * @param @param id ?id * @param @param session * @param @return * @return Map<String,Object> * @throws * @date 20151130 ?10:59:21 */ @RequestMapping("/identflag") @ResponseBody public Map<String, Object> identflag(Integer id, HttpSession session) { Map<String, Object> map = new HashMap<String, Object>(); logger.info("?--------?id:" + id); User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); //TODO ?? Byte TaxVerify = user.getTaxVerify(); map.put("TaxVerify", TaxVerify);//?? if (TaxVerify == 4) {//? //?? String area = service.getAreaFlag(id, user.getVrfAreaid()); map.put("areaflag", area); // int appflag = service.queryApplyFlag(id, user.getId()); map.put("appflag", appflag); } return map; } /** * * @author gkm * @Description: ?? * @param @return * @return ModelAndView * @throws * @date 20151130 ?11:02:30 */ @RequestMapping("") public ModelAndView identify() { ArrayList<AreaBean> list = service.getProvince(); return new ModelAndView("identify/identification").addObject("province", list); } /** * * @author gkm * @Description: ?province id? * @param @param id * @param @return * @return Map<String,Object> * @throws * @date 20151130 ?11:02:59 */ @RequestMapping("/getCity") @ResponseBody public Map<String, Object> identifyCity(Integer id, HttpSession session) { User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); logger.info("??? ----id:" + user.getId() + "------?id:" + id); Map<String, Object> map = new HashMap<String, Object>(); ArrayList<AreaBean> list = service.getCity(id); map.put("list", list); return map; } /** * * @author gkm * @Description: ???--(??) * @param @param id * @param @return * @return ModelAndView * @throws * @date 20151130 ?11:03:35 */ @RequestMapping("/next") public ModelAndView identifyNext(Integer id, String verifyUrl, HttpSession session) { User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); logger.info("??? ? ----id:" + user.getId() + "------id:" + id); AreaBean area = service.getVerifyType(user, id); if (null != area) { logger.info("??? ? ----id:" + user.getId() + "------?:" + area.getVerifyType()); if ("0".equals(area.getVerifyType())) { return new ModelAndView("identify/identify_platform1").addObject("province", area.getAname()) .addObject("id", session.getId()).addObject("verifyUrl", verifyUrl); } else if ("1".equals(area.getVerifyType())) { return new ModelAndView("identify/identify_platform2"); } else if ("2".equals(area.getVerifyType())) { return new ModelAndView("identify/identify_platform3"); } } return new ModelAndView("identify/identify_platform1"); } /** * * @author gkm * @Description: ? ? * @param @return * @return String * @throws * @date 20151130 ?3:33:51 */ @RequestMapping("/taxResult") @ResponseBody public Map<String, Object> taxResult(HttpSession session) { User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); logger.info("---?----id:" + user.getId()); Map<String, Object> map = new HashMap<String, Object>(); String result = "-1"; /*if(4 == user.getTaxVerify()){//? map.put("result", result); return map; }*/ //TODO ?,session result = "5588"; map.put("result", result);// // int success = service.plat2("", System.currentTimeMillis()+"", "110108197508230318", user.getId());//?? user.setCorpName("??"); user.setIdcard("110108197508230318"); user.setTaxSn(System.currentTimeMillis() + ""); user.setApName("?"); user.setAddress(""); user.setLicenseRegnum("88888888"); user.setTaxVerify((byte) 4); int success = service.plat2(user);//?? map.put("success", success); session.setAttribute(ConfigUtil.getLoginedUserStr(), service.selectById(user.getId())); logger.info("---?--id:" + user.getId() + "---:" + result + ",?:" + success); return map; } /** * * @author gkm * @Description: ? ? * @param @return * @return String * @throws * @date 20151130 ?3:33:51 */ @RequestMapping("/success") public String success() { return "identify/identify_success"; } /** * * @author gkm * @Description: ?2? * @param @param corpName * @param @param taxSn * @param @param idcard * @param @param session * @param @return * @return Map * @throws * @date 20151130 ?3:43:54 */ @RequestMapping("plat2") @ResponseBody public Map<String, Object> plat2(String corpName, String taxSn, String idcard, HttpSession session) { User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); logger.info("??? ?2 ?----id:" + user.getId() + "--???:" + corpName + ",?:" + taxSn + ",??:" + idcard); Map<String, Object> map = new HashMap<String, Object>(); user.setCorpName(corpName); user.setIdcard(idcard); user.setTaxSn(taxSn); user.setApName("?"); user.setAddress(""); user.setLicenseRegnum("88888888"); user.setTaxVerify((byte) 4); int success = service.plat2(user); map.put("success", success); logger.info("??? ?2?----id:" + user.getId() + ",?:" + success); session.setAttribute(ConfigUtil.getLoginedUserStr(), service.selectById(user.getId())); return map; } /** * * @author gkm * @Description: ?3? * @param @param corpName * @param @param taxSn * @param @param idcard * @param @param session * @param @return * @return Map * @throws * @date 20151130 ?3:43:54 */ @RequestMapping("plat3") @ResponseBody public Map<String, Object> plat3(String corpName, String taxSn, String code, HttpSession session) { Map<String, Object> map = new HashMap<String, Object>(); User user = (User) session.getAttribute(ConfigUtil.getLoginedUserStr()); String imageCode = (String) session.getAttribute("imageCode"); logger.info("??? ?3 ?----id:" + user.getId() + "--???:" + corpName + ",?:" + taxSn); int success = 0; if (!"".equals(StringUtils.getString(imageCode))) {//?? if (StringUtils.getString(code).equals(imageCode)) {//?? //TODO ?3 ? if (null != user.getTaxVerify() && user.getTaxVerify() > 0 && user.getTaxVerify() < 4) {//? success = -3; } else success = service.plat3(corpName, taxSn, "333333000000", user.getId()); session.setAttribute(ConfigUtil.getLoginedUserStr(), service.selectById(user.getId())); } else { success = -2;//?? } } else { success = -1; } logger.info("??? ?3 ?----id:" + user.getId() + ",?:" + success); map.put("success", success); return map; } /** * * @author gkm * @Description: ?3? ? * @param @return * @return String * @throws * @date 20151130 ?3:33:51 */ @RequestMapping("/succes") public String success3() { return "identify/identify_success3"; } /** * * @author ldm * @Description: ???? * @param @return * @return String * @throws * @date 20151130 ?3:33:51 */ @RequestMapping("/toProtocol") public String toProtocol() { return "identify/protocol"; } }