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>
相关推荐
springboot mybatis mapper.xml 配置,里面包含了新增,修改,删除,查询,分页查询例子以及通过 网页访问的例子
根据项目模块来生成对应的Mapper,这里采用Maven构建项目。Mybatis Generator插件怎么使用请参考:https://my.oschina.net/boonya/blog/719502。更多代码生成器介绍请参考:...
mybatis mapper 和xml文件生成
MyBatis Mapper映射文件
IntelliJ IDEA修改了mybatis mapper xml后自动热发布 热更新 热部署.zip Mybatis xml文件使用热加载检测不更新怎么办?看我的
IntellijIDEA 中 MybatisMapper 自动注入警告的 6 种解决方案 IntellijIDEA 中 MybatisMapper 自动注入警告的 6 种解决方案是开发者们经常遇到的问题。本文将分析原因,并列出解决该警告的几种方案。 方案 1:为 @...
Mybatis的Mapper方式整合elasticsearch的DSL调用,之前的AOP进行了改进,使用cglib动态代理生成代理类,基于接口和代理生成bean注入的方式进行调用
mybatis自动生成实体类和mapper文件。自动添加实体类注释。
Mybatis Mapper.xml中字符串形式传参,逗号分隔 AND中拼接OR。
这是mybatis的生成mapper工具,可以生成bean、dao和mapper.xml.这是maven的项目的。
Spring+mvc+mybatis Mapper xml自动加载修改SQL不用重启tomcat,附带sql脚本,下载直接能运行,启动输入http://localhost:8080/aclome/
MybatisMapper主要实现只写dao接口,从而不用写到接口的实现类!
本文详细介绍了在Mybatis框架 mapper.xml文件中parameterType传递参数常用的几种方式,以及如何实现的案列,同时#和$传参的区别。
操作简单方便,通过外置可运行jar包实现,无需集成到... 操作过程:1 ) 修改配置文件中的数据库地址,表名,和要输出的文件路径,2)通过命令一键生成xml文件,mybatis接口,实体映射类三个文件。 亲测执行结果正确。
Mapper用于映射SQL语句,可以说是MyBatis操作数据库的核心特性之一,这里我们来讨论Java的MyBatis框架中Mapper映射配置的使用及原理解析,包括对mapper的xml配置文件的读取流程解读.
里面包含说明使用方法,主要是mybatis生成mysql 数据库表并生成mapper对象和xml,此jar包请解压后,查看源码
mybatis中mapper文件resultMap中collection和association的使用,参考地址:https://blog.csdn.net/zhizhuodewo6/article/details/82863452
在 MyBatis 中,Mapper 代理方式是通过使用 SqlSessionFactoryBuilder 类的 build 方法来生成的,该方法将读取 MyBatis 的配置文件,例如 SqlMapConfig.xml,然后生成一个 SqlSessionFactory 对象,该对象可以用来...
mybatis基本文件xml、mapper等自动生成工具 可自己根据自己的项目路径自行配置文件夹路径,本DEMO是使用的mysql数据库,可自行更换其他数据源 本DEMO会自动生成dao、model、mapper、xml文件,自带基本方法,可自动...
自动化生成mybatis mapper 文件及 POJO类