...
|
...
|
@@ -13,13 +13,13 @@ type ChanceFavorite struct { |
|
|
Id int64 `orm:"column(id);pk" description:"点赞编号"`
|
|
|
UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
|
|
|
CompanyId int64 `orm:"column(company_id)" description:"company.id 公司编号"`
|
|
|
ObjectType int `orm:"column(object_type)" description:"类型 1:点赞 2:收藏"`
|
|
|
MarkFlag int `orm:"column(mark_flag)" description:"类型 1:点赞 2:收藏"`
|
|
|
SourceType int `orm:"column(source_type)" description:"来源类型 1:机会 2:评论"`
|
|
|
SourceId int64 `orm:"column(source_id)" description:"来源id 机会编号/评论编号"`
|
|
|
ChanceType int `orm:"column(chance_type)" description:"机会类型编号 - 附加 "`
|
|
|
EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"`
|
|
|
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
|
|
|
DeleteAt time.Time `orm:"column(delete_at);type(timestamp);null" description:"删除时间"`
|
|
|
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
|
|
|
}
|
|
|
|
|
|
func (t *ChanceFavorite) TableName() string {
|
...
|
...
|
@@ -79,15 +79,15 @@ func DeleteChanceFavorite(id int64) (err error) { |
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
|
|
|
func GetChanceFavorites(userId, companyId int64, markFlag, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
|
|
|
sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
|
|
|
sql.Where(fmt.Sprintf("user_id=%d", userId))
|
|
|
sql.Where(fmt.Sprintf("company_id=%d", companyId))
|
|
|
if chanceType > 0 {
|
|
|
sql.Where(fmt.Sprintf("chance_type=%d", chanceType))
|
|
|
}
|
|
|
if objectType > 0 {
|
|
|
sql.Where(fmt.Sprintf("object_type&%d>0", objectType))
|
|
|
if markFlag > 0 {
|
|
|
sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag))
|
|
|
}
|
|
|
if pageSize > 0 {
|
|
|
sql.Limit(0, pageSize)
|
...
|
...
|
@@ -103,12 +103,34 @@ func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, las |
|
|
|
|
|
}
|
|
|
|
|
|
func ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) {
|
|
|
func ExitsChanceFavorite(userId, companyId int64, sourceId int64, markFlag int) (exits bool, err error) {
|
|
|
sql := mybeego.NewSqlExutor().Table("chance_favorite")
|
|
|
sql.Where(fmt.Sprintf("source_id=%d", sourceId)).
|
|
|
Where(fmt.Sprintf("user_id=%d", userId)).
|
|
|
Where(fmt.Sprintf("company_id=%d", companyId)).
|
|
|
Where(fmt.Sprintf("(object_type&%d)>0", objectType)).
|
|
|
Where(fmt.Sprintf("enable_status=1"))
|
|
|
if markFlag>0{
|
|
|
sql.Where(fmt.Sprintf("(mark_flag&%d)>0", markFlag))
|
|
|
}
|
|
|
return sql.QueryExists()
|
|
|
}
|
|
|
|
|
|
|
|
|
func UpdateChanceFavorite(userId, companyId int64,sourceId int64,markFlag int)(err error){
|
|
|
o := orm.NewOrm()
|
|
|
sql := `update chance_favorite set mark_flag = mark_flag ^ ?
|
|
|
where user_id =? and company_id =? and source_id=? ` //
|
|
|
if _,err = o.Raw(sql,markFlag,userId,companyId,sourceId).Exec(); err == nil {
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *ChanceFavorite,err error){
|
|
|
o :=orm.NewOrm()
|
|
|
sql :=`select * from chance_favorite where user_id =? and company_id =? and source_id=? and source_type=?`
|
|
|
if err = o.Raw(sql,userId,companyId,sourceId,sourceType).QueryRow(&v);err!=nil{
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|