fix
fix add the pageInfo, keyword to contact list
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Contact |
| | | // @Summary 联系人列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.ContactResponse} |
| | | // @Router /api/contact/list [get] |
| | | func (con *ContactApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | contacts, errCode := contactService.GetContactList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ContactResponse{ |
| | | List: contacts, |
| | | }) |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags Contact |
| | |
| | | contact.IsFirst = params.IsFirst |
| | | return ecode.OK, contact |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Contact |
| | | // @Summary 联系人列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetContactList true "参数" |
| | | // @Success 200 {object} contextx.Response{data=response.ContactResponse} |
| | | // @Router /api/contact/list [post] |
| | | func (con *ContactApi) List(c *gin.Context) { |
| | | var params request.GetContactList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | contacts, errCode := contactService.GetContactList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ContactResponse{ |
| | | List: contacts, |
| | | Count: len(contacts), |
| | | }) |
| | | } |
| | |
| | | // @Summary 获取销售线索列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SalesLeadsResponse} |
| | | // @Router /api/salesLeads/list [get] |
| | | // @Router /api/salesLeads/list [post] |
| | | func (s *SalesLeadsApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | |
| | | } |
| | | }, |
| | | "/api/contact/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "Contact" |
| | | ], |
| | | "summary": "联系人列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetContactList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | }, |
| | | "/api/salesLeads/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetContactList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetUserList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.ContactResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "count": { |
| | | "type": "integer" |
| | | }, |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | } |
| | | }, |
| | | "/api/contact/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "Contact" |
| | | ], |
| | | "summary": "联系人列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetContactList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | } |
| | | }, |
| | | "/api/salesLeads/list": { |
| | | "get": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetContactList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetUserList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.ContactResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "count": { |
| | | "type": "integer" |
| | | }, |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | |
| | | topic: |
| | | type: string |
| | | type: object |
| | | request.GetContactList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetUserList: |
| | | properties: |
| | | keyword: |
| | |
| | | type: object |
| | | response.ContactResponse: |
| | | properties: |
| | | count: |
| | | type: integer |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ContactDetail' |
| | |
| | | tags: |
| | | - Contact |
| | | /api/contact/list: |
| | | get: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.GetContactList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | tags: |
| | | - SalesLeads |
| | | /api/salesLeads/list: |
| | | get: |
| | | post: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | |
| | | ContactSearch struct { |
| | | Contact |
| | | Orm *gorm.DB |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | |
| | | ContactDetail struct { |
| | |
| | | |
| | | func (slf *ContactSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Contact{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | |
| | | func (slf *ContactSearch) SetKeyword(keyword string) *ContactSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ContactSearch) SetPage(page, size int) *ContactSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ContactSearch) SetOrder(order string) *ContactSearch { |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | |
| | | Id int `json:"id"` |
| | | Contact |
| | | } |
| | | |
| | | type GetContactList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | |
| | | } |
| | | |
| | | ContactResponse struct { |
| | | List []*model.ContactDetail `json:"list"` |
| | | List []*model.ContactDetail `json:"list"` |
| | | Count int `json:"count"` |
| | | } |
| | | |
| | | ClientResponse struct { |
| | |
| | | |
| | | // 币种 |
| | | Currency []*model.Currency `json:"currency"` |
| | | |
| | | |
| | | // 报价单状态 |
| | | QuotationStatus []*model.QuotationStatus `json:"quotationStatus"` |
| | |
| | | CurrencyResponse struct { |
| | | List []*model.Currency `json:"list"` |
| | | } |
| | | ) |
| | | ) |
| | |
| | | contactRouter.POST("add", contactApi.Add) // 添加联系人 |
| | | contactRouter.DELETE("delete/:id", contactApi.Delete) // 删除联系人 |
| | | contactRouter.PUT("update", contactApi.Update) // 更新联系人 |
| | | contactRouter.GET("list", contactApi.List) // 获取联系人列表 |
| | | contactRouter.POST("list", contactApi.List) // 获取联系人列表 |
| | | } |
| | | } |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContactService) GetContactList() ([]*model.ContactDetail, int) { |
| | | // get contact list |
| | | contacts, err := model.NewContactSearch(nil).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ContactListErr |
| | | } |
| | | return contacts, ecode.OK |
| | | } |
| | | |
| | | func (ContactService) UpdateContact(contact *model.Contact) int { |
| | | // check contact exist |
| | |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContactService) GetContactList(page, pageSize int, keyword string) ([]*model.ContactDetail, int) { |
| | | // get contact list |
| | | contacts, err := model.NewContactSearch(nil).SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ContactListErr |
| | | } |
| | | return contacts, ecode.OK |
| | | } |