12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // 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 OrganizationUserUpdate(ctx context.Context, req *pb_v1.OrganizationUserUpdateRequest) (reply *pb_v1.OrganizationUserUpdateReply, err error) {
- reply = &pb_v1.OrganizationUserUpdateReply{}
- // 捕获各个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.Username == "" {
- return nil, errors.ParamsError
- }
- rReq := &pb_v1.ManagementSuperUserUpdateRequest{
- OrganizationCode: req.OrganizationCode,
- Email:req.Email,
- Id:req.Id,
- Phone:req.Phone,
- Username:req.Username,
- }
- mreply, err := pb.Organization.ManagementSuperUserUpdate(ctx, rReq)
- if err != nil {
- return reply, errors.ServiceError
- }
- reply.Origin = &pb_v1.OrganizationUserUpdateRequest{
- OrganizationCode: mreply.Origin.OrganizationCode,
- Username:mreply.Origin.Username,
- Phone: mreply.Origin.Phone,
- Email:mreply.Origin.Email,
- Id:mreply.Origin.Id,
- Password:req.Password,
- }
- return reply, nil
- }
|