1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package cygx
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // 活动详情
- type CygxActivitySpecialDay struct {
- Id int `orm:"column(id);pk";description:"Id"`
- ActivityId int `description:"活动ID"`
- CreateTime time.Time `description:"创建时间"`
- DayTime string `description:"活动行程时间"`
- }
- // 活动详情
- type CygxActivitySpecialDayResp struct {
- Id int `orm:"column(id);pk";description:"Id"`
- ActivityId int `description:"活动ID"`
- CreateTime time.Time `description:"创建时间"`
- DayTime time.Time `description:"活动行程时间"`
- }
- // 添加活动
- func AddCygxActivitySpecialDay(items []*CygxActivitySpecialDay, activityId int) (newId int64, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- sql := ` DELETE FROM cygx_activity_special_day WHERE activity_id = ?`
- _, err = to.Raw(sql, activityId).Exec()
- if err != nil {
- return
- }
- if len(items) > 0 {
- for _, v := range items {
- _, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- }
- return
- }
- // 列表
- func GetCygxActivitySpecialDayByActivityId(activityId int) (items []*CygxActivitySpecialDayResp, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_activity_special_day as art WHERE activity_id= ? `
- _, err = o.Raw(sql, activityId).QueryRows(&items)
- return
- }
|