-
Notifications
You must be signed in to change notification settings - Fork 16
/
user_info.go
43 lines (41 loc) · 1.29 KB
/
user_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* @Author: SpenserCai
* @Date: 2023-09-29 21:26:43
* @version:
* @LastEditors: SpenserCai
* @LastEditTime: 2023-10-04 00:12:56
* @Description: file content
*/
package business
import (
"github.com/SpenserCai/sd-webui-discord/api/gen/models"
ServiceOperations "github.com/SpenserCai/sd-webui-discord/api/gen/restapi/operations/user"
"github.com/SpenserCai/sd-webui-discord/global"
"github.com/go-openapi/runtime/middleware"
)
func (b BusinessBase) SetUserInfoHandler() {
global.ApiService.UserUserInfoHandler = ServiceOperations.UserInfoHandlerFunc(func(params ServiceOperations.UserInfoParams, principal interface{}) middleware.Responder {
userInfo, err := global.UserCenterSvc.GetUserInfo(principal.(string))
if err != nil {
return ServiceOperations.NewUserInfoOK().WithPayload(&models.UserInfo{
Code: -1,
Message: err.Error(),
})
}
return ServiceOperations.NewUserInfoOK().WithPayload(&models.UserInfo{
Code: 0,
Message: "success",
Data: &models.UserInfoData{
User: &models.UserItem{
ID: userInfo.Id,
Username: userInfo.Name,
Avatar: userInfo.Avatar,
Enable: userInfo.Enable,
StableConfig: userInfo.StableConfig,
Roles: userInfo.Roles,
Created: userInfo.Created,
},
},
})
})
}