fix
wangpengfei
2023-07-25 da23babe80de0d32e736e8777430ddfbf185373a
fix

fix add the pageInfo, keyword to contact list
10个文件已修改
202 ■■■■ 已修改文件
api/v1/contact.go 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesLeads.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contacts.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contact.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/contact.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/contact.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/contact.go
@@ -66,30 +66,6 @@
    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
@@ -168,3 +144,30 @@
    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, &params)
    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),
    })
}
api/v1/salesLeads.go
@@ -105,7 +105,7 @@
//    @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 {
docs/docs.go
@@ -1095,7 +1095,7 @@
            }
        },
        "/api/contact/list": {
            "get": {
            "post": {
                "produces": [
                    "application/json"
                ],
@@ -1103,6 +1103,17 @@
                    "Contact"
                ],
                "summary": "联系人列表",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetContactList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
@@ -4816,7 +4827,7 @@
            }
        },
        "/api/salesLeads/list": {
            "get": {
            "post": {
                "produces": [
                    "application/json"
                ],
@@ -9703,6 +9714,22 @@
                }
            }
        },
        "request.GetContactList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.GetUserList": {
            "type": "object",
            "properties": {
@@ -11813,6 +11840,9 @@
        "response.ContactResponse": {
            "type": "object",
            "properties": {
                "count": {
                    "type": "integer"
                },
                "list": {
                    "type": "array",
                    "items": {
docs/swagger.json
@@ -1083,7 +1083,7 @@
            }
        },
        "/api/contact/list": {
            "get": {
            "post": {
                "produces": [
                    "application/json"
                ],
@@ -1091,6 +1091,17 @@
                    "Contact"
                ],
                "summary": "联系人列表",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetContactList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
@@ -4804,7 +4815,7 @@
            }
        },
        "/api/salesLeads/list": {
            "get": {
            "post": {
                "produces": [
                    "application/json"
                ],
@@ -9691,6 +9702,22 @@
                }
            }
        },
        "request.GetContactList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.GetUserList": {
            "type": "object",
            "properties": {
@@ -11801,6 +11828,9 @@
        "response.ContactResponse": {
            "type": "object",
            "properties": {
                "count": {
                    "type": "integer"
                },
                "list": {
                    "type": "array",
                    "items": {
docs/swagger.yaml
@@ -1907,6 +1907,17 @@
      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:
@@ -3318,6 +3329,8 @@
    type: object
  response.ContactResponse:
    properties:
      count:
        type: integer
      list:
        items:
          $ref: '#/definitions/model.ContactDetail'
@@ -4475,7 +4488,14 @@
      tags:
      - Contact
  /api/contact/list:
    get:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.GetContactList'
      produces:
      - application/json
      responses:
@@ -6760,7 +6780,7 @@
      tags:
      - SalesLeads
  /api/salesLeads/list:
    get:
    post:
      produces:
      - application/json
      responses:
model/contacts.go
@@ -26,7 +26,12 @@
    ContactSearch struct {
        Contact
        Orm *gorm.DB
        Orm      *gorm.DB
        Keyword  string
        OrderBy  string
        PageNum  int
        PageSize int
    }
    ContactDetail struct {
@@ -51,6 +56,9 @@
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)
    }
@@ -137,3 +145,18 @@
    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
}
model/request/contact.go
@@ -26,3 +26,8 @@
    Id int `json:"id"`
    Contact
}
type GetContactList struct {
    PageInfo
    Keyword string `json:"keyword"`
}
model/response/response.go
@@ -47,7 +47,8 @@
    }
    ContactResponse struct {
        List []*model.ContactDetail `json:"list"`
        List  []*model.ContactDetail `json:"list"`
        Count int                    `json:"count"`
    }
    ClientResponse struct {
@@ -182,7 +183,6 @@
        // 币种
        Currency []*model.Currency `json:"currency"`
        // 报价单状态
        QuotationStatus []*model.QuotationStatus `json:"quotationStatus"`
@@ -328,4 +328,4 @@
    CurrencyResponse struct {
        List []*model.Currency `json:"list"`
    }
)
)
router/contact.go
@@ -14,6 +14,6 @@
        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)            // 获取联系人列表
    }
}
}
service/contact.go
@@ -48,14 +48,6 @@
    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
@@ -125,3 +117,12 @@
    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
}