12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "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:"内容"`
- }
- // 添加优化建议
- 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
- }
- //report_or_activity_id
- // 主题列表
- func GetActivityAskList(userId 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 AND a.chart_permission_id = 31 ORDER BY k.ask_id DESC`
- _, err = o.Raw(sql, userId).QueryRows(&items)
- 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 AND a.article_type_id > 0 ORDER BY k.ask_id DESC`
- _, err = o.Raw(sql, userId).QueryRows(&items)
- return
- }
- // 通过ID获取详情
- func GetCygxActivityHelpAskById(id int) (item *CygxActivityHelpAsk, err error) {
- sql := `SELECT * FROM cygx_activity_help_ask WHERE ask_id=? `
- err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
- return
- }
|