New file |
| | |
| | | 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, |
| | | }) |
| | | } |
| | |
| | | SatisfactionApi |
| | | AssignApi |
| | | CollectionProjectionApi |
| | | ContactInformationApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | currencyService = service.ServiceGroup.CurrencyService |
| | | assignService = service.ServiceGroup.AssignService |
| | | collectionProjectionService = service.ServiceGroup.CollectionProjectionService |
| | | contactInformationService = service.ServiceGroup.ContactInformationService |
| | | ) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ContactInformation": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ContactInformationResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ContactInformation" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ContactResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ContactInformation": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ContactInformationResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ContactInformation" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ContactResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | wechat: |
| | | type: string |
| | | type: object |
| | | model.ContactInformation: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Contract: |
| | | properties: |
| | | _: |
| | |
| | | $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: |
| | |
| | | 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: |
New file |
| | |
| | | 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 |
| | | } |
| | |
| | | QuotationStatus{}, |
| | | Currency{}, |
| | | CollectionProjection{}, |
| | | ContactInformation{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | type GetContactInformationList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | |
| | | List []*model.CollectionProjection `json:"list"` |
| | | Count int `json:"count"` |
| | | } |
| | | |
| | | ContactInformationResponse struct { |
| | | List []*model.ContactInformation `json:"list"` |
| | | } |
| | | ) |
| | |
| | | CollectionProjectionListErr = 5800003 // 获取收款预测列表失败 |
| | | CollectionProjectionSetErr = 5800004 // 设置收款预测失败 |
| | | CollectionProjectionUpdateErr = 5800005 // 更新收款预测失败 |
| | | |
| | | ContactInformationListErr = 5900001 // 获取联系信息列表失败 |
| | | ) |
New file |
| | |
| | | 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) // 设置联系方式 |
| | | } |
| | | } |
| | |
| | | SatisfactionRouter |
| | | AssignRouter |
| | | CollectionProjectionRouter |
| | | ContactInformationRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | InitCourierCompanyRouter(PrivateGroup) |
| | | InitProductRouter(PrivateGroup) |
| | | routerGroup.InitCollectionProjectionRouter(PrivateGroup) |
| | | routerGroup.InitContactInformationRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | 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 |
| | | } |
| | |
| | | CurrencyService |
| | | AssignService |
| | | CollectionProjectionService |
| | | ContactInformationService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |