12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxIndustryFllow struct {
- Id int `orm:"column(id);pk"`
- IndustrialManagementId int `description:"产业D"`
- UserId int `description:"用户ID"`
- Mobile string `description:"手机号"`
- Email string `description:"邮箱"`
- CompanyId int `description:"公司id"`
- CompanyName string `description:"公司名称"`
- Type int `description:"操作方式,1报名,2取消报名"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- RealName string `description:"用户实际名称"`
- }
- type CygxIndustryFllowRep struct {
- IndustrialManagementId int `description:"产业D"`
- }
- //添加
- func AddCygxIndustryFllow(item *CygxIndustryFllow) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type CygxIndustryFllowResp struct {
- Status int `description:"1:关注,2:取消关注"`
- GoFollow bool `description:"是否去关注"`
- }
- func RemoveCygxIndustryFllow(userId, industrialManagementId, doType int) (err error) {
- o := orm.NewOrm()
- sql := `DELETE FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? `
- _, err = o.Raw(sql, userId, industrialManagementId).Exec()
- return
- }
- //获取数量
- func GetCountCygxIndustryFllow(userId, industrialManagementId int, condition string) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? ` + condition
- err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
- return
- }
- //获取数量
- func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
- sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? `
- err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
- return
- }
- //获取列表信息根据手机号分组
- func GetCygxIndustryFllowList(condition string) (items []*CygxIndustryFllow, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_industry_fllow WHERE 1 =1 ` + condition + ` GROUP BY user_id `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- //修改用户关注的相关信息
- func UpdateCygxIndustryFllow(wxUser *WxUserItem) (err error) {
- o := orm.NewOrm()
- var sql string
- if wxUser.Mobile != "" {
- sql = `UPDATE cygx_industry_fllow SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
- _, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
- } else if wxUser.Email != "" {
- sql = `UPDATE cygx_industry_fllow SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
- _, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
- }
- return
- }
|