Files
waf-platform/EdgeAdmin/internal/web/actions/default/users/identity/index.go

73 lines
1.7 KiB
Go

// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build plus
package identity
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/users/userutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "", "identity")
}
func (this *IndexAction) RunGet(params struct {
UserId int64
}) {
err := userutils.InitUser(this.Parent(), params.UserId)
if err != nil {
this.ErrorPage(err)
return
}
userIdentityResp, err := this.RPC().UserIdentityRPC().FindEnabledUserIdentityWithOrgType(this.AdminContext(), &pb.FindEnabledUserIdentityWithOrgTypeRequest{
UserId: params.UserId,
OrgType: userconfigs.UserIdentityOrgTypeIndividual,
})
if err != nil {
this.ErrorPage(err)
return
}
var identity = userIdentityResp.UserIdentity
if identity == nil {
this.Data["identity"] = nil
this.Show()
return
}
if identity.FileIds == nil {
identity.FileIds = []int64{0, 0}
}
var backFileId int64 = 0
var frontFileId int64 = 0
if len(identity.FileIds) > 0 {
backFileId = identity.FileIds[0]
}
if len(identity.FileIds) > 1 {
frontFileId = identity.FileIds[1]
}
this.Data["identity"] = maps.Map{
"id": identity.Id,
"realName": identity.RealName,
"number": identity.Number,
"fileIds": identity.FileIds,
"backFileId": backFileId,
"frontFileId": frontFileId,
"status": identity.Status,
"rejectReason": identity.RejectReason,
}
this.Show()
}