From a53591167bf111ffc0eb2cb129aa7ff8b4cb470d Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 15 八月 2023 19:34:22 +0800
Subject: [PATCH] add
---
api/v1/index.go | 2
service/contactInformation.go | 17 ++
pkg/ecode/code.go | 2
docs/swagger.yaml | 31 +++++
docs/docs.go | 53 ++++++++
docs/swagger.json | 53 ++++++++
model/response/response.go | 4
api/v1/contactInformation.go | 34 +++++
service/index.go | 1
model/index.go | 1
router/contactInformation.go | 20 +++
router/index.go | 2
model/contactInformation.go | 80 +++++++++++++
model/request/contactInformation.go | 6 +
14 files changed, 306 insertions(+), 0 deletions(-)
diff --git a/api/v1/contactInformation.go b/api/v1/contactInformation.go
new file mode 100644
index 0000000..72c7354
--- /dev/null
+++ b/api/v1/contactInformation.go
@@ -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,
+ })
+}
diff --git a/api/v1/index.go b/api/v1/index.go
index b1d7c1e..b7d9326 100644
--- a/api/v1/index.go
+++ b/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
)
diff --git a/docs/docs.go b/docs/docs.go
index d451ef2..6282947 100644
--- a/docs/docs.go
+++ b/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": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 67ea090..68d2743 100644
--- a/docs/swagger.json
+++ b/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": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 9952676..cafe058 100644
--- a/docs/swagger.yaml
+++ b/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:
diff --git a/model/contactInformation.go b/model/contactInformation.go
new file mode 100644
index 0000000..1ae901d
--- /dev/null
+++ b/model/contactInformation.go
@@ -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
+}
diff --git a/model/index.go b/model/index.go
index 0da8fa8..340ce2b 100644
--- a/model/index.go
+++ b/model/index.go
@@ -84,6 +84,7 @@
QuotationStatus{},
Currency{},
CollectionProjection{},
+ ContactInformation{},
)
return err
}
diff --git a/model/request/contactInformation.go b/model/request/contactInformation.go
new file mode 100644
index 0000000..159a513
--- /dev/null
+++ b/model/request/contactInformation.go
@@ -0,0 +1,6 @@
+package request
+
+type GetContactInformationList struct {
+ PageInfo
+ Keyword string `json:"keyword"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index cc15773..0c6991f 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -349,4 +349,8 @@
List []*model.CollectionProjection `json:"list"`
Count int `json:"count"`
}
+
+ ContactInformationResponse struct {
+ List []*model.ContactInformation `json:"list"`
+ }
)
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index efc2052..3ef1e48 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -400,4 +400,6 @@
CollectionProjectionListErr = 5800003 // 鑾峰彇鏀舵棰勬祴鍒楄〃澶辫触
CollectionProjectionSetErr = 5800004 // 璁剧疆鏀舵棰勬祴澶辫触
CollectionProjectionUpdateErr = 5800005 // 鏇存柊鏀舵棰勬祴澶辫触
+
+ ContactInformationListErr = 5900001 // 鑾峰彇鑱旂郴淇℃伅鍒楄〃澶辫触
)
diff --git a/router/contactInformation.go b/router/contactInformation.go
new file mode 100644
index 0000000..264ac8e
--- /dev/null
+++ b/router/contactInformation.go
@@ -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) // 璁剧疆鑱旂郴鏂瑰紡
+ }
+}
diff --git a/router/index.go b/router/index.go
index 8f21017..a85ca58 100644
--- a/router/index.go
+++ b/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
}
diff --git a/service/contactInformation.go b/service/contactInformation.go
new file mode 100644
index 0000000..398434e
--- /dev/null
+++ b/service/contactInformation.go
@@ -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
+}
diff --git a/service/index.go b/service/index.go
index e76998e..4fed338 100644
--- a/service/index.go
+++ b/service/index.go
@@ -62,6 +62,7 @@
CurrencyService
AssignService
CollectionProjectionService
+ ContactInformationService
}
var ServiceGroup = new(Group)
--
Gitblit v1.8.0