使用qoder优化后更新
Some checks failed
Go build / build and run (push) Has been cancelled

This commit is contained in:
2026-02-12 13:48:35 +08:00
parent abd5962ae9
commit bc59f616fd
15 changed files with 130 additions and 278 deletions

View File

@@ -1,9 +1,3 @@
/*
@Time : 2020/6/28 22:01
@Author : xuyiqing
@File : users.py
*/
package models
import (
@@ -43,24 +37,13 @@ func (a *Account) SetPassword(password string) error {
return nil
}
// 验证登录帐户密码合法性
func (a *Account) CheckPassword() bool {
password := a.Password
aa, err1 := bcrypt.GenerateFromPassword([]byte(a.Password), 12)
print(aa, err1)
DB.Where("username = ?", a.Username).First(&a)
err := bcrypt.CompareHashAndPassword([]byte(a.Password), []byte(password))
return err == nil
}
// 验证登录帐户密码合法性
// IsPasswordEqual 验证密码是否匹配
func (a *Account) IsPasswordEqual(password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(a.Password), []byte(password))
return err == nil
}
// 验证用户重复
// CheckDuplicateUsername 验证用户名是否重复
func (a *Account) CheckDuplicateUsername() bool {
var count int64
if DB.Model(&Account{}).Where("username=?", a.Username).Count(&count); count > 0 {