From 8fab255a4509a7ec5bfc7439b6e352054d677e29 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 10 八月 2023 17:40:58 +0800 Subject: [PATCH] fix --- router/serviceOrder.go | 2 api/v1/serviceOrder.go | 4 docs/swagger.yaml | 66 ++---- service/serviceFollowup.go | 4 docs/docs.go | 88 +++----- docs/swagger.json | 88 +++----- model/serviceFollowup.go | 305 ++++++++++++++++-------------- 7 files changed, 264 insertions(+), 293 deletions(-) diff --git a/api/v1/serviceOrder.go b/api/v1/serviceOrder.go index e482d3c..1eec84f 100644 --- a/api/v1/serviceOrder.go +++ b/api/v1/serviceOrder.go @@ -99,9 +99,9 @@ // @Tags 鏈嶅姟鍗曠鐞� // @Summary 鑾峰彇鏈嶅姟鍗曞垪琛� // @Produce application/json -// @Param object query request.GetServiceOrderList true "鍙傛暟" +// @Param object body request.GetServiceOrderList true "鍙傛暟" // @Success 200 {object} response.ListResponse{data=[]model.ServiceOrder} -// @Router /api/serviceOrder/list [get] +// @Router /api/serviceOrder/list [post] func (s *ServiceOrderApi) List(c *gin.Context) { var params request.GetServiceOrderList ctx, ok := contextx.NewContext(c, ¶ms) diff --git a/docs/docs.go b/docs/docs.go index 5b72437..217dc9b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -8267,7 +8267,7 @@ } }, "/api/serviceOrder/list": { - "get": { + "post": { "produces": [ "application/json" ], @@ -8277,57 +8277,13 @@ "summary": "鑾峰彇鏈嶅姟鍗曞垪琛�", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "鏈嶅姟鍗曠紪鍙�", - "涓婚", - "瀹㈡埛鍚嶇О", - "瀹為檯澶勭悊鏃堕棿", - "鏈嶅姟浜哄憳", - "鏈嶅姟鏂瑰紡", - "浜у搧绫诲埆", - "鏁呴殰绫诲埆" - ], - "type": "string", - "x-enum-varnames": [ - "ServiceOrderKeywordOrderNumber", - "ServiceOrderKeywordSubject", - "ServiceOrderKeywordClientName", - "ServiceOrderKeywordRealProcessTime", - "ServiceOrderKeywordServiceMan", - "ServiceOrderKeywordServiceType", - "ServiceOrderKeywordProductType", - "ServiceOrderKeywordFaultType" - ], - "name": "keywordType", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "ServiceOrderQueryClassExpireLessThen60Days" - ], - "name": "queryClass", - "in": "query" + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetServiceOrderList" + } } ], "responses": { @@ -11820,8 +11776,14 @@ "model.ServiceFollowup": { "type": "object", "properties": { + "client": { + "$ref": "#/definitions/model.Client" + }, "clientId": { "type": "integer" + }, + "contact": { + "$ref": "#/definitions/model.Contact" }, "contactId": { "type": "integer" @@ -14374,6 +14336,28 @@ } } }, + "request.GetServiceOrderList": { + "type": "object", + "properties": { + "keyword": { + "type": "string" + }, + "keywordType": { + "$ref": "#/definitions/constvar.ServiceOrderKeywordType" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "queryClass": { + "$ref": "#/definitions/constvar.ServiceOrderQueryClass" + } + } + }, "request.GetSubOrderList": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 04fbdf9..84d5dbc 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -8255,7 +8255,7 @@ } }, "/api/serviceOrder/list": { - "get": { + "post": { "produces": [ "application/json" ], @@ -8265,57 +8265,13 @@ "summary": "鑾峰彇鏈嶅姟鍗曞垪琛�", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "鏈嶅姟鍗曠紪鍙�", - "涓婚", - "瀹㈡埛鍚嶇О", - "瀹為檯澶勭悊鏃堕棿", - "鏈嶅姟浜哄憳", - "鏈嶅姟鏂瑰紡", - "浜у搧绫诲埆", - "鏁呴殰绫诲埆" - ], - "type": "string", - "x-enum-varnames": [ - "ServiceOrderKeywordOrderNumber", - "ServiceOrderKeywordSubject", - "ServiceOrderKeywordClientName", - "ServiceOrderKeywordRealProcessTime", - "ServiceOrderKeywordServiceMan", - "ServiceOrderKeywordServiceType", - "ServiceOrderKeywordProductType", - "ServiceOrderKeywordFaultType" - ], - "name": "keywordType", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "ServiceOrderQueryClassExpireLessThen60Days" - ], - "name": "queryClass", - "in": "query" + "description": "鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetServiceOrderList" + } } ], "responses": { @@ -11808,8 +11764,14 @@ "model.ServiceFollowup": { "type": "object", "properties": { + "client": { + "$ref": "#/definitions/model.Client" + }, "clientId": { "type": "integer" + }, + "contact": { + "$ref": "#/definitions/model.Contact" }, "contactId": { "type": "integer" @@ -14362,6 +14324,28 @@ } } }, + "request.GetServiceOrderList": { + "type": "object", + "properties": { + "keyword": { + "type": "string" + }, + "keywordType": { + "$ref": "#/definitions/constvar.ServiceOrderKeywordType" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "queryClass": { + "$ref": "#/definitions/constvar.ServiceOrderQueryClass" + } + } + }, "request.GetSubOrderList": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index aa5fcc2..0cf171b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1436,8 +1436,12 @@ type: object model.ServiceFollowup: properties: + client: + $ref: '#/definitions/model.Client' clientId: type: integer + contact: + $ref: '#/definitions/model.Contact' contactId: type: integer customerServiceSheet: @@ -3185,6 +3189,21 @@ pageSize: description: 姣忛〉澶у皬 type: integer + type: object + request.GetServiceOrderList: + properties: + keyword: + type: string + keywordType: + $ref: '#/definitions/constvar.ServiceOrderKeywordType' + page: + description: 椤电爜 + type: integer + pageSize: + description: 姣忛〉澶у皬 + type: integer + queryClass: + $ref: '#/definitions/constvar.ServiceOrderQueryClass' type: object request.GetSubOrderList: properties: @@ -10540,47 +10559,14 @@ tags: - 鏈嶅姟鍗曠鐞� /api/serviceOrder/list: - get: + post: parameters: - - in: query - name: keyword - type: string - - enum: - - 鏈嶅姟鍗曠紪鍙� - - 涓婚 - - 瀹㈡埛鍚嶇О - - 瀹為檯澶勭悊鏃堕棿 - - 鏈嶅姟浜哄憳 - - 鏈嶅姟鏂瑰紡 - - 浜у搧绫诲埆 - - 鏁呴殰绫诲埆 - in: query - name: keywordType - type: string - x-enum-varnames: - - ServiceOrderKeywordOrderNumber - - ServiceOrderKeywordSubject - - ServiceOrderKeywordClientName - - ServiceOrderKeywordRealProcessTime - - ServiceOrderKeywordServiceMan - - ServiceOrderKeywordServiceType - - ServiceOrderKeywordProductType - - ServiceOrderKeywordFaultType - - description: 椤电爜 - in: query - name: page - type: integer - - description: 姣忛〉澶у皬 - in: query - name: pageSize - type: integer - - enum: - - "" - in: query - name: queryClass - type: string - x-enum-varnames: - - ServiceOrderQueryClassExpireLessThen60Days + - description: 鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.GetServiceOrderList' produces: - application/json responses: diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go index d2d4ada..917d2a5 100644 --- a/model/serviceFollowup.go +++ b/model/serviceFollowup.go @@ -1,145 +1,160 @@ -package model - -import ( - "aps_crm/constvar" - "aps_crm/pkg/mysqlx" - "gorm.io/gorm" -) - -type ( - ServiceFollowup struct { - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` - Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` - ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"` - ServiceId int `json:"serviceId" gorm:"column:service_id;type:int;comment:瀹㈡埛鏈嶅姟鍗昳d"` - ServiceOrder ServiceOrder `gorm:"foreignKey:ServiceId"` - CustomerServiceSheet CustomerServiceSheet `json:"customerServiceSheet" gorm:"foreignKey:ServiceId"` - MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:鏈嶅姟浜哄憳id"` - PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:鏈嶅姟璁″垝id"` - SatisfactionId int `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:婊℃剰搴d"` - TimelyRateId int `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:鍙婃椂鐜噄d"` - SolveRateId int `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:瑙e喅鐜噄d"` - IsVisitId int `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:鏈嶅姟浜哄憳鏄惁鏉ヨ繃id"` - OldMemberId int `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:鍘熸湇鍔′汉鍛�"` - Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"` - File string `json:"file" gorm:"column:file;type:varchar(255);comment:闄勪欢"` - - gorm.Model `json:"-"` - } - - ServiceFollowupSearch struct { - ServiceFollowup - Orm *gorm.DB - KeywordType constvar.ServiceFollowupKeywordType - Keyword interface{} - OrderBy string - PageNum int - PageSize int - } -) - -func (ServiceFollowup) TableName() string { - return "service_followup" -} - -func NewServiceFollowupSearch() *ServiceFollowupSearch { - return &ServiceFollowupSearch{ - Orm: mysqlx.GetDB(), - } -} - -func (slf *ServiceFollowupSearch) build() *gorm.DB { - var db = slf.Orm.Model(&ServiceFollowup{}) - if slf.Id != 0 { - db = db.Where("id = ?", slf.Id) - } - - switch slf.KeywordType { - case constvar.ServiceFollowupKeywordFollowupNo: - db = db.Where("number = ?", slf.Keyword) - case constvar.ServiceFollowupKeywordCustomerName: - db = db.Where("client_id = ?", slf.Keyword) - case constvar.ServiceFollowupKeywordContactName: - db = db.Where("contact_id = ?", slf.Keyword) - case constvar.ServiceFollowupKeywordCustomerServiceNo: - db = db.Where("service_id = ?", slf.Keyword) - case constvar.ServiceFollowupKeywordVisitor: - db = db.Where("member_id = ?", slf.Keyword) - case constvar.ServiceFollowupKeywordSatisfactionDegree: - db = db.Where("satisfaction_id = ?", slf.Keyword) - - } - - return db -} - -func (slf *ServiceFollowupSearch) Create(record *ServiceFollowup) error { - var db = slf.build() - return db.Create(record).Error -} - -func (slf *ServiceFollowupSearch) Update(record *ServiceFollowup) error { - var db = slf.build() - return db.Updates(record).Error -} - -func (slf *ServiceFollowupSearch) Delete() error { - var db = slf.build() - return db.Delete(&ServiceFollowup{}).Error -} - -func (slf *ServiceFollowupSearch) Find() (*ServiceFollowup, error) { - var db = slf.build() - var record = &ServiceFollowup{} - err := db.First(record).Error - return record, err -} - -func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, int64, error) { - var db = slf.build() - var records = make([]*ServiceFollowup, 0) - var total int64 - if err := db.Count(&total).Error; err != nil { - return records, total, err - } - if slf.PageNum > 0 && slf.PageSize > 0 { - db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) - } - - if slf.PageNum > 0 && slf.PageSize > 0 { - db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) - } - - err := db.Preload("CustomerServiceSheet").Preload("ServiceOrder").Find(&records).Error - return records, total, err -} - -func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch { - slf.Id = id - return slf -} - -func (slf *ServiceFollowupSearch) SetKeywordType(keyword constvar.ServiceFollowupKeywordType) *ServiceFollowupSearch { - slf.KeywordType = keyword - return slf -} - -func (slf *ServiceFollowupSearch) SetKeyword(keyword string) *ServiceFollowupSearch { - slf.Keyword = keyword - return slf -} - -func (slf *ServiceFollowupSearch) SetPage(page, size int) *ServiceFollowupSearch { - slf.PageNum, slf.PageSize = page, size - return slf -} - -func (slf *ServiceFollowupSearch) SetOrder(order string) *ServiceFollowupSearch { - slf.OrderBy = order - return slf -} -func (slf *ServiceFollowupSearch) SetIds(ids []int) *ServiceFollowupSearch { - slf.Orm = slf.Orm.Where("id in (?)", ids) - return slf -} +package model + +import ( + "aps_crm/constvar" + "aps_crm/pkg/mysqlx" + "gorm.io/gorm" +) + +type ( + ServiceFollowup struct { + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` + Client Client `json:"client" gorm:"foreignKey:ClientId"` + Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` + ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"` + Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` + ServiceId int `json:"serviceId" gorm:"column:service_id;type:int;comment:瀹㈡埛鏈嶅姟鍗昳d"` + ServiceOrder ServiceOrder `gorm:"foreignKey:ServiceId"` + CustomerServiceSheet CustomerServiceSheet `json:"customerServiceSheet" gorm:"foreignKey:ServiceId"` + MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:鏈嶅姟浜哄憳id"` + PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:鏈嶅姟璁″垝id"` + SatisfactionId int `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:婊℃剰搴d"` + TimelyRateId int `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:鍙婃椂鐜噄d"` + SolveRateId int `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:瑙e喅鐜噄d"` + IsVisitId int `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:鏈嶅姟浜哄憳鏄惁鏉ヨ繃id"` + OldMemberId int `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:鍘熸湇鍔′汉鍛�"` + Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"` + File string `json:"file" gorm:"column:file;type:varchar(255);comment:闄勪欢"` + + gorm.Model `json:"-"` + } + + ServiceFollowupSearch struct { + ServiceFollowup + Orm *gorm.DB + KeywordType constvar.ServiceFollowupKeywordType + Keyword interface{} + OrderBy string + PageNum int + PageSize int + Preload bool + } +) + +func (ServiceFollowup) TableName() string { + return "service_followup" +} + +func NewServiceFollowupSearch() *ServiceFollowupSearch { + return &ServiceFollowupSearch{ + Orm: mysqlx.GetDB(), + } +} + +func (slf *ServiceFollowupSearch) build() *gorm.DB { + var db = slf.Orm.Model(&ServiceFollowup{}) + if slf.Id != 0 { + db = db.Where("id = ?", slf.Id) + } + + switch slf.KeywordType { + case constvar.ServiceFollowupKeywordFollowupNo: + db = db.Where("number = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordCustomerName: + db = db.Where("client_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordContactName: + db = db.Where("contact_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordCustomerServiceNo: + db = db.Where("service_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordVisitor: + db = db.Where("member_id = ?", slf.Keyword) + case constvar.ServiceFollowupKeywordSatisfactionDegree: + db = db.Where("satisfaction_id = ?", slf.Keyword) + + } + + if slf.Preload { + db = db.Preload("CustomerServiceSheet"). + Preload("ServiceOrder"). + Preload("Client"). + Preload("Contact") + } + + return db +} + +func (slf *ServiceFollowupSearch) Create(record *ServiceFollowup) error { + var db = slf.build() + return db.Create(record).Error +} + +func (slf *ServiceFollowupSearch) Update(record *ServiceFollowup) error { + var db = slf.build() + return db.Updates(record).Error +} + +func (slf *ServiceFollowupSearch) Delete() error { + var db = slf.build() + return db.Delete(&ServiceFollowup{}).Error +} + +func (slf *ServiceFollowupSearch) Find() (*ServiceFollowup, error) { + var db = slf.build() + var record = &ServiceFollowup{} + err := db.First(record).Error + return record, err +} + +func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, int64, error) { + var db = slf.build() + var records = make([]*ServiceFollowup, 0) + var total int64 + if err := db.Count(&total).Error; err != nil { + return records, total, err + } + if slf.PageNum > 0 && slf.PageSize > 0 { + db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) + } + + if slf.PageNum > 0 && slf.PageSize > 0 { + db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) + } + + err := db.Find(&records).Error + return records, total, err +} + +func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch { + slf.Id = id + return slf +} + +func (slf *ServiceFollowupSearch) SetPreload(preload bool) *ServiceFollowupSearch { + slf.Preload = preload + return slf +} + +func (slf *ServiceFollowupSearch) SetKeywordType(keyword constvar.ServiceFollowupKeywordType) *ServiceFollowupSearch { + slf.KeywordType = keyword + return slf +} + +func (slf *ServiceFollowupSearch) SetKeyword(keyword string) *ServiceFollowupSearch { + slf.Keyword = keyword + return slf +} + +func (slf *ServiceFollowupSearch) SetPage(page, size int) *ServiceFollowupSearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + +func (slf *ServiceFollowupSearch) SetOrder(order string) *ServiceFollowupSearch { + slf.OrderBy = order + return slf +} +func (slf *ServiceFollowupSearch) SetIds(ids []int) *ServiceFollowupSearch { + slf.Orm = slf.Orm.Where("id in (?)", ids) + return slf +} diff --git a/router/serviceOrder.go b/router/serviceOrder.go index 8efdc84..c9db554 100644 --- a/router/serviceOrder.go +++ b/router/serviceOrder.go @@ -12,6 +12,6 @@ ServiceOrderRouter.POST("add", ServiceOrderApi.Add) // 娣诲姞鏈嶅姟鍗� ServiceOrderRouter.DELETE("delete/:id", ServiceOrderApi.Delete) // 鍒犻櫎鏈嶅姟鍗� ServiceOrderRouter.PUT("update", ServiceOrderApi.Update) // 鏇存柊鏈嶅姟鍗� - ServiceOrderRouter.GET("list", ServiceOrderApi.List) // 鑾峰彇鏈嶅姟鍗曞垪琛� + ServiceOrderRouter.POST("list", ServiceOrderApi.List) // 鑾峰彇鏈嶅姟鍗曞垪琛� } } diff --git a/service/serviceFollowup.go b/service/serviceFollowup.go index bdcb710..1ae3722 100644 --- a/service/serviceFollowup.go +++ b/service/serviceFollowup.go @@ -46,7 +46,9 @@ contacts, total, err := model.NewServiceFollowupSearch(). SetKeywordType(keywordType). SetKeyword(keyword). - SetPage(page, pageSize).FindAll() + SetPage(page, pageSize). + SetPreload(true). + FindAll() if err != nil { return nil, 0, ecode.ServiceFollowupListErr } -- Gitblit v1.8.0