xu 2 months ago
parent
commit
9a7459693b
4 changed files with 7 additions and 2 deletions
  1. 0 0
      go.sum
  2. 5 1
      server/dao/crm/customer.go
  3. 1 0
      server/model/common/request/common.go
  4. 1 1
      server/service/crm/customer.go

+ 0 - 0
go.sum


+ 5 - 1
server/dao/crm/customer.go

@@ -26,13 +26,17 @@ func QueryAllCustomers() (customers []Customer, err error) {
 	return customers, err
 }
 
-func QueryCustomerList(limit, offset int, name string) (customers []Customer, total int64, err error) {
+func QueryCustomerList(limit, offset, genre int, name string) (customers []Customer, total int64, err error) {
 	db := global.GVA_DB.Model(&Customer{})
 
 	if name != "" {
 		db = db.Where("name LIKE ?", "%"+name+"%")
 	}
 
+	if genre != 0 {
+		db = db.Where("genre = ?", genre)
+	}
+
 	err = db.Count(&total).Error
 	if err != nil {
 		return

+ 1 - 0
server/model/common/request/common.go

@@ -140,6 +140,7 @@ type SearchWarehouse struct {
 
 type SearchCustomer struct {
 	PageInfo PageInfo `json:"pageInfo" form:"pageInfo"`
+	Genre    int      `json:"genre" form:"genre"`
 	Name     string   `json:"name" form:"name"`
 }
 

+ 1 - 1
server/service/crm/customer.go

@@ -14,7 +14,7 @@ func (cs *CustomerService) QueryAllCustomers() ([]crm.Customer, error) {
 func (cs *CustomerService) QueryCustomerList(info request.SearchCustomer) (customers []crm.Customer, total int64, err error) {
 	limit := info.PageInfo.PageSize
 	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
-	return crm.QueryCustomerList(limit, offset, info.Name)
+	return crm.QueryCustomerList(limit, offset, info.Genre, info.Name)
 }
 
 func (cs *CustomerService) CreateCustomer(customer crm.Customer) error {