访问许可时,会报错
Invalid JSON text in argument 1 to function cast_as_json: "The document root must not be followed by other values." at position 40.
找到 getLicenses 方法,将 ${postSqlFragment.innerJoinFile} 改为 ${postSqlFragment.innerJoinOneFile}
export const getLicenses = async (options: GetLicensesOptions) => {
const {
filters: { user },
pagination: { limit, offset },
} = options;
// 查询参数
const params = [user, limit, offset];
// 准备查询
const statement = `
SELECT
license.id,
license.created,
${postSqlFragment.user},
${licenseSqlFragment.order},
${licenseSqlFragment.resource},
${postSqlFragment.file}
FROM
license
${licenseSqlFragment.leftJoinLicenseUser}
${licenseSqlFragment.leftJoinOrder}
${licenseSqlFragment.leftJoinPost}
${licenseSqlFragment.leftJoinResourceUser}
${postSqlFragment.innerJoinOneFile}
WHERE
license.status = 'valid'
AND license.userId = ?
GROUP BY license.id
ORDER BY license.id DESC
LIMIT ?
OFFSET ?
`;
// 执行查询
const [data] = await connection.promise().query(statement, params);
// 提供数据
return data as any;
};