• 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>
  • 相关阅读:
    SJTU T4143 推箱子
    Markdown基本语法
    命令行的操作——cd
    C++ ------- 类和对象
    数据结构------栈和队列
    MySQL------ 子查询
    MySQL------ SQL99语法
    C++------内存分区模型
    第三章------数据链路层
    MySQL------ SQL92语法
  • 原文地址:https://www.cnblogs.com/yangjinwang/p/6028026.html
Copyright © 2020-2023  润新知