refactor(group): update user group handling to utilize userUsableGroups directly and add GetUserGroupRatio function

This commit is contained in:
CaIon
2025-10-30 21:16:42 +08:00
parent f1ac5606ee
commit 52d9b8cc78
4 changed files with 15 additions and 3 deletions

View File

@@ -29,11 +29,11 @@ func GetUserGroups(c *gin.Context) {
userId := c.GetInt("id")
userGroup, _ = model.GetUserGroup(userId, false)
userUsableGroups := service.GetUserUsableGroups(userGroup)
for groupName, ratio := range ratio_setting.GetGroupRatioCopy() {
for groupName, _ := range ratio_setting.GetGroupRatioCopy() {
// UserUsableGroups contains the groups that the user can use
if desc, ok := userUsableGroups[groupName]; ok {
usableGroups[groupName] = map[string]interface{}{
"ratio": ratio,
"ratio": service.GetUserGroupRatio(userGroup, groupName),
"desc": desc,
}
}