+ 添加数据资源操作相关的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

@@ -72,6 +72,8 @@ var (
VendorIDXiaoWM: "XiaoWM",
VendorIDYiLianYun: "Yilianyun",
VendorIDZhongWu: "ZhongWu",
VendorIDQiNiuCloud: "Qiniu",
}
VendorTypeName = map[int]string{

View File

@@ -13,19 +13,13 @@ var (
type DataResource struct {
ModelIDCUL
HashCode string `orm:"size(48);unique" json:"hash_code"`
ResoureType string // 资料的mime type
HashCode string `orm:"size(48);unique" json:"hashCode"`
Name string `orm:"size(48)" json:"name"`
ResoureType string `orm:"size(48)" json:"resoureType"` // 资料的mime type
Name string `orm:"size(48);index" json:"name"`
MainURL string
QiniuURL string
EbaiURL string
MtwmURL string
}
func (*DataResource) TableUnique() [][]string {
return [][]string{
[]string{"HashCode", "ResoureType"},
}
MainURL string `orm:"size(1024);column(main_url);index" json:"mainURL"`
QiniuURL string `orm:"size(1024);column(qiniu_url);index" json:"qiniuURL"`
EbaiURL string `orm:"size(1024);column(ebai_url);index" json:"ebaiURL"`
MtwmURL string `orm:"size(1024);column(mtwm_url);index" json:"mtwmURL"`
}

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
}