gejun123456 / MyBatisCodeHelper-Pro

http://brucege.com
1.91k stars 240 forks source link

注解提示可以做吗 #891

Closed zigaai closed 1 year ago

zigaai commented 1 year ago

大佬, 能否做注解提示这个feature呢? 现在的版本是不支持注解提示的,java17版本支持Text Blocks 特性, 感觉可以在接口里写SQL

一些示例:

    @Results(id = "VillagesVOMap", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "province_id", property = "provinceId", jdbcType = JdbcType.BIGINT),
            @Result(column = "city_id ", property = "cityId", jdbcType = JdbcType.BIGINT),
            @Result(column = "area_id", property = "areaId", jdbcType = JdbcType.BIGINT),
            @Result(column = "street_id", property = "streetId", jdbcType = JdbcType.BIGINT),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "tb_status", property = "tbStatus", jdbcType = JdbcType.TINYINT)
    })
    @Select("""
            <script>
            select `villages`.id, `villages`.province_id, `villages`.city_id, `villages`.area_id, `villages`.street_id, `villages`.`name`, `villages`.tb_status
            from `villages`
            <where>
                <if test="provinceId != null">
                    `province_id` = #{provinceId,jdbcType=BIGINT}
                </if>
                <if test="name != null">
                    and `name` = #{name,jdbcType=CHAR}
                </if>
            </where>
            </script>
            """)
    List<VillagesVO> page(VillagesQuery params);

    @Insert("""
            <script>
            insert into `villages`
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="provinceId != null">
                    `province_id`,
                </if>
                <if test="cityId != null">
                    `city_id`,
                </if>
                <if test="areaId != null">
                    `area_id`,
                </if>
                <if test="streetId != null">
                    `street_id`,
                </if>
                <if test="name != null">
                    `name`,
                </if>
                <if test="tbStatus != null">
                    `tb_status`,
                </if>
            </trim>
            <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="provinceId != null">
                    #{provinceId,jdbcType=BIGINT},
                </if>
                <if test="cityId != null">
                    #{cityId,jdbcType=BIGINT},
                </if>
                <if test="areaId != null">
                    #{areaId,jdbcType=BIGINT},
                </if>
                <if test="streetId != null">
                    #{streetId,jdbcType=BIGINT},
                </if>
                <if test="name != null">
                    #{name,jdbcType=CHAR},
                </if>
                <if test="tbStatus != null">
                    #{tbStatus,jdbcType=TINYINT},
                </if>
            </trim>
            </script>
            """)
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(Villages record);
gejun123456 commented 1 year ago

image 这个勾了没,注解支持的,可以试试,if test里面不支持双引号 用单引号

zigaai commented 1 year ago

谢谢大佬回答,确定勾选了, 但是没提示出来 使用的是 idea community 版本:

IntelliJ IDEA 2023.1.2 (Community Edition)
Build #IC-231.9011.34, built on May 16, 2023
Runtime version: 17.0.6+10-b829.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Registry:
    debugger.new.tool.window.layout=true
    ide.experimental.ui=true

插件版本: 3.2.0

a b image

gejun123456 commented 1 year ago

idea高级版才有,这个代码提示要依赖idea高级版的database插件,社区版还没有

zigaai commented 1 year ago

了解了 谢谢