zoukankan      html  css  js  c++  java
  • JSON格式的字段

    mysql中定义 json 格式的字段, 在 Spring 中定义 字段:  

    private JSON tags;
    POSTMAN中 可以传:   "tags":["aaa"]   或者  "tags":{"qq":"111"}  。
     
    如果 mysql 中的 tags 定义json, 存储的是 json数组,例如: ["test"]  ,则 在 spring 中可以定义字段:
    private JSON tags;  或者  private JSONArray tags;

    查询 tags 中是否包含某个 字符串:
        <select id="queryAllPage" resultMap="TtProductContentMap">
            select <include refid="resultColumn"/>
            from lesmart_cms.tt_product_content
            <where>
                <if test="productMode != null and productMode !=''">and product_mode = #{productMode}</if>
                <if test="terminalType != null and terminalType !=''">and terminal_type = #{terminalType}</if>
                <if test="keyWord != null and keyWord !=''">
                    and (
                        title like concat('%',#{keyWord},'%')
                        or JSON_LENGTH(tags) = 0
                        or  JSON_CONTAINS(tags, JSON_ARRAY(#{keyWord}))
                    )
                </if>
            </where>
        </select>

    查询出的结果:

  • 相关阅读:
    C#按键打开文件选择对话框,并把选择好的路径保存/显示到textBox
    C#按钮打开浏览器,网址
    阅读笔记05
    进度条14
    冲刺4--10
    冲刺3
    冲刺2
    课堂训练书本
    进度条13
    课堂水王2
  • 原文地址:https://www.cnblogs.com/z360519549/p/13539443.html
Copyright © 2011-2022 走看看