新增几大中心功能

This commit is contained in:
Administrator
2026-04-23 15:29:07 +08:00
parent 5c2a146a44
commit c6354ee065
123 changed files with 13074 additions and 229 deletions

View File

@@ -0,0 +1,31 @@
package app
import (
"errors"
"git.echol.cn/loser/Go-Web-Template/server/global"
appModel "git.echol.cn/loser/Go-Web-Template/server/model/app"
"git.echol.cn/loser/Go-Web-Template/server/utils"
"gorm.io/gorm"
)
type AppAuthService struct{}
var AppAuthServiceApp = new(AppAuthService)
func (s *AppAuthService) Login(username, password string) (*appModel.AppUser, error) {
var user appModel.AppUser
if err := global.GVA_DB.Where("username = ?", username).First(&user).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errors.New("用户名或密码错误")
}
return nil, err
}
if user.Enable != 1 {
return nil, errors.New("用户被禁止登录")
}
if !utils.BcryptCheck(password, user.Password) {
return nil, errors.New("用户名或密码错误")
}
return &user, nil
}