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

【jeecg-mybatis版本】 mybatis+spring mvc 完美整合方案 查询,保存,更新,删除自动生成  

程序员文章站 2022-03-12 13:09:10
...

Jeecg-mybatis-framework 版本

简要说明

  • JEECG[J2EE Code Generation]是一款基于代码生成器的J2EE智能开发框架,借助该框架可以节省50%的工作量,实现代码生成+手工merge的半智能开发
  • 代码生成:根据表生成对应的Bean,Service,Dao,Action,XML,JSP等,增删改查功能直接使用,实现了快速开发
  • jeecg-mybatis-framework,采用SpringMVC+Mybatis等主流框架
  • 支持数据库: Mysql,Oracle10g
  • 前端:使用Jquery和Easyui技术.JS封装简洁,操作简单.
  • 权限:对菜单,按钮控制.根据登陆用户权限展示拥有的菜单和按钮.
  • 拦截:对所有无权限URL进行拦截,防止手动发送HTTP请求,确保系统全性.


源码下载:

链接:http://pan.baidu.com/s/1pJMkprt密码: k3u8



入门视频:

链接:http://pan.baidu.com/s/1ntD0O1z密码: 66gi



环境搭建:

1.创建一个utf-8的数据库,数据库名jeecgmybatis
2.执行脚本jeecgmybatis.sql,初始化数据库
3.项目导入myeclipse工程
4.启动项目
访问:http://localhost:8080/jeecg-mybatis-framework
5.代码生成器路径
/jeecg-mybatis-framework/src/com/code/CodeUtil.java


技术交流

本系统由JEECG社区提供,如需个性化定制,可与官方(www.jeecg.org)联系.



Java代码【jeecg-mybatis版本】 mybatis+spring mvc 完美整合方案 查询,保存,更新,删除自动生成
            
    
    
         
  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <!DOCTYPEmapper
  3. PUBLIC"-//mybatis.org//DTDMapper3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mappernamespace="scott.dao.demo.JeecgNoteDao">
  6. <!--ResultMap-->
  7. <resultMapid="BaseResultMap"type="scott.entity.demo.JeecgNote">
  8. <resultcolumn="id"property="id"/>
  9. <resultcolumn="title"property="title"/>
  10. <resultcolumn="content"property="content"/>
  11. <resultcolumn="crtuser"property="crtuser"/>
  12. <resultcolumn="crtuser_name"property="crtuser_name"/>
  13. <resultcolumn="create_dt"property="create_dt"/>
  14. <resultcolumn="deleted"property="deleted"/>
  15. </resultMap>
  16. <!--jeecg_notetableallfields-->
  17. <sqlid="Base_Column_List">
  18. id,title,content,crtuser,crtuser_name,create_dt,deleted
  19. </sql>
  20. <!--查询条件-->
  21. <sqlid="Example_Where_Clause">
  22. where1=1
  23. <trimsuffixOverrides=",">
  24. <iftest="id!=nullandid!=''">
  25. andid=#{id}
  26. </if>
  27. <iftest="title!=nullandtitle!=''">
  28. andtitle=#{title}
  29. </if>
  30. <iftest="content!=nullandcontent!=''">
  31. andcontent=#{content}
  32. </if>
  33. <iftest="crtuser!=nullandcrtuser!=''">
  34. andcrtuser=#{crtuser}
  35. </if>
  36. <iftest="crtuser_name!=nullandcrtuser_name!=''">
  37. andcrtuser_name=#{crtuser_name}
  38. </if>
  39. <iftest="create_dt!=nullandcreate_dt!=''">
  40. andcreate_dt=#{create_dt}
  41. </if>
  42. <iftest="deleted!=nullanddeleted!=''">
  43. anddeleted=#{deleted}
  44. </if>
  45. </trim>
  46. </sql>
  47. <!--插入记录-->
  48. <insertid="add"parameterType="Object">
  49. <selectKeyresultType="java.lang.Integer"order="AFTER"keyProperty="id">
  50. SELECTLAST_INSERT_ID()
  51. </selectKey>
  52. insertintojeecg_note(id,title,content,crtuser,crtuser_name,create_dt,deleted)
  53. values(#{id},#{title},#{content},#{crtuser},#{crtuser_name},#{create_dt},#{deleted})
  54. </insert>
  55. <!--根据id,修改记录-->
  56. <updateid="update"parameterType="Object">
  57. updatejeecg_notesettitle=#{title},content=#{content},crtuser=#{crtuser},crtuser_name=#{crtuser_name},create_dt=#{create_dt},deleted=#{deleted}whereid=#{id}
  58. </update>
  59. <!--修改记录,只修改只不为空的字段-->
  60. <updateid="updateBySelective"parameterType="Object">
  61. updatejeecg_noteset
  62. <trimsuffixOverrides=",">
  63. <iftest="title!=null">
  64. title=#{title},
  65. </if>
  66. <iftest="content!=null">
  67. content=#{content},
  68. </if>
  69. <iftest="crtuser!=null">
  70. crtuser=#{crtuser},
  71. </if>
  72. <iftest="crtuser_name!=null">
  73. crtuser_name=#{crtuser_name},
  74. </if>
  75. <iftest="create_dt!=null">
  76. create_dt=#{create_dt},
  77. </if>
  78. <iftest="deleted!=null">
  79. deleted=#{deleted},
  80. </if>
  81. </trim>whereid=#{id}
  82. </update>
  83. <!--删除记录-->
  84. <deleteid="delete"parameterType="Object">
  85. deletefromjeecg_notewhereid=#{id}
  86. </delete>
  87. <!--根据id查询公告-->
  88. <selectid="queryById"resultMap="BaseResultMap"parameterType="Object">
  89. select<includerefid="Base_Column_List"/>
  90. fromjeecg_notewhereid=#{id}
  91. </select>
  92. <!--公告列表总数-->
  93. <selectid="queryByCount"resultType="java.lang.Integer"parameterType="Object">
  94. selectcount(1)fromjeecg_note
  95. <includerefid="Example_Where_Clause"/>
  96. </select>
  97. <!--查询公告列表-->
  98. <selectid="queryByList"resultMap="BaseResultMap"parameterType="Object">
  99. select
  100. <includerefid="Base_Column_List"/>
  101. fromjeecg_note
  102. <includerefid="Example_Where_Clause"/>
  103. <iftest="pager.orderCondition!=nullandpager.orderCondition!=''">
  104. ${pager.orderCondition}
  105. </if>
  106. <iftest="pager.mysqlQueryCondition!=nullandpager.mysqlQueryCondition!=''">
  107. ${pager.mysqlQueryCondition}
  108. </if>
  109. </select>
  110. </mapper>