GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 新增支持假删除 by cloudAndMonkey · Pull Request #493 · APIJSON/APIJSON

Conversation

@cloudAndMonkey

@cloudAndMonkey cloudAndMonkey commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

1、新增支持假删除
使用描述,参见framework
2、修改bug
{
"User_address": {
"user_id!": "3123f016-a4cc-455c-aac5-264c1230dcb",
"count": 11,
"count+": 1,
"@combine": "user_id! | count"
},
"tag": "User_address",
"@Explain": true
}
条件 修改、删除,@combine 强制指定 "count": "" 为条件

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TommyLemon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@cloudAndMonkey
新增支持假删除
5f5300e
1、新增支持假删除
2、修改bug
{
    "User_address": {
        "user_id!": "3123f016-a4cc-455c-aac5-264c1230dcb",
        "count": 11,
        "count+": 1,
        "@combine": "user_id! | count"
    },
    "tag": "User_address",
    "@Explain": true
}
条件 修改、删除,@combine 强制指定 "count": "" 为条件
TommyLemon
TommyLemon reviewed Jan 6, 2023
View reviewed changes

@TommyLemon TommyLemon left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GETS/HEADS/PUT/DELETE 不允许前端传 @combine,目前在这里去掉了校验,需要在 AbstractVerifier 补上,这样就只能通过后端配置 @combine 了,既保证了功能,又保证了安全
#425

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@TommyLemon
TommyLemon merged commit 297bdac into APIJSON:master Jan 6, 2023
@cloudAndMonkey

cloudAndMonkey commented Jan 6, 2023

Copy link
Copy Markdown
Contributor Author

@TommyLemon
请问,Request 表如何配置:
1、delete 需要同时支持id、条件删除
2、如何灵活组装 combine条件(前端 不同场景 删除条件不一致)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TommyLemon

TommyLemon commented Jan 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

1.AbstractVerifier.IS_UPDATE_MUST_HAVE_ID_CONDITION = false
就同时支持 id、其它条件删除
https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L84-L86

但因为 Operation 没有 AT_LEAST_ONE/ANY_ONE 这样的操作,
所以如果只配置一条规则,只能允许 MUST 配置传一种条件,不能单独 传 id 和 其它字段都行。

如果都传了,因为 id 强制作为 AND 条件,所以不能和其它条件 OR,
可以配置两条不同规则,用不同的 tag 对应使用不同的条件。

method: DELETE
通过 id 删除

tag: Comment-by-id // 当然写成 Comment:id 等其它任何不符合表名格式的名称都可
structure: ... "MUST":"id" ...

通过 date 条件删除

tag: Comment-by-date
structure: ... "MUST":"date" ...

如果想只配置一条规则,则 Operation 加上 AT_LEAST_ONE/ANY_ONE ,然后配置

tag: Comment
structure: ... "AT_LEAST_ONE":"id,date" ... // 至少传其中一个

或

tag: Comment
structure: ... "ANY_ONE":"id,date" ... // 必须传其中一个,不能同时传 2 个以上

2.为了安全,目前只能让后端配置 @combine,可以参考 1 配置多条规则,对应不同的 @combine

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TommyLemon

TommyLemon commented Jan 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

AT_LEAST_ONE/ANY_ONE 其中一个也可以通过扩展 MUST 来实现
"MUST":"id | date,其它" 通过 | 或来表示其中任何一个,注意左右一定要各有一个空格,因为可能有 "name|$" "id|{}" 等包含 "|" 的 key
https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/Operation.java

还可以设置更复杂的表达方式
"MUST":"1:id | date,其它" // id,date 必须传其中一个,且不能多传
"MUST":">=2:id | momentId | date,其它" // id,date 必须至少其中 2 个
"MUST":"2+:id | momentId | date,其它" // id,date 必须至少其中 2 个,替代 >= 2
"MUST":"2-:id | momentId | date,其它" // id,date 最多传其中 2 个,替代 <= 2

这样的话就不用加 Operation 了,不过 AbstractVerifier 仍然要处理下 REFUSE 和 MUST 的互斥关系
https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L1012-L1042
image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cloudAndMonkey

cloudAndMonkey commented Jan 6, 2023

Copy link
Copy Markdown
Contributor Author

哈哈,我先把 判断条件加啦。
你先加到loadmap,排期... 😁

TommyLemon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TommyLemon

TommyLemon commented Jan 6, 2023

Copy link
Copy Markdown
Member

已加上
32db282

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cloudAndMonkey added a commit to cloudAndMonkey/APIJSON that referenced this pull request Jan 9, 2023
@cloudAndMonkey
GETS/HEADS/PUT/DELETE 不允许前端传 @combine
e94c44f
APIJSON#493
GETS/HEADS/PUT/DELETE 不允许前端传 @combine,目前在这里去掉了校验,需要在 AbstractVerifier 补上,这样就只能通过后端配置 @combine 了,既保证了功能,又保证了安全
@cloudAndMonkey cloudAndMonkey mentioned this pull request Jan 9, 2023
GETS/HEADS/PUT/DELETE 不允许前端传 @combine #494
Merged
@TommyLemon TommyLemon mentioned this pull request Feb 16, 2023
为什么限制在GETS中使用@combine #425
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TommyLemon TommyLemon TommyLemon left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@cloudAndMonkey @TommyLemon
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.