123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package advisory
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type PublishChart struct {
- ChartIds string `description:"分类id,多个用英文逗号隔开"`
- }
- type PublishReq struct {
- ReportIds string `description:"报告id,多个用英文逗号隔开"`
- }
- type AdvisoryAdminFllowChart struct {
- Id int `orm:"column(advisory_fllow_id);pk"`
- //AdvisoryFllowId int `description:"主键id"`
- AdvisoryAdminUserId int `description:"用户id"`
- ChartPermissionId string `description:"分类id"`
- CreatedTime time.Time `description:"创建时间"`
- LastUpdatedTime time.Time `description:"修改时间"`
- }
- type AdvisoryAdminFllowChartList struct {
- List []*AdvisoryAdminFllowChart
- }
- //检查用户是否关注过分类
- func ChckeAdminUserIsFllow(Uid int) (isFllow bool) {
- fllowInfo, _ := GetUserFllowInfo(Uid)
- if fllowInfo.AdvisoryAdminUserId > 0 {
- return false
- } else {
- return true
- }
- }
- func GetUserFllowInfo(Uid int) (items *AdvisoryAdminFllowChart, err error) {
- o := orm.NewOrm()
- //o.Using("rddp")
- sql := `SELECT * FROM advisory_admin_fllow_chart WHERE advisory_admin_user_id=? LIMIT 1`
- err = o.Raw(sql, Uid).QueryRow(&items)
- return
- }
- //添加用户关注
- func AddAdminUserFllow(item *AdvisoryAdminFllowChart) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(item)
- return
- }
- func GetUserFllowListByIds(Ids string) (items []*AdvisoryAdminFllowChartList, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (` + Ids + `)`
- fmt.Println(sql)
- err = o.Raw(sql).QueryRow(&items)
- return
- }
- //修改选择的分类
- func UpdateAdminUserFllow(item *AdvisoryAdminFllowChart) (err error) {
- o := orm.NewOrm()
- sql := " UPDATE advisory_admin_fllow_chart SET chart_permission_id = ? WHERE advisory_admin_user_id = ? "
- o.Raw(sql, item.ChartPermissionId, item.AdvisoryAdminUserId).Exec()
- return
- }
|