manual_user.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/rdlucklib/rdluck_tools/orm"
  5. "time"
  6. )
  7. type ManualUser struct {
  8. ManualUserId int `orm:"column(manual_user_id);pk"`
  9. AdminId int `description:"用户id"`
  10. AdminRealName string `description:"用户姓名"`
  11. SysUserId int `description:"创建人id"`
  12. SysUserRealName string `description:"创建人姓名"`
  13. CreateTime time.Time `description:"创建时间"`
  14. }
  15. func DeleteManualUser(adminId int) (err error) {
  16. sql := `DELETE FROM manual_user WHERE admin_id=? `
  17. o := orm.NewOrm()
  18. o.Using("data")
  19. _, err = o.Raw(sql, adminId).Exec()
  20. return
  21. }
  22. func AddManualUser(item *ManualUser) (err error) {
  23. o := orm.NewOrm()
  24. o.Using("data")
  25. _, err = o.Insert(item)
  26. return
  27. }
  28. type ManualUserItem struct {
  29. AdminId int `description:"用户id"`
  30. AdminRealName string `description:"用户姓名"`
  31. }
  32. func GetManualUserList() (list []*ManualUserItem, err error) {
  33. o := orm.NewOrm()
  34. o.Using("data")
  35. sql := ` SELECT admin_id,admin_real_name FROM manual_user
  36. GROUP BY admin_id
  37. ORDER BY create_time DESC `
  38. fmt.Println("GetManualUserList:",sql)
  39. _, err = o.Raw(sql).QueryRows(&list)
  40. return
  41. }
  42. type ManualUserList struct {
  43. AdminId int `description:"用户id"`
  44. AdminRealName int `description:"用户姓名"`
  45. }
  46. func GetManualSysuserAll() (list []*ManualUserList, err error) {
  47. o := orm.NewOrm()
  48. o.Using("data")
  49. sql := ` SELECT * FROM manual_user
  50. ORDER BY create_time ASC `
  51. o.Raw(sql).QueryRows()
  52. return
  53. }
  54. type ManualSysUserClassifySaveReq struct {
  55. AdminId int `description:"用户id"`
  56. ClassifyId []int `description:"分类id数组"`
  57. }
  58. type ManualUserClassify struct {
  59. ManualUserClassifyId int `orm:"column(manual_user_classify_id);pk"`
  60. AdminId int
  61. ClassifyId int
  62. CreateTime time.Time
  63. }
  64. func AddManualUserClassifyMulti(items []*ManualUserClassify) (err error) {
  65. o := orm.NewOrm()
  66. o.Using("data")
  67. _, err = o.InsertMulti(1, items)
  68. return
  69. }
  70. func DeleteManualUserClassifyCount(adminId int) (err error) {
  71. o := orm.NewOrm()
  72. o.Using("data")
  73. sql := ` DELETE FROM manual_user_classify WHERE admin_id=? `
  74. _, err = o.Raw(sql, adminId).Exec()
  75. return
  76. }
  77. func GetManualUserClassifyCount(adminId, classifyId int) (count int, err error) {
  78. o := orm.NewOrm()
  79. o.Using("data")
  80. sql := ` SELECT COUNT(1) AS count FROM manual_user_classify WHERE admin_id=? AND classify_id=? `
  81. err = o.Raw(sql, adminId, classifyId).QueryRow(&count)
  82. return
  83. }
  84. func GetManualUserCount(adminId int) (count int, err error) {
  85. o := orm.NewOrm()
  86. o.Using("data")
  87. sql := ` SELECT COUNT(1) AS count FROM manual_user WHERE admin_id=? `
  88. err = o.Raw(sql, adminId).QueryRow(&count)
  89. return
  90. }
  91. func GetManualUserSetClassify(adminId int) (list []*EdbdataClassify, err error) {
  92. o := orm.NewOrm()
  93. o.Using("data")
  94. sql := ` SELECT * FROM manual_user_classify WHERE admin_id=? `
  95. _, err = o.Raw(sql, adminId).QueryRows(&list)
  96. return
  97. }