feat(jpush): add vendor-specific message classification support for push notifications
- Add OPPO category/notify_level support (2024.11.20 regulation: category required when notify_level present) - Add Honor importance field (NORMAL=service/LOW=marketing) for notification classification - Add vivo category field (IM/ACCOUNT) for message scenario identification - Set Xiaomi channel/template defaults in code (system=153609, chat=153608, templates P10761/M10289) - Add classification option to JPush push payloads (0=operation, 1=system) - Update xiaomi template keywords mapping to match actual template placeholders - Add keyword search support for GetFollowers and GetFollowing endpoints - Bind new config fields to environment variables for OPPO/Honor/vivo
This commit is contained in:
@@ -21,8 +21,8 @@ type UserRepository interface {
|
||||
Update(user *model.User) error
|
||||
Delete(id string) error
|
||||
List(page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowers(userID string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowing(userID string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowers(userID, keyword string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowing(userID, keyword string, page, pageSize int) ([]*model.User, int64, error)
|
||||
CreateFollow(follow *model.Follow) error
|
||||
DeleteFollow(followerID, followingID string) error
|
||||
IsFollowing(followerID, followingID string) (bool, error)
|
||||
@@ -137,35 +137,49 @@ func (r *userRepository) List(page, pageSize int) ([]*model.User, int64, error)
|
||||
}
|
||||
|
||||
// GetFollowers 获取用户粉丝
|
||||
func (r *userRepository) GetFollowers(userID string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
func (r *userRepository) GetFollowers(userID, keyword string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
var users []*model.User
|
||||
var total int64
|
||||
|
||||
subQuery := r.db.Model(&model.Follow{}).Where("following_id = ?", userID).Select("follower_id")
|
||||
r.db.Model(&model.User{}).Where("id IN (?)", subQuery).Count(&total)
|
||||
query := r.db.Model(&model.User{}).Where("id IN (?)", subQuery)
|
||||
if keyword != "" {
|
||||
if r.db.Dialector.Name() == "postgres" {
|
||||
p := "%" + keyword + "%"
|
||||
query = query.Where("(username ILIKE ? OR nickname ILIKE ?)", p, p)
|
||||
} else {
|
||||
p := "%" + strings.ToLower(keyword) + "%"
|
||||
query = query.Where("(LOWER(username) LIKE ? OR LOWER(nickname) LIKE ?)", p, p)
|
||||
}
|
||||
}
|
||||
query.Count(&total)
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
err := r.db.Where("id IN (?)", subQuery).
|
||||
Order("created_at DESC, id DESC").
|
||||
Offset(offset).Limit(pageSize).
|
||||
Find(&users).Error
|
||||
err := query.Order("created_at DESC, id DESC").Offset(offset).Limit(pageSize).Find(&users).Error
|
||||
|
||||
return users, total, err
|
||||
}
|
||||
|
||||
// GetFollowing 获取用户关注
|
||||
func (r *userRepository) GetFollowing(userID string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
func (r *userRepository) GetFollowing(userID, keyword string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
var users []*model.User
|
||||
var total int64
|
||||
|
||||
subQuery := r.db.Model(&model.Follow{}).Where("follower_id = ?", userID).Select("following_id")
|
||||
r.db.Model(&model.User{}).Where("id IN (?)", subQuery).Count(&total)
|
||||
query := r.db.Model(&model.User{}).Where("id IN (?)", subQuery)
|
||||
if keyword != "" {
|
||||
if r.db.Dialector.Name() == "postgres" {
|
||||
p := "%" + keyword + "%"
|
||||
query = query.Where("(username ILIKE ? OR nickname ILIKE ?)", p, p)
|
||||
} else {
|
||||
p := "%" + strings.ToLower(keyword) + "%"
|
||||
query = query.Where("(LOWER(username) LIKE ? OR LOWER(nickname) LIKE ?)", p, p)
|
||||
}
|
||||
}
|
||||
query.Count(&total)
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
err := r.db.Where("id IN (?)", subQuery).
|
||||
Order("created_at DESC, id DESC").
|
||||
Offset(offset).Limit(pageSize).
|
||||
Find(&users).Error
|
||||
err := query.Order("created_at DESC, id DESC").Offset(offset).Limit(pageSize).Find(&users).Error
|
||||
|
||||
return users, total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user