siteserver / cms

SS CMS 基于 .NET Core,能够以最低的成本、最少的人力投入在最短的时间内架设一个功能齐全、性能优异、规模庞大并易于维护的网站平台。
https://sscms.com
GNU Affero General Public License v3.0
3.66k stars 1.21k forks source link

REST API中的获取内容列表 API 在wheres条件中查询ExtendValues字段无法使用json查询方法 #3559

Open fsea opened 1 year ago

fsea commented 1 year ago

select * from sscms_20211101_1 where ExtendValues->'$.rowGuid' = '12112';这样是可以查出来数据的 但是在/api/v1/contents接口中发送如下请求,会报错Unknown column,所以要怎么ExtendValues中的json节点呢? { "siteId": 3, "checked":true, "wheres": [{ "column": "ExtendValues->'$.rowGuid'", "operator": "=", "value": "12112" }], "page": 1, "perPage": 30 }

starlying commented 1 year ago

API传输的Column字段后端会验证数据库表是否有这个字段,所以传ExtendValues->'$.rowGuid'这种后端验证通不过。 "wheres": [{ "column": "ExtendValues", "operator": "LIKE", "value": "%12112%" }], 试试这样看行不行

fsea commented 1 year ago

这样like误差太大了,如果别的自定义自段里也有12112,也会被查出来。 是希望实现查询ExtendValues里的某个具体扩展字段的值,而不是整个ExtendValues的值。 建议添加一个独立的节点,可与wheres同级,专门用来查询ExtendValues里的节点,例如: “whereExtendValues”:[{ "column": "rowGuid", "operator": "LIKE", "value": "%12112%" }],

fsea commented 1 year ago

然后后台接收到后,按josn查询方法,执行查询,例如: select * from sscms_20230221_1 where json_extract(ExtendValues,'$.rowGuid')='12112'

fsea commented 1 year ago

当然,每个数据库的json查询方法不一样,需要分别处理

starlying commented 1 year ago

收到,我们会研究一下

WaitFYting commented 4 months ago

我也遇到这个问题了