manual_user.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package data_manage
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "time"
  7. )
  8. type ManualUser struct {
  9. ManualUserId int `gorm:"primaryKey" `
  10. AdminId int `description:"用户id"`
  11. AdminRealName string `description:"用户姓名"`
  12. SysUserId int `description:"创建人id"`
  13. SysUserRealName string `description:"创建人姓名"`
  14. CreateTime time.Time `description:"创建时间"`
  15. }
  16. func DeleteManualUser(adminId int) (err error) {
  17. sql := `DELETE FROM manual_user WHERE admin_id=? `
  18. err = global.DmSQL["data"].Exec(sql, adminId).Error
  19. return
  20. }
  21. func AddManualUser(item *ManualUser) (err error) {
  22. err = global.DmSQL["data"].Create(item).Error
  23. return
  24. }
  25. type ManualUserItem struct {
  26. AdminId int `description:"用户id"`
  27. AdminRealName string `description:"用户姓名"`
  28. }
  29. func GetManualUserList() (list []*ManualUserItem, err error) {
  30. sql := ` SELECT admin_id,admin_real_name FROM manual_user
  31. GROUP BY admin_id
  32. ORDER BY create_time DESC `
  33. fmt.Println("GetManualUserList:", sql)
  34. err = global.DmSQL["data"].Raw(sql).Find(&list).Error
  35. return
  36. }
  37. type ManualUserList struct {
  38. AdminId int `description:"用户id"`
  39. AdminRealName int `description:"用户姓名"`
  40. }
  41. type ManualSysUserClassifySaveReq struct {
  42. AdminId int `description:"用户id"`
  43. ClassifyId []int `description:"分类id数组"`
  44. }
  45. type ManualUserClassify struct {
  46. ManualUserClassifyId int `gorm:"primaryKey" `
  47. AdminId int
  48. ClassifyId int
  49. CreateTime time.Time
  50. }
  51. func AddManualUserClassifyMulti(items []*ManualUserClassify) (err error) {
  52. err = global.DmSQL["data"].CreateInBatches(items, utils.MultiAddNum).Error
  53. return
  54. }
  55. func DeleteManualUserClassifyCount(adminId int) (err error) {
  56. sql := ` DELETE FROM manual_user_classify WHERE admin_id=? `
  57. err = global.DmSQL["data"].Exec(sql, adminId).Error
  58. return
  59. }
  60. func GetManualUserClassifyCount(adminId, classifyId int) (count int, err error) {
  61. sql := ` SELECT COUNT(1) AS count FROM manual_user_classify WHERE admin_id=? AND classify_id=? `
  62. err = global.DmSQL["data"].Raw(sql, adminId, classifyId).Scan(&count).Error
  63. return
  64. }
  65. func GetManualUserCount(adminId int) (count int, err error) {
  66. sql := ` SELECT COUNT(1) AS count FROM manual_user WHERE admin_id=? `
  67. err = global.DmSQL["data"].Raw(sql, adminId).Scan(&count).Error
  68. return
  69. }
  70. func GetManualUserSetClassify(adminId int) (list []*EdbdataClassify, err error) {
  71. sql := ` SELECT * FROM manual_user_classify WHERE admin_id=? `
  72. err = global.DmSQL["data"].Raw(sql, adminId).Find(&list).Error
  73. return
  74. }