UpdateByID update a userExample by id
(ctx context.Context, req *serverNameExampleV1.UpdateUserExampleByIDRequest)
| 91 | |
| 92 | // UpdateByID update a userExample by id |
| 93 | func (s *userExample) UpdateByID(ctx context.Context, req *serverNameExampleV1.UpdateUserExampleByIDRequest) (*serverNameExampleV1.UpdateUserExampleByIDReply, error) { |
| 94 | err := req.Validate() |
| 95 | if err != nil { |
| 96 | logger.Warn("req.Validate error", logger.Err(err), logger.Any("req", req), interceptor.ServerCtxRequestIDField(ctx)) |
| 97 | return nil, ecode.StatusInvalidParams.Err() |
| 98 | } |
| 99 | ctx = interceptor.WrapServerCtx(ctx) |
| 100 | |
| 101 | record := &model.UserExample{} |
| 102 | err = copier.Copy(record, req) |
| 103 | if err != nil { |
| 104 | return nil, ecode.StatusUpdateByIDUserExample.Err() |
| 105 | } |
| 106 | // Note: if copier.Copy cannot assign a value to a field, add it here |
| 107 | record.ID = req.Id |
| 108 | |
| 109 | err = s.iDao.UpdateByID(ctx, record) |
| 110 | if err != nil { |
| 111 | logger.Error("UpdateByID error", logger.Err(err), logger.Any("userExample", record), interceptor.ServerCtxRequestIDField(ctx)) |
| 112 | return nil, ecode.StatusInternalServerError.ToRPCErr() |
| 113 | } |
| 114 | |
| 115 | return &serverNameExampleV1.UpdateUserExampleByIDReply{}, nil |
| 116 | } |
| 117 | |
| 118 | // GetByID get a userExample by id |
| 119 | func (s *userExample) GetByID(ctx context.Context, req *serverNameExampleV1.GetUserExampleByIDRequest) (*serverNameExampleV1.GetUserExampleByIDReply, error) { |
nothing calls this directly
no test coverage detected