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:
[email protected]


Reply via email to