hr_email.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package rcrt
  2. import (
  3. "hongze/hrms_api/global"
  4. "hongze/hrms_api/models/base"
  5. )
  6. // Hr邮箱表
  7. type HrEmail struct {
  8. HrEmailId int64 `gorm:"primaryKey;column:hr_email_id" json:"hr_email_id"` //Hr邮箱序号
  9. AdminId uint64 `gorm:"column:admin_id" json:"admin_id"` //Hr账号
  10. Email string `gorm:"column:email" json:"email"` //邮箱地址
  11. EmailPwd string `gorm:"column:email_pwd" json:"email_pwd"` //邮箱密码
  12. base.TimeBase
  13. }
  14. // TableName get sql table name.获取数据库表名
  15. func (e *HrEmail) TableName() string {
  16. return "rcrt_hr_email"
  17. }
  18. // Add 新增
  19. func (e *HrEmail) Add() (err error) {
  20. err = global.DEFAULT_MYSQL.Create(e).Error
  21. return
  22. }
  23. // 修改
  24. func (e *HrEmail) Update(updateCols []string) (err error) {
  25. err = global.DEFAULT_MYSQL.Model(e).Select(updateCols).Updates(e).Error
  26. return
  27. }
  28. // 删除
  29. func (e *HrEmail) Delete() (err error) {
  30. err = global.DEFAULT_MYSQL.Delete(e).Error
  31. return
  32. }
  33. type HrEmailListReq struct {
  34. HrAdminIds string `json:"hr_admin_ids" form:"hr_admin_ids"` //hr账号ID数组
  35. base.PageReq
  36. }
  37. type HrEmailListTmpItem struct {
  38. HrEmail
  39. AdminName string `json:"admin_name"`
  40. }
  41. type HrEmailListItem struct {
  42. HrEmailId int64 `json:"hr_email_id"`
  43. AdminId uint64 `json:"admin_id"` //Hr账号
  44. Email string `json:"email"` //邮箱地址
  45. EmailPwd string `json:"email_pwd"` //邮箱密码
  46. AdminName string `json:"admin_name"`
  47. CreateTime string `json:"create_time"` //创建时间
  48. ModifyTime string `json:"modify_time"` //最后更新时间
  49. }
  50. type HrEmailDelReq struct {
  51. HrEmailId int64 `json:"hr_email_id" binding:"required,gte=1"`
  52. }
  53. type HrEmailEditReq struct {
  54. HrEmailId int64 `json:"hr_email_id" binding:"required,gte=1"`
  55. AdminId uint64 `json:"admin_id"` //Hr账号
  56. Email string `json:"email"` //邮箱地址
  57. EmailPwd string `json:"email_pwd"` //邮箱密码
  58. }
  59. type HrEmailAddReq struct {
  60. AdminId uint64 `json:"admin_id"` //Hr账号
  61. Email string `json:"email"` //邮箱地址
  62. EmailPwd string `json:"email_pwd"` //邮箱密码
  63. }
  64. func (e *HrEmail) GetHrEmailById(id int64) (item *HrEmail, err error) {
  65. err = global.DEFAULT_MYSQL.Model(e).Where("hr_email_id = ? ", id).First(&item).Error
  66. return
  67. }
  68. func (e *HrEmail) GetHrEmailByEmail(email string) (item *HrEmail, err error) {
  69. err = global.DEFAULT_MYSQL.Model(e).Where("email = ? ", email).First(&item).Error
  70. return
  71. }
  72. func (e *HrEmail) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*HrEmailListTmpItem, err error) {
  73. results = make([]*HrEmailListTmpItem, 0)
  74. query := global.DEFAULT_MYSQL.
  75. Table("rcrt_hr_email as e ").
  76. Select("e.*, a.real_name as admin_name").
  77. Joins("Left JOIN sys_admin a ON a.admin_id = e.admin_id").
  78. Where(condition, pars...)
  79. query.Count(&count)
  80. if len(page.GetOrderItemsString()) > 0 {
  81. query = query.Order(page.GetOrderItemsString())
  82. }
  83. err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
  84. return
  85. }