package rcrt import ( "hongze/hrms_api/global" "hongze/hrms_api/models/base" ) // Hr邮箱表 type HrEmail struct { HrEmailId int64 `gorm:"primaryKey;column:hr_email_id" json:"hr_email_id"` //Hr邮箱序号 AdminId uint64 `gorm:"column:admin_id" json:"admin_id"` //Hr账号 Email string `gorm:"column:email" json:"email"` //邮箱地址 EmailPwd string `gorm:"column:email_pwd" json:"email_pwd"` //邮箱密码 base.TimeBase } // TableName get sql table name.获取数据库表名 func (e *HrEmail) TableName() string { return "rcrt_hr_email" } // Add 新增 func (e *HrEmail) Add() (err error) { err = global.DEFAULT_MYSQL.Create(e).Error return } // 修改 func (e *HrEmail) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(e).Select(updateCols).Updates(e).Error return } // 删除 func (e *HrEmail) Delete() (err error) { err = global.DEFAULT_MYSQL.Delete(e).Error return } type HrEmailListReq struct { HrAdminIds string `json:"hr_admin_ids" form:"hr_admin_ids"` //hr账号ID数组 base.PageReq } type HrEmailListTmpItem struct { HrEmail AdminName string `json:"admin_name"` } type HrEmailListItem struct { HrEmailId int64 `json:"hr_email_id"` AdminId uint64 `json:"admin_id"` //Hr账号 Email string `json:"email"` //邮箱地址 EmailPwd string `json:"email_pwd"` //邮箱密码 AdminName string `json:"admin_name"` CreateTime string `json:"create_time"` //创建时间 ModifyTime string `json:"modify_time"` //最后更新时间 } type HrEmailDelReq struct { HrEmailId int64 `json:"hr_email_id" binding:"required,gte=1"` } type HrEmailEditReq struct { HrEmailId int64 `json:"hr_email_id" binding:"required,gte=1"` AdminId uint64 `json:"admin_id"` //Hr账号 Email string `json:"email"` //邮箱地址 EmailPwd string `json:"email_pwd"` //邮箱密码 } type HrEmailAddReq struct { AdminId uint64 `json:"admin_id"` //Hr账号 Email string `json:"email"` //邮箱地址 EmailPwd string `json:"email_pwd"` //邮箱密码 } func (e *HrEmail) GetHrEmailById(id int64) (item *HrEmail, err error) { err = global.DEFAULT_MYSQL.Model(e).Where("hr_email_id = ? ", id).First(&item).Error return } func (e *HrEmail) GetHrEmailByEmail(email string) (item *HrEmail, err error) { err = global.DEFAULT_MYSQL.Model(e).Where("email = ? ", email).First(&item).Error return } func (e *HrEmail) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*HrEmailListTmpItem, err error) { results = make([]*HrEmailListTmpItem, 0) query := global.DEFAULT_MYSQL. Table("rcrt_hr_email as e "). Select("e.*, a.real_name as admin_name"). Joins("Left JOIN sys_admin a ON a.admin_id = e.admin_id"). Where(condition, pars...) query.Count(&count) if len(page.GetOrderItemsString()) > 0 { query = query.Order(page.GetOrderItemsString()) } err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error return }