123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type CygxActivityHelpAsk struct {
- AskId int `orm:"column(ask_id);pk" description:"带问id"`
- UserId int `description:"用户id"`
- ActivityId int `description:"活动id"`
- CreateTime time.Time `description:"创建时间"`
- Mobile string `description:"手机号"`
- Email string `description:"邮箱"`
- CompanyId int `description:"公司id"`
- CompanyName string `description:"公司名称"`
- Content string `description:"内容"`
- RegisterPlatform int `description:"来源 1小程序,2:网页"`
- }
- //添加优化建议
- func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type AddCygxActivityHelpAsk struct {
- ActivityId int `description:"活动id"`
- Content string `description:"内容"`
- }
- type CygxAskList struct {
- ReportOrActivityId int ` description:"对应的文章或者活动Id"`
- Title string `description:"标题"`
- Content string `description:"内容"`
- AskType string `description:"类型 Activity 活动 、Report 文章报告"`
- CreateTime string `description:"创建时间"`
- }
- type CygxAskListResp struct {
- List []*CygxAskList
- Paging *paging.PagingItem
- }
- //report_or_activity_id
- //主题列表
- func GetActivityAskList(userId, startSize, pageSize int) (items []*CygxAskList, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- k.activity_id as report_or_activity_id,
- k.content,
- k.create_time,
- a.activity_name as title
- FROM
- cygx_activity_help_ask AS k
- INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id
- WHERE
- user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
- return
- }
- //主题列表
- func GetActivityAskCount(userId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT( 1 ) as count
- FROM
- cygx_activity_help_ask AS k
- INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id
- WHERE
- user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC `
- err = o.Raw(sql, userId).QueryRow(&count)
- return
- }
- //列表
- func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- k.article_id as report_or_activity_id,
- k.content,
- k.create_time,
- a.title as title
- FROM
- cygx_article_ask AS k
- INNER JOIN cygx_article AS a ON a.article_id = k.article_id
- WHERE
- user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC`
- _, err = o.Raw(sql, userId).QueryRows(&items)
- return
- }
- type AskEmailRep struct {
- Name string `description:"姓名"`
- Email string `description:"邮箱"`
- Mobile string `description:"手机号"`
- }
- func GetAskEmail() (item []*AskEmailRep, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_activity_ask_email`
- _, err = o.Raw(sql).QueryRows(&item)
- return
- }
|