add
IsInvoice 是否开票
add, Delete, update, lis
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | IsInvoiceApi |
| | | RefundMethodApi |
| | | ServiceContractTypeApi |
| | | ServiceContractStatusApi |
| | |
| | | serviceContractStatusService = service.ServiceGroup.ServiceContractStatusService |
| | | serviceContractTypeService = service.ServiceGroup.ServiceContractTypeService |
| | | refundMethodService = service.ServiceGroup.RefundMethodService |
| | | isInvoiceService = service.ServiceGroup.IsInvoiceService |
| | | ) |
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 IsInvoiceApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags IsInvoice |
| | | // @Summary 添加是否开票 |
| | | // @Produce application/json |
| | | // @Param object body request.AddIsInvoice true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/isInvoice/add [post] |
| | | func (s *IsInvoiceApi) Add(c *gin.Context) { |
| | | var params request.AddIsInvoice |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | isInvoice := new(model.IsInvoice) |
| | | isInvoice.Name = params.Name |
| | | |
| | | errCode := isInvoiceService.AddIsInvoice(isInvoice) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags IsInvoice |
| | | // @Summary 删除是否开票 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/isInvoice/delete/{id} [delete] |
| | | func (s *IsInvoiceApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := isInvoiceService.DeleteIsInvoice(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags IsInvoice |
| | | // @Summary 更新是否开票 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateIsInvoices true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/isInvoice/update [put] |
| | | func (s *IsInvoiceApi) Update(c *gin.Context) { |
| | | var params request.UpdateIsInvoices |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := isInvoiceService.UpdateIsInvoice(params.IsInvoices) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags IsInvoice |
| | | // @Summary 获取是否开票列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.IsInvoiceResponse} |
| | | // @Router /api/isInvoice/list [get] |
| | | func (s *IsInvoiceApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | isInvoices, errCode := isInvoiceService.GetIsInvoiceList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.IsInvoiceResponse{ |
| | | List: isInvoices, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "添加是否开票", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddIsInvoice" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "删除是否开票", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "获取是否开票列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.IsInvoiceResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "更新是否开票", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateIsInvoices" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isVisit/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.IsInvoice": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.IsVisit": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.AddIndustry": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddIsInvoice": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsInvoice": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsInvoices": { |
| | | "type": "object", |
| | | "required": [ |
| | | "is_invoice" |
| | | ], |
| | | "properties": { |
| | | "is_invoice": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateIsInvoice" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsVisit": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "$ref": "#/definitions/model.Industry" |
| | | } |
| | | }, |
| | | "isInvoice": { |
| | | "description": "是否开票", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.IsInvoice" |
| | | } |
| | | }, |
| | | "isVisit": { |
| | | "description": "服务人员是否来过", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.IsInvoiceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.IsInvoice" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.IsVisitResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "添加是否开票", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddIsInvoice" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "删除是否开票", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "获取是否开票列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.IsInvoiceResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isInvoice/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "IsInvoice" |
| | | ], |
| | | "summary": "更新是否开票", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateIsInvoices" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/isVisit/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.IsInvoice": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.IsVisit": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.AddIndustry": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddIsInvoice": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsInvoice": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsInvoices": { |
| | | "type": "object", |
| | | "required": [ |
| | | "is_invoice" |
| | | ], |
| | | "properties": { |
| | | "is_invoice": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateIsInvoice" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateIsVisit": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "$ref": "#/definitions/model.Industry" |
| | | } |
| | | }, |
| | | "isInvoice": { |
| | | "description": "是否开票", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.IsInvoice" |
| | | } |
| | | }, |
| | | "isVisit": { |
| | | "description": "服务人员是否来过", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.IsInvoiceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.IsInvoice" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.IsVisitResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.IsInvoice: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.IsVisit: |
| | | properties: |
| | | id: |
| | |
| | | - follow_record |
| | | type: object |
| | | request.AddIndustry: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddIsInvoice: |
| | | properties: |
| | | name: |
| | | type: string |
| | |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateIsInvoice: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateIsInvoices: |
| | | properties: |
| | | is_invoice: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateIsInvoice' |
| | | type: array |
| | | required: |
| | | - is_invoice |
| | | type: object |
| | | request.UpdateIsVisit: |
| | | properties: |
| | | id: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Industry' |
| | | type: array |
| | | isInvoice: |
| | | description: 是否开票 |
| | | items: |
| | | $ref: '#/definitions/model.IsInvoice' |
| | | type: array |
| | | isVisit: |
| | | description: 服务人员是否来过 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Industry' |
| | | type: array |
| | | type: object |
| | | response.IsInvoiceResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.IsInvoice' |
| | | type: array |
| | | type: object |
| | | response.IsVisitResponse: |
| | |
| | | summary: 更新行业 |
| | | tags: |
| | | - Industry |
| | | /api/isInvoice/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddIsInvoice' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加是否开票 |
| | | tags: |
| | | - IsInvoice |
| | | /api/isInvoice/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: |
| | | - IsInvoice |
| | | /api/isInvoice/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.IsInvoiceResponse' |
| | | type: object |
| | | summary: 获取是否开票列表 |
| | | tags: |
| | | - IsInvoice |
| | | /api/isInvoice/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateIsInvoices' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新是否开票 |
| | | tags: |
| | | - IsInvoice |
| | | /api/isVisit/add: |
| | | post: |
| | | parameters: |
| | |
| | | ServiceContractStatus{}, |
| | | ServiceContractType{}, |
| | | RefundMethod{}, |
| | | IsInvoice{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // IsInvoice 商机阶段 |
| | | IsInvoice struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | IsInvoiceSearch struct { |
| | | IsInvoice |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (IsInvoice) TableName() string { |
| | | return "is_invoice" |
| | | } |
| | | |
| | | func NewIsInvoiceSearch() *IsInvoiceSearch { |
| | | return &IsInvoiceSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&IsInvoice{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) Create(record *IsInvoice) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&IsInvoice{}).Error |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) Update(record *IsInvoice) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) Find() (*IsInvoice, error) { |
| | | var db = slf.build() |
| | | var record = new(IsInvoice) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) FindAll() ([]*IsInvoice, error) { |
| | | var db = slf.build() |
| | | var records = make([]*IsInvoice, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) SetId(id int) *IsInvoiceSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) SetName(name string) *IsInvoiceSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *IsInvoiceSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddIsInvoice struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateIsInvoice struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateIsInvoices struct { |
| | | IsInvoices []*UpdateIsInvoice `json:"is_invoice" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 是否开票 |
| | | IsInvoice []*model.IsInvoice `json:"isInvoice"` |
| | | |
| | | |
| | | // 退款方式 |
| | | RefundMethod []*model.RefundMethod `json:"refundMethod"` |
| | | |
| | |
| | | RefundMethodResponse struct { |
| | | List []*model.RefundMethod `json:"list"` |
| | | } |
| | | |
| | | IsInvoiceResponse struct { |
| | | List []*model.IsInvoice `json:"list"` |
| | | } |
| | | ) |
| | |
| | | ServiceContractTypeSetErr = 4900004 // 设置服务合同类型失败 |
| | | ServiceContractTypeUpdateErr = 4900005 // 更新服务合同类型失败 |
| | | |
| | | |
| | | RefundMethodExist = 5000001 // 退款方式已存在 |
| | | RefundMethodNotExist = 5000002 // 退款方式不存在 |
| | | RefundMethodListErr = 5000003 // 获取退款方式列表失败 |
| | | RefundMethodSetErr = 5000004 // 设置退款方式失败 |
| | | RefundMethodUpdateErr = 5000005 // 更新退款方式失败 |
| | | |
| | | IsInvoiceExist = 5100001 // 是否开票已存在 |
| | | IsInvoiceNotExist = 5100002 // 是否开票不存在 |
| | | IsInvoiceListErr = 5100003 // 获取是否开票列表失败 |
| | | IsInvoiceSetErr = 5100004 // 设置是否开票失败 |
| | | IsInvoiceUpdateErr = 5100005 // 更新是否开票失败 |
| | | |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | IsInvoiceRouter |
| | | RefundMethodRouter |
| | | ServiceContractTypeRouter |
| | | ServiceContractStatusRouter |
| | |
| | | routerGroup.InitServiceContractStatusRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractTypeRouter(PrivateGroup) |
| | | routerGroup.InitRefundMethodRouter(PrivateGroup) |
| | | routerGroup.InitIsInvoiceRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type IsInvoiceRouter struct{} |
| | | |
| | | func (s *IsInvoiceRouter) InitIsInvoiceRouter(router *gin.RouterGroup) { |
| | | isInvoiceRouter := router.Group("isInvoice") |
| | | isInvoiceApi := v1.ApiGroup.IsInvoiceApi |
| | | { |
| | | isInvoiceRouter.POST("add", isInvoiceApi.Add) // 添加$CName$ |
| | | isInvoiceRouter.DELETE("delete/:id", isInvoiceApi.Delete) // 删除$CName$ |
| | | isInvoiceRouter.PUT("update", isInvoiceApi.Update) // 更新$CName$ |
| | | isInvoiceRouter.GET("list", isInvoiceApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | data.RefundMethod = refundMethodList |
| | | |
| | | |
| | | // get IsInvoice list |
| | | isInvoiceList, _ := ServiceGroup.GetIsInvoiceList() |
| | | data.IsInvoice = isInvoiceList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | ServiceContractStatusService |
| | | ServiceContractTypeService |
| | | RefundMethodService |
| | | IsInvoiceService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type IsInvoiceService struct{} |
| | | |
| | | func (IsInvoiceService) AddIsInvoice(isInvoice *model.IsInvoice) int { |
| | | err := model.NewIsInvoiceSearch().Create(isInvoice) |
| | | if err != nil { |
| | | return ecode.IsInvoiceExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (IsInvoiceService) DeleteIsInvoice(id int) int { |
| | | _, err := model.NewIsInvoiceSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.IsInvoiceNotExist |
| | | } |
| | | |
| | | err = model.NewIsInvoiceSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.IsInvoiceNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (IsInvoiceService) GetIsInvoiceList() ([]*model.IsInvoice, int) { |
| | | list, err := model.NewIsInvoiceSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.IsInvoiceListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (IsInvoiceService) UpdateIsInvoice(isInvoices []*request.UpdateIsInvoice) int { |
| | | for _, v := range isInvoices { |
| | | // check isInvoice exist |
| | | _, err := model.NewIsInvoiceSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.IsInvoiceNotExist |
| | | } |
| | | |
| | | err = model.NewIsInvoiceSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.IsInvoiceSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (IsInvoiceService) GetIsInvoiceDetail(id int) (*model.IsInvoice, int) { |
| | | isInvoice, err := model.NewIsInvoiceSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.IsInvoiceNotExist |
| | | } |
| | | |
| | | return isInvoice, ecode.OK |
| | | } |