12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package models
- import (
- "eta/eta_hub/global"
- "eta/eta_hub/utils"
- "time"
- )
- type Resource struct {
- Id int `orm:"column(id);" description:"资源id"`
- ResourceUrl string `description:"资源地址"`
- CreateTime time.Time `description:"创建时间"`
- ResourceType int `description:"资源类型,1:图片,2:音频,3:视频 ,4:ppt"`
- }
- type ResourceResp struct {
- Id int64 `orm:"column(id);" description:"用户id"`
- ResourceUrl string `description:"资源地址"`
- PlaySeconds uint32 `description:"播放时长,单位秒"`
- Source string
- CacheKey string
- ResourceName string `description:"资源名称"`
- OpenaiFileId string `description:"openai返回的文件id"`
- AiChatTopicId int `description:"主题id"`
- }
- func AddResource(item *Resource) (newId int64, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- sql := "INSERT INTO resource(resource_url,create_time,resource_type) VALUES(?,?,?)"
- err = global.DbMap[utils.MYSQL_URL_RDDP].Exec(sql, item.ResourceUrl, item.CreateTime, item.ResourceType).Error
- if err != nil {
- return 0, err
- }
- //newId, err = res.LastInsertId()
- //if err != nil {
- // return 0, err
- //}
- return newId, err
- }
- func GetResourceById(id string) (item *Resource, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- sql := "SELECT * FROM resource WHERE id=? "
- err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, id).Scan(&item).Error
- return
- }
- type ResourceBase64Resp struct {
- Image string `description:"图片,base64字符串"`
- }
- type PptResourceResp struct {
- Id int64 `orm:"column(id);" description:"用户id"`
- ResourceUrl []string `description:"资源地址"`
- PlaySeconds uint32 `description:"播放时长,单位秒"`
- }
- type ImageSvgToPngResp struct {
- Data struct {
- ResourceURL string `json:"ResourceUrl"`
- } `json:"Data"`
- ErrCode string `json:"ErrCode"`
- ErrMsg string `json:"ErrMsg"`
- IsSendEmail bool `json:"IsSendEmail"`
- Msg string `json:"Msg"`
- Ret int64 `json:"Ret"`
- Success bool `json:"Success"`
- }
|