You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
546 B
28 lines
546 B
4 years ago
|
package models
|
||
|
|
||
|
import "github.com/toolkits/pkg/logger"
|
||
|
|
||
|
type Role struct {
|
||
|
Id int64 `json:"id"`
|
||
|
Name string `json:"name"`
|
||
|
Note string `json:"note"`
|
||
|
}
|
||
|
|
||
|
func (Role) TableName() string {
|
||
|
return "role"
|
||
|
}
|
||
|
|
||
|
func RoleGets(where string, args ...interface{}) ([]Role, error) {
|
||
|
var objs []Role
|
||
|
err := DB.Where(where, args...).OrderBy("name").Find(&objs)
|
||
|
if err != nil {
|
||
|
logger.Errorf("mysql.error: list role fail: %v", err)
|
||
|
return objs, internalServerError
|
||
|
}
|
||
|
return objs, nil
|
||
|
}
|
||
|
|
||
|
func RoleGetsAll() ([]Role, error) {
|
||
|
return RoleGets("")
|
||
|
}
|