mybatis+spring mvc 完美整合方案 查詢,保存,更新,刪除自動生成
阿新 • • 發佈:2019-02-04
esp mys null java ted 簡單 easyu make 主流框架
Java代碼
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代碼
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="scott.dao.demo.JeecgNoteDao" >
- <!-- Result Map-->
-
<resultMap id="BaseResultMap"
- <result column="id" property="id"/>
- <result column="title" property="title"/>
- <result column="content" property="content"/>
- <result column="crtuser" property="crtuser"/>
-
<result column="crtuser_name" property="crtuser_name"
- <result column="create_dt" property="create_dt"/>
- <result column="deleted" property="deleted"/>
- </resultMap>
- <!-- jeecg_note table all fields -->
- <sql id="Base_Column_List" >
- id,title,content,crtuser,crtuser_name,create_dt,deleted
- </sql>
- <!-- 查詢條件 -->
- <sql id="Example_Where_Clause">
- where 1=1
- <trim suffixOverrides="," >
- <if test="id != null and id != ‘‘" >
- and id = #{id}
- </if>
- <if test="title != null and title != ‘‘" >
- and title = #{title}
- </if>
- <if test="content != null and content != ‘‘" >
- and content = #{content}
- </if>
- <if test="crtuser != null and crtuser != ‘‘" >
- and crtuser = #{crtuser}
- </if>
- <if test="crtuser_name != null and crtuser_name != ‘‘" >
- and crtuser_name = #{crtuser_name}
- </if>
- <if test="create_dt != null and create_dt != ‘‘" >
- and create_dt = #{create_dt}
- </if>
- <if test="deleted != null and deleted != ‘‘" >
- and deleted = #{deleted}
- </if>
- </trim>
- </sql>
- <!-- 插入記錄 -->
- <insert id="add" parameterType="Object" >
- <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
- SELECT LAST_INSERT_ID()
- </selectKey>
- insert into jeecg_note(id,title,content,crtuser,crtuser_name,create_dt,deleted)
- values(#{id},#{title},#{content},#{crtuser},#{crtuser_name},#{create_dt},#{deleted})
- </insert>
- <!-- 根據id,修改記錄-->
- <update id="update" parameterType="Object" >
- update jeecg_note set title=#{title},content=#{content},crtuser=#{crtuser},crtuser_name=#{crtuser_name},create_dt=#{create_dt},deleted=#{deleted} where id=#{id}
- </update>
- <!-- 修改記錄,只修改只不為空的字段 -->
- <update id="updateBySelective" parameterType="Object" >
- update jeecg_note set
- <trim suffixOverrides="," >
- <if test="title != null ">
- title=#{title},
- </if>
- <if test="content != null ">
- content=#{content},
- </if>
- <if test="crtuser != null ">
- crtuser=#{crtuser},
- </if>
- <if test="crtuser_name != null ">
- crtuser_name=#{crtuser_name},
- </if>
- <if test="create_dt != null ">
- create_dt=#{create_dt},
- </if>
- <if test="deleted != null ">
- deleted=#{deleted},
- </if>
- </trim> where id=#{id}
- </update>
- <!-- 刪除記錄 -->
- <delete id="delete" parameterType="Object">
- delete from jeecg_note where id = #{id}
- </delete>
- <!-- 根據id查詢 公告 -->
- <select id="queryById" resultMap="BaseResultMap" parameterType="Object">
- select <include refid="Base_Column_List" />
- from jeecg_note where id = #{id}
- </select>
- <!-- 公告 列表總數-->
- <select id="queryByCount" resultType="java.lang.Integer" parameterType="Object">
- select count(1) from jeecg_note
- <include refid="Example_Where_Clause"/>
- </select>
- <!-- 查詢公告列表 -->
- <select id="queryByList" resultMap="BaseResultMap" parameterType="Object">
- select
- <include refid="Base_Column_List"/>
- from jeecg_note
- <include refid="Example_Where_Clause"/>
- <if test="pager.orderCondition != null and pager.orderCondition != ‘‘" >
- ${pager.orderCondition}
- </if>
- <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ‘‘" >
- ${pager.mysqlQueryCondition}
- </if>
- </select>
- </mapper>
再分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!https://blog.csdn.net/jiangjunshow
mybatis+spring mvc 完美整合方案 查詢,保存,更新,刪除自動生成