sql片段的定义;
1 <sql id="condition"> 2 <if test="entity.dicttype != null"> and `dicttype` = #{entity.dicttype} </if> 3 <if test="entity.dictname != null and entity.dictname != ''"> and `dictname` LIKE concat(concat('%',#{entity.dictname}),'%') </if> 4 <if test="entity.sortno != null"> and `sortno` = #{entity.sortno} </if> 5 <if test="entity.status != null"> and `status` = #{entity.status}</if> 6 <if test="entity.dictcode != null and entity.dictcode != '' "> and `dictcode` LIKE concat(concat('%',#{entity.dictcode}),'%') </if> 7 <if test="entity.createTime != null"> and `create_time` = #{entity.createTime} </if> 8 <if test="entity.createBy != null"> and `create_by` = #{entity.createBy} </if> 9 <if test="entity.lastModifyTime != null"> and `last_modify_time` = #{entity.lastModifyTime} </if> 10 <if test="entity.lastModifyBy != null"> and `last_modify_by` = #{entity.lastModifyBy} </if> 11 </sql>
sql片段的使用:
1 /**mycat:schema=${schemaLabel}*/ select * from t_ac_dictdeta 2 <where> 3 <include refid="condition" /> 4 </where> 5 order by dictid asc 6 <if test="entity.offset != null and entity.limit != null"> 7 limit #{entity.offset}, #{entity.limit} 8 </if>
标签:status,片段,Sql,entity,sql,mybatis,sortno,concat From: https://www.cnblogs.com/joe-tang/p/9176034.html