12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package admin
- import (
-
- "hongze/hongze_mobile_admin/models/custom"
- "rdluck_tools/orm"
- )
- type Admin struct {
- AdminId int `orm:"column(admin_id);pk";json:"admin_id"`
- AdminName string `orm:"column(admin_name);";json:"admin_name"`
- RealName string `orm:"column(real_name);" json:"real_name"`
- Password string `orm:"column(password);" json:"password"`
- LastUpdatedPasswordTime string `orm:"column(last_updated_password_time);" json:"last_updated_password_time"`
- Enabled int `orm:"column(enabled);" json:"enabled"`
- Email string `orm:"column(email);" json:"email"`
- LastLoginTime string `orm:"column(last_login_time);" json:"last_login_time"`
- CreatedTime string `orm:"column(created_time);" json:"created_time"`
- LastUpdatedTime string `orm:"column(last_updated_time);" json:"last_updated_time"`
- Role string `orm:"column(role);" json:"role"`
- Mobile string `orm:"column(mobile);" json:"mobile"`
- RoleType int `orm:"column(role_type);" json:"role_type"`
- RoleId int `orm:"column(role_id);" json:"role_id"`
- RoleName string `orm:"column(role_name);" json:"role_name"`
- RoleTypeCode string `orm:"column(role_type_code);" json:"role_type_code"`
- DepartmentId int `orm:"column(department_id);" json:"department_id"`
- DepartmentName string `orm:"column(department_name);" json:"department_name"`
- GroupId int `orm:"column(group_id);" json:"group_id"`
- GroupName string `orm:"column(group_name);" json:"group_name"`
- Authority int `orm:"column(authority);" json:"authority"`
- Position string `orm:"column(position);" json:"position"`
- }
- func CheckAdmin(userName, password string) (item *Admin, err error) {
- sql := ` SELECT a.*,b.role_type_code FROM admin AS a
- INNER JOIN sys_role AS b ON a.role_id=b.role_id WHERE a.admin_name=? AND a.password=? LIMIT 1`
- o := orm.NewOrm()
- err = o.Raw(sql, userName, password).QueryRow(&item)
- return
- }
- func GetAdminById(adminId int) (item *Admin, err error) {
- sql := `SELECT * FROM admin WHERE admin_id=? LIMIT 1`
- o := orm.NewOrm()
- err = o.Raw(sql, adminId).QueryRow(&item)
- return
- }
- func GetAdminListByRoleCode(roleTypeCode string) (items []*Admin, err error) {
- sql := `SELECT * FROM admin WHERE role_type_code=? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, roleTypeCode).QueryRows(&items)
- return
- }
- func GetAdminListByIds(ids string) (items []*Admin, err error) {
- sql := `SELECT * FROM admin WHERE admin_id in (` + ids + `)`
- o := orm.NewOrm()
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func GetAdminWxById(adminId int) (item *custom.AdminWx, err error) {
- sql := `SELECT * FROM admin WHERE admin_id=? LIMIT 1`
- o := orm.NewOrm()
- err = o.Raw(sql, adminId).QueryRow(&item)
- return
- }
|