Skip to content

Commit

Permalink
Merge branch 'feature/publish-perm' into fix/social-bind
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjies committed Jul 23, 2024
2 parents 26b3ef9 + 1e70823 commit 463d803
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/app/api/v2/quest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func AddQuestV2(c *gin.Context) {
}
address := c.GetString("address")
if list, err := srv.AddQuestV2(address, add); err != nil {
FailWithMessage(GetMessage(c, "FetchFailed"), c)
FailWithMessage(GetMessage(c, err.Error()), c)
} else {
OkWithData(list, c)
}
Expand Down
6 changes: 4 additions & 2 deletions internal/app/assets/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"EmailAlreadyLinked": "The email has already been linked to another address!",
"GithubAlreadyLinked": "Github has been linked to another wallet address!",
"AddressAlreadyLinkedGithub": "The wallet address has already been linked to Github. Please do not repeat the operation.",
"FailedObtainGithubInfo": "Failed to obtain Github information!"
"FailedObtainGithubInfo": "Failed to obtain Github information!",
"PermissionDenied": "Permission Denied!"
},
"zh-CN": {
"OperationSuccess": "操作成功!",
Expand Down Expand Up @@ -79,6 +80,7 @@
"EmailAlreadyLinked": "邮箱已绑定其他钱包地址",
"GithubAlreadyLinked": "Github 已绑定其他钱包地址",
"AddressAlreadyLinkedGithub": "钱包地址已绑定Github,请勿重复操作",
"FailedObtainGithubInfo": "绑定 Github 信息失败!"
"FailedObtainGithubInfo": "绑定 Github 信息失败!",
"PermissionDenied": "权限不足!"
}
}
5 changes: 5 additions & 0 deletions internal/app/model/response/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ type QuestWithClaimed struct {
func (QuestWithClaimed) TableName() string {
return "quest"
}

type GetUserInfoRes struct {
model.Users
IsAdmin bool `json:"is_admin"`
}
8 changes: 8 additions & 0 deletions internal/app/service/quest_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
)

func (s *Service) AddQuestV2(address string, add request.AddQuestV2Request) (res string, err error) {
// 是否管理员
isAdmin, err := s.dao.IsAdmin(address)
if err != nil {
return
}
if !isAdmin {
return "", errors.New("PermissionDenied")
}
privateKey, err := crypto.HexToECDSA(s.c.BlockChain.SignPrivateKey)
if err != nil {
return
Expand Down
10 changes: 7 additions & 3 deletions internal/app/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"backend-go/internal/app/model"
"backend-go/internal/app/model/request"
"backend-go/internal/app/model/response"
"backend-go/internal/app/utils"
"backend-go/pkg/auth"
"backend-go/pkg/log"
Expand All @@ -20,7 +21,7 @@ import (
"strings"
)

func (s *Service) GetUserInfo(address string, loginAddress string) (res interface{}, err error) {
func (s *Service) GetUserInfo(address string, loginAddress string) (res response.GetUserInfoRes, err error) {
var user model.Users
if user, err = s.dao.GetUser(address); err != nil {
return
Expand Down Expand Up @@ -48,7 +49,9 @@ func (s *Service) GetUserInfo(address string, loginAddress string) (res interfac
}
}
user.NickName = &showStr
return user, err
res.IsAdmin = true
res.Users = user
return res, err
}
// default nickname
if user.NickName == nil || *user.NickName == "" {
Expand All @@ -57,7 +60,8 @@ func (s *Service) GetUserInfo(address string, loginAddress string) (res interfac
user.NickName = &nickName
}
}
return user, err
res.Users = user
return res, err
}

func (s *Service) UpdateUserInfo(address string, user request.UpdateUserInfo) (err error) {
Expand Down

0 comments on commit 463d803

Please sign in to comment.