MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetUserModels

Function GetUserModels

controller/user.go:638–670  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

636}
637
638func GetUserModels(c *gin.Context) {
639 id, err := strconv.Atoi(c.Param("id"))
640 if err != nil {
641 id = c.GetInt("id")
642 }
643 user, err := model.GetUserCache(id)
644 if err != nil {
645 common.ApiError(c, err)
646 return
647 }
648 groups := service.GetUserUsableGroups(user.Group)
649 group := c.Query("group")
650 var groupsToQuery []string
651 switch {
652 case group == "":
653 for g := range groups {
654 groupsToQuery = append(groupsToQuery, g)
655 }
656 case group == "auto":
657 if _, ok := groups[group]; ok {
658 groupsToQuery = service.GetUserAutoGroup(user.Group)
659 }
660 default:
661 if _, ok := groups[group]; ok {
662 groupsToQuery = []string{group}
663 }
664 }
665 c.JSON(http.StatusOK, gin.H{
666 "success": true,
667 "message": "",
668 "data": service.GetGroupsEnabledModels(groupsToQuery),
669 })
670}
671
672func UpdateUser(c *gin.Context) {
673 var updatedUser model.User

Calls 6

GetUserCacheFunction · 0.92
ApiErrorFunction · 0.92
GetUserUsableGroupsFunction · 0.92
GetUserAutoGroupFunction · 0.92
GetGroupsEnabledModelsFunction · 0.92
QueryMethod · 0.80