123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package cygx
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxActivityVivoPointsSet struct {
- PointSetId int `orm:"column(point_set_id);pk";comment:"主键id"`
- ActivityId int `comment:"活动ID"`
- PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
- PointsNum string `comment:"扣点数量"`
- GoodsMoney string `comment:"商品总价"`
- Source string `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
- CreateTime time.Time `comment:"创建时间"`
- ModifyTime time.Time `comment:"更新时间"`
- }
- type CygxActivityVivoPointsResp struct {
- IsPay int `comment:"是否付费查看 ,1是。0否,默认否"`
- PointSetId int `orm:"column(point_set_id);pk";comment:"主键id"`
- ActivityId int `comment:"活动ID"`
- PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
- PointsNum string `comment:"扣点数量"`
- GoodsMoney string `comment:"商品总价"`
- Source string `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
- }
- type CygxActivityVivoPointsSetReq struct {
- IsPay int `comment:"是否付费查看 ,1是。0否,默认否"`
- PointsObject string `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
- PointsNum string `comment:"扣点数量"`
- GoodsMoney string `comment:"商品总价"`
- }
- // 根据活动ID判断音视频是否设置了扣点
- func GetCygxActivityVivoPointsSetCountByActivityId(activityId int) (count int, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_vivo_points_set WHERE activity_id =? `
- err = o.Raw(sqlCount, activityId).QueryRow(&count)
- return
- }
- func GetCygxActivityVivoPointsSetByActivityId(activityId int) (item *CygxActivityVivoPointsResp, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_activity_vivo_points_set WHERE activity_id = ? `
- err = o.Raw(sql, activityId).QueryRow(&item)
- return
- }
- // 添加
- func AddCygxActivityVivoPointsSet(item *CygxActivityVivoPointsSet) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- _, err = o.Insert(item)
- return
- }
- // 编辑
- func EditCygxActivityVivoPointsSet(item *CygxActivityVivoPointsSet) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- updateParams := make(map[string]interface{})
- updateParams["PointsObject"] = item.PointsObject
- updateParams["PointsNum"] = item.PointsNum
- updateParams["GoodsMoney"] = item.GoodsMoney
- updateParams["Source"] = item.Source
- updateParams["ModifyTime"] = time.Now()
- ptrStructOrTableName := "cygx_activity_vivo_points_set"
- whereParam := map[string]interface{}{"activity_id": item.ActivityId}
- qs := o.QueryTable(ptrStructOrTableName)
- for expr, exprV := range whereParam {
- qs = qs.Filter(expr, exprV)
- }
- _, err = qs.Update(updateParams)
- return
- }
|