add admin names api
This commit is contained in:
@@ -84,3 +84,9 @@ type AdminOutInfo struct {
|
||||
Email string `json:"email"`
|
||||
Roles []string `json:"roles"`
|
||||
}
|
||||
|
||||
type AdminNames struct {
|
||||
Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"`
|
||||
Name string `gorm:"column:name;type:varchar(30);comment:真实姓名;NOT NULL" json:"name"`
|
||||
Phone string `gorm:"column:phone;type:char(12);comment:电话" json:"phone"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"admin/admin"
|
||||
"admin/internal/dao"
|
||||
"admin/internal/model"
|
||||
"admin/internal/svc"
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"pkg.local/modelbase"
|
||||
"pkg.local/utils"
|
||||
)
|
||||
|
||||
type AdminNamesLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewAdminNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminNamesLogic {
|
||||
return &AdminNamesLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminNamesLogic) AdminNames(in *admin.AdminEmptyRequest) (*admin.Response, error) {
|
||||
modelObj := model.AdminModel{}.Init()
|
||||
w := modelbase.Params{
|
||||
Order: "id desc",
|
||||
}
|
||||
var items []dao.AdminNames
|
||||
err := modelObj.Items(w, &items)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
for item := range items {
|
||||
mobile, dErr := utils.DecryptPhone(items[item].Phone)
|
||||
if dErr == nil {
|
||||
items[item].Phone = mobile
|
||||
}
|
||||
}
|
||||
|
||||
return l.ok(items)
|
||||
}
|
||||
@@ -53,6 +53,11 @@ func (s *AdminServer) AdminItems(ctx context.Context, in *admin.AdminItemsReques
|
||||
return l.AdminItems(in)
|
||||
}
|
||||
|
||||
func (s *AdminServer) AdminNames(ctx context.Context, in *admin.AdminEmptyRequest) (*admin.Response, error) {
|
||||
l := logic.NewAdminNamesLogic(ctx, s.svcCtx)
|
||||
return l.AdminNames(in)
|
||||
}
|
||||
|
||||
func (s *AdminServer) LoginRefresh(ctx context.Context, in *admin.AdminEmptyRequest) (*admin.Response, error) {
|
||||
l := logic.NewLoginRefreshLogic(ctx, s.svcCtx)
|
||||
return l.LoginRefresh(in)
|
||||
|
||||
Reference in New Issue
Block a user