MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / batchQueryProjectUser

Function batchQueryProjectUser

cmd/cql-proxy/api/project.go:1114–1160  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

1112}
1113
1114func batchQueryProjectUser(c *gin.Context) {
1115 r := struct {
1116 DB proto.DatabaseID `json:"db" json:"project" form:"db" form:"project" uri:"db" uri:"project" binding:"required,len=64"`
1117 ID []int64 `json:"id" form:"id" binding:"required,dive,required,gt=0"`
1118 }{}
1119
1120 _ = c.ShouldBindUri(&r)
1121
1122 if err := c.ShouldBind(&r); err != nil {
1123 abortWithError(c, http.StatusBadRequest, err)
1124 return
1125 }
1126
1127 _, projectDB, err := getProjectDB(c, r.DB)
1128 if err != nil {
1129 _ = c.Error(err)
1130 abortWithError(c, http.StatusForbidden, ErrLoadProjectDatabaseFailed)
1131 return
1132 }
1133
1134 users, err := model.GetProjectUsers(projectDB, r.ID)
1135 if err != nil {
1136 _ = c.Error(err)
1137 abortWithError(c, http.StatusInternalServerError, ErrGetProjectUserFailed)
1138 return
1139 }
1140
1141 var resp = gin.H{}
1142
1143 for _, u := range users {
1144 resp[fmt.Sprint(u.ID)] = gin.H{
1145 "id": u.ID,
1146 "name": u.Name,
1147 "email": u.Email,
1148 "state": u.State.String(),
1149 "provider": u.Provider,
1150 "provider_uid": u.ProviderUID,
1151 "extra": u.Extra,
1152 "created": formatUnixTime(u.Created),
1153 "last_login": formatUnixTime(u.LastLogin),
1154 }
1155 }
1156
1157 responseWithData(c, http.StatusOK, gin.H{
1158 "users": resp,
1159 })
1160}
1161
1162func updateProjectTableRules(c *gin.Context) {
1163 r := struct {

Callers

nothing calls this directly

Calls 7

GetProjectUsersFunction · 0.92
abortWithErrorFunction · 0.85
getProjectDBFunction · 0.85
formatUnixTimeFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected