add
contract 合同管理
add, Delete, update, list
| | |
| | | SalesDetailsApi |
| | | SalesReturnApi |
| | | SalesRefundApi |
| | | ContractApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | salesDetailsService = service.ServiceGroup.SalesDetailsService |
| | | salesReturnService = service.ServiceGroup.SalesReturnService |
| | | salesRefundService = service.ServiceGroup.SalesRefundService |
| | | contractService = service.ServiceGroup.ContractService |
| | | ) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "添加合同", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddContract" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "删除合同", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "获取合同列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ContractResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "更新合同", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateContract" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/country/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.Country": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "wechat": { |
| | | "description": "微信号", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCountry": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ContractResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Contract" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.CountryResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "添加合同", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddContract" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "删除合同", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "获取合同列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ContractResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/contract/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Contract" |
| | | ], |
| | | "summary": "更新合同", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateContract" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/country/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Contract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "memberId": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotationId": { |
| | | "type": "integer" |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.Country": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "wechat": { |
| | | "description": "微信号", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | | "file": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "quotation_id": { |
| | | "type": "integer" |
| | | }, |
| | | "status_id": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCountry": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ContractResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Contract" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.CountryResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | wechat: |
| | | type: string |
| | | type: object |
| | | model.Contract: |
| | | properties: |
| | | clientId: |
| | | type: integer |
| | | file: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | memberId: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | quotationId: |
| | | type: integer |
| | | statusId: |
| | | type: integer |
| | | type: object |
| | | model.Country: |
| | | properties: |
| | | id: |
| | |
| | | wechat: |
| | | description: 微信号 |
| | | type: string |
| | | type: object |
| | | request.AddContract: |
| | | properties: |
| | | client_id: |
| | | type: integer |
| | | file: |
| | | type: string |
| | | member_id: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | quotation_id: |
| | | type: integer |
| | | status_id: |
| | | type: integer |
| | | type: object |
| | | request.AddCountry: |
| | | properties: |
| | |
| | | description: 微信号 |
| | | type: string |
| | | type: object |
| | | request.UpdateContract: |
| | | properties: |
| | | client_id: |
| | | type: integer |
| | | file: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | member_id: |
| | | type: integer |
| | | number: |
| | | type: string |
| | | quotation_id: |
| | | type: integer |
| | | status_id: |
| | | type: integer |
| | | type: object |
| | | request.UpdateCountry: |
| | | properties: |
| | | id: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ContactDetail' |
| | | type: array |
| | | type: object |
| | | response.ContractResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Contract' |
| | | type: array |
| | | type: object |
| | | response.CountryResponse: |
| | |
| | | summary: 更新联系人 |
| | | tags: |
| | | - Contact |
| | | /api/contract/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddContract' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加合同 |
| | | tags: |
| | | - Contract |
| | | /api/contract/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: |
| | | - Contract |
| | | /api/contract/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.ContractResponse' |
| | | type: object |
| | | summary: 获取合同列表 |
| | | tags: |
| | | - Contract |
| | | /api/contract/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateContract' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新合同 |
| | | tags: |
| | | - Contract |
| | | /api/country/add: |
| | | post: |
| | | parameters: |
| | |
| | | [2023-07-11 11:33:55] [error] [gorm.io/gorm/migrator.Migrator.AutoMigrate:104] failed to parse value model.SubOrder{Id:0, ClientId:0, MemberId:0, MasterOrderId:0, Number:"", ProductOrder:model.ProductOrder{Id:0, Products:[]model.Product(nil)}, Model:gorm.Model{ID:0x0, CreatedAt:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), UpdatedAt:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), DeletedAt:gorm.DeletedAt{Time:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Valid:false}}}, got error invalid field found for struct aps_crm/model.SubOrder's field ProductOrder: define a valid foreign key for relations or implement the Valuer/Scanner interface |
| | | [2023-07-11 11:33:55] [error] [gorm.io/gorm/migrator.Migrator.CreateTable:198] failed to parse value model.SubOrder{Id:0, ClientId:0, MemberId:0, MasterOrderId:0, Number:"", ProductOrder:model.ProductOrder{Id:0, Products:[]model.Product(nil)}, Model:gorm.Model{ID:0x0, CreatedAt:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), UpdatedAt:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), DeletedAt:gorm.DeletedAt{Time:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Valid:false}}}, got error invalid field found for struct aps_crm/model.SubOrder's field ProductOrder: define a valid foreign key for relations or implement the Valuer/Scanner interface |
| | | [2023-07-11 11:33:55] [error] [main.main:29] model Init err:invalid field found for struct aps_crm/model.SubOrder's field ProductOrder: define a valid foreign key for relations or implement the Valuer/Scanner interface |
| | | [2023-07-12 15:23:10] [error] [aps_crm/model.(*ContractSearch).Create:46] trace {"error": "Error 1146 (42S02): Table 'aps_crm.contract' doesn't exist", "elapsed": 0.003547, "rows": 0, "sql": "INSERT INTO `contract` (`client_id`,`member_id`,`number`,`quotation_id`,`status_id`,`file`) VALUES (11,11,'ZDYB02-2',0,0,'string')"} |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | Contract struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:合同状态"` |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:合同文件"` |
| | | } |
| | | |
| | | ContractSearch struct { |
| | | Contract |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (Contract) TableName() string { |
| | | return "contract" |
| | | } |
| | | |
| | | func NewContractSearch() *ContractSearch { |
| | | return &ContractSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *ContractSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Contract{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *ContractSearch) Create(record *Contract) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *ContractSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&Contract{}).Error |
| | | } |
| | | |
| | | func (slf *ContractSearch) Update(record *Contract) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *ContractSearch) Find() (*Contract, error) { |
| | | var db = slf.build() |
| | | var record = &Contract{} |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ContractSearch) FindAll() ([]*Contract, error) { |
| | | var db = slf.build() |
| | | var records = make([]*Contract, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *ContractSearch) SetId(id int) *ContractSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | |
| | | SalesDetails{}, |
| | | SalesReturn{}, |
| | | SalesRefund{}, |
| | | Contract{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | type AddContract struct { |
| | | Contract |
| | | } |
| | | |
| | | type Contract struct { |
| | | ClientId int `json:"client_id"` |
| | | MemberId int `json:"member_id"` |
| | | Number string `json:"number"` |
| | | QuotationId int `json:"quotation_id"` |
| | | StatusId int `json:"status_id"` |
| | | File string `json:"file"` |
| | | } |
| | | |
| | | type UpdateContract struct { |
| | | Id int `json:"id"` |
| | | Contract |
| | | } |
| | |
| | | SalesRefundResponse struct { |
| | | List []*model.SalesRefund `json:"list"` |
| | | } |
| | | |
| | | ContractResponse struct { |
| | | List []*model.Contract `json:"list"` |
| | | } |
| | | ) |
| | |
| | | SalesRefundSetErr = 3000004 // 设置销售退款单失败 |
| | | SalesRefundUpdateErr = 3000005 // 更新销售退款单失败 |
| | | SalesRefundDeleteErr = 3000006 // 删除销售退款单失败 |
| | | |
| | | ContractExist = 3100001 // 合同已存在 |
| | | ContractNotExist = 3100002 // 合同不存在 |
| | | ContractListErr = 3100003 // 获取合同列表失败 |
| | | ContractSetErr = 3100004 // 设置合同失败 |
| | | ContractUpdateErr = 3100005 // 更新合同失败 |
| | | ContractDeleteErr = 3100006 // 删除合同失败 |
| | | ) |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type ContractRouter struct{} |
| | | |
| | | func (s *ContractRouter) InitContractRouter(router *gin.RouterGroup) { |
| | | contractRouter := router.Group("contract") |
| | | contractApi := v1.ApiGroup.ContractApi |
| | | { |
| | | contractRouter.POST("add", contractApi.Add) // 添加合同 |
| | | contractRouter.DELETE("delete/:id", contractApi.Delete) // 删除合同 |
| | | contractRouter.PUT("update", contractApi.Update) // 更新合同 |
| | | contractRouter.GET("list", contractApi.List) // 获取合同列表 |
| | | } |
| | | } |
| | |
| | | SalesDetailsRouter |
| | | SalesReturnRouter |
| | | SalesRefundRouter |
| | | ContractRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitSalesDetailsRouter(PrivateGroup) // 注册salesDetails路由 |
| | | routerGroup.InitSalesReturnRouter(PrivateGroup) // 注册salesReturn路由 |
| | | routerGroup.InitSalesRefundRouter(PrivateGroup) // 注册salesRefund路由 |
| | | routerGroup.InitContractRouter(PrivateGroup) // 注册contract路由 |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type ContractService struct{} |
| | | |
| | | func (ContractService) AddContract(contract *model.Contract) int { |
| | | err := model.NewContractSearch().Create(contract) |
| | | if err != nil { |
| | | return ecode.ContractExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) DeleteContract(id int) int { |
| | | _, err := model.NewContractSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.ContractNotExist |
| | | } |
| | | |
| | | err = model.NewContractSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ContractNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ContractService) GetContractList() ([]*model.Contract, int) { |
| | | list, err := model.NewContractSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ContractListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (ContractService) UpdateContract(contract *model.Contract) int { |
| | | // check contract exist |
| | | _, err := model.NewContractSearch().SetId(contract.Id).Find() |
| | | if err != nil { |
| | | return ecode.ContractNotExist |
| | | } |
| | | |
| | | err = model.NewContractSearch().SetId(contract.Id).Update(contract) |
| | | if err != nil { |
| | | return ecode.ContractSetErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | |
| | | SalesDetailsService |
| | | SalesReturnService |
| | | SalesRefundService |
| | | ContractService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |