package dao import ( "github.com/druidcaesa/gotool" "ulink-admin/frame" "ulink-admin/modules/car/models/model" "ulink-admin/modules/car/models/req" "ulink-admin/pkg/base" "ulink-admin/pkg/page" ) type ComplaintDao struct { base.BaseDao } // Page 查询投诉管理分页数据 func (this ComplaintDao) Page(query *req.ComplaintQuery, list interface{}) int64 { session := this.GetSession().Table(model.Complaint{}.TableName()) if query.Id > 0 { session.And("id = ?", query.Id) } if !gotool.StrUtils.HasEmpty(query.CarNo) { session.And("car_no = ?", query.CarNo) } if !gotool.StrUtils.HasEmpty(query.Company) { session.And("company = ?", query.Company) } if !gotool.StrUtils.HasEmpty(query.Contacts) { session.And("contacts = ?", query.Contacts) } if !gotool.StrUtils.HasEmpty(query.Phone) { session.And("phone = ?", query.Phone) } if !gotool.StrUtils.HasEmpty(query.OldContent) { session.And("old_content = ?", query.OldContent) } if !gotool.StrUtils.HasEmpty(query.Content) { session.And("content = ?", query.Content) } if query.State > 0 { session.And("state = ?", query.State) } if !gotool.StrUtils.HasEmpty(query.HandlerTime) { session.And("handler_time = ?", query.HandlerTime) } if query.HandlerUser > 0 { session.And("handler_user = ?", query.HandlerUser) } if query.AssignUser > 0 { session.And("assign_user = ?", query.AssignUser) } if !gotool.StrUtils.HasEmpty(query.CreateBy) { session.And("create_by = ?", query.CreateBy) } if !gotool.StrUtils.HasEmpty(query.UpdateBy) { session.And("update_by = ?", query.UpdateBy) } if !gotool.StrUtils.HasEmpty(query.Remark) { session.And("remark = ?", query.Remark) } if !gotool.StrUtils.HasEmpty(query.BeginTime) { session.And("date_format(u.create_time,'%y%m%d') >= date_format(?,'%y%m%d')", query.BeginTime) } if !gotool.StrUtils.HasEmpty(query.EndTime) { session.And("date_format(u.create_time,'%y%m%d') <= date_format(?,'%y%m%d')", query.EndTime) } session.Desc("id") total, err := session.Limit(query.PageSize, page.StartSize(query.PageNum, query.PageSize)).FindAndCount(list) if err != nil { frame.Throw(frame.SQL_CODE, "数据查询错误"+err.Error()) } return total } // List 查询投诉管理分页数据 func (this ComplaintDao) List(query *req.ComplaintQuery, list interface{}) { session := this.GetSession().Table(model.Complaint{}.TableName()) if query.Id > 0 { session.And("id = ?", query.Id) } if !gotool.StrUtils.HasEmpty(query.CarNo) { session.And("car_no = ?", query.CarNo) } if !gotool.StrUtils.HasEmpty(query.Company) { session.And("company = ?", query.Company) } if !gotool.StrUtils.HasEmpty(query.Contacts) { session.And("contacts = ?", query.Contacts) } if !gotool.StrUtils.HasEmpty(query.Phone) { session.And("phone = ?", query.Phone) } if !gotool.StrUtils.HasEmpty(query.OldContent) { session.And("old_content = ?", query.OldContent) } if !gotool.StrUtils.HasEmpty(query.Content) { session.And("content = ?", query.Content) } if query.State > 0 { session.And("state = ?", query.State) } if !gotool.StrUtils.HasEmpty(query.HandlerTime) { session.And("handler_time = ?", query.HandlerTime) } if query.HandlerUser > 0 { session.And("handler_user = ?", query.HandlerUser) } if query.AssignUser > 0 { session.And("assign_user = ?", query.AssignUser) } if !gotool.StrUtils.HasEmpty(query.CreateBy) { session.And("create_by = ?", query.CreateBy) } if !gotool.StrUtils.HasEmpty(query.UpdateBy) { session.And("update_by = ?", query.UpdateBy) } if !gotool.StrUtils.HasEmpty(query.Remark) { session.And("remark = ?", query.Remark) } if !gotool.StrUtils.HasEmpty(query.BeginTime) { session.And("date_format(u.create_time,'%y%m%d') >= date_format(?,'%y%m%d')", query.BeginTime) } if !gotool.StrUtils.HasEmpty(query.EndTime) { session.And("date_format(u.create_time,'%y%m%d') <= date_format(?,'%y%m%d')", query.EndTime) } session.Desc("id") err := session.Find(list) if err != nil { frame.Throw(frame.SQL_CODE, "数据查询错误"+err.Error()) } }