123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package admin
- import (
- "hongze/hongze_yb/global"
- )
- // GetByAdminId 根据admin_id获取系统用户信息
- func GetByAdminId(adminId int) (item *Admin, err error) {
- err = global.DEFAULT_MYSQL.Where("admin_id = ? ", adminId).First(&item).Error
- return
- }
- // GetAdminByMobile 通过手机号获取系统用户信息
- func GetAdminByMobile(mobile string) (item *Admin, err error) {
- err = global.DEFAULT_MYSQL.Model(Admin{}).Where("mobile = ? AND enabled = 1", mobile).First(&item).Error
- return
- }
- // GetAdminByEmail 通过邮箱获取系统用户信息
- func GetAdminByEmail(mobile string) (item *Admin, err error) {
- err = global.DEFAULT_MYSQL.Model(Admin{}).Where("email = ? AND enabled = 1", mobile).First(&item).Error
- return
- }
- // GetVWangInfo 获取沛总的账户信息
- func GetVWangInfo() (item *Admin, err error) {
- return GetByAdminId(66)
- }
- // ResearcherAdminAndUser 研究员admin信息及wx_user信息
- type ResearcherAdminAndUser struct {
- UserId int `description:"用户ID"`
- UserName string `description:"用户名称"`
- AdminId int `description:"管理员ID"`
- AdminName string `description:"管理员姓名"`
- OpenId string `description:"openid"`
- }
- // GetResearcherAdminAndWxUserByAdminId 通过adminId获取研究员admin及user信息
- func GetResearcherAdminAndWxUserByAdminId(adminId int) (item *ResearcherAdminAndUser, err error) {
- sql := `SELECT
- a.admin_id,
- a.real_name AS admin_name,
- a.open_id,
- b.user_id,
- b.real_name AS user_name
- FROM
- admin AS a
- JOIN wx_user AS b ON a.mobile = b.mobile
- WHERE
- a.admin_id = ? AND a.open_id != ""`
- err = global.DEFAULT_MYSQL.Raw(sql, adminId).First(&item).Error
- return
- }
|