add
accountId 账户
add, Delete, update, lis
New file |
| | |
| | | |
| | | 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, |
| | | }) |
| | | } |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | AccountIdApi |
| | | IsInvoiceApi |
| | | RefundMethodApi |
| | | ServiceContractTypeApi |
| | |
| | | serviceContractTypeService = service.ServiceGroup.ServiceContractTypeService |
| | | refundMethodService = service.ServiceGroup.RefundMethodService |
| | | isInvoiceService = service.ServiceGroup.IsInvoiceService |
| | | accountIdService = service.ServiceGroup.AccountIdService |
| | | ) |
| | |
| | | "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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.AccountId": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Authority": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "uuid": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddAccountId": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "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" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.AccountIdResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.AccountId" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.CityResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.DataResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "description": "账户", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.AccountId" |
| | | } |
| | | }, |
| | | "city": { |
| | | "description": "城市数据", |
| | | "type": "array", |
| | |
| | | "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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.AccountId": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Authority": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "uuid": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddAccountId": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "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" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.AccountIdResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.AccountId" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.CityResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "response.DataResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "accountId": { |
| | | "description": "账户", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.AccountId" |
| | | } |
| | | }, |
| | | "city": { |
| | | "description": "城市数据", |
| | | "type": "array", |
| | |
| | | msg: |
| | | type: string |
| | | type: object |
| | | model.AccountId: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Authority: |
| | | properties: |
| | | authorityName: |
| | |
| | | type: string |
| | | uuid: |
| | | type: string |
| | | type: object |
| | | request.AddAccountId: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddAuthority: |
| | | properties: |
| | |
| | | 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: |
| | |
| | | required: |
| | | - timely_rate |
| | | type: object |
| | | response.AccountIdResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.AccountId' |
| | | type: array |
| | | type: object |
| | | response.CityResponse: |
| | | properties: |
| | | list: |
| | |
| | | type: object |
| | | response.DataResponse: |
| | | properties: |
| | | accountId: |
| | | description: 账户 |
| | | items: |
| | | $ref: '#/definitions/model.AccountId' |
| | | type: array |
| | | city: |
| | | description: 城市数据 |
| | | items: |
| | |
| | | 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: |
New file |
| | |
| | | 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 |
| | | } |
| | |
| | | ServiceContractType{}, |
| | | RefundMethod{}, |
| | | IsInvoice{}, |
| | | AccountId{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | |
| | | 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"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 账户 |
| | | AccountId []*model.AccountId `json:"accountId"` |
| | | |
| | | |
| | | // 是否开票 |
| | | IsInvoice []*model.IsInvoice `json:"isInvoice"` |
| | | |
| | |
| | | IsInvoiceResponse struct { |
| | | List []*model.IsInvoice `json:"list"` |
| | | } |
| | | |
| | | AccountIdResponse struct { |
| | | List []*model.AccountId `json:"list"` |
| | | } |
| | | ) |
| | |
| | | IsInvoiceSetErr = 5100004 // 设置是否开票失败 |
| | | IsInvoiceUpdateErr = 5100005 // 更新是否开票失败 |
| | | |
| | | ) |
| | | |
| | | AccountIdExist = 5000001 // 账户已存在 |
| | | AccountIdNotExist = 5000002 // 账户不存在 |
| | | AccountIdListErr = 5000003 // 获取账户列表失败 |
| | | AccountIdSetErr = 5000004 // 设置账户失败 |
| | | AccountIdUpdateErr = 5000005 // 更新账户失败 |
| | | |
| | | ) |
New file |
| | |
| | | |
| | | 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$列表 |
| | | } |
| | | } |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | AccountIdRouter |
| | | IsInvoiceRouter |
| | | RefundMethodRouter |
| | | ServiceContractTypeRouter |
| | |
| | | routerGroup.InitServiceContractTypeRouter(PrivateGroup) |
| | | routerGroup.InitRefundMethodRouter(PrivateGroup) |
| | | routerGroup.InitIsInvoiceRouter(PrivateGroup) |
| | | routerGroup.InitAccountIdRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | 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 |
| | | } |
| | |
| | | data.IsInvoice = isInvoiceList |
| | | |
| | | |
| | | // get AccountId list |
| | | accountIdList, _ := ServiceGroup.GetAccountIdList() |
| | | data.AccountId = accountIdList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | ServiceContractTypeService |
| | | RefundMethodService |
| | | IsInvoiceService |
| | | AccountIdService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |