+ 添加数据资源操作相关的API

This commit is contained in:
gazebo
2019-09-17 16:02:44 +08:00
parent bf8fd2f255
commit f4b6516b4d
9 changed files with 147 additions and 19 deletions

View File

@@ -0,0 +1,23 @@
package dao
import (
"git.rosy.net.cn/jx-callback/business/model"
)
func GetDataResource(db *DaoDB, hashCode, fullURL string) (dataRes *model.DataResource, err error) {
sql := `
SELECT t1.*
FROM data_resource t1
WHERE 1 = 1`
sqlParams := []interface{}{}
if hashCode != "" {
sql += " AND t1.hash_code = ?"
sqlParams = append(sqlParams, hashCode)
}
if fullURL != "" {
sql += " AND (t1.main_url = ? OR t1.qiniu_url = ? OR t1.ebai_url = ? OR t1.mtwm_url = ?)"
sqlParams = append(sqlParams, fullURL, fullURL, fullURL, fullURL)
}
err = GetRow(db, &dataRes, sql, sqlParams...)
return dataRes, err
}