fix
fix the total number client
| | |
| | | return |
| | | } |
| | | |
| | | clients, errCode := clientService.GetClientList(params.Page, params.PageSize, params.Keyword) |
| | | clients, total, errCode := clientService.GetClientList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | |
| | | ctx.OkWithDetailed(response.ClientResponse{ |
| | | List: clients, |
| | | Count: len(clients), |
| | | Count: int(total), |
| | | }) |
| | | } |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags FollowRecord |
| | |
| | | // List |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 跟进记录列表 |
| | | // @Summary 回访记录列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetFollowRecordList true "参数" |
| | | // @Success 200 {object} contextx.Response{data=response.FollowRecordResponse} |
| | | // @Router /api/followRecord/list [post] |
| | | func (con *FollowRecordApi) List(c *gin.Context) { |
| | | func (fr *FollowRecordApi) List(c *gin.Context) { |
| | | var params request.GetFollowRecordList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | |
| | | "tags": [ |
| | | "FollowRecord" |
| | | ], |
| | | "summary": "跟进记录列表", |
| | | "summary": "回访记录列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | "tags": [ |
| | | "FollowRecord" |
| | | ], |
| | | "summary": "跟进记录列表", |
| | | "summary": "回访记录列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | data: |
| | | $ref: '#/definitions/response.FollowRecordResponse' |
| | | type: object |
| | | summary: 跟进记录列表 |
| | | summary: 回访记录列表 |
| | | tags: |
| | | - FollowRecord |
| | | /api/followRecord/update: |
| | |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | |
| | | } |
| | | ) |
| | | |
| | |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ClientSearch) Find() ([]*Client, error) { |
| | | func (slf *ClientSearch) Find() ([]*Client, int64, error) { |
| | | var db = slf.build() |
| | | var records = make([]*Client, 0) |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | var total int64 |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, err |
| | | } |
| | | |
| | | err := db.Preload("ClientStatus").Preload("ClientType").Preload("ClientOrigin").Preload("ClientLevel").Preload("FollowRecord").Preload("EnterpriseNature").Preload("RegisteredCapital").Preload("Industry").Preload("EnterpriseScale").Preload("Contacts").Preload("Country").Preload("Province").Preload("City").Preload("Region").Find(&records).Error |
| | | return records, err |
| | | return records, total, err |
| | | } |
| | | |
| | | func (slf *ClientSearch) UpdateByMap(data map[string]interface{}) error { |
| | |
| | | func (slf *FollowRecordSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&FollowRecord{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Keyword != "" { |
| | | db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Find() ([]*FollowRecord, error) { |
| | | var db = slf.build() |
| | | var records = make([]*FollowRecord, 0) |
| | | err := slf.build().Preload("Client").Preload("Contact").Find(&records).Error |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Client").Preload("Contact").Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ClientService) GetClientList(page, pageSize int, keyword string) ([]*model.Client, int) { |
| | | func (ClientService) GetClientList(page, pageSize int, keyword string) ([]*model.Client, int64, int) { |
| | | // get contact list |
| | | contacts, err := model.NewClientSearch(nil).SetKeyword(keyword).SetPage(page, pageSize).Find() |
| | | contacts, total, err := model.NewClientSearch(nil).SetKeyword(keyword).SetPage(page, pageSize).Find() |
| | | if err != nil { |
| | | return nil, ecode.ClientListErr |
| | | return nil, 0, ecode.ClientListErr |
| | | } |
| | | return contacts, ecode.OK |
| | | return contacts, total, ecode.OK |
| | | } |