zhangqian
2024-03-22 6cce6de2161840f77d397fe25bee6096d0eb9877
物料搜索接口
4个文件已添加
9个文件已修改
707 ■■■■■ 已修改文件
conf/config.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.yaml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/order.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/outsourcing.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/grpc.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/outsourcing/outsourcing.pb.go 361 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/outsourcing/outsourcing.proto 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/outsourcing/outsourcing_grpc.pb.go 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.go
@@ -41,6 +41,10 @@
    localConf struct {
        StorePath string // 本地文件存储路径
    }
    serviceConf struct {
        Aps string // 本地文件存储路径
    }
)
var (
@@ -49,9 +53,9 @@
    DbConf    = &mysqlx.Conf{}
    NsqConf   = &nsqConf{}
    LocalConf = &localConf{}
    NodeId    string
    GrpcPort  string
    Viper     *viper.Viper
    Service   = &serviceConf{}
)
func Init() error {
@@ -107,8 +111,8 @@
    _ = v.UnmarshalKey("web", WebConf)
    _ = v.UnmarshalKey("log", LogConf)
    _ = v.UnmarshalKey("db", DbConf)
    _ = v.UnmarshalKey("nsq", NsqConf)
    _ = v.UnmarshalKey("local", LocalConf)
    _ = v.UnmarshalKey("service", Service)
    showConfig()
}
@@ -120,5 +124,6 @@
    log.Printf("   NsqConf:                %+v", NsqConf)
    log.Printf("   GrpcPort:               %+v", GrpcPort)
    log.Printf("   LocalConf:               %+v", LocalConf)
    log.Printf("   ServiceConf:               %+v", Service)
    log.Println("......................................................")
}
conf/config.yaml
@@ -1,6 +1,8 @@
web:
  port: 8008
  host: 192.168.20.119
service:
  aps: 192.168.20.120:9091
db:
  dsn: root:c++java123@tcp(192.168.20.119:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local
  logMode: true
controllers/order.go
@@ -8,8 +8,11 @@
    "outsourcing/extend/code"
    "outsourcing/extend/util"
    "outsourcing/models"
    "outsourcing/pkg/logx"
    "outsourcing/pkg/structx"
    "outsourcing/request"
    "outsourcing/service"
    "outsourcing/service/outsourcing"
)
type OrderController struct{}
@@ -293,3 +296,30 @@
    }
    util.ResponseFormat(c, code.Success, list)
}
// MaterialSearch
// @Tags      订单管理
// @Summary   物料搜索
// @Produce   application/json
// @Param     object  body    request.MaterialSearch true  "参数"
// @Success   200   {object}  util.ResponseList{[]models.OutsourcingOrderDeliveryDetails}  "成功"
// @Router    /api-outsourcing/v1/order/materialSearch [post]
func (slf *OrderController) MaterialSearch(c *gin.Context) {
    var params request.MaterialSearch
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    client := outsourcing.NewOutsourcingServiceClient(service.ApsServiceConn)
    list, err := client.GetMaterialList(c, &outsourcing.GetMaterialListRequest{
        Page:     int32(params.Page),
        PageSize: int32(params.PageSize),
        Keyword:  params.Keyword,
    })
    if err != nil {
        logx.Errorf("grpc outsourcing GetProductList err:%v", err)
        util.ResponseFormat(c, code.RequestParamError, "查询失败")
        return
    }
    util.ResponseFormat(c, code.Success, list)
}
docs/docs.go
@@ -186,6 +186,36 @@
                }
            }
        },
        "/api-outsourcing/v1/order/materialSearch": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "订单管理"
                ],
                "summary": "物料搜索",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.MaterialSearch"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.ResponseList"
                        }
                    }
                }
            }
        },
        "/api-outsourcing/v1/order/overview": {
            "get": {
                "produces": [
@@ -541,6 +571,23 @@
                }
            }
        },
        "request.MaterialSearch": {
            "type": "object",
            "properties": {
                "keyword": {
                    "description": "关键字",
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.OutsourcingOrderOverview": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -174,6 +174,36 @@
                }
            }
        },
        "/api-outsourcing/v1/order/materialSearch": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "订单管理"
                ],
                "summary": "物料搜索",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.MaterialSearch"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.ResponseList"
                        }
                    }
                }
            }
        },
        "/api-outsourcing/v1/order/overview": {
            "get": {
                "produces": [
@@ -529,6 +559,23 @@
                }
            }
        },
        "request.MaterialSearch": {
            "type": "object",
            "properties": {
                "keyword": {
                    "description": "关键字",
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.OutsourcingOrderOverview": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -142,6 +142,18 @@
      unit:
        type: string
    type: object
  request.MaterialSearch:
    properties:
      keyword:
        description: 关键字
        type: string
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
    type: object
  request.OutsourcingOrderOverview:
    properties:
      hasAssigned:
@@ -310,6 +322,25 @@
      summary: 委外订单列表
      tags:
      - 订单管理
  /api-outsourcing/v1/order/materialSearch:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.MaterialSearch'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.ResponseList'
      summary: 物料搜索
      tags:
      - 订单管理
  /api-outsourcing/v1/order/overview:
    get:
      produces:
main.go
@@ -6,10 +6,10 @@
    "os"
    "os/signal"
    "outsourcing/conf"
    "outsourcing/constvar"
    "outsourcing/models"
    "outsourcing/pkg/logx"
    "outsourcing/router"
    "outsourcing/service"
    "syscall"
    "time"
)
@@ -38,18 +38,14 @@
        ReadTimeout:  5 * time.Second,
        WriteTimeout: 5 * time.Second,
    }
    go service.InitApsServiceConn()
    go shutdown(server)
    logx.Error(server.ListenAndServe().Error())
}
func shutdown(server *http.Server) {
    quit := make(chan os.Signal, 1)
    signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
    <-quit
    if constvar.GrpcClient != nil {
        _ = constvar.GrpcClient.Close()
    }
    // 创建一个上下文,设置超时时间
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()
@@ -58,5 +54,8 @@
        logx.Warnf("服务优雅退出失败: %v", err)
        return
    }
    service.CloseApsServiceConn()
    logx.Infof("server exited success")
}
request/outsourcing.go
@@ -79,3 +79,8 @@
    OutsourcingOrderProductID uint            `json:"outsourcingOrderProductID"  gorm:"comment:委外订单产品表ID"` //委外订单产品表ID
    SendAmount                decimal.Decimal `gorm:"type:decimal(18,2);comment:数量" json:"sendAmount"`     //发货数量
}
type MaterialSearch struct {
    PageInfo
    Keyword string `json:"keyword"` //关键字
}
router/router.go
@@ -33,6 +33,7 @@
        outsourcingGroup.GET("deliveryPrepare", outsourcingApi.DeliveryPrepare)            //发货准备信息
        outsourcingGroup.POST("deliveryList", outsourcingApi.GetDeliveryList)              // 发货历史
        outsourcingGroup.POST("saveDelivery", outsourcingApi.SaveDelivery)                 // 保存发货信息
        outsourcingGroup.POST("materialSearch", outsourcingApi.MaterialSearch)             // 物料搜索
    }
service/grpc.go
New file
@@ -0,0 +1,25 @@
package service
import (
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials/insecure"
    "outsourcing/conf"
    "outsourcing/pkg/logx"
)
var ApsServiceConn *grpc.ClientConn
func InitApsServiceConn() {
    var err error
    ApsServiceConn, err = grpc.Dial(conf.Service.Aps, grpc.WithTransportCredentials(insecure.NewCredentials()))
    if err != nil {
        logx.Errorf("grpc dial product service error: %v", err.Error())
        return
    }
}
func CloseApsServiceConn() {
    if ApsServiceConn != nil {
        ApsServiceConn.Close()
    }
}
service/outsourcing/outsourcing.pb.go
New file
@@ -0,0 +1,361 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//     protoc-gen-go v1.31.0
//     protoc        v3.19.0
// source: outsourcing.proto
package outsourcing
import (
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    sync "sync"
)
const (
    // Verify that this generated code is sufficiently up-to-date.
    _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
    // Verify that runtime/protoimpl is sufficiently up-to-date.
    _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Material struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    ID    string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`       //编号
    Name  string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`   //名称
    Unit  string `protobuf:"bytes,3,opt,name=Unit,proto3" json:"Unit,omitempty"`   //单位
    Specs string `protobuf:"bytes,4,opt,name=Specs,proto3" json:"Specs,omitempty"` // 规格
    Type  string `protobuf:"bytes,5,opt,name=Type,proto3" json:"Type,omitempty"`   // 型号
}
func (x *Material) Reset() {
    *x = Material{}
    if protoimpl.UnsafeEnabled {
        mi := &file_outsourcing_proto_msgTypes[0]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *Material) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*Material) ProtoMessage() {}
func (x *Material) ProtoReflect() protoreflect.Message {
    mi := &file_outsourcing_proto_msgTypes[0]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use Material.ProtoReflect.Descriptor instead.
func (*Material) Descriptor() ([]byte, []int) {
    return file_outsourcing_proto_rawDescGZIP(), []int{0}
}
func (x *Material) GetID() string {
    if x != nil {
        return x.ID
    }
    return ""
}
func (x *Material) GetName() string {
    if x != nil {
        return x.Name
    }
    return ""
}
func (x *Material) GetUnit() string {
    if x != nil {
        return x.Unit
    }
    return ""
}
func (x *Material) GetSpecs() string {
    if x != nil {
        return x.Specs
    }
    return ""
}
func (x *Material) GetType() string {
    if x != nil {
        return x.Type
    }
    return ""
}
type GetMaterialListRequest struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Page     int32  `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
    PageSize int32  `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
    Keyword  string `protobuf:"bytes,3,opt,name=Keyword,proto3" json:"Keyword,omitempty"`
}
func (x *GetMaterialListRequest) Reset() {
    *x = GetMaterialListRequest{}
    if protoimpl.UnsafeEnabled {
        mi := &file_outsourcing_proto_msgTypes[1]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetMaterialListRequest) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetMaterialListRequest) ProtoMessage() {}
func (x *GetMaterialListRequest) ProtoReflect() protoreflect.Message {
    mi := &file_outsourcing_proto_msgTypes[1]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetMaterialListRequest.ProtoReflect.Descriptor instead.
func (*GetMaterialListRequest) Descriptor() ([]byte, []int) {
    return file_outsourcing_proto_rawDescGZIP(), []int{1}
}
func (x *GetMaterialListRequest) GetPage() int32 {
    if x != nil {
        return x.Page
    }
    return 0
}
func (x *GetMaterialListRequest) GetPageSize() int32 {
    if x != nil {
        return x.PageSize
    }
    return 0
}
func (x *GetMaterialListRequest) GetKeyword() string {
    if x != nil {
        return x.Keyword
    }
    return ""
}
type GetMaterialListResponse struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Code  int32       `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
    Msg   string      `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
    List  []*Material `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"`
    Total int64       `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"`
}
func (x *GetMaterialListResponse) Reset() {
    *x = GetMaterialListResponse{}
    if protoimpl.UnsafeEnabled {
        mi := &file_outsourcing_proto_msgTypes[2]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *GetMaterialListResponse) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*GetMaterialListResponse) ProtoMessage() {}
func (x *GetMaterialListResponse) ProtoReflect() protoreflect.Message {
    mi := &file_outsourcing_proto_msgTypes[2]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
            ms.StoreMessageInfo(mi)
        }
        return ms
    }
    return mi.MessageOf(x)
}
// Deprecated: Use GetMaterialListResponse.ProtoReflect.Descriptor instead.
func (*GetMaterialListResponse) Descriptor() ([]byte, []int) {
    return file_outsourcing_proto_rawDescGZIP(), []int{2}
}
func (x *GetMaterialListResponse) GetCode() int32 {
    if x != nil {
        return x.Code
    }
    return 0
}
func (x *GetMaterialListResponse) GetMsg() string {
    if x != nil {
        return x.Msg
    }
    return ""
}
func (x *GetMaterialListResponse) GetList() []*Material {
    if x != nil {
        return x.List
    }
    return nil
}
func (x *GetMaterialListResponse) GetTotal() int64 {
    if x != nil {
        return x.Total
    }
    return 0
}
var File_outsourcing_proto protoreflect.FileDescriptor
var file_outsourcing_proto_rawDesc = []byte{
    0x0a, 0x11, 0x6f, 0x75, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72,
    0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x08, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x12,
    0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12,
    0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e,
    0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
    0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x63, 0x73,
    0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x53, 0x70, 0x65, 0x63, 0x73, 0x12, 0x12, 0x0a,
    0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x79, 0x70,
    0x65, 0x22, 0x62, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c,
    0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70,
    0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12,
    0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
    0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x4b,
    0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4b, 0x65,
    0x79, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x74, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x74, 0x65,
    0x72, 0x69, 0x61, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
    0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
    0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
    0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03,
    0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x52,
    0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04,
    0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x32, 0x5c, 0x0a, 0x12, 0x6f,
    0x75, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
    0x65, 0x12, 0x46, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c,
    0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69,
    0x61, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
    0x47, 0x65, 0x74, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x52,
    0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x3b, 0x6f,
    0x75, 0x74, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
    0x6f, 0x33,
}
var (
    file_outsourcing_proto_rawDescOnce sync.Once
    file_outsourcing_proto_rawDescData = file_outsourcing_proto_rawDesc
)
func file_outsourcing_proto_rawDescGZIP() []byte {
    file_outsourcing_proto_rawDescOnce.Do(func() {
        file_outsourcing_proto_rawDescData = protoimpl.X.CompressGZIP(file_outsourcing_proto_rawDescData)
    })
    return file_outsourcing_proto_rawDescData
}
var file_outsourcing_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_outsourcing_proto_goTypes = []interface{}{
    (*Material)(nil),                // 0: Material
    (*GetMaterialListRequest)(nil),  // 1: GetMaterialListRequest
    (*GetMaterialListResponse)(nil), // 2: GetMaterialListResponse
}
var file_outsourcing_proto_depIdxs = []int32{
    0, // 0: GetMaterialListResponse.List:type_name -> Material
    1, // 1: outsourcingService.GetMaterialList:input_type -> GetMaterialListRequest
    2, // 2: outsourcingService.GetMaterialList:output_type -> GetMaterialListResponse
    2, // [2:3] is the sub-list for method output_type
    1, // [1:2] is the sub-list for method input_type
    1, // [1:1] is the sub-list for extension type_name
    1, // [1:1] is the sub-list for extension extendee
    0, // [0:1] is the sub-list for field type_name
}
func init() { file_outsourcing_proto_init() }
func file_outsourcing_proto_init() {
    if File_outsourcing_proto != nil {
        return
    }
    if !protoimpl.UnsafeEnabled {
        file_outsourcing_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*Material); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_outsourcing_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetMaterialListRequest); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_outsourcing_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*GetMaterialListResponse); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
    }
    type x struct{}
    out := protoimpl.TypeBuilder{
        File: protoimpl.DescBuilder{
            GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
            RawDescriptor: file_outsourcing_proto_rawDesc,
            NumEnums:      0,
            NumMessages:   3,
            NumExtensions: 0,
            NumServices:   1,
        },
        GoTypes:           file_outsourcing_proto_goTypes,
        DependencyIndexes: file_outsourcing_proto_depIdxs,
        MessageInfos:      file_outsourcing_proto_msgTypes,
    }.Build()
    File_outsourcing_proto = out.File
    file_outsourcing_proto_rawDesc = nil
    file_outsourcing_proto_goTypes = nil
    file_outsourcing_proto_depIdxs = nil
}
service/outsourcing/outsourcing.proto
New file
@@ -0,0 +1,29 @@
syntax = "proto3";
option go_package = ".;outsourcing";
service outsourcingService {
  rpc GetMaterialList(GetMaterialListRequest) returns(GetMaterialListResponse) {}
}
message Material {
  string ID = 1; //编号
  string Name = 2; //名称
  string Unit = 3; //单位
  string Specs = 4; // 规格
  string Type = 5; // 型号
}
message GetMaterialListRequest{
  int32 page = 1;
  int32 pageSize = 2;
  string Keyword = 3;
}
message GetMaterialListResponse{
  int32   Code = 1;
  string  Msg = 2;
  repeated Material List = 3;
  int64 Total = 4;
}
service/outsourcing/outsourcing_grpc.pb.go
New file
@@ -0,0 +1,109 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v3.19.0
// source: outsourcing.proto
package outsourcing
import (
    context "context"
    grpc "google.golang.org/grpc"
    codes "google.golang.org/grpc/codes"
    status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
    OutsourcingService_GetMaterialList_FullMethodName = "/outsourcingService/GetMaterialList"
)
// OutsourcingServiceClient is the client API for OutsourcingService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type OutsourcingServiceClient interface {
    GetMaterialList(ctx context.Context, in *GetMaterialListRequest, opts ...grpc.CallOption) (*GetMaterialListResponse, error)
}
type outsourcingServiceClient struct {
    cc grpc.ClientConnInterface
}
func NewOutsourcingServiceClient(cc grpc.ClientConnInterface) OutsourcingServiceClient {
    return &outsourcingServiceClient{cc}
}
func (c *outsourcingServiceClient) GetMaterialList(ctx context.Context, in *GetMaterialListRequest, opts ...grpc.CallOption) (*GetMaterialListResponse, error) {
    out := new(GetMaterialListResponse)
    err := c.cc.Invoke(ctx, OutsourcingService_GetMaterialList_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
// OutsourcingServiceServer is the server API for OutsourcingService service.
// All implementations must embed UnimplementedOutsourcingServiceServer
// for forward compatibility
type OutsourcingServiceServer interface {
    GetMaterialList(context.Context, *GetMaterialListRequest) (*GetMaterialListResponse, error)
    mustEmbedUnimplementedOutsourcingServiceServer()
}
// UnimplementedOutsourcingServiceServer must be embedded to have forward compatible implementations.
type UnimplementedOutsourcingServiceServer struct {
}
func (UnimplementedOutsourcingServiceServer) GetMaterialList(context.Context, *GetMaterialListRequest) (*GetMaterialListResponse, error) {
    return nil, status.Errorf(codes.Unimplemented, "method GetMaterialList not implemented")
}
func (UnimplementedOutsourcingServiceServer) mustEmbedUnimplementedOutsourcingServiceServer() {}
// UnsafeOutsourcingServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to OutsourcingServiceServer will
// result in compilation errors.
type UnsafeOutsourcingServiceServer interface {
    mustEmbedUnimplementedOutsourcingServiceServer()
}
func RegisterOutsourcingServiceServer(s grpc.ServiceRegistrar, srv OutsourcingServiceServer) {
    s.RegisterService(&OutsourcingService_ServiceDesc, srv)
}
func _OutsourcingService_GetMaterialList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
    in := new(GetMaterialListRequest)
    if err := dec(in); err != nil {
        return nil, err
    }
    if interceptor == nil {
        return srv.(OutsourcingServiceServer).GetMaterialList(ctx, in)
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: OutsourcingService_GetMaterialList_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(OutsourcingServiceServer).GetMaterialList(ctx, req.(*GetMaterialListRequest))
    }
    return interceptor(ctx, in, info, handler)
}
// OutsourcingService_ServiceDesc is the grpc.ServiceDesc for OutsourcingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var OutsourcingService_ServiceDesc = grpc.ServiceDesc{
    ServiceName: "outsourcingService",
    HandlerType: (*OutsourcingServiceServer)(nil),
    Methods: []grpc.MethodDesc{
        {
            MethodName: "GetMaterialList",
            Handler:    _OutsourcingService_GetMaterialList_Handler,
        },
    },
    Streams:  []grpc.StreamDesc{},
    Metadata: "outsourcing.proto",
}