From 3c921c53c2b4dcd617a4ec88bd2a78fe69f2b600 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期四, 10 八月 2023 19:34:33 +0800
Subject: [PATCH] temp
---
model/collectionProjection.go | 17 +
service/collectionProjection.go | 28 +++
model/saleChance.go | 71 ++++---
router/colletionProjection.go | 8
api/v1/collectionProjection.go | 102 +++++++++++
model/index.go | 1
router/index.go | 2
docs/swagger.yaml | 69 +++++++
model/request/collectionProjection.go | 11 +
docs/docs.go | 107 +++++++++++
docs/swagger.json | 107 +++++++++++
model/response/response.go | 5
12 files changed, 481 insertions(+), 47 deletions(-)
diff --git a/api/v1/collectionProjection.go b/api/v1/collectionProjection.go
index 7556283..49fb8a1 100644
--- a/api/v1/collectionProjection.go
+++ b/api/v1/collectionProjection.go
@@ -3,9 +3,11 @@
import (
"aps_crm/model"
"aps_crm/model/request"
+ "aps_crm/model/response"
"aps_crm/pkg/contextx"
"aps_crm/pkg/ecode"
"github.com/gin-gonic/gin"
+ "strconv"
)
type CollectionProjectionApi struct{}
@@ -27,8 +29,14 @@
tmp := new(model.CollectionProjection)
tmp.EstimatedCollectionAmount = params.CollectionProjection.EstimatedCollectionAmount
- tmp.EstimatedCollectionDate = params.CollectionProjection.EstimatedCollectionTime
- tmp.SaleChanceId = params.CollectionProjection.SaleChanceId
+
+ if params.EstimatedCollectionTime == "" {
+ tmp.EstimatedCollectionDate = nil
+ } else {
+ tmp.EstimatedCollectionDate = ¶ms.CollectionProjection.EstimatedCollectionTime
+ }
+
+ tmp.SaleChanceId = params.SaleChanceId
errCode := collectionProjectionService.AddCollectionProjection(tmp)
if errCode != ecode.OK {
@@ -38,3 +46,93 @@
ctx.Ok()
}
+
+// Delete
+//
+// @Tags CollectionProjection
+// @Summary 鍒犻櫎鏀舵棰勬祴
+// @Produce application/json
+// @Param id path int true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/collectionProjection/delete/{id} [delete]
+func (cp *CollectionProjectionApi) Delete(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ id, err := strconv.Atoi(c.Param("id"))
+ if err != nil {
+ ctx.Fail(ecode.InvalidParams)
+ return
+ }
+
+ errCode := collectionProjectionService.DeleteCollectionProjection(id)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// Update
+//
+// @Tags CollectionProjection
+// @Summary 鏇存柊鏀舵棰勬祴
+// @Produce application/json
+// @Param object body request.UpdateCollectionProjection true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/collectionProjection/update [put]
+func (cp *CollectionProjectionApi) Update(c *gin.Context) {
+ var params request.UpdateCollectionProjection
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ tmp := new(model.CollectionProjection)
+ tmp.EstimatedCollectionAmount = params.CollectionProjection.EstimatedCollectionAmount
+ tmp.Id = params.Id
+
+ if params.EstimatedCollectionTime == "" {
+ tmp.EstimatedCollectionDate = nil
+ } else {
+ tmp.EstimatedCollectionDate = ¶ms.CollectionProjection.EstimatedCollectionTime
+ }
+
+ errCode := collectionProjectionService.UpdateCollectionProjection(tmp)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// List
+//
+// @Tags CollectionProjection
+// @Summary 鑾峰彇鏀舵棰勬祴鍒楄〃
+// @Produce application/json
+// @Param object query request.GetCollectionProjectionList true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/collectionProjection/list [post]
+func (cp *CollectionProjectionApi) List(c *gin.Context) {
+ var params request.GetCollectionProjectionList
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ total, errCode, list := collectionProjectionService.GetCollectionProjectionList(params.Page, params.PageSize)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.OkWithDetailed(response.CollectionProjectionListResponse{
+ List: list,
+ Count: int(total),
+ })
+}
diff --git a/docs/docs.go b/docs/docs.go
index c23e327..b034d29 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1272,6 +1272,97 @@
}
}
},
+ "/api/collectionProjection/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鍒犻櫎鏀舵棰勬祴",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/collectionProjection/list": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鑾峰彇鏀舵棰勬祴鍒楄〃",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/collectionProjection/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鏇存柊鏀舵棰勬祴",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateCollectionProjection"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/api/contact/add": {
"post": {
"produces": [
@@ -14954,6 +15045,22 @@
}
}
},
+ "request.UpdateCollectionProjection": {
+ "type": "object",
+ "properties": {
+ "estimated_collection_amount": {
+ "description": "棰勮鏀舵閲戦",
+ "type": "number"
+ },
+ "estimated_collection_time": {
+ "description": "棰勮鏀舵鏃堕棿",
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ }
+ }
+ },
"request.UpdateContact": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 56da808..ae236c1 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1260,6 +1260,97 @@
}
}
},
+ "/api/collectionProjection/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鍒犻櫎鏀舵棰勬祴",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/collectionProjection/list": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鑾峰彇鏀舵棰勬祴鍒楄〃",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/collectionProjection/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "CollectionProjection"
+ ],
+ "summary": "鏇存柊鏀舵棰勬祴",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateCollectionProjection"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/api/contact/add": {
"post": {
"produces": [
@@ -14942,6 +15033,22 @@
}
}
},
+ "request.UpdateCollectionProjection": {
+ "type": "object",
+ "properties": {
+ "estimated_collection_amount": {
+ "description": "棰勮鏀舵閲戦",
+ "type": "number"
+ },
+ "estimated_collection_time": {
+ "description": "棰勮鏀舵鏃堕棿",
+ "type": "string"
+ },
+ "id": {
+ "type": "integer"
+ }
+ }
+ },
"request.UpdateContact": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index f9f1d1f..81560ca 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -3590,6 +3590,17 @@
required:
- client_types
type: object
+ request.UpdateCollectionProjection:
+ properties:
+ estimated_collection_amount:
+ description: 棰勮鏀舵閲戦
+ type: number
+ estimated_collection_time:
+ description: 棰勮鏀舵鏃堕棿
+ type: string
+ id:
+ type: integer
+ type: object
request.UpdateContact:
properties:
birthday:
@@ -6222,6 +6233,64 @@
summary: 娣诲姞鏀舵棰勬祴
tags:
- CollectionProjection
+ /api/collectionProjection/delete/{id}:
+ delete:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: path
+ name: id
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鍒犻櫎鏀舵棰勬祴
+ tags:
+ - CollectionProjection
+ /api/collectionProjection/list:
+ post:
+ parameters:
+ - description: 椤电爜
+ in: query
+ name: page
+ type: integer
+ - description: 姣忛〉澶у皬
+ in: query
+ name: pageSize
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鑾峰彇鏀舵棰勬祴鍒楄〃
+ tags:
+ - CollectionProjection
+ /api/collectionProjection/update:
+ put:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.UpdateCollectionProjection'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鏇存柊鏀舵棰勬祴
+ tags:
+ - CollectionProjection
/api/contact/add:
post:
parameters:
diff --git a/model/collectionProjection.go b/model/collectionProjection.go
index c289864..e6d758b 100644
--- a/model/collectionProjection.go
+++ b/model/collectionProjection.go
@@ -11,7 +11,7 @@
SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:閿�鍞満浼歩d"`
Creator int `json:"creator" gorm:"column:creator;type:int(11);comment:鍒涘缓浜�"`
Modifier int `json:"modifier" gorm:"column:modifier;type:int(11);comment:淇敼浜�"`
- EstimatedCollectionDate string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:棰勮鏀舵鏃ユ湡"`
+ EstimatedCollectionDate *string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:棰勮鏀舵鏃ユ湡"`
EstimatedCollectionAmount float64 `json:"estimated_collection_amount" gorm:"column:estimated_collection_amount;type:decimal(10,2);comment:棰勮鏀舵閲戦"`
gorm.Model
}
@@ -63,10 +63,19 @@
return
}
-func (slf *CollectionProjectionSearch) Find() (record CollectionProjection, err error) {
+func (slf *CollectionProjectionSearch) Find() (int64, error, []*CollectionProjection) {
var db = slf.build()
- err = db.First(&record).Error
- return
+ var records = make([]*CollectionProjection, 0)
+ var total int64
+ if err := db.Count(&total).Error; err != nil {
+ return total, err, records
+ }
+ if slf.PageNum > 0 && slf.PageSize > 0 {
+ db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+ }
+
+ err := db.Find(&records).Error
+ return total, err, records
}
func (slf *CollectionProjectionSearch) SetID(id int) *CollectionProjectionSearch {
diff --git a/model/index.go b/model/index.go
index 7a90d35..0da8fa8 100644
--- a/model/index.go
+++ b/model/index.go
@@ -83,6 +83,7 @@
Repository{},
QuotationStatus{},
Currency{},
+ CollectionProjection{},
)
return err
}
diff --git a/model/request/collectionProjection.go b/model/request/collectionProjection.go
index e5f1202..f60a1b1 100644
--- a/model/request/collectionProjection.go
+++ b/model/request/collectionProjection.go
@@ -2,10 +2,19 @@
type AddCollectionProjection struct {
CollectionProjection
+ SaleChanceId int `json:"sale_chance_id"` // 閿�鍞満浼歩d
}
type CollectionProjection struct {
EstimatedCollectionAmount float64 `json:"estimated_collection_amount"` // 棰勮鏀舵閲戦
EstimatedCollectionTime string `json:"estimated_collection_time"` // 棰勮鏀舵鏃堕棿
- SaleChanceId int `json:"sale_chance_id"` // 閿�鍞満浼歩d
+}
+
+type UpdateCollectionProjection struct {
+ Id int `json:"id"`
+ CollectionProjection
+}
+
+type GetCollectionProjectionList struct {
+ PageInfo
}
diff --git a/model/response/response.go b/model/response/response.go
index 46774ab..cc15773 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -344,4 +344,9 @@
CurrencyResponse struct {
List []*model.Currency `json:"list"`
}
+
+ CollectionProjectionListResponse struct {
+ List []*model.CollectionProjection `json:"list"`
+ Count int `json:"count"`
+ }
)
diff --git a/model/saleChance.go b/model/saleChance.go
index 320cafb..9efbc3d 100644
--- a/model/saleChance.go
+++ b/model/saleChance.go
@@ -8,39 +8,40 @@
type (
SaleChance struct {
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍏徃鍚嶇О"`
- Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞嚎绱㈢紪鍙�"`
- ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篒D"`
- ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛ID"`
- SalesSourcesId int `json:"sales_sources_id" gorm:"column:sales_sources_id;type:int(11);comment:鍟嗘満鏉ユ簮ID"`
- SaleTypeId int `json:"sale_type_id" gorm:"column:sale_type_id;type:int(11);comment:鍟嗘満绫诲瀷ID"`
- SaleStageId int `json:"sale_stage_id" gorm:"column:sale_stage_id;type:int(11);comment:鍟嗘満闃舵ID"`
- MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:閿�鍞礋璐d汉ID"`
- RegularCustomersId int `json:"regular_customers_id" gorm:"column:regular_customers_id;type:int(11);comment:甯稿ID"`
- Competitors string `json:"competitors" gorm:"column:competitors;type:varchar(255);comment:绔炰簤瀵规墜"`
- PossibilitiesId int `json:"possibilities_id" gorm:"column:possibilities_id;type:int(11);comment:鍙兘鎬D"`
- Budget float64 `json:"budget" gorm:"column:budget;type:decimal(10,2);comment:棰勭畻"`
- ProjectedAmount float64 `json:"projected_amount" gorm:"column:projected_amount;type:decimal(10,2);comment:棰勮閲戦"`
- Currency int `json:"currency" gorm:"column:currency;type:int(11);comment:甯佺"`
- ExpectedTime time.Time `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:棰勮鎴愪氦鏃堕棿"`
- StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:鐘舵�両D"`
- PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:鐥涚偣"`
- WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:鏄惁鎴愮珛"`
- CapitalBudget string `json:"capital_budget" gorm:"column:capital_budget;type:text;comment:璧勯噾棰勭畻"`
- KeyMaker string `json:"key_maker" gorm:"column:key_maker;type:text;comment:鍏抽敭浜�"`
- KeyFactors string `json:"key_factors" gorm:"column:key_factors;type:text;comment:鍏抽敭鍥犵礌"`
- Process string `json:"process" gorm:"column:process;type:text;comment:鍐崇瓥娴佺▼"`
- Solutions string `json:"solutions" gorm:"column:solutions;type:text;comment:绔炰簤瀵规墜瑙e喅鏂规"`
- Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:绔炰簤浼樺娍"`
- Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:绔炰簤鍔e娍"`
- Opportunities string `json:"opportunities" gorm:"column:opportunities;type:text;comment:绔炰簤鏈轰細"`
- Threats string `json:"threats" gorm:"column:threats;type:text;comment:绔炰簤濞佽儊"`
- DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:text;comment:璇︾粏鍦板潃"`
- Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
- Contact Contact `json:"contact" gorm:"foreignKey:ContactId;references:Id"`
- Client Client `json:"client" gorm:"foreignKey:ClientId;references:Id"`
- SalesSources SalesSources
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍏徃鍚嶇О"`
+ Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閿�鍞嚎绱㈢紪鍙�"`
+ ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:鑱旂郴浜篒D"`
+ ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:瀹㈡埛ID"`
+ SalesSourcesId int `json:"sales_sources_id" gorm:"column:sales_sources_id;type:int(11);comment:鍟嗘満鏉ユ簮ID"`
+ SaleTypeId int `json:"sale_type_id" gorm:"column:sale_type_id;type:int(11);comment:鍟嗘満绫诲瀷ID"`
+ SaleStageId int `json:"sale_stage_id" gorm:"column:sale_stage_id;type:int(11);comment:鍟嗘満闃舵ID"`
+ MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:閿�鍞礋璐d汉ID"`
+ RegularCustomersId int `json:"regular_customers_id" gorm:"column:regular_customers_id;type:int(11);comment:甯稿ID"`
+ Competitors string `json:"competitors" gorm:"column:competitors;type:varchar(255);comment:绔炰簤瀵规墜"`
+ PossibilitiesId int `json:"possibilities_id" gorm:"column:possibilities_id;type:int(11);comment:鍙兘鎬D"`
+ Budget float64 `json:"budget" gorm:"column:budget;type:decimal(10,2);comment:棰勭畻"`
+ ProjectedAmount float64 `json:"projected_amount" gorm:"column:projected_amount;type:decimal(10,2);comment:棰勮閲戦"`
+ Currency int `json:"currency" gorm:"column:currency;type:int(11);comment:甯佺"`
+ ExpectedTime time.Time `json:"expected_time" gorm:"column:expected_time;type:datetime;comment:棰勮鎴愪氦鏃堕棿"`
+ StatusId int `json:"status_id" gorm:"column:status_id;type:int(11);comment:鐘舵�両D"`
+ PainPoints string `json:"pain_points" gorm:"column:pain_points;type:text;comment:鐥涚偣"`
+ WhetherEstablished string `json:"whether_established" gorm:"column:whether_established;type:text;comment:鏄惁鎴愮珛"`
+ CapitalBudget string `json:"capital_budget" gorm:"column:capital_budget;type:text;comment:璧勯噾棰勭畻"`
+ KeyMaker string `json:"key_maker" gorm:"column:key_maker;type:text;comment:鍏抽敭浜�"`
+ KeyFactors string `json:"key_factors" gorm:"column:key_factors;type:text;comment:鍏抽敭鍥犵礌"`
+ Process string `json:"process" gorm:"column:process;type:text;comment:鍐崇瓥娴佺▼"`
+ Solutions string `json:"solutions" gorm:"column:solutions;type:text;comment:绔炰簤瀵规墜瑙e喅鏂规"`
+ Advantages string `json:"advantages" gorm:"column:advantages;type:text;comment:绔炰簤浼樺娍"`
+ Disadvantages string `json:"disadvantages" gorm:"column:disadvantages;type:text;comment:绔炰簤鍔e娍"`
+ Opportunities string `json:"opportunities" gorm:"column:opportunities;type:text;comment:绔炰簤鏈轰細"`
+ Threats string `json:"threats" gorm:"column:threats;type:text;comment:绔炰簤濞佽儊"`
+ DetailAddress string `json:"detail_address" gorm:"column:detail_address;type:text;comment:璇︾粏鍦板潃"`
+ Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
+ Contact Contact `json:"contact" gorm:"foreignKey:ContactId;references:Id"`
+ Client Client `json:"client" gorm:"foreignKey:ClientId;references:Id"`
+ CollectionProjections []CollectionProjection `json:"collection_projections" gorm:"foreignKey:SaleChanceId"`
+ SalesSources SalesSources
Address
gorm.Model `json:"-"`
}
@@ -114,7 +115,7 @@
db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
}
- err := db.Preload("Client").Preload("Contact").Find(&records).Error
+ err := db.Preload("CollectionProjections").Preload("Client").Preload("Contact").Find(&records).Error
return records, total, err
}
@@ -141,4 +142,4 @@
func (slf *SaleChanceSearch) SetOrder(order string) *SaleChanceSearch {
slf.OrderBy = order
return slf
-}
\ No newline at end of file
+}
diff --git a/router/colletionProjection.go b/router/colletionProjection.go
index 80e463e..7a6f098 100644
--- a/router/colletionProjection.go
+++ b/router/colletionProjection.go
@@ -11,9 +11,9 @@
collectionProjectionRouter := router.Group("collectionProjection")
collectionProjectionApi := v1.ApiGroup.CollectionProjectionApi
{
- collectionProjectionRouter.POST("add", collectionProjectionApi.Add) // 娣诲姞鏀舵棰勬祴
- //collectionProjectionRouter.DELETE("delete", collectionProjectionApi.Delete) // 鍒犻櫎鏀舵棰勬祴
- //collectionProjectionRouter.PUT("update", collectionProjectionApi.Update) // 鏇存柊鏀舵棰勬祴
- //collectionProjectionRouter.POST("list", collectionProjectionApi.List) // 鑾峰彇鏀舵棰勬祴鍒楄〃
+ collectionProjectionRouter.POST("add", collectionProjectionApi.Add) // 娣诲姞鏀舵棰勬祴
+ collectionProjectionRouter.DELETE("delete/:id", collectionProjectionApi.Delete) // 鍒犻櫎鏀舵棰勬祴
+ collectionProjectionRouter.PUT("update", collectionProjectionApi.Update) // 鏇存柊鏀舵棰勬祴
+ collectionProjectionRouter.POST("list", collectionProjectionApi.List) // 鑾峰彇鏀舵棰勬祴鍒楄〃
}
}
diff --git a/router/index.go b/router/index.go
index bc3afe4..8f21017 100644
--- a/router/index.go
+++ b/router/index.go
@@ -177,7 +177,7 @@
InitInvoiceTypeRouter(PrivateGroup)
InitCourierCompanyRouter(PrivateGroup)
InitProductRouter(PrivateGroup)
- InitServiceCollectionPlanRouter(PrivateGroup)
+ routerGroup.InitCollectionProjectionRouter(PrivateGroup)
}
return Router
}
diff --git a/service/collectionProjection.go b/service/collectionProjection.go
index b86d98b..7da5f09 100644
--- a/service/collectionProjection.go
+++ b/service/collectionProjection.go
@@ -15,3 +15,31 @@
return ecode.OK
}
+
+func (CollectionProjectionService) UpdateCollectionProjection(collectionProjection *model.CollectionProjection) int {
+ err := model.NewCollectionProjectionSearch().SetID(collectionProjection.Id).Update(collectionProjection)
+ if err != nil {
+ return ecode.CollectionProjectionUpdateErr
+ }
+
+ return ecode.OK
+}
+
+func (CollectionProjectionService) DeleteCollectionProjection(id int) int {
+ err := model.NewCollectionProjectionSearch().SetID(id).Delete()
+ if err != nil {
+ return ecode.CollectionProjectionNotExist
+ }
+
+ return ecode.OK
+}
+
+func (CollectionProjectionService) GetCollectionProjectionList(page, pageSize int) (int64, int, []*model.CollectionProjection) {
+
+ total, err, list := model.NewCollectionProjectionSearch().SetPage(page, pageSize).Find()
+ if err != nil {
+ return total, ecode.CollectionProjectionListErr, list
+ }
+
+ return total, ecode.OK, list
+}
--
Gitblit v1.8.0