beetl 模板编写疑惑

Blade 未结 1 699
hhq啊
hhq啊 剑圣 2020-12-22 14:55

一、该问题的重现步骤是什么?

  1.  不知道这个算不算界定符 官方的例子 这个 #if{ #}image.png

2. 而beetl 上 默认是 <% %> 里面嵌表达式

image.png

3. 我在做mapperxml 的时候,想原样输出#{xxx} ,提示错误


image.png

二、你期待的结果是什么?实际看到的又是什么?

这个是#if{ #}官方自己配置的? 还是 说 配置了这个 <% %>就不生效了


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

archer 2.6.1

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

我的mapper xml 文件

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="${plan.packagePath!}.mapper.${model.modelClass!}Mapper">


<!-- 通用查询映射结果 -->

    <resultMap id="${model.modelCode!}ResultMap" type="${plan.packagePath!}.entity.${model.modelClass!}Entity">

        #for(x in model.prototypes) {

        <result column="${x.jdbcName!}" property="${x.propertyName!}"/>

        #}

    </resultMap>

<!-- 通用lazy-list -->

    <resultMap id="${model.modelCode!}VOResultMap" type="${plan.packagePath!}.vo.${model.modelClass!}VO">

        #for(x in model.prototypes) {

        <result column="${x.jdbcName!}" property="${x.propertyName!}"/>

        #}

<result column="has_children" property="hasChildren"/>

    </resultMap>


<select id="lazyList" resultMap="${model.modelCode!}VOResultMap">

        SELECT

            ${model.modelCode!}.* ,

            (

                SELECT

                    CASE WHEN count(1) > 0 THEN 1 ELSE 0 END

                FROM

                    ${model.modelTable!}

                WHERE

                    parent_id = ${model.modelCode!}.id and is_deleted = 0

            ) AS "has_children"

        FROM

            ${model.modelTable!} ${model.modelCode!}

        WHERE ${model.modelCode!}.is_deleted = 0

<if test="param1!=null and param1!=''">

            and ${model.modelCode!}.tenant_id = #{param1}

        </if>

        <if test="param2!=null">

            and ${model.modelCode!}.parent_id = #{param2}

        </if>

#for(x in model.prototypes) {

#if(x.isQuery==1){

#if(!(strutil.contain(x.propertyType,"LocalDateTime")||strutil.contain(x.propertyType,"Date"))){

<if test="param3.${x.propertyName}!=null and param3.${x.propertyName}!=''">

and ${model.modelCode!}.${x.jdbcName!} like concat(concat('%', #{param3.${x.propertyName}}),'%')

</if>  

#}

#if((strutil.contain(x.propertyType,"LocalDateTime")||strutil.contain(x.propertyType,"Date"))){

<if test="param3.${x.propertyName}!=null and param3.${x.propertyName}!=''">

and date_format(${model.modelCode!}.${x.jdbcName!},'%Y-%m-%d') between 'param3.${x.propertyName}_datege' and 'param3.${x.propertyName}_datelt';

</if> 

#}

#}

        #}

        ORDER BY ${model.modelCode!}.create_time

    </select>

</mapper>


1条回答
  • 2020-12-23 13:00

    自定义过了

    image.png

    0 讨论(0)
提交回复