5.5

解决昨天的问题
在vite.config.js文件中配置 请求后端

//请求后端的配置
  server: {
    proxy: {
      '/api': {
        //获取路径中包含了/api的请求
        target: 'http://localhost:8080',//后台服务所在的源
        changeOrigin: true,//修改源
        rewrite: (path) => path.replace(/^\/api/, '')// /api替换为空字符串 
      }
    },
  }

动态sql查询 对一个数据库中的null进行查询

  <!--    动态sql-->
    <select id="list" resultType="com.example.pojo.Policy">
        SELECT * FROM policy
        <where>
            <!--                        name LIKE CONCAT('%',"中国",'%')-->
            <if test="name != null">
                name LIKE CONCAT('%' ,#{name}, '%')
            </if>
            <if test="document != null">
                AND document LIKE CONCAT('%',#{document},'%')
            </if>
            <if test="text != null">
                AND text LIKE CONCAT('%',#{text},'%')
            </if>
            <if test="organ != null">
                AND organ LIKE CONCAT('%',#{organ},'%')
            </if>
            <if test="checkList != null and checkList.size() > 0">
                AND (
                type IN
                <foreach collection="checkList" item="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
                <choose>
                    <when test="flag != null">
                        OR type IS NULL
                        )
                    </when>
                    <otherwise>
                        )
                    </otherwise>
                </choose>
            </if>

        </where>
    </select>
posted @ 2024-05-05 23:26  258333  阅读(5)  评论(0编辑  收藏  举报