更新管理员相关接口

This commit is contained in:
WuYuuuub
2026-04-05 11:57:47 +08:00
parent a630ae733e
commit 8457cf1450
8 changed files with 808 additions and 0 deletions

View File

@@ -176,6 +176,10 @@ go run cmd/server/main.go -config config.yaml
|------|------|
| Login | 管理员登录 |
| GetStatistics | 获取统计数据 |
| CreateAdmin | 创建管理员账号 |
| GetAdminList | 获取管理员列表 |
| UpdateAdmin | 更新管理员信息 |
| DeleteAdmin | 删除管理员 |
## 数据模型

View File

@@ -921,6 +921,148 @@ paths:
active_printers:
type: integer
/cloudprint.AdminService/CreateAdmin:
post:
tags: [Admin]
summary: 创建管理员账号
description: 创建新的管理员账号密码将使用bcrypt进行哈希处理
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- username
- password
properties:
username:
type: string
description: 管理员用户名
example: "admin"
password:
type: string
description: 管理员密码
example: "admin123"
nickname:
type: string
description: 昵称
example: "管理员"
role:
type: integer
description: 角色 (1-普通管理员, 2-超级管理员)
example: 1
responses:
"200":
description: 创建成功
content:
application/json:
schema:
type: object
properties:
admin:
$ref: '#/components/schemas/Admin'
/cloudprint.AdminService/GetAdminList:
post:
tags: [Admin]
summary: 获取管理员列表
security:
- bearerAuth: []
requestBody:
content:
application/json:
schema:
type: object
properties:
page:
type: integer
description: 页码
example: 1
page_size:
type: integer
description: 每页数量
example: 10
responses:
"200":
description: 成功
content:
application/json:
schema:
type: object
properties:
admins:
type: array
items:
$ref: '#/components/schemas/Admin'
total:
type: integer
description: 总数
/cloudprint.AdminService/UpdateAdmin:
post:
tags: [Admin]
summary: 更新管理员信息
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
type: integer
description: 管理员ID
example: 1
nickname:
type: string
description: 昵称
example: "新昵称"
role:
type: integer
description: 角色 (1-普通管理员, 2-超级管理员)
example: 2
responses:
"200":
description: 更新成功
content:
application/json:
schema:
$ref: '#/components/schemas/Admin'
/cloudprint.AdminService/DeleteAdmin:
post:
tags: [Admin]
summary: 删除管理员
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
type: integer
description: 管理员ID
example: 1
responses:
"200":
description: 删除成功
content:
application/json:
schema:
type: object
components:
securitySchemes:
bearerAuth:

View File

@@ -3,11 +3,13 @@ package service
import (
"context"
"github.com/cloudprint/cloudprint-backend/internal/model"
"github.com/cloudprint/cloudprint-backend/internal/repository"
"github.com/cloudprint/cloudprint-backend/internal/service"
pb "github.com/cloudprint/cloudprint-backend/proto/generated"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)
type AdminServiceServer struct {
@@ -66,3 +68,68 @@ func (s *AdminServiceServer) GetStatistics(ctx context.Context, req *pb.GetStati
ActivePrinters: int32(activePrinters),
}, nil
}
func (s *AdminServiceServer) CreateAdmin(ctx context.Context, req *pb.CreateAdminRequest) (*pb.CreateAdminResponse, error) {
admin, err := s.authService.CreateAdmin(ctx, req.Username, req.Password, req.Nickname, int8(req.Role))
if err != nil {
return nil, status.Errorf(codes.Internal, "create admin failed: %v", err)
}
return &pb.CreateAdminResponse{
Admin: convertAdminToProto(admin),
}, nil
}
func (s *AdminServiceServer) GetAdminList(ctx context.Context, req *pb.GetAdminListRequest) (*pb.AdminListResponse, error) {
page := req.Page
if page <= 0 {
page = 1
}
pageSize := req.PageSize
if pageSize <= 0 {
pageSize = 10
}
admins, total, err := s.authService.GetAdminList(ctx, int(page), int(pageSize))
if err != nil {
return nil, status.Errorf(codes.Internal, "get admin list failed: %v", err)
}
pbAdmins := make([]*pb.Admin, len(admins))
for i, admin := range admins {
pbAdmins[i] = convertAdminToProto(&admin)
}
return &pb.AdminListResponse{
Admins: pbAdmins,
Total: int32(total),
}, nil
}
func (s *AdminServiceServer) UpdateAdmin(ctx context.Context, req *pb.UpdateAdminRequest) (*pb.Admin, error) {
admin, err := s.authService.UpdateAdmin(ctx, req.Id, req.Nickname, int8(req.Role))
if err != nil {
return nil, status.Errorf(codes.Internal, "update admin failed: %v", err)
}
return convertAdminToProto(admin), nil
}
func (s *AdminServiceServer) DeleteAdmin(ctx context.Context, req *pb.DeleteAdminRequest) (*pb.Empty, error) {
if err := s.authService.DeleteAdmin(ctx, req.Id); err != nil {
return nil, status.Errorf(codes.Internal, "delete admin failed: %v", err)
}
return &pb.Empty{}, nil
}
// convertAdminToProto 将model.Admin转换为pb.Admin
func convertAdminToProto(admin *model.Admin) *pb.Admin {
return &pb.Admin{
Id: admin.ID,
Username: admin.Username,
Nickname: admin.Nickname,
Role: int32(admin.Role),
CreatedAt: timestamppb.New(admin.CreatedAt),
}
}

View File

@@ -47,3 +47,23 @@ func (r *AdminRepository) GetByUsername(ctx context.Context, username string) (*
func (r *AdminRepository) Update(ctx context.Context, admin *model.Admin) error {
return r.db.WithContext(ctx).Save(admin).Error
}
func (r *AdminRepository) Delete(ctx context.Context, id int32) error {
return r.db.WithContext(ctx).Delete(&model.Admin{}, id).Error
}
func (r *AdminRepository) List(ctx context.Context, page, pageSize int) ([]model.Admin, int64, error) {
var admins []model.Admin
var total int64
if err := r.db.WithContext(ctx).Model(&model.Admin{}).Count(&total).Error; err != nil {
return nil, 0, err
}
offset := (page - 1) * pageSize
if err := r.db.WithContext(ctx).Offset(offset).Limit(pageSize).Find(&admins).Error; err != nil {
return nil, 0, err
}
return admins, total, nil
}

View File

@@ -181,6 +181,68 @@ type AdminLoginResult struct {
Admin *model.Admin
}
// CreateAdmin 创建管理员账号
func (s *AuthService) CreateAdmin(ctx context.Context, username, password, nickname string, role int8) (*model.Admin, error) {
// 检查用户名是否已存在
existingAdmin, err := s.adminRepo.GetByUsername(ctx, username)
if err != nil {
return nil, fmt.Errorf("failed to check existing admin: %w", err)
}
if existingAdmin != nil {
return nil, errors.New("username already exists")
}
// 对密码进行哈希处理
passwordHash, err := HashPassword(password)
if err != nil {
return nil, fmt.Errorf("failed to hash password: %w", err)
}
// 创建管理员
admin := &model.Admin{
Username: username,
PasswordHash: passwordHash,
Nickname: nickname,
Role: role,
}
if err := s.adminRepo.Create(ctx, admin); err != nil {
return nil, fmt.Errorf("failed to create admin: %w", err)
}
return admin, nil
}
// UpdateAdmin 更新管理员信息
func (s *AuthService) UpdateAdmin(ctx context.Context, id int32, nickname string, role int8) (*model.Admin, error) {
admin, err := s.adminRepo.GetByID(ctx, id)
if err != nil {
return nil, fmt.Errorf("failed to get admin: %w", err)
}
if admin == nil {
return nil, errors.New("admin not found")
}
admin.Nickname = nickname
admin.Role = role
if err := s.adminRepo.Update(ctx, admin); err != nil {
return nil, fmt.Errorf("failed to update admin: %w", err)
}
return admin, nil
}
// DeleteAdmin 删除管理员
func (s *AuthService) DeleteAdmin(ctx context.Context, id int32) error {
return s.adminRepo.Delete(ctx, id)
}
// GetAdminList 获取管理员列表
func (s *AuthService) GetAdminList(ctx context.Context, page, pageSize int) ([]model.Admin, int64, error) {
return s.adminRepo.List(ctx, page, pageSize)
}
// HashPassword creates a bcrypt hash of the password
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)

View File

@@ -440,6 +440,43 @@ message Statistics {
int32 active_printers = 6;
}
// 创建管理员请求
message CreateAdminRequest {
string username = 1;
string password = 2;
string nickname = 3;
int32 role = 4; // 1:普通管理员 2:超级管理员
}
// 创建管理员响应
message CreateAdminResponse {
Admin admin = 1;
}
// 获取管理员列表请求
message GetAdminListRequest {
int32 page = 1;
int32 page_size = 2;
}
// 管理员列表响应
message AdminListResponse {
repeated Admin admins = 1;
int32 total = 2;
}
// 更新管理员请求
message UpdateAdminRequest {
int32 id = 1;
string nickname = 2;
int32 role = 3;
}
// 删除管理员请求
message DeleteAdminRequest {
int32 id = 1;
}
// ============ 服务定义 ============
service AuthService {
@@ -499,4 +536,8 @@ service PayService {
service AdminService {
rpc Login(AdminLoginRequest) returns (AdminLoginResponse);
rpc GetStatistics(GetStatisticsRequest) returns (Statistics);
rpc CreateAdmin(CreateAdminRequest) returns (CreateAdminResponse);
rpc GetAdminList(GetAdminListRequest) returns (AdminListResponse);
rpc UpdateAdmin(UpdateAdminRequest) returns (Admin);
rpc DeleteAdmin(DeleteAdminRequest) returns (Empty);
}

View File

@@ -4203,6 +4203,326 @@ func (x *Statistics) GetActivePrinters() int32 {
return 0
}
// CreateAdminRequest 创建管理员请求
type CreateAdminRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
Nickname string `protobuf:"bytes,3,opt,name=nickname,proto3" json:"nickname,omitempty"`
Role int32 `protobuf:"varint,4,opt,name=role,proto3" json:"role,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateAdminRequest) Reset() {
*x = CreateAdminRequest{}
mi := &file_cloudprint_proto_msgTypes[69]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateAdminRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateAdminRequest) ProtoMessage() {}
func (x *CreateAdminRequest) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[69]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*CreateAdminRequest) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{69}
}
func (x *CreateAdminRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
func (x *CreateAdminRequest) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *CreateAdminRequest) GetNickname() string {
if x != nil {
return x.Nickname
}
return ""
}
func (x *CreateAdminRequest) GetRole() int32 {
if x != nil {
return x.Role
}
return 0
}
// CreateAdminResponse 创建管理员响应
type CreateAdminResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Admin *Admin `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateAdminResponse) Reset() {
*x = CreateAdminResponse{}
mi := &file_cloudprint_proto_msgTypes[70]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateAdminResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateAdminResponse) ProtoMessage() {}
func (x *CreateAdminResponse) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[70]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*CreateAdminResponse) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{70}
}
func (x *CreateAdminResponse) GetAdmin() *Admin {
if x != nil {
return x.Admin
}
return nil
}
// GetAdminListRequest 获取管理员列表请求
type GetAdminListRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetAdminListRequest) Reset() {
*x = GetAdminListRequest{}
mi := &file_cloudprint_proto_msgTypes[71]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetAdminListRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetAdminListRequest) ProtoMessage() {}
func (x *GetAdminListRequest) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[71]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*GetAdminListRequest) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{71}
}
func (x *GetAdminListRequest) GetPage() int32 {
if x != nil {
return x.Page
}
return 0
}
func (x *GetAdminListRequest) GetPageSize() int32 {
if x != nil {
return x.PageSize
}
return 0
}
// AdminListResponse 管理员列表响应
type AdminListResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Admins []*Admin `protobuf:"bytes,1,rep,name=admins,proto3" json:"admins,omitempty"`
Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AdminListResponse) Reset() {
*x = AdminListResponse{}
mi := &file_cloudprint_proto_msgTypes[72]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AdminListResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AdminListResponse) ProtoMessage() {}
func (x *AdminListResponse) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[72]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*AdminListResponse) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{72}
}
func (x *AdminListResponse) GetAdmins() []*Admin {
if x != nil {
return x.Admins
}
return nil
}
func (x *AdminListResponse) GetTotal() int32 {
if x != nil {
return x.Total
}
return 0
}
// UpdateAdminRequest 更新管理员请求
type UpdateAdminRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"`
Role int32 `protobuf:"varint,3,opt,name=role,proto3" json:"role,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UpdateAdminRequest) Reset() {
*x = UpdateAdminRequest{}
mi := &file_cloudprint_proto_msgTypes[73]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateAdminRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateAdminRequest) ProtoMessage() {}
func (x *UpdateAdminRequest) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[73]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*UpdateAdminRequest) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{73}
}
func (x *UpdateAdminRequest) GetId() int32 {
if x != nil {
return x.Id
}
return 0
}
func (x *UpdateAdminRequest) GetNickname() string {
if x != nil {
return x.Nickname
}
return ""
}
func (x *UpdateAdminRequest) GetRole() int32 {
if x != nil {
return x.Role
}
return 0
}
// DeleteAdminRequest 删除管理员请求
type DeleteAdminRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DeleteAdminRequest) Reset() {
*x = DeleteAdminRequest{}
mi := &file_cloudprint_proto_msgTypes[74]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeleteAdminRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteAdminRequest) ProtoMessage() {}
func (x *DeleteAdminRequest) ProtoReflect() protoreflect.Message {
mi := &file_cloudprint_proto_msgTypes[74]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
func (*DeleteAdminRequest) Descriptor() ([]byte, []int) {
return file_cloudprint_proto_rawDescGZIP(), []int{74}
}
func (x *DeleteAdminRequest) GetId() int32 {
if x != nil {
return x.Id
}
return 0
}
var File_cloudprint_proto protoreflect.FileDescriptor
const file_cloudprint_proto_rawDesc = "" +

View File

@@ -1718,6 +1718,10 @@ var PayService_ServiceDesc = grpc.ServiceDesc{
const (
AdminService_Login_FullMethodName = "/cloudprint.AdminService/Login"
AdminService_GetStatistics_FullMethodName = "/cloudprint.AdminService/GetStatistics"
AdminService_CreateAdmin_FullMethodName = "/cloudprint.AdminService/CreateAdmin"
AdminService_GetAdminList_FullMethodName = "/cloudprint.AdminService/GetAdminList"
AdminService_UpdateAdmin_FullMethodName = "/cloudprint.AdminService/UpdateAdmin"
AdminService_DeleteAdmin_FullMethodName = "/cloudprint.AdminService/DeleteAdmin"
)
// AdminServiceClient is the client API for AdminService service.
@@ -1726,6 +1730,10 @@ const (
type AdminServiceClient interface {
Login(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*AdminLoginResponse, error)
GetStatistics(ctx context.Context, in *GetStatisticsRequest, opts ...grpc.CallOption) (*Statistics, error)
CreateAdmin(ctx context.Context, in *CreateAdminRequest, opts ...grpc.CallOption) (*CreateAdminResponse, error)
GetAdminList(ctx context.Context, in *GetAdminListRequest, opts ...grpc.CallOption) (*AdminListResponse, error)
UpdateAdmin(ctx context.Context, in *UpdateAdminRequest, opts ...grpc.CallOption) (*Admin, error)
DeleteAdmin(ctx context.Context, in *DeleteAdminRequest, opts ...grpc.CallOption) (*Empty, error)
}
type adminServiceClient struct {
@@ -1756,12 +1764,56 @@ func (c *adminServiceClient) GetStatistics(ctx context.Context, in *GetStatistic
return out, nil
}
func (c *adminServiceClient) CreateAdmin(ctx context.Context, in *CreateAdminRequest, opts ...grpc.CallOption) (*CreateAdminResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateAdminResponse)
err := c.cc.Invoke(ctx, AdminService_CreateAdmin_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *adminServiceClient) GetAdminList(ctx context.Context, in *GetAdminListRequest, opts ...grpc.CallOption) (*AdminListResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AdminListResponse)
err := c.cc.Invoke(ctx, AdminService_GetAdminList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *adminServiceClient) UpdateAdmin(ctx context.Context, in *UpdateAdminRequest, opts ...grpc.CallOption) (*Admin, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Admin)
err := c.cc.Invoke(ctx, AdminService_UpdateAdmin_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *adminServiceClient) DeleteAdmin(ctx context.Context, in *DeleteAdminRequest, opts ...grpc.CallOption) (*Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(Empty)
err := c.cc.Invoke(ctx, AdminService_DeleteAdmin_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AdminServiceServer is the server API for AdminService service.
// All implementations must embed UnimplementedAdminServiceServer
// for forward compatibility.
type AdminServiceServer interface {
Login(context.Context, *AdminLoginRequest) (*AdminLoginResponse, error)
GetStatistics(context.Context, *GetStatisticsRequest) (*Statistics, error)
CreateAdmin(context.Context, *CreateAdminRequest) (*CreateAdminResponse, error)
GetAdminList(context.Context, *GetAdminListRequest) (*AdminListResponse, error)
UpdateAdmin(context.Context, *UpdateAdminRequest) (*Admin, error)
DeleteAdmin(context.Context, *DeleteAdminRequest) (*Empty, error)
mustEmbedUnimplementedAdminServiceServer()
}
@@ -1778,6 +1830,18 @@ func (UnimplementedAdminServiceServer) Login(context.Context, *AdminLoginRequest
func (UnimplementedAdminServiceServer) GetStatistics(context.Context, *GetStatisticsRequest) (*Statistics, error) {
return nil, status.Error(codes.Unimplemented, "method GetStatistics not implemented")
}
func (UnimplementedAdminServiceServer) CreateAdmin(context.Context, *CreateAdminRequest) (*CreateAdminResponse, error) {
return nil, status.Error(codes.Unimplemented, "method CreateAdmin not implemented")
}
func (UnimplementedAdminServiceServer) GetAdminList(context.Context, *GetAdminListRequest) (*AdminListResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetAdminList not implemented")
}
func (UnimplementedAdminServiceServer) UpdateAdmin(context.Context, *UpdateAdminRequest) (*Admin, error) {
return nil, status.Error(codes.Unimplemented, "method UpdateAdmin not implemented")
}
func (UnimplementedAdminServiceServer) DeleteAdmin(context.Context, *DeleteAdminRequest) (*Empty, error) {
return nil, status.Error(codes.Unimplemented, "method DeleteAdmin not implemented")
}
func (UnimplementedAdminServiceServer) mustEmbedUnimplementedAdminServiceServer() {}
func (UnimplementedAdminServiceServer) testEmbeddedByValue() {}
@@ -1835,6 +1899,78 @@ func _AdminService_GetStatistics_Handler(srv interface{}, ctx context.Context, d
return interceptor(ctx, in, info, handler)
}
func _AdminService_CreateAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateAdminRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).CreateAdmin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AdminService_CreateAdmin_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).CreateAdmin(ctx, req.(*CreateAdminRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AdminService_GetAdminList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAdminListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).GetAdminList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AdminService_GetAdminList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).GetAdminList(ctx, req.(*GetAdminListRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AdminService_UpdateAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateAdminRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).UpdateAdmin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AdminService_UpdateAdmin_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).UpdateAdmin(ctx, req.(*UpdateAdminRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AdminService_DeleteAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteAdminRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).DeleteAdmin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AdminService_DeleteAdmin_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).DeleteAdmin(ctx, req.(*DeleteAdminRequest))
}
return interceptor(ctx, in, info, handler)
}
// AdminService_ServiceDesc is the grpc.ServiceDesc for AdminService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -1850,6 +1986,22 @@ var AdminService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetStatistics",
Handler: _AdminService_GetStatistics_Handler,
},
{
MethodName: "CreateAdmin",
Handler: _AdminService_CreateAdmin_Handler,
},
{
MethodName: "GetAdminList",
Handler: _AdminService_GetAdminList_Handler,
},
{
MethodName: "UpdateAdmin",
Handler: _AdminService_UpdateAdmin_Handler,
},
{
MethodName: "DeleteAdmin",
Handler: _AdminService_DeleteAdmin_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cloudprint.proto",