zoukankan      html  css  js  c++  java
  • java mybatis 动态sql

     
    
    //-------------------------------查询-------------------------------------//
    
    <sql id="cmsGuestbookColumns">
         
            
             a.id AS "id",
            a.GROUP_NUMBER AS "groupNumber",
            a.GROUP_NAME AS "groupName",
            a.GROUP_AMOUNT  as "groupAmount", 
            a.GROUP_STATUS AS "groupStatus",
               a.RULES AS "rules",
            a.DELETE_STATUS AS "deleteStatus",
            <!-- a.MODIFIEDBY AS "modifiedby", -->
            a.MODIFIEDBY AS "updateBy",
            <!-- DATE_FORMAT(a.MODIFIEDON,'%Y-%m-%d %H:%i:%s')     AS "modifiedon", -->
             DATE_FORMAT(a.MODIFIEDON,'%Y-%m-%d %H:%i:%s')     AS "updateDate", 
            a.CREATEDBY AS "createdby",  
                <!-- DATE_FORMAT(a.CREATEDON,'%Y-%m-%d %H:%i:%s') AS "createdon"   -->
             DATE_FORMAT(a.CREATEDON,'%Y-%m-%d %H:%i:%s') AS "createDate"     
        </sql>
        
         
      
        
        <select id="findList" resultType="com.thinkgem.jeesite.modules.rule.entity.RuleCombinationModel">
            SELECT 
                <include refid="cmsGuestbookColumns"/>
            FROM t_zg_rule_group  a
             
            <where>
                a.DELETE_STATUS = 0
                <if test="groupNumber!='' and groupNumber!=null ">
                and a.GROUP_NUMBER=#{groupNumber}
                </if>
                <if test="groupName!='' and groupName!=null ">
                and a.GROUP_NAME=#{groupName}
                </if>
                <if test="groupStatus!='' and groupStatus!=null ">
                and a.GROUP_STATUS=#{groupStatus}
                </if>
            </where>
            <choose>
                <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                    ORDER BY ${page.orderBy}
                </when>
                <otherwise>
                    ORDER BY a.CREATEDON DESC
                </otherwise>
            </choose>
        </select>
    
     
    
     
    
    //-------------------------------修改-------------------------------------//
    
        <update id="update">
            UPDATE t_zg_rule_group
             <set>     
            <if test="groupNumber !='' and groupNumber !=null">
            GROUP_NUMBER=#{groupNumber},
            </if>
            <if test="groupName !='' and groupName !=null">
            GROUP_NAME=#{groupName},
            </if>
                <if test="groupStatus !='' and groupStatus !=null">
            GROUP_STATUS=#{groupStatus},
            </if>
                <if test="groupAmount !='' and groupAmount !=null">
            GROUP_AMOUNT=#{groupAmount},
            </if>
            <if test="deleteStatus !='' and deleteStatus !=null">
            DELETE_STATUS=#{deleteStatus},
            </if>
                <if test="modifiedby !='' and modifiedby !=null">
            MODIFIEDBY=#{modifiedby},
            </if>        
            </set>            
            WHERE id = #{id}
        </update>
  • 相关阅读:
    HDU_oj_2048 错排问题
    HDU_oj_2047 阿牛的EOF牛肉面
    HDU_oj_2046 骨牌铺方格
    HDU_oj_2045 不容易系列之RPG问题
    拷贝构造函数(三)——重载赋值运算符
    拷贝构造函数(二)——深拷贝与浅拷贝
    拷贝构造函数(一)——哲学三连
    HDU_oj_2044 一只小蜜蜂
    【转发】【linux】【ftp】CentOS 7.0安装配置Vsftp服务器
    【编码】【转发】enca 转换编码
  • 原文地址:https://www.cnblogs.com/yangjinwang/p/6028026.html
Copyright © 2011-2022 走看看