123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package cygx
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ActivityVoice 活动语音表结构体
- type CygxActivityVoice struct {
- ActivityVoiceId int `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
- ActivityId int ` description:"活动ID"`
- VoiceUrl string `description:"音频地址"`
- VoiceName string `description:"音频名称"`
- VoicePlaySeconds string `description:"音频时长"`
- BackgroundImg string `description:"封面图片"`
- ShareImg string `description:"分享图片"`
- IsByHand int `description:"是否手动修改过"`
- FileType int `description:"文件类型,1:路演回放,2:调研反馈"`
- CreateTime time.Time `description:"创建时间"`
- }
- // ActivityVoiceReq 音频数据
- type CygxActivityVoiceReq struct {
- Url string `description:"音频资源url地址"`
- Name string `description:"音频名称"`
- PlaySeconds string `description:"音频时长"`
- ActivityVoiceId int `description:"活动音频ID"`
- BackgroundImg string `description:"封面图片"`
- ShareImg string `description:"分享图片"`
- }
- // 添加
- func AddCygxActivityVoice(item *CygxActivityVoice) (newId int64, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- newId, err = o.Insert(item)
- return
- }
- // 修改
- func UpdateCygxActivityVoice(item *CygxActivityVoice) (err error) {
- to := orm.NewOrmUsingDB("hz_cygx")
- updateParams := make(map[string]interface{})
- updateParams["VoiceName"] = item.VoiceName
- updateParams["VoicePlaySeconds"] = item.VoicePlaySeconds
- updateParams["VoiceUrl"] = item.VoiceUrl
- updateParams["BackgroundImg"] = item.BackgroundImg
- updateParams["ShareImg"] = item.ShareImg
- updateParams["FileType"] = item.FileType
- ptrStructOrTableName := "cygx_activity_voice"
- whereParam := map[string]interface{}{"activity_id": item.ActivityId}
- qs := to.QueryTable(ptrStructOrTableName)
- for expr, exprV := range whereParam {
- qs = qs.Filter(expr, exprV)
- }
- _, err = qs.Update(updateParams)
- return
- }
- // 获取数量
- func GetCygxActivityVoiceCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_voice WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrmUsingDB("hz_cygx")
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 列表
- func GetCygxActivityVoiceReqList(activityId int) (items []*CygxActivityVoiceReq, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT
- background_img,
- share_img,
- activity_voice_id,
- voice_url AS url,
- voice_name AS name,
- voice_play_seconds AS play_seconds FROM cygx_activity_voice WHERE activity_id= ? `
- _, err = o.Raw(sql, activityId).QueryRows(&items)
- return
- }
- // 列表
- func GetActivityVoiceList(condition string, pars []interface{}) (items []*CygxActivityVoice, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := ` SELECT * FROM cygx_activity_voice WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // 列表
- func GetActivityVoiceListNew(condition string, pars []interface{}) (items []*CygxActivityVoice, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := ` SELECT
- v.*
- FROM
- cygx_activity_voice as v
- INNER JOIN cygx_activity as a ON a.activity_id = v.activity_id
- WHERE
- 1= 1
- AND a.activity_time > '2023-09-22'
- AND v.voice_name NOT LIKE '%调研反馈%'
- AND v.voice_name NOT LIKE '%【%' `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- func GetCygxActivityVoiceReqDetail(activityId int) (item *CygxActivityVoice, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_activity_voice WHERE activity_id= ? `
- err = o.Raw(sql, activityId).QueryRow(&item)
- return
- }
- // 删除数据
- func DeleteCygxActivityVoice(activityId int) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := ` DELETE FROM cygx_activity_voice WHERE activity_id= ? `
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // 根据音频ID获取详情
- func GetCygxActivityVoiceReqDetailByActivityVoiceId(activityVoiceId int) (item *CygxActivityVoice, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_activity_voice WHERE activity_voice_id= ? `
- err = o.Raw(sql, activityVoiceId).QueryRow(&item)
- return
- }
- // 根据活动ID获取详情
- func GetCygxActivityVoiceReqDetailByActivityId(activityId int) (item *CygxActivityVoice, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_activity_voice WHERE activity_id= ? `
- err = o.Raw(sql, activityId).QueryRow(&item)
- return
- }
|