You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/18 04:14:59 UTC

[GitHub] [apisix-dashboard] ShiningRush commented on a change in pull request #561: feat: compatible with PUT method of `admin api` and nodes of upstream

ShiningRush commented on a change in pull request #561:
URL: https://github.com/apache/apisix-dashboard/pull/561#discussion_r507012891



##########
File path: api/internal/core/store/store.go
##########
@@ -256,7 +263,7 @@ func (s *GenericStore) Create(ctx context.Context, obj interface{}) error {
 	return nil
 }
 
-func (s *GenericStore) Update(ctx context.Context, obj interface{}) error {
+func (s *GenericStore) Update(ctx context.Context, obj interface{}, createOnFail bool) error {

Review comment:
       `createOnFail` is confusing, it is just a existing check, `isReplace` or `isPut` would be better

##########
File path: api/internal/core/store/store.go
##########
@@ -267,6 +274,9 @@ func (s *GenericStore) Update(ctx context.Context, obj interface{}) error {
 	}
 	oldObj, ok := s.cache.Load(key)
 	if !ok {
+		if createOnFail {
+			return s.Create(ctx, obj)

Review comment:
       We should init `create_time`、`update_time`  and `id`,Hmmm,we can add two function for baseinfo: `creating` and `updating` to do some logic about `BaseInfo`, then add `BaseInfoSetter` interface to use it. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org