https://www.bbsmax.com/A/WpdKnQOm5V/ 实例
http://www.mybatis.org/mybatis-3/zh/dynamic-sql.html 官网
<!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, grade_code AS gradeCode, grade_name AS gradeName, max_num AS maxNum, min_num AS minNum, is_and AS isAnd, max_total_brokerage AS maxTotalBrokerage, min_total_brokerage AS minTotalBrokerage, remark, is_enable AS isEnable, creator, modifier, created, modified, is_deleted AS isDeleted </sql> <select id="getUserMemberGradeLists" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page"> select <include refid="Base_Column_List"></include> from p_user_member_grade where is_deleted = 0 <if test="keyword!=null and keyword!=''"> and grade_name like concat('%',#{keyword},'%') </if> <choose> <when test="orderByField != null and orderByField !=''"> <choose> <when test="isAsc == true"> order by ${orderByField} ASC </when> <otherwise> order by ${orderByField} DESC </otherwise> </choose> </when> <otherwise> order by created DESC </otherwise> </choose> </select> <select id="getByUserMemberGradeName" resultType="com.zjdfwl.mall.modular.user.model.UserMemberGrade"> select <include refid="Base_Column_List" /> from p_user_member_grade where grade_name = #{gradeName} and is_deleted = 0 </select>