You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
859 B
Go
39 lines
859 B
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"weather/models"
|
|
|
|
"github.com/astaxie/beego/orm"
|
|
_ "github.com/astaxie/beego/session/mysql"
|
|
)
|
|
|
|
type AccountService struct {
|
|
}
|
|
|
|
func (s *AccountService) LoginAccount(account models.Account) *models.Account {
|
|
o := orm.NewOrm()
|
|
var accountTemp models.Account
|
|
err := o.QueryTable(new(models.Account)).Filter("username", account.Username).Filter("password", account.Password).One(&accountTemp)
|
|
|
|
if err == orm.ErrNoRows {
|
|
// 没有找到记录
|
|
fmt.Println("查询不到")
|
|
}
|
|
if err == nil {
|
|
fmt.Println("登录成功")
|
|
return &accountTemp
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *AccountService) RegistAccount(account models.Account) bool {
|
|
|
|
o := orm.NewOrm()
|
|
accountTemp := new(models.Account)
|
|
accountTemp.Username = account.Username
|
|
accountTemp.Password = account.Password
|
|
fmt.Println(o.Insert(accountTemp))
|
|
return true
|
|
}
|