package models

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

type CygxReportSelectionSubjectHistory struct {
	Id                     int       `orm:"column(id);pk"`
	ArticleId              int       `description:"文章ID"`
	UserId                 int       `description:"用户ID"`
	CreateTime             time.Time `description:"创建时间"`
	ModifyTime             time.Time `description:"修改时间"`
	Mobile                 string    `description:"手机号"`
	Email                  string    `description:"邮箱"`
	CompanyId              int       `description:"公司id"`
	CompanyName            string    `description:"公司名称"`
	IndustrialSubjectId    int       `description:"标的ID"`
	IndustrialManagementId int       `description:"产业Id"`
	RegisterPlatform       int       `description:"来源 1小程序，2：网页"`
	ThirdId                int       `description:"类似产业、标的的三方ID"`
}

type AddCygxReportSelectionSubjectHistoryReq struct {
	ArticleId              int `description:"文章id"`
	IndustrialSubjectId    int `description:"标的ID"`
	IndustrialManagementId int `description:"产业Id"`
	ThirdId                int `description:"类似产业、标的的三方ID"`
}

// 添加
func AddCygxReportSelectionSubjectHistory(item *CygxReportSelectionSubjectHistory) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	return
}

// 列表
func GetCygxReportSelectionSubjectHistory() (items []*CygxReportSelectionSubjectHistory, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_report_selection_subject_history as art WHERE 1= 1 `
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

func UpdateCygxReportSelectionSubjectHistoryName(lableName string, id int) (err error) {
	o := orm.NewOrm()
	sql := `UPDATE cygx_report_selection_subject_history SET lable_name=? WHERE id = ? `
	_, err = o.Raw(sql, lableName, id).Exec()
	return
}
