Files
mayfly-go/models/account.go

27 lines
699 B
Go
Raw Normal View History

2020-09-01 10:34:11 +08:00
package models
import (
2021-01-08 15:37:32 +08:00
"mayfly-go/base/model"
2020-09-01 10:34:11 +08:00
"mayfly-go/controllers/vo"
2021-01-08 15:37:32 +08:00
"github.com/beego/beego/v2/client/orm"
2020-09-01 10:34:11 +08:00
)
type Account struct {
2021-01-08 15:37:32 +08:00
model.Model
2020-09-01 10:34:11 +08:00
Username string `orm:"column(username)" json:"username"`
Password string `orm:"column(password)" json:"-"`
Status int8 `json:"status"`
}
func init() {
orm.RegisterModelWithPrefix("t_", new(Account))
}
2021-01-08 15:37:32 +08:00
func ListAccount(param *model.PageParam, args ...interface{}) model.PageResult {
2020-09-01 10:34:11 +08:00
sql := "SELECT a.id, a.username, a.create_time, a.creator_id, a.creator, r.Id AS 'Role.Id', r.Name AS 'Role.Name'" +
" FROM t_account a LEFT JOIN t_role r ON a.id = r.account_id"
2021-01-08 15:37:32 +08:00
return model.GetPageBySql(sql, new([]vo.AccountVO), param, args)
2020-09-01 10:34:11 +08:00
}