mybatis 的mapper文件解析规律
mybatis 的mapper文件解析规律,只会解析出一层你申明好的参数类型,如果就是map一层解析出来后就是字符串k-v,
表达式中直接用key,若果map中套map解析出来的就是内层param,后面用的时候用key在点入一层渠道具体常用类型数据
返回结果是 resultType="java.util.HashMap" 可以不用建立特意的实体,去承接
例如:
@Override
@Transactional(rollbackFor=Exception.class)
public void updateUser(Map<String, Object> param, String[] pz) throws Exception {
param.remove("CUSTOMER_ID1");
Map<String, Object> paramTableKey = new HashMap<String, Object>();
TbCusFirmAffix record = new TbCusFirmAffix();
record.setCustomerKey(BigDecimal.valueOf(Long.valueOf((String)param.get("CUSTOMER_KEY"))) );
tbCusFirmAffixMapper.delete(record);
Map<String,Object> fileMap;
Map<String,Object> dictMap;
if("Y".equals(param.get("COMP_TYPE"))){
//if(param.get("LANGUAGE")==null||param.get("LANGUAGE").toString().equals("")){
//param.put("LANGUAGE", "CN");
//}
param.put("CUSTOMER_NAME", param.get("CHINESE_NAME"));
fileMap = new HashMap();
List<Map> GN = new ArrayList<Map>();
Map<String,Object> paramCodeGN = new HashMap<String,Object>();
paramCodeGN.put("code", "TB_CUS_FIRM_AFFIX.AFFIX_KIND.QY.GN");
GN=tbCusFirmChgMapper.getCodeMap(paramCodeGN);
for(Map gn: GN){
String key="";
for(Object k: gn.keySet()){
key=(String) k;
break;
}
if((!"".equals(param.get("fjCode_N_"+gn.get(key)))&¶m.get("fjCode_N_"+gn.get(key))!=null)||(param.get("zjInfo_N_"+gn.get(key))!=null&&!"".equals(param.get("zjInfo_N_"+gn.get(key))))){
Map<String, Object> paramTableKey1 = new HashMap<String, Object>();
paramTableKey.put("P_KEYMGR_KEY", Integer.valueOf(41));
paramTableKey.put("P_GETNUM", Integer.valueOf(1));
String tk1= tbCusFirmChgMapper.getTableKey(paramTableKey);
Integer X_CURVAL1=0;
if(paramTableKey.get("X_CURVAL")!=null){
X_CURVAL1=(Integer) paramTableKey.get("X_CURVAL")+1;
}
fileMap.put("CUSAFFIX_KEY", X_CURVAL1);
fileMap.put("CUSTOMER_KEY", param.get("CUSTOMER_KEY"));
fileMap.put("AFFIX_KIND", gn.get(key));
if(gn.get(key)==null){
fileMap.put("FJNAME", "");
}else{
fileMap.put("FJNAME", gn.get(key));
}
if(param.get("fjCode_N_"+gn.get(key))==null){
fileMap.put("PAPERS_NUM", "");
}else{
fileMap.put("PAPERS_NUM", param.get("fjCode_N_"+gn.get(key)));
}
String filePath="";
if(gn.get(key)!=null){
filePath=(String) param.get("zjInfo_N_"+gn.get(key));
}
if(filePath==null){
filePath="";
}
fileMap.put("AFFIX_PATH", filePath);
if(getFileExt(filePath).contains("/")){
fileMap.put("AFFIX_TYPE", getFileExt(filePath).substring(0, getFileExt(filePath).indexOf("/")));
}else{
fileMap.put("AFFIX_TYPE", getFileExt(filePath));
}
fileMap.put("AFFIX_DATE", new Date());
Map<String,Object> filem = new HashMap<String,Object>();
filem.put("param", fileMap);
//tbCusFirmChgMapper.saveDataMapAFFIX2(filem);
tbCusFirmWebMapper.saveDataMapWeb(filem);
}
<insert id="saveDataMapWeb" parameterType="map" >
INSERT INTO TB_CUS_FIRM_AFFIX_CHG
<foreach collection="param.keys" item="k" open="(" close=")" separator=",">
${k}
</foreach>
VALUES
<foreach collection="param.keys" item="k" open="(" close=")" separator=",">
<if test="null != param[k]">
#{param[${k}]}
</if>
</foreach>
@RequestMapping("/account/tbCusFirmWeb/autio")
public String autio(@RequestParam(value = "customerKey", required = false) String customerKey,@RequestParam Map<String, Object> regUser,Model model) throws EsteelException {
List<TbBasBed> tbBasBedList2 = new ArrayList<TbBasBed>();
tbBasBedList2 = tbBasBedService.list();
if(!"".equals(customerKey)&&null!=customerKey){
TbConFirmFeeVo tbConFirmFee = new TbConFirmFeeVo();
tbConFirmFee.setWareKey(BigDecimal.valueOf(Long.valueOf(customerKey)));
Map<String,Object> param = new HashMap<String,Object>();
param.put("customerKey", customerKey);
if(tbConFeeService.getTbConFeeVoListVO(param)!=null&&tbConFeeService.getTbConFeeVoListVO(param).size()>0){
tbConFirmFee= tbCusFirmChgService.getTbConFirmFeeListVO(param).size()==0?null:tbCusFirmChgService.getTbConFirmFeeListVO(param).get(0);
}
model.addAttribute("vo", tbConFirmFee);
model.addAttribute("flag", "1");
}else{
model.addAttribute("flag", "0");
}
Map<String,Object> param = new HashMap<String,Object>();
List<TbBasFee> sp = new ArrayList<TbBasFee>();
sp= tbBasFeeService.getTbBasFeeListNoPage(param);
List<TbBasBedSrt> tbBasBedSrtList = new ArrayList<TbBasBedSrt>();
tbBasBedSrtList= tbBasBedSrtService.list();
model.addAttribute("fq", sp);
List<TbBasLkp> gj= tbBasLkpService.getTbBasLkpByBusinessType("GJ");
model.addAttribute("gj", gj);
List<TbBasAreaVo> tbBasAreas= tbCusFirmService.getShen();
model.addAttribute("shen", tbBasAreas);
List<Map> GN = new ArrayList<Map>();
List<Map> GW = new ArrayList<Map>();
Map<String, Object> GN1 = new HashMap<String,Object>();
Map<String, Object> GW1 = new HashMap<String,Object>();
GN1.put("lookup_type", "1");
GN1.put("lookup_name", "2,2y");
GW1.put("lookup_type", "1");
GW1.put("lookup_name", "2");
GN.add(GN1);
GW.add(GW1);
Map<String,Object> paramCodeGW = new HashMap<String,Object>();
paramCodeGW.put("code", "TB_CUS_FIRM_AFFIX.AFFIX_KIND.QY.GW");
Map<String,Object> paramCodeGN = new HashMap<String,Object>();
paramCodeGN.put("code", "TB_CUS_FIRM_AFFIX.AFFIX_KIND.QY.GN");
Map<String,Object> paramCodeZJ = new HashMap<String,Object>();
paramCodeZJ.put("code", "TB_CUS_FIRM_WEB.CARD_TYPE");
GN=tbCusFirmChgService.getCodeMap(paramCodeGN);
GW=tbCusFirmChgService.getCodeMap(paramCodeGW);
model.addAttribute("mapGN", GN);
model.addAttribute("mapGW", GW);
String customerID= tbCusFirmChgService.createCustomerID();
model.addAttribute("CUSTOMER_ID", customerID);
List<String> companyType= tbCusFirmChgService.getCompanyType();
model.addAttribute("companyType", companyType);
model.addAttribute("CUS_RANK_NUM", tbCusFirmChgService.getCusRankList());
model.addAttribute("CREDIT_RANK_NUM", tbCusFirmChgService.getCreditRank());
model.addAttribute("TRADE_RANK_NUM", tbCusFirmChgService.getTradeRank());
model.addAttribute("CARD_TYPE", tbCusFirmChgService.getCodeMap(paramCodeZJ));
model.addAttribute("customerKey", customerKey);
Map<String,Object> userInfo =null;
if(!"".equals(customerKey)&&customerKey!=null){
Map<String,Object> paramEdit = new HashMap<String,Object>();
paramEdit.put("CUSTOMER_KEY", Integer.valueOf(customerKey));
if(tbCusFirmWebService.getUserInfoWeb(customerKey)!=null&&tbCusFirmWebService.getUserInfoWeb(customerKey).size()>0){
userInfo =tbCusFirmWebService.getUserInfoWeb(customerKey).get(0);
}
if(userInfo!=null){
userInfo.put("zjInfo", tbCusFirmWebService.getZjInfoWeb(paramEdit));
}
if(userInfo!=null){
List list = tbCusFirmWebService.getJypzInfoList(customerKey);
userInfo.put("jypzInfoList", list);
if(list!=null&&list.size()>0){
Map jypzInfoMap1 = new HashMap();
for(int i=0;i<list.size();i++){
Map pzDate = (Map) list.get(i);
jypzInfoMap1.put(pzDate.get("WAREKIND_KEY")+"-"+pzDate.get("CURRENCY_TYPE"), pzDate.get("WAREKIND_KEY")+"-"+pzDate.get("CURRENCY_TYPE"));
}
userInfo.put("jypzInfoMap", jypzInfoMap1);
Map jypzInfoMap = null;
jypzInfoMap=(Map) userInfo.get("jypzInfoMap");
List<Map> codeLibraryjypzList= tbCusFirmChgService.getCodeLibraryListForjypz(jypzInfoMap);
model.addAttribute("codeLibraryjypzList", codeLibraryjypzList);
}
}
List<TbBasAreaVo> tbBasShis= tbCusFirmService.getShi(userInfo.get("PROVINCE_AREA_KEY")+"");
model.addAttribute("regUser", userInfo);
model.addAttribute("tbBasShis", tbBasShis);
model.addAttribute("operateuserList", tbCusFirmChgService.getOperateUserByCustomerKey(paramEdit));
}
return "/account/tbCusFirmWeb/autio";
}
<select id="getUserInfoWeb" parameterType="string" resultType="java.util.HashMap">
SELECT t.*,FC_GET_AREANAME(t.CITY_AREA_KEY) AREA_NAME FROM TB_CUS_FIRM_WEB t WHERE CUSTOMER_KEY=#{CUSTOMER_KEY}
</select>
推荐阅读
-
Android 使用Pull方法解析XML文件的方法
-
实例解析iOS app开发中音频文件播放工具类的封装
-
Android编程使用pull方式解析xml格式文件的方法详解
-
Java实现解析dcm医学影像文件并提取文件信息的方法示例
-
php的SimpleXML方法读写XML接口文件实例解析
-
MyBatis启动之XMLConfigBuilder解析配置文件(二)
-
解析PHP实现下载文件的两种方法
-
jQuery加载及解析XML文件的方法实例分析
-
Mybaits 源码解析 (十二)----- Mybatis的事务如何被Spring管理?Mybatis和Spring事务中用的Connection是同一个吗?
-
IE6不能正常解析CSS文件问题的解决方法及原因分析