1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package models
- import (
- "eta_gn/eta_task/global"
- "fmt"
- "strings"
- )
- type Admin struct {
- AdminId int `gorm:"primaryKey;autoIncrement;column:admin_id"`
- AdminName string `description:"系统用户名称"`
- RealName string `description:"系统用户姓名"`
- Password string `description:"密码"`
- Mobile string `description:"手机号"`
- RoleId int `description:"角色id"`
- RoleName string `description:"角色名称"`
- RoleTypeCode string `description:"角色编码"`
- DepartmentId int `description:"部门id"`
- GroupId int `description:"分组id"`
- Authority int `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
- Position string `description:"职位"`
- OpenId string `description:"弘则部门公众号的openid"`
- OutId string `description:"外部ID"`
- }
- func GetAdminByAdminId(adminId int) (item *Admin, err error) {
- //sql := `SELECT * FROM admin WHERE admin_id=? `
- //err = orm.NewOrm().Raw(sql, adminId).QueryRow(&item)
- sql := `SELECT * FROM "admin" WHERE admin_id=? `
- err = global.DmSQL["eta"].Raw(sql, adminId).Find(&item).Error
- return
- }
- func (m *Admin) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*Admin, err error) {
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := `ORDER BY created_time DESC`
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM "admin" WHERE 1=1 %s %s`, fields, condition, order)
- err = global.DmSQL["eta"].Raw(sql, pars...).Find(&items).Error
- return
- }
|