实现修改管理员信息功能

This commit is contained in:
GoEdgeLab
2020-10-14 19:42:32 +08:00
parent c31ef4f558
commit f558eec79e
8 changed files with 155 additions and 6 deletions

View File

@@ -1,6 +1,11 @@
package profile
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
@@ -11,5 +16,41 @@ func (this *IndexAction) Init() {
}
func (this *IndexAction) RunGet(params struct{}) {
adminResp, err := this.RPC().AdminRPC().FindEnabledAdmin(this.AdminContext(), &pb.FindEnabledAdminRequest{AdminId: this.AdminId()})
if err != nil {
this.ErrorPage(err)
return
}
admin := adminResp.Admin
if admin == nil {
this.NotFound("admin", this.AdminId())
return
}
this.Data["admin"] = maps.Map{
"fullname": admin.Fullname,
}
this.Show()
}
func (this *IndexAction) RunPost(params struct {
Fullname string
Must *actions.Must
}) {
params.Must.
Field("fullname", params.Fullname).
Require("请输入你的姓名")
_, err := this.RPC().AdminRPC().UpdateAdmin(this.AdminContext(), &pb.UpdateAdminRequest{
AdminId: this.AdminId(),
Fullname: params.Fullname,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}