|
@@ -3,13 +3,13 @@ package controller
|
|
|
import (
|
|
import (
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
- "one-api/common"
|
|
|
|
|
"one-api/model"
|
|
"one-api/model"
|
|
|
|
|
+ "one-api/setting"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func GetGroups(c *gin.Context) {
|
|
func GetGroups(c *gin.Context) {
|
|
|
groupNames := make([]string, 0)
|
|
groupNames := make([]string, 0)
|
|
|
- for groupName, _ := range common.GroupRatio {
|
|
|
|
|
|
|
+ for groupName, _ := range setting.GetGroupRatioCopy() {
|
|
|
groupNames = append(groupNames, groupName)
|
|
groupNames = append(groupNames, groupName)
|
|
|
}
|
|
}
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
c.JSON(http.StatusOK, gin.H{
|
|
@@ -24,9 +24,9 @@ func GetUserGroups(c *gin.Context) {
|
|
|
userGroup := ""
|
|
userGroup := ""
|
|
|
userId := c.GetInt("id")
|
|
userId := c.GetInt("id")
|
|
|
userGroup, _ = model.CacheGetUserGroup(userId)
|
|
userGroup, _ = model.CacheGetUserGroup(userId)
|
|
|
- for groupName, _ := range common.GroupRatio {
|
|
|
|
|
|
|
+ for groupName, _ := range setting.GetGroupRatioCopy() {
|
|
|
// UserUsableGroups contains the groups that the user can use
|
|
// UserUsableGroups contains the groups that the user can use
|
|
|
- userUsableGroups := common.GetUserUsableGroups(userGroup)
|
|
|
|
|
|
|
+ userUsableGroups := setting.GetUserUsableGroups(userGroup)
|
|
|
if _, ok := userUsableGroups[groupName]; ok {
|
|
if _, ok := userUsableGroups[groupName]; ok {
|
|
|
usableGroups[groupName] = userUsableGroups[groupName]
|
|
usableGroups[groupName] = userUsableGroups[groupName]
|
|
|
}
|
|
}
|