feat: import services and standardize Go 1.26.5
This commit is contained in:
43
apps/ec/mall/internal/logic/staff/set_profile.go
Normal file
43
apps/ec/mall/internal/logic/staff/set_profile.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package staff
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-ec/mall/internal/impl"
|
||||
"git.apinb.com/bsm-ec/mall/internal/models"
|
||||
pb "git.apinb.com/bsm-ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// SetProfile 设置个人信息
|
||||
func SetProfile(ctx context.Context, in *pb.StaffItem) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data := &models.MallStaff{
|
||||
Name: in.Name,
|
||||
Account: in.Account,
|
||||
Profile: in.Profile,
|
||||
Phone: in.Phone,
|
||||
Email: in.Email,
|
||||
Avatar: in.Avatar,
|
||||
}
|
||||
err = impl.DBService.Debug().Where("identity = ?", auth.Identity).Updates(data).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user