2021-01-19 22:05:46 +08:00
|
|
|
package database
|
2020-10-10 20:28:36 +08:00
|
|
|
|
2020-10-14 19:42:32 +08:00
|
|
|
import (
|
2020-12-09 20:44:54 +08:00
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
2020-10-14 19:42:32 +08:00
|
|
|
"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"
|
|
|
|
|
)
|
2020-10-10 20:28:36 +08:00
|
|
|
|
|
|
|
|
type IndexAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *IndexAction) Init() {
|
|
|
|
|
this.Nav("", "", "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *IndexAction) RunGet(params struct{}) {
|
2020-10-14 19:42:32 +08:00
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 20:28:36 +08:00
|
|
|
this.Show()
|
|
|
|
|
}
|
2020-10-14 19:42:32 +08:00
|
|
|
|
|
|
|
|
func (this *IndexAction) RunPost(params struct {
|
|
|
|
|
Fullname string
|
|
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
2020-11-20 15:32:42 +08:00
|
|
|
defer this.CreateLogInfo("修改个人资料")
|
|
|
|
|
|
2020-10-14 19:42:32 +08:00
|
|
|
params.Must.
|
|
|
|
|
Field("fullname", params.Fullname).
|
|
|
|
|
Require("请输入你的姓名")
|
|
|
|
|
|
2020-12-02 23:11:43 +08:00
|
|
|
_, err := this.RPC().AdminRPC().UpdateAdminInfo(this.AdminContext(), &pb.UpdateAdminInfoRequest{
|
2020-10-14 19:42:32 +08:00
|
|
|
AdminId: this.AdminId(),
|
|
|
|
|
Fullname: params.Fullname,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 20:44:54 +08:00
|
|
|
// 通知更新
|
|
|
|
|
err = configloaders.NotifyAdminModuleMappingChange()
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-14 19:42:32 +08:00
|
|
|
this.Success()
|
|
|
|
|
}
|