123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type CygxYanxuanSpecialFollow struct {
- CygxYanxuanSpecialFollowId int `orm:"column(cygx_yanxuan_special_follow_id);pk"`
- UserId int // 用户ID
- FollowUserId int // 被关注用户ID
- Mobile string // 手机号
- Email string // 邮箱
- CompanyId int // 公司ID
- CompanyName string // 公司名称
- RealName string // 用户实际名称
- SellerName string // 所属销售
- CreateTime time.Time // 创建时间
- ModifyTime time.Time // 修改时间
- RegisterPlatform int // 来源 1小程序,2:网页
- YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
- }
- type FollowCygxYanxuanSpecialReq struct {
- FollowUserId int // 被关注的用户id
- Status int // 1关注2取消关注
- SpecialId int // 研选专栏Id
- }
- func AddCygxYanxuanSpecialFollow(item *CygxYanxuanSpecialFollow) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(item)
- return
- }
- func DelCygxYanxuanSpecialFollow(userId, followUserId int) (err error) {
- o := orm.NewOrm()
- sql := `DELETE FROM cygx_yanxuan_special_follow WHERE user_id=? AND follow_user_id=? `
- _, err = o.Raw(sql, userId, followUserId).Exec()
- return
- }
- func GetCygxYanxuanSpecialFollowOpenIdList(followUserId int) (items []*OpenIdList, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- cr.*,
- c.user_id
- FROM
- user_record AS c
- INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
- INNER JOIN cygx_yanxuan_special_follow AS cf ON cf.user_id = c.user_id
- AND cf.follow_user_id = ?
- WHERE
- create_platform = 4 `
- _, err = o.Raw(sql, followUserId).QueryRows(&items)
- return
- }
- // 获取数量
- func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_follow as a WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 获取数量判断用户是否关注专栏
- func GetCygxYanxuanSpecialFollowCountByUser(userId, followUserId int) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_follow as a WHERE user_id=? AND follow_user_id=? `
- o := orm.NewOrm()
- err = o.Raw(sqlCount, userId, followUserId).QueryRow(&count)
- return
- }
- type CygxYanxuanSpecialFollowResp struct {
- CompanyName string // 公司名称
- RealName string // 用户实际名称
- CreateTime string // 创建时间
- Headimgurl string `comment:"用户头像"`
- }
- type CygxYanxuanSpecialFollowListResp struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxYanxuanSpecialFollowResp
- }
- func GetCygxYanxuanSpecialFollowList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialFollow, err error) {
- o := orm.NewOrm()
- sql := `SELECT *
- FROM
- cygx_yanxuan_special_follow
- WHERE 1 = 1 ` + condition
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
|