refactor(api): 移除未生效的 fetchAll 参数
- 删除 FetchChangedRequest 中未使用的 FetchAll 字段 - addChangedConfigs 去掉 fetchAll 参数及两处调用
This commit is contained in:
@@ -155,7 +155,6 @@ type FetchChangedRequest struct {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
LastTime int64 `json:"lastTime" binding:"required"`
|
LastTime int64 `json:"lastTime" binding:"required"`
|
||||||
IgnoreGlobal bool `json:"ignoreGlobal"`
|
IgnoreGlobal bool `json:"ignoreGlobal"`
|
||||||
FetchAll bool `json:"fetchAll"`
|
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +237,7 @@ func (h *ConfigApiHandler) FetchChangedConfigs(c *gin.Context) {
|
|||||||
dao.Engine.Where("env = ? AND version = ? AND enabled = 1 AND group_id = ? AND (app_id is null OR app_id = 0) AND updated_at > ? AND updated_at <= ?",
|
dao.Engine.Where("env = ? AND version = ? AND enabled = 1 AND group_id = ? AND (app_id is null OR app_id = 0) AND updated_at > ? AND updated_at <= ?",
|
||||||
req.Env, version, *app.GroupId, lastUpdateTime, upperBound).Find(&globalConfigs)
|
req.Env, version, *app.GroupId, lastUpdateTime, upperBound).Find(&globalConfigs)
|
||||||
for _, cfg := range globalConfigs {
|
for _, cfg := range globalConfigs {
|
||||||
if h.addChangedConfigs(result, &cfg, req.FetchAll) {
|
if h.addChangedConfigs(result, &cfg) {
|
||||||
configIds = append(configIds, cfg.Id)
|
configIds = append(configIds, cfg.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +248,7 @@ func (h *ConfigApiHandler) FetchChangedConfigs(c *gin.Context) {
|
|||||||
dao.Engine.Where("env = ? AND version = ? AND enabled = 1 AND app_id = ? AND updated_at > ? AND updated_at <= ?",
|
dao.Engine.Where("env = ? AND version = ? AND enabled = 1 AND app_id = ? AND updated_at > ? AND updated_at <= ?",
|
||||||
req.Env, version, app.Id, lastUpdateTime, upperBound).Find(&appConfigs1)
|
req.Env, version, app.Id, lastUpdateTime, upperBound).Find(&appConfigs1)
|
||||||
for _, cfg := range appConfigs1 {
|
for _, cfg := range appConfigs1 {
|
||||||
if h.addChangedConfigs(result, &cfg, req.FetchAll) {
|
if h.addChangedConfigs(result, &cfg) {
|
||||||
configIds = append(configIds, cfg.Id)
|
configIds = append(configIds, cfg.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +283,7 @@ func (h *ConfigApiHandler) FetchChangedConfigs(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, model.WrapperResponse{Code: 0, Data: result})
|
c.JSON(http.StatusOK, model.WrapperResponse{Code: 0, Data: result})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ConfigApiHandler) addChangedConfigs(result map[string]string, config *model.AppConfig, fetchAll bool) bool {
|
func (h *ConfigApiHandler) addChangedConfigs(result map[string]string, config *model.AppConfig) bool {
|
||||||
kvMap, err := h.parseService.ParseConfigToKVMap(config)
|
kvMap, err := h.parseService.ParseConfigToKVMap(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.SugaredLogger.Errorf("[FetchChangedConfigs] parse config %d (%s) error: %v", config.Id, config.Name, err)
|
logger.SugaredLogger.Errorf("[FetchChangedConfigs] parse config %d (%s) error: %v", config.Id, config.Name, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user