今天星期八66 2023-03-10 23:33 采纳率: 100%
浏览 30
已结题

返回的数据不符合规范,正确的成功状态码应为:"code": 0;Mysql报错 Error querying database.

后端数据传不到前端,报错显示:

img

单独查看传输的数据,显示为:

img

代码接口:

img

实现:

img

查询代码:***

//"countPurchaseTotal"查询代码如下:

<select id="countPurchaseTotal" resultType="java.lang.Long">
        select
            count(*)
        form t_purchase_list pl
            LEFT JOIN t_supplier s on pl.supplier_id = s.id
                LEFT JOIN t_purchase_list_goods plg on pl.id = plg.purchase_list_id
                LEFT JOIN t_goods_type gt on plg.type_id = gt.id

        <where>
            <if test="null != purchaseListQuery.startDate and purchaseListQuery.startDate !='' ">
                and purchase_date >=#{purchaseListQuery.startDate}
            </if>

            <if test="null !=purchaseListQuery.endDate and purchaseListQuery.endDate !='' ">
                and purchase_date <=#{purchaseListQuery.endDate}
            </if>

            <if test="null != purchaseListQuery.goodsName and purchaseListQuery.goodsName !='' ">
                and (
                plg.name like concat('%',#{purchaseListQuery.goodsName},'%') or plg.code =#{purchaseListQuery.goodsName}
                )
            </if>

            <if test="null != purchaseListQuery.typeIds and purchaseListQuery.typeIds.size>0">
                and plg.type_id in
                <foreach collection="purchaseListQuery.typeIds" item="typeId" open="(" separator="," close=")">
                    #{typeId}
                </foreach>
            </if>
        </where>
    </select>

//countPurchaseList查询代码如下

    <select id="countPurchaseList" resultType="com.lzj.admin.model.CountResultModel">
        select
            pl.purchase_number as number,
            pl.purchase_date as date,
            s.`name` as name,
            plg.`code`,
            plg.`name` as goodsName,
            plg.model,
            plg.unit as unitName,
            plg.price,
            plg.num,
            plg.total,
            gt.`name` as typeName
        form t_purchase_list pl
            LEFT JOIN t_supplier s on pl.supplier_id = s.id
                left join t_purchase_list_goods plg on pl.id = plg.purchase_list_id
                LEFT JOIN t_goods_type gt on plg.type_id = gt.id
        <where>
            <if test="null != purchaseListQuery.startDate and purchaseListQuery.startDate !='' ">
                and purchase_date >= #{purchaseListQuery.startDate}
            </if>

            <if test="null !=purchaseListQuery.endDate and purchaseListQuery.endDate !='' ">
                and purchase_date <= #{purchaseListQuery.endDate}
            </if>

            <if test="null != purchaseListQuery.goodsName and purchaseListQuery.goodsName !='' ">
                and (
                plg.name like concat('%',#{purchaseListQuery.goodsName},'%') or plg.code =#{purchaseListQuery.goodsName}
                )
            </if>

            <if test="null != purchaseListQuery.typeIds and purchaseListQuery.typeIds.size>0">
                and plg.type_id in
                <foreach collection="purchaseListQuery.typeIds" item="typeId" open="(" separator="," close=")">
                    #{typeId}
                </foreach>
            </if>
        </where>

        limit #{purchaseListQuery.index},#{purchaseListQuery.limit}
 </select>

日志显示内容为:

img

请问一下大家,这个问题该怎么解决呀?谢谢大家啦!

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-03-10 23:46
    关注

    返回的json解析成字符串了,导致取不到数据

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月19日
  • 已采纳回答 3月11日
  • 创建了问题 3月10日

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动