feat: add run.ps1 script to start projects easily
add a powershell script that supports starting MES, WMS, WMSClient, Workstation and Dashboard projects with one command, includes build and run logic for backend services and npm dev for dashboard
This commit is contained in:
@@ -42,6 +42,11 @@ type UserInfoResp struct {
|
||||
PermissionCodes []string `json:"permissionCodes"`
|
||||
}
|
||||
|
||||
type ChangePasswordReq struct {
|
||||
OldPassword string `json:"oldPassword"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
}
|
||||
|
||||
type permissionItem struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
@@ -148,6 +153,31 @@ func (s *Service) UserInfo(ctx context.Context, userId int) (UserInfoResp, error
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ChangePassword 当前登录用户修改自己的密码
|
||||
func (s *Service) ChangePassword(ctx context.Context, userId int, req ChangePasswordReq) error {
|
||||
if userId <= 0 {
|
||||
return errors.New("未登录")
|
||||
}
|
||||
if req.OldPassword == "" || req.NewPassword == "" {
|
||||
return errors.New("请输入旧密码与新密码")
|
||||
}
|
||||
if len(req.NewPassword) < 6 {
|
||||
return errors.New("新密码长度至少 6 位")
|
||||
}
|
||||
usr, err := s.ctx.EntClient.User.Get(ctx, userId)
|
||||
if err != nil {
|
||||
return errors.New("用户不存在")
|
||||
}
|
||||
if bcrypt.CompareHashAndPassword([]byte(usr.Password), []byte(req.OldPassword)) != nil {
|
||||
return errors.New("旧密码不正确")
|
||||
}
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(req.NewPassword), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.ctx.EntClient.User.UpdateOneID(userId).SetPassword(string(hash)).Exec(ctx)
|
||||
}
|
||||
|
||||
// ------ 用户 / 角色 / 权限 管理 ------
|
||||
|
||||
type UserReq struct {
|
||||
|
||||
Reference in New Issue
Block a user