mybatis+spring mvc 完美整合方案 查询,保存,更新,删除自动生成

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.          
  17. <!-- jeecg_note table all fields -->  
  18. <sql id="Base_Column_List" >  
  19.      id,title,content,crtuser,crtuser_name,create_dt,deleted  
  20. </sql>  
  21.      
  22.      
  23. <!-- 查询条件 -->  
  24. <sql id="Example_Where_Clause">  
  25. where 1=1  
  26. <trim  suffixOverrides="," >  
  27.     <if test="id != null and id != ''" >  
  28.         and id =  #{id}  
  29.     </if>  
  30.     <if test="title != null and title != ''" >  
  31.         and title =  #{title}  
  32.     </if>  
  33.     <if test="content != null and content != ''" >  
  34.         and content =  #{content}  
  35.     </if>  
  36.     <if test="crtuser != null and crtuser != ''" >  
  37.         and crtuser =  #{crtuser}  
  38.     </if>  
  39.     <if test="crtuser_name != null and crtuser_name != ''" >  
  40.         and crtuser_name =  #{crtuser_name}  
  41.     </if>  
  42.     <if test="create_dt != null and create_dt != ''" >  
  43.         and create_dt =  #{create_dt}  
  44.     </if>  
  45.     <if test="deleted != null and deleted != ''" >  
  46.         and deleted =  #{deleted}  
  47.     </if>  
  48. </trim>  
  49. </sql>  
  50.      
  51.   
  52. <!-- 插入记录 -->  
  53. <insert id="add" parameterType="Object" >  
  54. <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">  
  55.     SELECT LAST_INSERT_ID()  
  56.   </selectKey>  
  57.   insert into jeecg_note(id,title,content,crtuser,crtuser_name,create_dt,deleted)  
  58.  values(#{id},#{title},#{content},#{crtuser},#{crtuser_name},#{create_dt},#{deleted})  
  59. </insert>  
  60.   
  61. <!-- 根据id,修改记录-->    
  62.  <update id="update" parameterType="Object" >  
  63.   update jeecg_note set title=#{title},content=#{content},crtuser=#{crtuser},crtuser_name=#{crtuser_name},create_dt=#{create_dt},deleted=#{deleted} where id=#{id}  
  64.  </update>  
  65.    
  66.  <!-- 修改记录,只修改只不为空的字段 -->  
  67. <update id="updateBySelective" parameterType="Object" >  
  68.     update jeecg_note set   
  69.     <trim  suffixOverrides="," >  
  70.     <if test="title != null  ">  
  71.         title=#{title},  
  72.     </if>  
  73.     <if test="content != null  ">  
  74.         content=#{content},  
  75.     </if>  
  76.     <if test="crtuser != null  ">  
  77.         crtuser=#{crtuser},  
  78.     </if>  
  79.     <if test="crtuser_name != null  ">  
  80.         crtuser_name=#{crtuser_name},  
  81.     </if>  
  82.     <if test="create_dt != null  ">  
  83.         create_dt=#{create_dt},  
  84.     </if>  
  85.     <if test="deleted != null  ">  
  86.         deleted=#{deleted},  
  87.     </if>  
  88.     </trim> where id=#{id}  
  89. </update>  
  90.   
  91. <!-- 删除记录 -->  
  92. <delete id="delete" parameterType="Object">  
  93.     delete   from jeecg_note where id = #{id}  
  94. </delete>  
  95.    
  96. <!-- 根据id查询 公告 -->  
  97. <select id="queryById"  resultMap="BaseResultMap" parameterType="Object">  
  98.     select <include refid="Base_Column_List" />   
  99.      from jeecg_note where id = #{id}  
  100. </select>  
  101.   
  102. <!-- 公告 列表总数-->  
  103. <select id="queryByCount" resultType="java.lang.Integer"  parameterType="Object">  
  104.     select count(1) from jeecg_note   
  105.     <include refid="Example_Where_Clause"/>  
  106. </select>  
  107.       
  108. <!-- 查询公告列表 -->  
  109. <select id="queryByList" resultMap="BaseResultMap"  parameterType="Object">  
  110.     select   
  111.     <include refid="Base_Column_List"/>  
  112.     from jeecg_note   
  113.     <include refid="Example_Where_Clause"/>  
  114.     <if test="pager.orderCondition != null and pager.orderCondition != ''" >  
  115.       ${pager.orderCondition}  
  116.     </if>  
  117.     <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''" >  
  118.        ${pager.mysqlQueryCondition}  
  119.     </if>  
  120. </select>  
  121.       
  122. </mapper>     
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JEECG低代码平台

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值