123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package organization
- import (
- "context"
- "cp-system-management/errors"
- "cp-system-management/pb"
- pb_v1 "cp-system-management/pb/v1"
- "encoding/json"
- "fmt"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "google.golang.org/grpc/status"
- )
- //
- func OrganizationUserResetPassword(ctx context.Context, req *pb_v1.OrganizationUserResetPasswordRequest) (reply *pb_v1.OrganizationUserResetPasswordReply, err error) {
- reply = &pb_v1.OrganizationUserResetPasswordReply{}
- // 捕获各个task中的异常并返回给调用者
- defer func() {
- if r := recover(); r != nil {
- err = fmt.Errorf("%+v", r)
- e := &status.Status{}
- if er := json.Unmarshal([]byte(err.Error()), e); er != nil {
- logger.Error("err",
- zap.String("system_err", err.Error()),
- zap.Stack("stacktrace"))
- }
- }
- }()
- if req.Id == 0 || req.OrganizationCode == "" || req.Password == "" {
- return nil, errors.ParamsError
- }
- rReq := &pb_v1.ManagementSuperUserResetPasswordRequest{
- OrganizationCode: req.OrganizationCode,
- Id:req.Id,
- Password:req.Password,
- }
- _, err = pb.Organization.ManagementSuperUserResetPassword(ctx, rReq)
- if err != nil {
- return reply, errors.ServiceError
- }
- return reply, nil
- }
|