add
add the pageInfo, keyword to follow list
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 获取跟进记录列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.FollowRecordResponse} |
| | | // @Router /api/followRecord/list [get] |
| | | func (fr *FollowRecordApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, followRecordList := followRecordService.GetFollowRecordList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.FollowRecordResponse{ |
| | | List: followRecordList, |
| | | }) |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | |
| | | |
| | | return time.Time{}, err |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags FollowRecord |
| | | // @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) { |
| | | var params request.GetFollowRecordList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | followRecords, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.FollowRecordResponse{ |
| | | List: followRecords, |
| | | Count: len(followRecords), |
| | | }) |
| | | } |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | |
| | | func checkSalesLeadsParams(params request.SalesLeads) (errCode int, salesLeads model.SalesLeads) { |
| | | //if params.Name == "" { |
| | | // return ecode.InvalidParams, salesLeads |
| | |
| | | // @Param object body request.GetSalesLeadsList true "参数" |
| | | // @Success 200 {object} contextx.Response{data=response.SalesLeadsResponse} |
| | | // @Router /api/salesLeads/list [post] |
| | | func (con *SalesLeadsApi) List(c *gin.Context) { |
| | | func (s *SalesLeadsApi) List(c *gin.Context) { |
| | | var params request.GetSalesLeadsList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SalesLeadsResponse{ |
| | | List: salesLeadss, |
| | | List: salesLeadss, |
| | | Count: len(salesLeadss), |
| | | }) |
| | | } |
| | |
| | | } |
| | | }, |
| | | "/api/followRecord/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "FollowRecord" |
| | | ], |
| | | "summary": "获取跟进记录列表", |
| | | "summary": "跟进记录列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetFollowRecordList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetFollowRecordList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetSalesLeadsList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.FollowRecordResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "count": { |
| | | "type": "integer" |
| | | }, |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | } |
| | | }, |
| | | "/api/followRecord/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "FollowRecord" |
| | | ], |
| | | "summary": "获取跟进记录列表", |
| | | "summary": "跟进记录列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetFollowRecordList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetFollowRecordList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetSalesLeadsList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.FollowRecordResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "count": { |
| | | "type": "integer" |
| | | }, |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetFollowRecordList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetSalesLeadsList: |
| | | properties: |
| | | keyword: |
| | |
| | | type: object |
| | | response.FollowRecordResponse: |
| | | properties: |
| | | count: |
| | | type: integer |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.FollowRecord' |
| | |
| | | tags: |
| | | - FollowRecord |
| | | /api/followRecord/list: |
| | | get: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.GetFollowRecordList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | data: |
| | | $ref: '#/definitions/response.FollowRecordResponse' |
| | | type: object |
| | | summary: 获取跟进记录列表 |
| | | summary: 跟进记录列表 |
| | | tags: |
| | | - FollowRecord |
| | | /api/followRecord/update: |
| | |
| | | |
| | | FollowRecordSearch struct { |
| | | FollowRecord |
| | | Orm *gorm.DB |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *FollowRecordSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&FollowRecord{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | |
| | | slf.ClientId = clientId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetKeyword(keyword string) *FollowRecordSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetPage(page, size int) *FollowRecordSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetOrder(order string) *FollowRecordSearch { |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | FollowRecord FollowRecord `json:"follow_record" binding:"required"` |
| | | } |
| | | |
| | | type GetFollowRecordList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | |
| | | } |
| | | |
| | | FollowRecordResponse struct { |
| | | List []*model.FollowRecord `json:"list"` |
| | | List []*model.FollowRecord `json:"list"` |
| | | Count int `json:"count"` |
| | | } |
| | | |
| | | SaleChanceResponse struct { |
| | |
| | | followRecordRouter.POST("add", followRecordApi.Add) // 添加跟进记录 |
| | | followRecordRouter.DELETE("delete/:id", followRecordApi.Delete) // 删除跟进记录 |
| | | followRecordRouter.PUT("update", followRecordApi.Update) // 更新跟进记录 |
| | | followRecordRouter.GET("list", followRecordApi.List) // 获取跟进记录列表 |
| | | followRecordRouter.POST("list", followRecordApi.List) // 获取跟进记录列表 |
| | | } |
| | | } |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (FollowRecordService) GetFollowRecordList() (int, []*model.FollowRecord) { |
| | | // get followRecord list |
| | | followRecords, err := model.NewFollowRecordSearch().Find() |
| | | if err != nil { |
| | | return ecode.FollowRecordListErr, nil |
| | | } |
| | | |
| | | return ecode.OK, followRecords |
| | | } |
| | | |
| | | // check followRecord exist |
| | | func checkFollowRecordExist(id int) int { |
| | | _, err := model.NewFollowRecordSearch().SetId(id).First() |
| | |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int) { |
| | | // get contact list |
| | | contacts, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).Find() |
| | | if err != nil { |
| | | return nil, ecode.FollowRecordListErr |
| | | } |
| | | return contacts, ecode.OK |
| | | } |