12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // Copyright 2019 githup.com. All rights reserved.
- // Use of this source code is governed by githup.com.
- package user
- import (
- "context"
- "github.com/jaryhe/gopkgs/database"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "smart-site-management/errors"
- dbmodel "smart-site-management/model"
- pb_v1 "smart-site-management/pb/v1"
- "time"
- )
- func EmailUpdate(ctx context.Context, req *pb_v1.EmailUpdateRequest)(reply *pb_v1.EmailUpdateReply, err error) {
- p := &dbmodel.TSiteUser{}
- where := map[string]interface{}{
- "id":req.Id,
- }
- // 状态判断
- err = p.Find(database.DB(), where, nil)
- if err != nil {
- logger.Error("EmailUpdate",
- zap.String("err", err.Error()))
- return nil, errors.DataBaseError
- }
- if p.Id == 0 {
- return nil, errors.NoRecordError
- }
- reply = &pb_v1.EmailUpdateReply{}
- values := map[string]interface{}{
- "email":req.Email,
- "updated_at":time.Now(),
- }
- err = p.Update(database.DB(), where, values)
- if err != nil {
- return nil, errors.DataBaseError
- }
- return reply, nil
- }
|