美文网首页
mybatis 的动态sql

mybatis 的动态sql

作者: 轰轰_9ccd | 来源:发表于2019-05-21 18:40 被阅读0次

    控制层就不多做解释了
    @Override
    public List<TO7xzApp> findRecommendDownByCategoryChilrenNameList(String categoryChildrenName, int size, List<String> idList) {
    Map<String, Object> queryMap = Maps.newHashMap();
    queryMap.put("categoryChildrenName", categoryChildrenName);
    queryMap.put("remark3", "1");
    queryMap.put("size", size);
    queryMap.put("idList", idList);
    return mapper.findRecommendDownByCategoryChilrenNameList(queryMap);
    }

    Mapper文件
    List<TO7xzApp> findRecommendDownByCategoryChilrenNameList(Map<String, Object> queryMap);
    这里直接传入一个map

    再看xml文件
    <select id="findHtmlStaticPageList" parameterType="hashmap" resultMap="BaseResultMap">
    SELECT
    CASE remark2 WHEN "soft" THEN "1" ELSE "2" END AS remark3,
    <include refid="baseSql1" />
    FROM
    t_o7xz_app
    <where>
    <if test="categoryParentId != null and categoryParentId != ''">
    and category_parent_id = #{categoryParentId}
    </if>
    <if test="id != null and id != ''">
    and id LIKE CONCAT('%',#{id},'%')
    </if>
    <if test="appName != null and appName != ''">
    and app_name LIKE CONCAT('%',#{appName},'%')
    </if>
    <if test="startTime != null and startTime != ''">
    and create_time >= #{startTime}
    </if>
    <if test="endTime != null and endTime != ''">
    and create_time <= #{endTime}
    </if>
    <if test="audit != null and audit != ''">
    and audit=#{audit}
    </if>
    </where>
    ORDER BY create_time desc
    </select>

    相关文章

      网友评论

          本文标题:mybatis 的动态sql

          本文链接:https://www.haomeiwen.com/subject/trfszqtx.html