lijian 6 лет назад
Родитель
Сommit
bc56438121

+ 8 - 0
services/knowoapi/controllers/application.go

@@ -125,6 +125,14 @@ func (a *AppController) Put() {
 			app.AppIcon = reply.FilePath
 		}
 	}
+	if app.AppIcon == "" {
+		old, _ := a.Service.GetAppInfo(a.Token.getVendorID(a.Ctx), app.AppKey)
+		arg := &rpcs.ArgsDeleteFile{
+			FileName: old.AppIcon,
+		}
+		reply := &rpcs.ReplyEmptyResult{}
+		server.RPCCallByName("fileaccess", "FileAccess.DeleteFile", arg, reply)
+	}
 	result, err := a.Service.Update(app)
 	if err != nil {
 		responseError(a.Ctx, ErrDatabase, err.Error())

+ 8 - 0
services/knowoapi/controllers/produdct.go

@@ -97,6 +97,14 @@ func (a *ProductController) Put() {
 		}
 
 	}
+	if product.ProductImage == "" {
+		old, _ := a.Service.QueryOne(a.Token.getVendorID(a.Ctx), product.ProductKey)
+		arg := &rpcs.ArgsDeleteFile{
+			FileName: old.ProductImage,
+		}
+		reply := &rpcs.ReplyEmptyResult{}
+		server.RPCCallByName("fileaccess", "FileAccess.DeleteFile", arg, reply)
+	}
 	pro, err := a.Service.Update(product)
 	if err != nil {
 		responseError(a.Ctx, ErrDatabase, err.Error())