complaint_dao.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package dao
  2. import (
  3. "github.com/druidcaesa/gotool"
  4. "ulink-admin/frame"
  5. "ulink-admin/modules/car/models/model"
  6. "ulink-admin/modules/car/models/req"
  7. "ulink-admin/pkg/base"
  8. "ulink-admin/pkg/page"
  9. )
  10. type ComplaintDao struct {
  11. base.BaseDao
  12. }
  13. // Page 查询投诉管理分页数据
  14. func (this ComplaintDao) Page(query *req.ComplaintQuery, list interface{}) int64 {
  15. session := this.GetSession().Table(model.Complaint{}.TableName())
  16. if query.Id > 0 {
  17. session.And("id = ?", query.Id)
  18. }
  19. if !gotool.StrUtils.HasEmpty(query.CarNo) {
  20. session.And("car_no = ?", query.CarNo)
  21. }
  22. if !gotool.StrUtils.HasEmpty(query.Company) {
  23. session.And("company = ?", query.Company)
  24. }
  25. if !gotool.StrUtils.HasEmpty(query.Contacts) {
  26. session.And("contacts = ?", query.Contacts)
  27. }
  28. if !gotool.StrUtils.HasEmpty(query.Phone) {
  29. session.And("phone = ?", query.Phone)
  30. }
  31. if !gotool.StrUtils.HasEmpty(query.OldContent) {
  32. session.And("old_content = ?", query.OldContent)
  33. }
  34. if !gotool.StrUtils.HasEmpty(query.Content) {
  35. session.And("content = ?", query.Content)
  36. }
  37. if query.State > 0 {
  38. session.And("state = ?", query.State)
  39. }
  40. if !gotool.StrUtils.HasEmpty(query.HandlerTime) {
  41. session.And("handler_time = ?", query.HandlerTime)
  42. }
  43. if query.HandlerUser > 0 {
  44. session.And("handler_user = ?", query.HandlerUser)
  45. }
  46. if query.AssignUser > 0 {
  47. session.And("assign_user = ?", query.AssignUser)
  48. }
  49. if !gotool.StrUtils.HasEmpty(query.CreateBy) {
  50. session.And("create_by = ?", query.CreateBy)
  51. }
  52. if !gotool.StrUtils.HasEmpty(query.UpdateBy) {
  53. session.And("update_by = ?", query.UpdateBy)
  54. }
  55. if !gotool.StrUtils.HasEmpty(query.Remark) {
  56. session.And("remark = ?", query.Remark)
  57. }
  58. if !gotool.StrUtils.HasEmpty(query.BeginTime) {
  59. session.And("date_format(u.create_time,'%y%m%d') >= date_format(?,'%y%m%d')", query.BeginTime)
  60. }
  61. if !gotool.StrUtils.HasEmpty(query.EndTime) {
  62. session.And("date_format(u.create_time,'%y%m%d') <= date_format(?,'%y%m%d')", query.EndTime)
  63. }
  64. session.Desc("id")
  65. total, err := session.Limit(query.PageSize, page.StartSize(query.PageNum, query.PageSize)).FindAndCount(list)
  66. if err != nil {
  67. frame.Throw(frame.SQL_CODE, "数据查询错误"+err.Error())
  68. }
  69. return total
  70. }
  71. // List 查询投诉管理分页数据
  72. func (this ComplaintDao) List(query *req.ComplaintQuery, list interface{}) {
  73. session := this.GetSession().Table(model.Complaint{}.TableName())
  74. if query.Id > 0 {
  75. session.And("id = ?", query.Id)
  76. }
  77. if !gotool.StrUtils.HasEmpty(query.CarNo) {
  78. session.And("car_no = ?", query.CarNo)
  79. }
  80. if !gotool.StrUtils.HasEmpty(query.Company) {
  81. session.And("company = ?", query.Company)
  82. }
  83. if !gotool.StrUtils.HasEmpty(query.Contacts) {
  84. session.And("contacts = ?", query.Contacts)
  85. }
  86. if !gotool.StrUtils.HasEmpty(query.Phone) {
  87. session.And("phone = ?", query.Phone)
  88. }
  89. if !gotool.StrUtils.HasEmpty(query.OldContent) {
  90. session.And("old_content = ?", query.OldContent)
  91. }
  92. if !gotool.StrUtils.HasEmpty(query.Content) {
  93. session.And("content = ?", query.Content)
  94. }
  95. if query.State > 0 {
  96. session.And("state = ?", query.State)
  97. }
  98. if !gotool.StrUtils.HasEmpty(query.HandlerTime) {
  99. session.And("handler_time = ?", query.HandlerTime)
  100. }
  101. if query.HandlerUser > 0 {
  102. session.And("handler_user = ?", query.HandlerUser)
  103. }
  104. if query.AssignUser > 0 {
  105. session.And("assign_user = ?", query.AssignUser)
  106. }
  107. if !gotool.StrUtils.HasEmpty(query.CreateBy) {
  108. session.And("create_by = ?", query.CreateBy)
  109. }
  110. if !gotool.StrUtils.HasEmpty(query.UpdateBy) {
  111. session.And("update_by = ?", query.UpdateBy)
  112. }
  113. if !gotool.StrUtils.HasEmpty(query.Remark) {
  114. session.And("remark = ?", query.Remark)
  115. }
  116. if !gotool.StrUtils.HasEmpty(query.BeginTime) {
  117. session.And("date_format(u.create_time,'%y%m%d') >= date_format(?,'%y%m%d')", query.BeginTime)
  118. }
  119. if !gotool.StrUtils.HasEmpty(query.EndTime) {
  120. session.And("date_format(u.create_time,'%y%m%d') <= date_format(?,'%y%m%d')", query.EndTime)
  121. }
  122. session.Desc("id")
  123. err := session.Find(list)
  124. if err != nil {
  125. frame.Throw(frame.SQL_CODE, "数据查询错误"+err.Error())
  126. }
  127. }