1. 程式人生 > >mybatis+spring mvc 完美整合方案 查詢,保存,更新,刪除自動生成

mybatis+spring mvc 完美整合方案 查詢,保存,更新,刪除自動生成

esp mys null java ted 簡單 easyu make 主流框架

Jeecg-Mybatis版本代碼生成器演示視頻

代碼下載:JEECG-mybatis參考學習版本

簡要說明
JEECG[J2EE Code Generation]
代碼生成:根據表生成對應的Bean,Service,Dao,Action,XML,JSP等,增刪改查功能直接使用,實現了快速開發
jeecg-mybatis-framework,采用SpringMVC+Mybatis等主流框架
支持數據庫: Mysql,Oracle10g
前端:使用Jquery和Easyui技術.JS封裝簡潔,操作簡單.
權限:對菜單,按鈕控制.根據登陸用戶權限展示擁有的菜單和按鈕.
攔截:對所有無權限URL進行攔截,防止手動發送HTTP請求,確保系統全性.




Java代碼 技術分享圖片
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="scott.dao.demo.JeecgNoteDao" >
  6. <!-- Result Map-->
  7. <resultMap id="BaseResultMap"
    type="scott.entity.demo.JeecgNote" >
  8. <result column="id" property="id"/>
  9. <result column="title" property="title"/>
  10. <result column="content" property="content"/>
  11. <result column="crtuser" property="crtuser"/>
  12. <result column="crtuser_name" property="crtuser_name"
    />
  13. <result column="create_dt" property="create_dt"/>
  14. <result column="deleted" property="deleted"/>
  15. </resultMap>
  16. <!-- jeecg_note table all fields -->
  17. <sql id="Base_Column_List" >
  18. id,title,content,crtuser,crtuser_name,create_dt,deleted
  19. </sql>
  20. <!-- 查詢條件 -->
  21. <sql id="Example_Where_Clause">
  22. where 1=1
  23. <trim suffixOverrides="," >
  24. <if test="id != null and id != ‘‘" >
  25. and id = #{id}
  26. </if>
  27. <if test="title != null and title != ‘‘" >
  28. and title = #{title}
  29. </if>
  30. <if test="content != null and content != ‘‘" >
  31. and content = #{content}
  32. </if>
  33. <if test="crtuser != null and crtuser != ‘‘" >
  34. and crtuser = #{crtuser}
  35. </if>
  36. <if test="crtuser_name != null and crtuser_name != ‘‘" >
  37. and crtuser_name = #{crtuser_name}
  38. </if>
  39. <if test="create_dt != null and create_dt != ‘‘" >
  40. and create_dt = #{create_dt}
  41. </if>
  42. <if test="deleted != null and deleted != ‘‘" >
  43. and deleted = #{deleted}
  44. </if>
  45. </trim>
  46. </sql>
  47. <!-- 插入記錄 -->
  48. <insert id="add" parameterType="Object" >
  49. <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
  50. SELECT LAST_INSERT_ID()
  51. </selectKey>
  52. insert into jeecg_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. <update id="update" parameterType="Object" >
  57. update jeecg_note set title=#{title},content=#{content},crtuser=#{crtuser},crtuser_name=#{crtuser_name},create_dt=#{create_dt},deleted=#{deleted} where id=#{id}
  58. </update>
  59. <!-- 修改記錄,只修改只不為空的字段 -->
  60. <update id="updateBySelective" parameterType="Object" >
  61. update jeecg_note set
  62. <trim suffixOverrides="," >
  63. <if test="title != null ">
  64. title=#{title},
  65. </if>
  66. <if test="content != null ">
  67. content=#{content},
  68. </if>
  69. <if test="crtuser != null ">
  70. crtuser=#{crtuser},
  71. </if>
  72. <if test="crtuser_name != null ">
  73. crtuser_name=#{crtuser_name},
  74. </if>
  75. <if test="create_dt != null ">
  76. create_dt=#{create_dt},
  77. </if>
  78. <if test="deleted != null ">
  79. deleted=#{deleted},
  80. </if>
  81. </trim> where id=#{id}
  82. </update>
  83. <!-- 刪除記錄 -->
  84. <delete id="delete" parameterType="Object">
  85. delete from jeecg_note where id = #{id}
  86. </delete>
  87. <!-- 根據id查詢 公告 -->
  88. <select id="queryById" resultMap="BaseResultMap" parameterType="Object">
  89. select <include refid="Base_Column_List" />
  90. from jeecg_note where id = #{id}
  91. </select>
  92. <!-- 公告 列表總數-->
  93. <select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
  94. select count(1) from jeecg_note
  95. <include refid="Example_Where_Clause"/>
  96. </select>
  97. <!-- 查詢公告列表 -->
  98. <select id="queryByList" resultMap="BaseResultMap" parameterType="Object">
  99. select
  100. <include refid="Base_Column_List"/>
  101. from jeecg_note
  102. <include refid="Example_Where_Clause"/>
  103. <if test="pager.orderCondition != null and pager.orderCondition != ‘‘" >
  104. ${pager.orderCondition}
  105. </if>
  106. <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ‘‘" >
  107. ${pager.mysqlQueryCondition}
  108. </if>
  109. </select>
  110. </mapper>

再分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!https://blog.csdn.net/jiangjunshow

mybatis+spring mvc 完美整合方案 查詢,保存,更新,刪除自動生成