add
wangpengfei
2023-08-15 a53591167bf111ffc0eb2cb129aa7ff8b4cb470d
add

contact Information
5个文件已添加
9个文件已修改
306 ■■■■■ 已修改文件
api/v1/contactInformation.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contactInformation.go 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contactInformation.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/contactInformation.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/contactInformation.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/contactInformation.go
New file
@@ -0,0 +1,34 @@
package v1
import (
    "aps_crm/model/response"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "github.com/gin-gonic/gin"
)
type ContactInformationApi struct{}
// List
//
//    @Tags        ContactInformation
//    @Summary    联系方式列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{data=response.ContactInformationResponse}
//    @Router        /api/contactInformation/list [get]
func (con *ContactInformationApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    contactInformations, errCode := contactInformationService.GetContactInformationList()
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.ContactInformationResponse{
        List: contactInformations,
    })
}
api/v1/index.go
@@ -66,6 +66,7 @@
    SatisfactionApi
    AssignApi
    CollectionProjectionApi
    ContactInformationApi
}
var ApiGroup = new(Group)
@@ -132,4 +133,5 @@
    currencyService              = service.ServiceGroup.CurrencyService
    assignService                = service.ServiceGroup.AssignService
    collectionProjectionService  = service.ServiceGroup.CollectionProjectionService
    contactInformationService    = service.ServiceGroup.ContactInformationService
)
docs/docs.go
@@ -1525,6 +1525,37 @@
                }
            }
        },
        "/api/contactInformation/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ContactInformation"
                ],
                "summary": "联系方式列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ContactInformationResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/contract/add": {
            "post": {
                "produces": [
@@ -10940,6 +10971,17 @@
                }
            }
        },
        "model.ContactInformation": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.Contract": {
            "type": "object",
            "properties": {
@@ -17872,6 +17914,17 @@
                }
            }
        },
        "response.ContactInformationResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ContactInformation"
                    }
                }
            }
        },
        "response.ContactResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -1513,6 +1513,37 @@
                }
            }
        },
        "/api/contactInformation/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ContactInformation"
                ],
                "summary": "联系方式列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ContactInformationResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/contract/add": {
            "post": {
                "produces": [
@@ -10928,6 +10959,17 @@
                }
            }
        },
        "model.ContactInformation": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.Contract": {
            "type": "object",
            "properties": {
@@ -17860,6 +17902,17 @@
                }
            }
        },
        "response.ContactInformationResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ContactInformation"
                    }
                }
            }
        },
        "response.ContactResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -679,6 +679,13 @@
      wechat:
        type: string
    type: object
  model.ContactInformation:
    properties:
      id:
        type: integer
      name:
        type: string
    type: object
  model.Contract:
    properties:
      _:
@@ -5375,6 +5382,13 @@
          $ref: '#/definitions/model.ClientType'
        type: array
    type: object
  response.ContactInformationResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.ContactInformation'
        type: array
    type: object
  response.ContactResponse:
    properties:
      count:
@@ -6850,6 +6864,23 @@
      summary: 更新联系人
      tags:
      - Contact
  /api/contactInformation/list:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.ContactInformationResponse'
              type: object
      summary: 联系方式列表
      tags:
      - ContactInformation
  /api/contract/add:
    post:
      parameters:
model/contactInformation.go
New file
@@ -0,0 +1,80 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    ContactInformation struct {
        Id   int    `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null"`
        Name string `json:"name" gorm:"column:name;type:varchar(255);comment:名称"`
    }
    ContactInformationSearch struct {
        ContactInformation
        Orm *gorm.DB
    }
)
func (ContactInformation) TableName() string {
    return "contact_information"
}
func NewContactInformationSearch() *ContactInformationSearch {
    return &ContactInformationSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *ContactInformationSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ContactInformation{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    return db
}
// Create 创建
func (slf *ContactInformationSearch) Create(record []*ContactInformation) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *ContactInformationSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&ContactInformation{}).Error
}
func (slf *ContactInformationSearch) Update(record *ContactInformation) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *ContactInformationSearch) Find() ([]*ContactInformation, error) {
    var db = slf.build()
    var result []*ContactInformation
    err := db.Find(&result).Error
    return result, err
}
func (slf *ContactInformationSearch) FindOne() (*ContactInformation, error) {
    var db = slf.build()
    var result ContactInformation
    err := db.First(&result).Error
    return &result, err
}
func (slf *ContactInformationSearch) SetId(id int) *ContactInformationSearch {
    slf.Id = id
    return slf
}
func (slf *ContactInformationSearch) SetName(name string) *ContactInformationSearch {
    slf.Name = name
    return slf
}
model/index.go
@@ -84,6 +84,7 @@
        QuotationStatus{},
        Currency{},
        CollectionProjection{},
        ContactInformation{},
    )
    return err
}
model/request/contactInformation.go
New file
@@ -0,0 +1,6 @@
package request
type GetContactInformationList struct {
    PageInfo
    Keyword string `json:"keyword"`
}
model/response/response.go
@@ -349,4 +349,8 @@
        List  []*model.CollectionProjection `json:"list"`
        Count int                           `json:"count"`
    }
    ContactInformationResponse struct {
        List []*model.ContactInformation `json:"list"`
    }
)
pkg/ecode/code.go
@@ -400,4 +400,6 @@
    CollectionProjectionListErr   = 5800003 // 获取收款预测列表失败
    CollectionProjectionSetErr    = 5800004 // 设置收款预测失败
    CollectionProjectionUpdateErr = 5800005 // 更新收款预测失败
    ContactInformationListErr = 5900001 // 获取联系信息列表失败
)
router/contactInformation.go
New file
@@ -0,0 +1,20 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ContactInformationRouter struct{}
func (c *ContactInformationRouter) InitContactInformationRouter(router *gin.RouterGroup) {
    contactInformationRouter := router.Group("contactInformation")
    contactInformationApi := v1.ApiGroup.ContactInformationApi
    {
        //contactInformationRouter.POST("add", contactInformationApi.Add)             // 添加联系方式
        //contactInformationRouter.DELETE("delete/:id", contactInformationApi.Delete) // 删除联系方式
        //contactInformationRouter.PUT("update", contactInformationApi.Update)        // 更新联系方式
        contactInformationRouter.GET("list", contactInformationApi.List) // 获取联系方式列表
        //contactInformationRouter.PUT("set", contactInformationApi.Set)              // 设置联系方式
    }
}
router/index.go
@@ -71,6 +71,7 @@
    SatisfactionRouter
    AssignRouter
    CollectionProjectionRouter
    ContactInformationRouter
}
func InitRouter() *gin.Engine {
@@ -178,6 +179,7 @@
        InitCourierCompanyRouter(PrivateGroup)
        InitProductRouter(PrivateGroup)
        routerGroup.InitCollectionProjectionRouter(PrivateGroup)
        routerGroup.InitContactInformationRouter(PrivateGroup)
    }
    return Router
}
service/contactInformation.go
New file
@@ -0,0 +1,17 @@
package service
import (
    "aps_crm/model"
    "aps_crm/pkg/ecode"
)
type ContactInformationService struct{}
func (ContactInformationService) GetContactInformationList() ([]*model.ContactInformation, int) {
    // get contact list
    contacts, err := model.NewContactInformationSearch().Find()
    if err != nil {
        return nil, ecode.ContactInformationListErr
    }
    return contacts, ecode.OK
}
service/index.go
@@ -62,6 +62,7 @@
    CurrencyService
    AssignService
    CollectionProjectionService
    ContactInformationService
}
var ServiceGroup = new(Group)