add
wangpengfei
2023-07-21 823296cc595b3167c31a6257352c136568d0aaaf
add

IsInvoice 是否开票
add, Delete, update, lis
5个文件已添加
10个文件已修改
822 ■■■■■ 已修改文件
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/isInvoice.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 188 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 188 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/isInvoice.go 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/isInvoice.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/isInvoice.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/isInvoice.go 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go
@@ -5,6 +5,7 @@
)
type Group struct {
    IsInvoiceApi
    RefundMethodApi
    ServiceContractTypeApi
    ServiceContractStatusApi
@@ -116,4 +117,5 @@
   serviceContractStatusService    = service.ServiceGroup.ServiceContractStatusService
   serviceContractTypeService    = service.ServiceGroup.ServiceContractTypeService
   refundMethodService    = service.ServiceGroup.RefundMethodService
   isInvoiceService    = service.ServiceGroup.IsInvoiceService
)
api/v1/isInvoice.go
New file
@@ -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 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, &params)
    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, &params)
    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,
    })
}
docs/docs.go
@@ -2040,6 +2040,125 @@
                }
            }
        },
        "/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": [
@@ -6698,6 +6817,17 @@
                }
            }
        },
        "model.IsInvoice": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.IsVisit": {
            "type": "object",
            "properties": {
@@ -7914,6 +8044,17 @@
            }
        },
        "request.AddIndustry": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddIsInvoice": {
            "type": "object",
            "required": [
                "name"
@@ -9615,6 +9756,35 @@
                }
            }
        },
        "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": [
@@ -10832,6 +11002,13 @@
                        "$ref": "#/definitions/model.Industry"
                    }
                },
                "isInvoice": {
                    "description": "是否开票",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsInvoice"
                    }
                },
                "isVisit": {
                    "description": "服务人员是否来过",
                    "type": "array",
@@ -11008,6 +11185,17 @@
                }
            }
        },
        "response.IsInvoiceResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsInvoice"
                    }
                }
            }
        },
        "response.IsVisitResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -2028,6 +2028,125 @@
                }
            }
        },
        "/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": [
@@ -6686,6 +6805,17 @@
                }
            }
        },
        "model.IsInvoice": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.IsVisit": {
            "type": "object",
            "properties": {
@@ -7902,6 +8032,17 @@
            }
        },
        "request.AddIndustry": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddIsInvoice": {
            "type": "object",
            "required": [
                "name"
@@ -9603,6 +9744,35 @@
                }
            }
        },
        "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": [
@@ -10820,6 +10990,13 @@
                        "$ref": "#/definitions/model.Industry"
                    }
                },
                "isInvoice": {
                    "description": "是否开票",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsInvoice"
                    }
                },
                "isVisit": {
                    "description": "服务人员是否来过",
                    "type": "array",
@@ -10996,6 +11173,17 @@
                }
            }
        },
        "response.IsInvoiceResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsInvoice"
                    }
                }
            }
        },
        "response.IsVisitResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -402,6 +402,13 @@
      name:
        type: string
    type: object
  model.IsInvoice:
    properties:
      id:
        type: integer
      name:
        type: string
    type: object
  model.IsVisit:
    properties:
      id:
@@ -1211,6 +1218,13 @@
    - follow_record
    type: object
  request.AddIndustry:
    properties:
      name:
        type: string
    required:
    - name
    type: object
  request.AddIsInvoice:
    properties:
      name:
        type: string
@@ -2361,6 +2375,25 @@
    - 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:
@@ -3172,6 +3205,11 @@
        items:
          $ref: '#/definitions/model.Industry'
        type: array
      isInvoice:
        description: 是否开票
        items:
          $ref: '#/definitions/model.IsInvoice'
        type: array
      isVisit:
        description: 服务人员是否来过
        items:
@@ -3291,6 +3329,13 @@
      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:
@@ -4759,6 +4804,79 @@
      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:
model/index.go
@@ -73,6 +73,7 @@
        ServiceContractStatus{},
        ServiceContractType{},
        RefundMethod{},
        IsInvoice{},
    )
    return err
}
model/isInvoice.go
New file
@@ -0,0 +1,85 @@
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
}
model/request/isInvoice.go
New file
@@ -0,0 +1,15 @@
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"`
}
model/response/response.go
@@ -180,6 +180,10 @@
    DataResponse struct {
        // 是否开票
        IsInvoice []*model.IsInvoice `json:"isInvoice"`
        // 退款方式
        RefundMethod []*model.RefundMethod `json:"refundMethod"`
@@ -286,4 +290,8 @@
    RefundMethodResponse struct {
        List []*model.RefundMethod `json:"list"`
    }
    IsInvoiceResponse struct {
        List []*model.IsInvoice `json:"list"`
    }
)
pkg/ecode/code.go
@@ -340,11 +340,16 @@
    ServiceContractTypeSetErr    = 4900004 // 设置服务合同类型失败
    ServiceContractTypeUpdateErr = 4900005 // 更新服务合同类型失败
    RefundMethodExist     = 5000001 // 退款方式已存在
    RefundMethodNotExist  = 5000002 // 退款方式不存在
    RefundMethodListErr   = 5000003 // 获取退款方式列表失败
    RefundMethodSetErr    = 5000004 // 设置退款方式失败
    RefundMethodUpdateErr = 5000005 // 更新退款方式失败
    IsInvoiceExist     = 5100001 // 是否开票已存在
    IsInvoiceNotExist  = 5100002 // 是否开票不存在
    IsInvoiceListErr   = 5100003 // 获取是否开票列表失败
    IsInvoiceSetErr    = 5100004 // 设置是否开票失败
    IsInvoiceUpdateErr = 5100005 // 更新是否开票失败
)
router/index.go
@@ -11,6 +11,7 @@
)
type Group struct {
    IsInvoiceRouter
    RefundMethodRouter
    ServiceContractTypeRouter
    ServiceContractStatusRouter
@@ -145,6 +146,7 @@
        routerGroup.InitServiceContractStatusRouter(PrivateGroup)
        routerGroup.InitServiceContractTypeRouter(PrivateGroup)
        routerGroup.InitRefundMethodRouter(PrivateGroup)
        routerGroup.InitIsInvoiceRouter(PrivateGroup)
    }
    return Router
}
router/isInvoice.go
New file
@@ -0,0 +1,20 @@
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$列表
    }
}
service/dataServer.go
@@ -121,6 +121,11 @@
    data.RefundMethod = refundMethodList
    // get IsInvoice list
    isInvoiceList, _ := ServiceGroup.GetIsInvoiceList()
    data.IsInvoice = isInvoiceList
    errCode = ecode.OK
    return
service/index.go
@@ -54,6 +54,7 @@
    ServiceContractStatusService
    ServiceContractTypeService
    RefundMethodService
    IsInvoiceService
}
var ServiceGroup = new(Group)
service/isInvoice.go
New file
@@ -0,0 +1,69 @@
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
}