apiPlugin.go 18.6 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
package console_mysql

import (
	SQL "database/sql"
	"errors"
	"fmt"
	"strings"

	log "github.com/eolinker/goku/goku-log"

	database2 "github.com/eolinker/goku/common/database"

	"time"
)

var apiPlugins = []string{"goku-proxy_caching", "goku-circuit_breaker"}

// 新增插件到接口
func AddPluginToApi(pluginName, config, strategyID string, apiID, userID int) (bool, interface{}, error) {
	db := database2.GetConnection()
	// 查询接口是否添加该插件
	sql := "SELECT apiID FROM goku_conn_plugin_api WHERE strategyID = ? AND pluginName = ? AND apiID = ?;"
	var id int
	err := db.QueryRow(sql, strategyID, pluginName, apiID).Scan(&id)
	if err == nil {
		return false, "[ERROR]The api plugin is already exist", errors.New("[ERROR]The api plugin is already exist")
	}
	now := time.Now().Format("2006-01-02 15:04:05")
	Tx, _ := db.Begin()
	result, err := Tx.Exec("INSERT INTO goku_conn_plugin_api (pluginName,pluginConfig,strategyID,apiID,updateTime,createTime,pluginStatus,updaterID) VALUES (?,?,?,?,?,?,?,?);", pluginName, config, strategyID, apiID, now, now, 1, userID)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to insert data", errors.New("[ERROR]Fail to insert data")
	}
	connID, _ := result.LastInsertId()
	sql = "UPDATE goku_gateway_strategy SET updateTime = ? WHERE strategyID = ?;"
	_, err = Tx.Exec(sql, now, strategyID)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Failed to update data!", err
	}
	Tx.Commit()
	return true, int(connID), nil
}

// 修改接口插件配置
func EditApiPluginConfig(pluginName, config, strategyID string, apiID, userID int) (bool, interface{}, error) {
	db := database2.GetConnection()
	// 查询接口是否添加该插件
	t := time.Now()
	now := t.Format("2006-01-02 15:04:05")

	sql := "SELECT connID,apiID FROM goku_conn_plugin_api WHERE strategyID = ? AND pluginName = ? AND apiID = ?;"
	var id, aID int
	err := db.QueryRow(sql, strategyID, pluginName, apiID).Scan(&id, &aID)
	if err != nil {
		return false, "[ERROR]The api plugin is not exist", errors.New("[ERROR]The api plugin is not exist")
	}
	updateTag := t.Format("20060102150405")
	Tx, _ := db.Begin()
	_, err = Tx.Exec("UPDATE goku_conn_plugin_api SET updateTag = ?,pluginConfig = ?,updateTime = ?,updaterID = ? WHERE strategyID = ? AND apiID = ? AND pluginName = ?;", updateTag, config, now, userID, strategyID, apiID, pluginName)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to update data", errors.New("[ERROR]Fail to update data")
	}

	sql = "UPDATE goku_gateway_strategy SET updateTime = ? WHERE strategyID = ?;"
	_, err = Tx.Exec(sql, now, strategyID)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Failed to update data!", err
	}
	Tx.Commit()
	return true, id, nil
}

func GetApiPluginList(apiID int, strategyID string) (bool, []map[string]interface{}, error) {
	db := database2.GetConnection()
	sql := `SELECT goku_conn_plugin_api.connID,goku_conn_plugin_api.pluginName,IFNULL(goku_conn_plugin_api.createTime,""),IFNULL(goku_conn_plugin_api.updateTime,""),goku_conn_plugin_api.pluginConfig,goku_plugin.pluginPriority, IF(goku_plugin.pluginStatus=0,-1,goku_conn_plugin_api.pluginStatus) as pluginStatus,goku_gateway_api.requestURL FROM goku_conn_plugin_api INNER JOIN goku_plugin ON goku_plugin.pluginName = goku_conn_plugin_api.pluginName INNER goku_gateway_api.apiID = goku_conn_plugin_api.apiID WHERE goku_conn_plugin_api.apiID = ? AND goku_conn_plugin_api.strategyID = ? ORDER BY pluginStatus DESC,goku_conn_plugin_api.updateTime DESC;`
	rows, err := db.Query(sql, apiID, strategyID)
	if err != nil {
		return false, nil, err
	}
	defer rows.Close()
	pluginList := make([]map[string]interface{}, 0)
	//获取记录列
	if _, err = rows.Columns(); err != nil {
		return false, nil, err
	} else {
		for rows.Next() {
			var pluginPriority, pluginStatus, connID int
			var pluginName, pluginConfig, createTime, updateTime, requestURL string
			err = rows.Scan(&connID, &pluginName, &pluginConfig, &createTime, &updateTime, &pluginPriority, &pluginStatus, &requestURL)
			if err != nil {
				info := err.Error()
				log.Info(info)
			}
			pluginInfo := map[string]interface{}{
				"connID":         connID,
				"pluginName":     pluginName,
				"pluginConfig":   pluginConfig,
				"pluginPriority": pluginPriority,
				"pluginStatus":   pluginStatus,
				"createTime":     createTime,
				"updateTime":     updateTime,
				"requestURL":     requestURL,
			}
			pluginList = append(pluginList, pluginInfo)
		}
		return true, pluginList, nil
	}
}

// 获取插件优先级
func GetPluginIndex(pluginName string) (bool, int, error) {
	db := database2.GetConnection()
	var pluginPriority int
	sql := "SELECT pluginPriority FROM goku_plugin WHERE pluginName = ?;"
	err := db.QueryRow(sql, pluginName).Scan(pluginPriority)
	if err != nil {
		return false, 0, err
	}
	return true, pluginPriority, nil
}

// 通过ApiID获取配置信息
func GetApiPluginConfig(apiID int, strategyID, pluginName string) (bool, map[string]string, error) {
	db := database2.GetConnection()
	sql := "SELECT goku_gateway_api.apiName,goku_gateway_api.requestURL,goku_conn_plugin_api.pluginConfig FROM goku_conn_plugin_api INNER JOIN goku_gateway_api ON goku_gateway_api.apiID = goku_conn_plugin_api.apiID WHERE goku_conn_plugin_api.apiID = ? AND goku_conn_plugin_api.strategyID = ? AND goku_conn_plugin_api.pluginName = ?;"
	var p, apiName, requestURL string
	err := db.QueryRow(sql, apiID, strategyID, pluginName).Scan(&apiName, &requestURL, &p)
	if err != nil {
		if err == SQL.ErrNoRows {
			return false, nil, errors.New("[ERROR]Can not find the plugin")
		} else {
			return false, nil, err
		}

	} else {
		apiPluginInfo := map[string]string{
			"pluginConfig": p,
			"apiName":      apiName,
			"requestURL":   requestURL,
		}
		return true, apiPluginInfo, nil
	}
}

// 检查策略组是否绑定插件
func CheckPluginIsExistInApi(strategyID, pluginName string, apiID int) (bool, error) {
	db := database2.GetConnection()
	sql := "SELECT apiID FROM goku_conn_plugin_api WHERE strategyID = ? AND pluginName = ? AND apiID = ?;"
	var id int
	err := db.QueryRow(sql, strategyID, pluginName, apiID).Scan(&id)
	if err != nil {
		return false, err
	} else {
		return true, err
	}
}

// GetAPIPluginInStrategyByAPIID 通过接口ID获取策略组中接口插件列表
func GetAPIPluginInStrategyByAPIID(strategyID string, apiID int, keyword string, condition int) (bool, []map[string]interface{}, map[string]interface{}, error) {
	db := database2.GetConnection()
	var (
		apiName       string
		requestURL    string
		targetURL     string
		target        string
		rewriteTarget string
	)
	sql := "SELECT A.apiName,A.requestURL,IFNULL(A.targetURL,''),IFNULL(A.balanceName,''),IFNULL(B.target,'') FROM goku_gateway_api A INNER JOIN goku_conn_strategy_api B ON A.apiID = B.apiID WHERE B.apiID = ? AND B.strategyID = ?;"
	err := db.QueryRow(sql, apiID, strategyID).Scan(&apiName, &requestURL, &targetURL, &target, &rewriteTarget)
	if err != nil {
		return false, nil, nil, err
	}
	apiInfo := map[string]interface{}{
		"apiID":         apiID,
		"apiName":       apiName,
		"requestURL":    requestURL,
		"targetURL":     targetURL,
		"target":        target,
		"rewriteTarget": rewriteTarget,
	}

	rule := make([]string, 0, 3)

	rule = append(rule, fmt.Sprintf("A.strategyID = '%s'", strategyID))
	rule = append(rule, fmt.Sprintf("A.apiID = %d", apiID))
	if keyword != "" {
		searchRule := "(A.pluginName LIKE '%" + keyword + "%' OR C.pluginDesc LIKE '%" + keyword + "%')"
		rule = append(rule, searchRule)
	}
	if condition > 0 {
		rule = append(rule, fmt.Sprintf("IF(C.pluginStatus=0,-1,A.pluginStatus) = %d", condition-1))
	}
	ruleStr := ""
	if len(rule) > 0 {
		ruleStr += "WHERE " + strings.Join(rule, " AND ")
	}
	sql = fmt.Sprintf(`SELECT A.connID,A.pluginName,IFNULL(A.createTime,""),IFNULL(A.updateTime,""),IF(C.pluginStatus=0,-1,A.pluginStatus) as pluginStatus,IFNULL(C.pluginDesc,""),IF(B.remark is null or B.remark = "",B.loginCall,B.remark) AS updaterName FROM goku_conn_plugin_api A LEFT JOIN goku_admin B ON A.updaterID=B.userID INNER JOIN goku_plugin C ON C.pluginName = A.pluginName %s ORDER BY pluginStatus DESC,A.updateTime DESC;`, ruleStr)
	rows, err := db.Query(sql)
	if err != nil {
		panic(err)
		return false, nil, nil, err
	}
	defer rows.Close()
	pluginList := make([]map[string]interface{}, 0)
	//获取记录列
	for rows.Next() {
		var updaterName SQL.NullString
		var pluginStatus, connID int
		var pluginName, pluginDesc, createTime, updateTime string
		err = rows.Scan(&connID, &pluginName, &createTime, &updateTime, &pluginStatus, &pluginDesc, &updaterName)
		if err != nil {
			return false, nil, nil, err
		}

		pluginInfo := map[string]interface{}{
			"connID":       connID,
			"pluginName":   pluginName,
			"pluginStatus": pluginStatus,
			"createTime":   createTime,
			"updateTime":   updateTime,
			"updaterName":  updaterName.String,
			"pluginDesc":   pluginDesc,
		}
		pluginList = append(pluginList, pluginInfo)
	}
	return true, pluginList, apiInfo, nil
}

// 获取策略组中所有接口插件列表
func GetAllApiPluginInStrategy(strategyID string) (bool, []map[string]interface{}, error) {
	db := database2.GetConnection()
	sql := `SELECT goku_conn_plugin_api.connID,goku_conn_plugin_api.apiID,goku_gateway_api.apiName,goku_gateway_api.requestURL,goku_conn_plugin_api.pluginName,IFNULL(goku_conn_plugin_api.createTime,""),IFNULL(goku_conn_plugin_api.updateTime,""),IF(goku_plugin.pluginStatus=0,-1,goku_conn_plugin_api.pluginStatus) as pluginStatus,IFNULL(goku_plugin.pluginDesc,"") FROM goku_conn_plugin_api INNER JOIN goku_gateway_api ON goku_gateway_api.apiID = goku_conn_plugin_api.apiID INNER JOIN goku_plugin ON goku_plugin.pluginName = goku_conn_plugin_api.pluginName WHERE goku_conn_plugin_api.strategyID = ? ORDER BY pluginStatus DESC,goku_conn_plugin_api.updateTime DESC;`
	rows, err := db.Query(sql, strategyID)
	if err != nil {
		return false, make([]map[string]interface{}, 0), err
	}
	defer rows.Close()
	pluginList := make([]map[string]interface{}, 0)
	//获取记录列
	if _, err = rows.Columns(); err != nil {
		return false, make([]map[string]interface{}, 0), err
	} else {
		for rows.Next() {
			var pluginStatus, apiID, connID int
			var apiName, pluginName, pluginDesc, createTime, updateTime, requestURL string
			err = rows.Scan(&connID, &apiID, &apiName, &requestURL, &pluginName, &createTime, &updateTime, &pluginStatus, &pluginDesc)
			if err != nil {
				return false, make([]map[string]interface{}, 0), err
			}
			pluginInfo := map[string]interface{}{
				"connID":       connID,
				"apiID":        apiID,
				"apiName":      apiName,
				"pluginName":   pluginName,
				"pluginStatus": pluginStatus,
				"createTime":   createTime,
				"updateTime":   updateTime,
				"requestURL":   requestURL,
				"pluginDesc":   pluginDesc,
			}
			pluginList = append(pluginList, pluginInfo)
		}
		return true, pluginList, nil
	}
}

// 批量修改策略组插件状态
func BatchEditApiPluginStatus(connIDList, strategyID string, pluginStatus, userID int) (bool, string, error) {
	db := database2.GetConnection()
	t := time.Now()
	now := t.Format("2006-01-02 15:04:05")
	updateTag := t.Format("20060102150405")
	Tx, _ := db.Begin()
	sql := "UPDATE goku_conn_plugin_api SET updateTag = ?,pluginStatus = ?,updateTime = ?,updaterID = ? WHERE connID IN (" + connIDList + ");"
	_, err := Tx.Exec(sql, updateTag, pluginStatus, now, userID)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to excute SQL statement!", err
	}

	// 根据connID获取apiID
	sql = "SELECT apiID FROM goku_conn_plugin_api WHERE connID IN (" + connIDList + ");"
	rows, err := db.Query(sql)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Illegal SQL Statement!", err
	}
	defer rows.Close()
	//获取记录列
	if _, err = rows.Columns(); err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to get data!", err
	} else {
		for rows.Next() {
			var apiID int
			err = rows.Scan(&apiID)
			if err != nil {
				Tx.Rollback()
				return false, "[ERROR]Fail to get data!", err
			}
		}
		sql = "UPDATE goku_gateway_strategy SET updateTime = ? WHERE strategyID = ?;"
		_, err = Tx.Exec(sql, now, strategyID)
		if err != nil {
			Tx.Rollback()
			return false, "[ERROR]Fail to update data!", err
		}
		Tx.Commit()
	}
	return true, "", nil
}

// 批量删除策略组插件
func BatchDeleteApiPlugin(connIDList, strategyID string) (bool, string, error) {
	db := database2.GetConnection()
	now := time.Now().Format("2006-01-02 15:04:05")
	Tx, _ := db.Begin()
	apiIDList := make([]int, 0)
	// 根据connID获取apiID
	sql := "SELECT apiID FROM goku_conn_plugin_api WHERE connID IN (" + connIDList + ");"
	rows, err := Tx.Query(sql)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Illegal SQL Statement!", err
	}
	defer rows.Close()
	//获取记录列
	if _, err = rows.Columns(); err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to get data!", err
	} else {
		for rows.Next() {
			var apiID int
			err = rows.Scan(&apiID)
			if err != nil {
				Tx.Rollback()
				return false, "[ERROR]Fail to get data!", err
			}
			apiIDList = append(apiIDList, apiID)
		}
	}
	sql = "DELETE FROM goku_conn_plugin_api WHERE connID IN (" + connIDList + ");"
	_, err = Tx.Exec(sql)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to excute SQL statement!", err
	}

	sql = "UPDATE goku_gateway_strategy SET updateTime = ? WHERE strategyID = ?;"
	_, err = Tx.Exec(sql, now, strategyID)
	if err != nil {
		Tx.Rollback()
		return false, "[ERROR]Fail to update data!", err
	}
	Tx.Commit()
	return true, "", nil
}

// 通过connID获取插件名称
func GetApiPluginName(connID int) (bool, string, error) {
	db := database2.GetConnection()
	var pluginName string
	sql := "SELECT pluginName FROM goku_conn_plugin_api WHERE connID = ?"
	err := db.QueryRow(sql, connID).Scan(&pluginName)
	if err != nil {
		return false, "[ERROR]The plugin is not existing!", err
	}
	return true, "", nil
}

// 通过connIDList判断插件是否存在
func CheckApiPluginIsExistByConnIDList(connIDList, pluginName string) (bool, []int, error) {
	db := database2.GetConnection()
	sql := "SELECT apiID FROM goku_conn_plugin_api WHERE connID IN (" + connIDList + ") AND pluginName = ?;"
	rows, err := db.Query(sql, pluginName)
	if err != nil {
		return false, make([]int, 0), err
	}
	defer rows.Close()
	apiIDList := make([]int, 0)
	if _, err = rows.Columns(); err != nil {
		return false, make([]int, 0), err
	} else {
		for rows.Next() {
			var apiID int
			err = rows.Scan(&apiID)
			if err != nil {
				return false, make([]int, 0), err
			}
			apiIDList = append(apiIDList, apiID)
		}
	}
	return true, apiIDList, nil
}

// 获取没有绑定嵌套插件列表
func GetApiPluginListWithNotAssignApiList(strategyID string) (bool, []map[string]interface{}, error) {
	db := database2.GetConnection()
	sql := "SELECT pluginID,pluginDesc,pluginName FROM goku_plugin WHERE pluginType = 2 AND pluginStatus = 1;"
	rows, err := db.Query(sql)
	if err != nil {
		return false, make([]map[string]interface{}, 0), err
	}
	defer rows.Close()
	pluginList := make([]map[string]interface{}, 0)
	//获取记录列
	if _, err = rows.Columns(); err != nil {
		return false, make([]map[string]interface{}, 0), err
	} else {
		sql = "SELECT goku_gateway_api.apiID,goku_gateway_api.apiName,goku_gateway_api.requestURL FROM goku_gateway_api INNER JOIN goku_conn_strategy_api ON goku_gateway_api.apiID = goku_conn_strategy_api.apiID WHERE goku_conn_strategy_api.strategyID = ? AND goku_gateway_api.apiID NOT IN (SELECT goku_conn_plugin_api.apiID FROM goku_conn_plugin_api WHERE goku_conn_plugin_api.strategyID = ? AND goku_conn_plugin_api.pluginName = ?);"
		for rows.Next() {
			var pluginID int
			var pluginName, chineseName string
			err = rows.Scan(&pluginID, &chineseName, &pluginName)
			if err != nil {
				info := err.Error()
				log.Info(info)
				return false, make([]map[string]interface{}, 0), err
			}
			r, err := db.Query(sql, strategyID, strategyID, pluginName)
			if err != nil {
				return false, make([]map[string]interface{}, 0), err
			}
			defer r.Close()
			apiList := make([]map[string]interface{}, 0)
			for r.Next() {
				var (
					apiID      int
					apiName    string
					requestURL string
				)
				err = r.Scan(&apiID, &apiName, &requestURL)
				if err != nil {
					return false, make([]map[string]interface{}, 0), err
				}
				apiList = append(apiList, map[string]interface{}{
					"apiID":      apiID,
					"apiName":    apiName,
					"requestURL": requestURL,
				})

			}
			pluginInfo := map[string]interface{}{
				"chineseName": chineseName,
				"pluginName":  pluginName,
				"pluginID":    pluginID,
				"apiList":     apiList,
			}
			pluginList = append(pluginList, pluginInfo)
		}
		return true, pluginList, nil
	}
}

func BatchUpdateApiPluginUpdateTag(strategyIDList string) error {
	db := database2.GetConnection()
	code := make([]string, 0, len(apiPlugins))
	strategyIDs := strings.Split(strategyIDList, ",")
	strategyCode := make([]string, 0, len(strategyIDs))
	updateTag := time.Now().Format("20060102150405")
	s := make([]interface{}, 0, len(strategyPlugins)+1+len(strategyIDs))
	s = append(s, updateTag)
	for i := 0; i < len(strategyIDs); i++ {
		strategyCode = append(strategyCode, "?")
		s = append(s, strategyIDs[i])
	}
	for i := 0; i < len(apiPlugins); i++ {
		code = append(code, "?")
		s = append(s, apiPlugins[i])
	}

	sql := "UPDATE goku_conn_plugin_api SET updateTag = ? WHERE strategyID IN (" + strings.Join(strategyCode, ",") + ") AND pluginName IN (" + strings.Join(code, ",") + ");"
	_, err := db.Exec(sql, s...)
	if err != nil {
		return err
	}
	return nil
}

func UpdateApiTagByPluginName(strategyID string, apiIDList string, pluginList string) error {
	db := database2.GetConnection()
	plugins := strings.Split(pluginList, ",")
	code := make([]string, 0, len(plugins))
	updateTag := time.Now().Format("20060102150405")
	s := make([]interface{}, 0, len(plugins)+2)
	s = append(s, updateTag, strategyID)
	for i := 0; i < len(plugins); i++ {
		code = append(code, "?")
		s = append(s, plugins[i])
	}

	sql := "UPDATE goku_conn_plugin_api SET updateTag = ? WHERE strategyID = ? AND apiID IN (" + apiIDList + ") AND pluginName IN (" + strings.Join(code, ",") + ");"
	_, err := db.Exec(sql, s...)
	if err != nil {
		return err
	}
	return nil
}

func UpdateAllApiPluginUpdateTag() error {
	db := database2.GetConnection()
	// code := make([]string, 0, len(apiPlugins))
	updateTag := time.Now().Format("20060102150405")
	// s := make([]interface{}, 0, len(apiPlugins)+1)
	// s = append(s, updateTag)
	// for i := 0; i < len(apiPlugins); i++ {
	// 	code = append(code, "?")
	// 	s = append(s, apiPlugins[i])
	// }
	// sql := "UPDATE goku_conn_plugin_api SET updateTag = ? WHERE pluginName IN (" + strings.Join(code, ",") + ");"
	sql := "UPDATE goku_conn_plugin_api SET updateTag = ?;"
	// _, err := db.Exec(sql, s...)
	_, err := db.Exec(sql, updateTag)
	if err != nil {
		return err
	}
	return nil
}