31 lines
881 B
Go
31 lines
881 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
sysModel "sundynix-micro-go/app/system/model"
|
|
"sundynix-micro-go/app/system/rpc/internal/svc"
|
|
"sundynix-micro-go/app/system/rpc/system"
|
|
"sundynix-micro-go/common/utils/hash"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ResetPasswordLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewResetPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResetPasswordLogic {
|
|
return &ResetPasswordLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
|
|
}
|
|
|
|
func (l *ResetPasswordLogic) ResetPassword(in *system.ResetPasswordReq) (*system.CommonResp, error) {
|
|
if err := l.svcCtx.DB.Model(&sysModel.SundynixUser{}).Where("id = ?", in.Id).
|
|
Update("password", hash.BcryptHash(in.Password)).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &system.CommonResp{Code: 200, Msg: "success"}, nil
|
|
}
|