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>