From 34c99ef40f26f8812610e7ca14c56825f9bf2c3c Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 11:46:56 +0800
Subject: [PATCH] add
---
api/v1/index.go | 2
service/dataServer.go | 5
model/request/accountId.go | 15 +
api/v1/accountId.go | 113 ++++++++
pkg/ecode/code.go | 9
docs/swagger.yaml | 118 ++++++++
model/accountId.go | 85 ++++++
docs/docs.go | 188 +++++++++++++
docs/swagger.json | 188 +++++++++++++
model/response/response.go | 8
service/index.go | 1
service/accountId.go | 69 ++++
model/index.go | 1
router/index.go | 2
router/accountId.go | 20 +
15 files changed, 823 insertions(+), 1 deletions(-)
diff --git a/api/v1/accountId.go b/api/v1/accountId.go
new file mode 100644
index 0000000..493633b
--- /dev/null
+++ b/api/v1/accountId.go
@@ -0,0 +1,113 @@
+
+package v1
+
+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 AccountIdApi struct{}
+
+// Add
+//
+// @Tags AccountId
+// @Summary 娣诲姞璐︽埛
+// @Produce application/json
+// @Param object body request.AddAccountId true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/accountId/add [post]
+func (s *AccountIdApi) Add(c *gin.Context) {
+ var params request.AddAccountId
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ accountId := new(model.AccountId)
+ accountId.Name = params.Name
+
+ errCode := accountIdService.AddAccountId(accountId)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// Delete
+//
+// @Tags AccountId
+// @Summary 鍒犻櫎璐︽埛
+// @Produce application/json
+// @Param id path int true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/accountId/delete/{id} [delete]
+func (s *AccountIdApi) Delete(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ id, _ := strconv.Atoi(c.Param("id"))
+ errCode := accountIdService.DeleteAccountId(id)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// Update
+//
+// @Tags AccountId
+// @Summary 鏇存柊璐︽埛
+// @Produce application/json
+// @Param object body request.UpdateAccountIds true "鏌ヨ鍙傛暟"
+// @Success 200 {object} contextx.Response{}
+// @Router /api/accountId/update [put]
+func (s *AccountIdApi) Update(c *gin.Context) {
+ var params request.UpdateAccountIds
+ ctx, ok := contextx.NewContext(c, ¶ms)
+ if !ok {
+ return
+ }
+
+ errCode := accountIdService.UpdateAccountId(params.AccountIds)
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.Ok()
+}
+
+// List
+//
+// @Tags AccountId
+// @Summary 鑾峰彇璐︽埛鍒楄〃
+// @Produce application/json
+// @Success 200 {object} contextx.Response{data=response.AccountIdResponse}
+// @Router /api/accountId/list [get]
+func (s *AccountIdApi) List(c *gin.Context) {
+ ctx, ok := contextx.NewContext(c, nil)
+ if !ok {
+ return
+ }
+
+ accountIds, errCode := accountIdService.GetAccountIdList()
+ if errCode != ecode.OK {
+ ctx.Fail(errCode)
+ return
+ }
+
+ ctx.OkWithDetailed(response.AccountIdResponse{
+ List: accountIds,
+ })
+}
diff --git a/api/v1/index.go b/api/v1/index.go
index 6b430b3..bc2a808 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -5,6 +5,7 @@
)
type Group struct {
+ AccountIdApi
IsInvoiceApi
RefundMethodApi
ServiceContractTypeApi
@@ -118,4 +119,5 @@
serviceContractTypeService = service.ServiceGroup.ServiceContractTypeService
refundMethodService = service.ServiceGroup.RefundMethodService
isInvoiceService = service.ServiceGroup.IsInvoiceService
+ accountIdService = service.ServiceGroup.AccountIdService
)
\ No newline at end of file
diff --git a/docs/docs.go b/docs/docs.go
index c6d453c..e97a5e1 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -16,6 +16,125 @@
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
+ "/api/accountId/add": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "娣诲姞璐︽埛",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddAccountId"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鍒犻櫎璐︽埛",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/list": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鑾峰彇璐︽埛鍒楄〃",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/response.AccountIdResponse"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鏇存柊璐︽埛",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateAccountIds"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/api/authority/add": {
"post": {
"security": [
@@ -6297,6 +6416,17 @@
}
}
},
+ "model.AccountId": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"model.Authority": {
"type": "object",
"properties": {
@@ -7722,6 +7852,17 @@
"type": "string"
},
"uuid": {
+ "type": "string"
+ }
+ }
+ },
+ "request.AddAccountId": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "name": {
"type": "string"
}
}
@@ -9260,6 +9401,35 @@
"type": "array",
"items": {
"type": "integer"
+ }
+ }
+ }
+ },
+ "request.UpdateAccountId": {
+ "type": "object",
+ "required": [
+ "id",
+ "name"
+ ],
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "request.UpdateAccountIds": {
+ "type": "object",
+ "required": [
+ "account_id"
+ ],
+ "properties": {
+ "account_id": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/request.UpdateAccountId"
}
}
}
@@ -10830,6 +11000,17 @@
}
}
},
+ "response.AccountIdResponse": {
+ "type": "object",
+ "properties": {
+ "list": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.AccountId"
+ }
+ }
+ }
+ },
"response.CityResponse": {
"type": "object",
"properties": {
@@ -10932,6 +11113,13 @@
"response.DataResponse": {
"type": "object",
"properties": {
+ "accountId": {
+ "description": "璐︽埛",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.AccountId"
+ }
+ },
"city": {
"description": "鍩庡競鏁版嵁",
"type": "array",
diff --git a/docs/swagger.json b/docs/swagger.json
index 148c7e1..1025e7b 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4,6 +4,125 @@
"contact": {}
},
"paths": {
+ "/api/accountId/add": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "娣诲姞璐︽埛",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.AddAccountId"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/delete/{id}": {
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鍒犻櫎璐︽埛",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "鏌ヨ鍙傛暟",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/list": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鑾峰彇璐︽埛鍒楄〃",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/contextx.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/response.AccountIdResponse"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api/accountId/update": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "AccountId"
+ ],
+ "summary": "鏇存柊璐︽埛",
+ "parameters": [
+ {
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateAccountIds"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/contextx.Response"
+ }
+ }
+ }
+ }
+ },
"/api/authority/add": {
"post": {
"security": [
@@ -6285,6 +6404,17 @@
}
}
},
+ "model.AccountId": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
"model.Authority": {
"type": "object",
"properties": {
@@ -7710,6 +7840,17 @@
"type": "string"
},
"uuid": {
+ "type": "string"
+ }
+ }
+ },
+ "request.AddAccountId": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "name": {
"type": "string"
}
}
@@ -9248,6 +9389,35 @@
"type": "array",
"items": {
"type": "integer"
+ }
+ }
+ }
+ },
+ "request.UpdateAccountId": {
+ "type": "object",
+ "required": [
+ "id",
+ "name"
+ ],
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ },
+ "request.UpdateAccountIds": {
+ "type": "object",
+ "required": [
+ "account_id"
+ ],
+ "properties": {
+ "account_id": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/request.UpdateAccountId"
}
}
}
@@ -10818,6 +10988,17 @@
}
}
},
+ "response.AccountIdResponse": {
+ "type": "object",
+ "properties": {
+ "list": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.AccountId"
+ }
+ }
+ }
+ },
"response.CityResponse": {
"type": "object",
"properties": {
@@ -10920,6 +11101,13 @@
"response.DataResponse": {
"type": "object",
"properties": {
+ "accountId": {
+ "description": "璐︽埛",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.AccountId"
+ }
+ },
"city": {
"description": "鍩庡競鏁版嵁",
"type": "array",
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index b55b2b0..b69ef06 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -60,6 +60,13 @@
msg:
type: string
type: object
+ model.AccountId:
+ properties:
+ id:
+ type: integer
+ name:
+ type: string
+ type: object
model.Authority:
properties:
authorityName:
@@ -997,6 +1004,13 @@
type: string
uuid:
type: string
+ type: object
+ request.AddAccountId:
+ properties:
+ name:
+ type: string
+ required:
+ - name
type: object
request.AddAuthority:
properties:
@@ -2038,6 +2052,25 @@
items:
type: integer
type: array
+ type: object
+ request.UpdateAccountId:
+ properties:
+ id:
+ type: integer
+ name:
+ type: string
+ required:
+ - id
+ - name
+ type: object
+ request.UpdateAccountIds:
+ properties:
+ account_id:
+ items:
+ $ref: '#/definitions/request.UpdateAccountId'
+ type: array
+ required:
+ - account_id
type: object
request.UpdateCities:
properties:
@@ -3090,6 +3123,13 @@
required:
- timely_rate
type: object
+ response.AccountIdResponse:
+ properties:
+ list:
+ items:
+ $ref: '#/definitions/model.AccountId'
+ type: array
+ type: object
response.CityResponse:
properties:
list:
@@ -3155,6 +3195,11 @@
type: object
response.DataResponse:
properties:
+ accountId:
+ description: 璐︽埛
+ items:
+ $ref: '#/definitions/model.AccountId'
+ type: array
city:
description: 鍩庡競鏁版嵁
items:
@@ -3568,6 +3613,79 @@
info:
contact: {}
paths:
+ /api/accountId/add:
+ post:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.AddAccountId'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 娣诲姞璐︽埛
+ tags:
+ - AccountId
+ /api/accountId/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:
+ - AccountId
+ /api/accountId/list:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/contextx.Response'
+ - properties:
+ data:
+ $ref: '#/definitions/response.AccountIdResponse'
+ type: object
+ summary: 鑾峰彇璐︽埛鍒楄〃
+ tags:
+ - AccountId
+ /api/accountId/update:
+ put:
+ parameters:
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.UpdateAccountIds'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/contextx.Response'
+ summary: 鏇存柊璐︽埛
+ tags:
+ - AccountId
/api/authority/add:
post:
consumes:
diff --git a/model/accountId.go b/model/accountId.go
new file mode 100644
index 0000000..6365041
--- /dev/null
+++ b/model/accountId.go
@@ -0,0 +1,85 @@
+package model
+
+import (
+ "aps_crm/pkg/mysqlx"
+ "gorm.io/gorm"
+)
+
+type (
+ // AccountId 鍟嗘満闃舵
+ AccountId struct {
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
+ }
+
+ AccountIdSearch struct {
+ AccountId
+ Orm *gorm.DB
+ }
+)
+
+func (AccountId) TableName() string {
+ return "account_id"
+}
+
+func NewAccountIdSearch() *AccountIdSearch {
+ return &AccountIdSearch{
+ Orm: mysqlx.GetDB(),
+ }
+}
+
+func (slf *AccountIdSearch) build() *gorm.DB {
+ var db = slf.Orm.Model(&AccountId{})
+ if slf.Id != 0 {
+ db = db.Where("id = ?", slf.Id)
+ }
+ if slf.Name != "" {
+ db = db.Where("name = ?", slf.Name)
+ }
+
+ return db
+}
+
+func (slf *AccountIdSearch) Create(record *AccountId) error {
+ var db = slf.build()
+ return db.Create(record).Error
+}
+
+func (slf *AccountIdSearch) Delete() error {
+ var db = slf.build()
+ return db.Delete(&AccountId{}).Error
+}
+
+func (slf *AccountIdSearch) Update(record *AccountId) error {
+ var db = slf.build()
+ return db.Updates(record).Error
+}
+
+func (slf *AccountIdSearch) Find() (*AccountId, error) {
+ var db = slf.build()
+ var record = new(AccountId)
+ err := db.First(record).Error
+ return record, err
+}
+
+func (slf *AccountIdSearch) FindAll() ([]*AccountId, error) {
+ var db = slf.build()
+ var records = make([]*AccountId, 0)
+ err := db.Find(&records).Error
+ return records, err
+}
+
+func (slf *AccountIdSearch) SetId(id int) *AccountIdSearch {
+ slf.Id = id
+ return slf
+}
+
+func (slf *AccountIdSearch) SetName(name string) *AccountIdSearch {
+ slf.Name = name
+ return slf
+}
+
+func (slf *AccountIdSearch) Updates(data map[string]interface{}) error {
+ var db = slf.build()
+ return db.Updates(data).Error
+}
diff --git a/model/index.go b/model/index.go
index 9a4e4b7..73726d6 100644
--- a/model/index.go
+++ b/model/index.go
@@ -74,6 +74,7 @@
ServiceContractType{},
RefundMethod{},
IsInvoice{},
+ AccountId{},
)
return err
}
\ No newline at end of file
diff --git a/model/request/accountId.go b/model/request/accountId.go
new file mode 100644
index 0000000..c0e2efd
--- /dev/null
+++ b/model/request/accountId.go
@@ -0,0 +1,15 @@
+
+package request
+
+type AddAccountId struct {
+ Name string ` json:"name" binding:"required"`
+}
+
+type UpdateAccountId struct {
+ Id int `json:"id" binding:"required"`
+ Name string `json:"name" binding:"required"`
+}
+
+type UpdateAccountIds struct {
+ AccountIds []*UpdateAccountId `json:"account_id" binding:"required"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index 8fff1d9..7975cd3 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -180,6 +180,10 @@
DataResponse struct {
+ // 璐︽埛
+ AccountId []*model.AccountId `json:"accountId"`
+
+
// 鏄惁寮�绁�
IsInvoice []*model.IsInvoice `json:"isInvoice"`
@@ -294,4 +298,8 @@
IsInvoiceResponse struct {
List []*model.IsInvoice `json:"list"`
}
+
+ AccountIdResponse struct {
+ List []*model.AccountId `json:"list"`
+ }
)
\ No newline at end of file
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index c2efed0..9549f13 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -352,4 +352,11 @@
IsInvoiceSetErr = 5100004 // 璁剧疆鏄惁寮�绁ㄥけ璐�
IsInvoiceUpdateErr = 5100005 // 鏇存柊鏄惁寮�绁ㄥけ璐�
-)
+
+ AccountIdExist = 5000001 // 璐︽埛宸插瓨鍦�
+ AccountIdNotExist = 5000002 // 璐︽埛涓嶅瓨鍦�
+ AccountIdListErr = 5000003 // 鑾峰彇璐︽埛鍒楄〃澶辫触
+ AccountIdSetErr = 5000004 // 璁剧疆璐︽埛澶辫触
+ AccountIdUpdateErr = 5000005 // 鏇存柊璐︽埛澶辫触
+
+)
\ No newline at end of file
diff --git a/router/accountId.go b/router/accountId.go
new file mode 100644
index 0000000..4c0e173
--- /dev/null
+++ b/router/accountId.go
@@ -0,0 +1,20 @@
+
+package router
+
+import (
+ v1 "aps_crm/api/v1"
+ "github.com/gin-gonic/gin"
+)
+
+type AccountIdRouter struct{}
+
+func (s *AccountIdRouter) InitAccountIdRouter(router *gin.RouterGroup) {
+ accountIdRouter := router.Group("accountId")
+ accountIdApi := v1.ApiGroup.AccountIdApi
+ {
+ accountIdRouter.POST("add", accountIdApi.Add) // 娣诲姞$CName$
+ accountIdRouter.DELETE("delete/:id", accountIdApi.Delete) // 鍒犻櫎$CName$
+ accountIdRouter.PUT("update", accountIdApi.Update) // 鏇存柊$CName$
+ accountIdRouter.GET("list", accountIdApi.List) // 鑾峰彇$CName$鍒楄〃
+ }
+}
\ No newline at end of file
diff --git a/router/index.go b/router/index.go
index 8adce2d..b03939e 100644
--- a/router/index.go
+++ b/router/index.go
@@ -11,6 +11,7 @@
)
type Group struct {
+ AccountIdRouter
IsInvoiceRouter
RefundMethodRouter
ServiceContractTypeRouter
@@ -147,6 +148,7 @@
routerGroup.InitServiceContractTypeRouter(PrivateGroup)
routerGroup.InitRefundMethodRouter(PrivateGroup)
routerGroup.InitIsInvoiceRouter(PrivateGroup)
+ routerGroup.InitAccountIdRouter(PrivateGroup)
}
return Router
}
\ No newline at end of file
diff --git a/service/accountId.go b/service/accountId.go
new file mode 100644
index 0000000..a53d7eb
--- /dev/null
+++ b/service/accountId.go
@@ -0,0 +1,69 @@
+
+package service
+
+import (
+ "aps_crm/model"
+ "aps_crm/model/request"
+ "aps_crm/pkg/ecode"
+)
+
+type AccountIdService struct{}
+
+func (AccountIdService) AddAccountId(accountId *model.AccountId) int {
+ err := model.NewAccountIdSearch().Create(accountId)
+ if err != nil {
+ return ecode.AccountIdExist
+ }
+
+ return ecode.OK
+}
+
+func (AccountIdService) DeleteAccountId(id int) int {
+ _, err := model.NewAccountIdSearch().SetId(id).Find()
+ if err != nil {
+ return ecode.AccountIdNotExist
+ }
+
+ err = model.NewAccountIdSearch().SetId(id).Delete()
+ if err != nil {
+ return ecode.AccountIdNotExist
+ }
+ return ecode.OK
+}
+
+func (AccountIdService) GetAccountIdList() ([]*model.AccountId, int) {
+ list, err := model.NewAccountIdSearch().FindAll()
+ if err != nil {
+ return nil, ecode.AccountIdListErr
+ }
+
+ return list, ecode.OK
+}
+
+func (AccountIdService) UpdateAccountId(accountIds []*request.UpdateAccountId) int {
+ for _, v := range accountIds {
+ // check accountId exist
+ _, err := model.NewAccountIdSearch().SetId(v.Id).Find()
+ if err != nil {
+ return ecode.AccountIdNotExist
+ }
+
+ err = model.NewAccountIdSearch().SetId(v.Id).Updates(map[string]interface{}{
+ "name": v.Name,
+ })
+ if err != nil {
+ return ecode.AccountIdSetErr
+ }
+ }
+
+ return ecode.OK
+}
+
+func (AccountIdService) GetAccountIdDetail(id int) (*model.AccountId, int) {
+ accountId, err := model.NewAccountIdSearch().SetId(id).Find()
+ if err != nil {
+ return nil, ecode.AccountIdNotExist
+ }
+
+ return accountId, ecode.OK
+}
diff --git a/service/dataServer.go b/service/dataServer.go
index cc1595f..71f3fb5 100644
--- a/service/dataServer.go
+++ b/service/dataServer.go
@@ -126,6 +126,11 @@
data.IsInvoice = isInvoiceList
+ // get AccountId list
+ accountIdList, _ := ServiceGroup.GetAccountIdList()
+ data.AccountId = accountIdList
+
+
errCode = ecode.OK
return
diff --git a/service/index.go b/service/index.go
index 84214db..261049d 100644
--- a/service/index.go
+++ b/service/index.go
@@ -55,6 +55,7 @@
ServiceContractTypeService
RefundMethodService
IsInvoiceService
+ AccountIdService
}
var ServiceGroup = new(Group)
\ No newline at end of file
--
Gitblit v1.8.0