+ 添加数据资源操作相关的API
This commit is contained in:
@@ -72,6 +72,8 @@ var (
|
||||
VendorIDXiaoWM: "XiaoWM",
|
||||
VendorIDYiLianYun: "Yilianyun",
|
||||
VendorIDZhongWu: "ZhongWu",
|
||||
|
||||
VendorIDQiNiuCloud: "Qiniu",
|
||||
}
|
||||
|
||||
VendorTypeName = map[int]string{
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
23
business/model/dao/common.go
Normal file
23
business/model/dao/common.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user