refactor: reorganize modules and add Linux build tooling
This commit is contained in:
42
module/ec/mall/internal/logic/staff/set_password.go
Normal file
42
module/ec/mall/internal/logic/staff/set_password.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package staff
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"bsm/full/module/ec/mall/internal/impl"
|
||||
"bsm/full/module/ec/mall/internal/models"
|
||||
pb "bsm/full/module/ec/mall/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
)
|
||||
|
||||
// SetPassword 设置账号密码
|
||||
func SetPassword(ctx context.Context, in *pb.SetAccountRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if in.Password == "" || in.Password != in.PasswordConfirmed {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
salt := utils.RandomString(8)
|
||||
pwd := utils.Md5(in.Password + salt)
|
||||
err = impl.DBService.Where("id = ?", auth.ID).Updates(&models.MallStaff{Salt: salt, Password: pwd}).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