package cygx

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type CygxActivityUserRemarks struct {
	Id         int       `orm:"column(id);pk"`
	ActivityId int       `description:"活动ID "`
	Mobile     string    `description:"参会人手机号 "`
	AdminId    int       `description:"销售/管理员ID"`
	RealName   string    `description:"销售/管理员姓名"`
	Content    string    `description:"备注信息"`
	CreateTime time.Time `description:"创建时间"`
}

type ActivityUserRemarksAddReq struct {
	ActivityId int    `description:"活动ID "`
	Mobile     string `description:"参会人手机号 "`
	Content    string `description:"备注信息"`
}

type CygxActivityUserRemarksResp struct {
	Id         int    `orm:"column(id);pk"`
	ActivityId int    `description:"活动ID "`
	Mobile     string `description:"参会人手机号 "`
	AdminId    int    `description:"销售/管理员ID"`
	RealName   string `description:"销售/管理员姓名"`
	Content    string `description:"备注信息"`
	CreateTime string `description:"创建时间"`
}

type CygxActivityUserRemarksListResp struct {
	List []*CygxActivityUserRemarksResp
}

// 新增
func AddCygxActivityUserRemarks(item *CygxActivityUserRemarks) (err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	_, err = o.Insert(item)
	return
}

// 获取备注列表
func GetCygxActivityUserRemarksLlist(mobile string) (items []*CygxActivityUserRemarksResp, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := ` SELECT * FROM cygx_activity_user_remarks WHERE  mobile IN (` + mobile + `)  ORDER BY id DESC`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

// 获取备注列表
func GetCygxActivityUserRemarksLlistByActivityId(mobile string, activityId int) (items []*CygxActivityUserRemarksResp, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := ` SELECT * FROM cygx_activity_user_remarks WHERE  mobile IN (` + mobile + `) AND activity_id = ?  ORDER BY id DESC`
	_, err = o.Raw(sql, activityId).QueryRows(&items)
	return
}
