欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mybatis 的mapper文件解析规律

程序员文章站 2022-07-13 16:06:40
...

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)))&&param.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>

 

 

 

 

 

相关标签: mybatis