From d1fb72e356ad694eafa4f7d821be44cfb41a8133 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 1 Oct 2021 16:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E5=9B=BE=E5=83=8F=E6=96=87=E4=BB=B6=E4=B8=BAWebP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/http_web_dao.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/db/models/http_web_dao.go b/internal/db/models/http_web_dao.go index 0ff30d27..077c1a93 100644 --- a/internal/db/models/http_web_dao.go +++ b/internal/db/models/http_web_dao.go @@ -398,6 +398,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap maps. config.Auth = authConfig } + // WebP + if IsNotNull(web.Webp) { + var webpConfig = &serverconfigs.WebPImageConfig{} + err = json.Unmarshal([]byte(web.Webp), webpConfig) + if err != nil { + return nil, err + } + config.WebP = webpConfig + } + cacheMap[cacheKey] = config return config, nil @@ -451,6 +461,22 @@ func (this *HTTPWebDAO) UpdateWebCompression(tx *dbs.Tx, webId int64, compressio return this.NotifyUpdate(tx, webId) } +// UpdateWebWebP 修改WebP配置 +func (this *HTTPWebDAO) UpdateWebWebP(tx *dbs.Tx, webId int64, webpConfig []byte) error { + if webId <= 0 { + return errors.New("invalid webId") + } + op := NewHTTPWebOperator() + op.Id = webId + op.Webp = JSONBytes(webpConfig) + err := this.Save(tx, op) + if err != nil { + return err + } + + return this.NotifyUpdate(tx, webId) +} + // UpdateWebCharset 修改字符编码 func (this *HTTPWebDAO) UpdateWebCharset(tx *dbs.Tx, webId int64, charsetJSON []byte) error { if webId <= 0 {