CreateGroup

This commit is contained in:
withchao
2023-01-06 16:19:57 +08:00
parent 90cc7937e6
commit 90fddd34d2
3 changed files with 100 additions and 98 deletions
+12
View File
@@ -205,6 +205,18 @@ func GetUserInfoFromCache(userID string) (*imdb.User, error) {
return userInfo, utils.Wrap(err, "")
}
func GetUserInfoFromCacheBatch(userIDs []string) ([]*imdb.User, error) {
var users []*imdb.User
for _, userID := range userIDs {
user, err := GetUserInfoFromCache(userID)
if err != nil {
return nil, err
}
users = append(users, user)
}
return users, nil
}
func DelUserInfoFromCache(userID string) error {
return db.DB.Rc.TagAsDeleted(userInfoCache + userID)
}
+13 -2
View File
@@ -37,7 +37,7 @@ func Uint32ToString(i uint32) string {
return strconv.FormatInt(int64(i), 10)
}
//judge a string whether in the string list
// judge a string whether in the string list
func IsContain(target string, List []string) bool {
for _, element := range List {
@@ -80,7 +80,7 @@ func StructToJsonBytes(param interface{}) []byte {
return dataType
}
//The incoming parameter must be a pointer
// The incoming parameter must be a pointer
func JsonStringToStruct(s string, args interface{}) error {
err := json.Unmarshal([]byte(s), args)
return err
@@ -121,3 +121,14 @@ func RemoveDuplicateElement(idList []string) []string {
}
return result
}
func IsRepeatStringSlice(arr []string) bool {
t := make(map[string]struct{})
for _, s := range arr {
if _, ok := t[s]; ok {
return true
}
t[s] = struct{}{}
}
return false
}