liujiandao
2024-04-07 4630cbf64d1d4f33376efaaec7b4fcb90b01bf05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package supplier
 
import (
    "context"
    "srm/global"
    "srm/model/test"
)
 
type Server struct {
    UnimplementedSupplierServiceServer
}
 
func (s *Server) GetSupplierList(c context.Context, req *SupplierListRequest) (*SupplierListResponse, error) {
    var supplierList []*test.Supplier
    resp := new(SupplierListResponse)
 
    db := global.GVA_DB.Table("srm_supplier")
    if req.Status != -1 {
        db = db.Where("status=?", req.Status)
    }
    if err := db.Find(&supplierList).Error; err != nil {
        return resp, err
    }
    for _, v := range supplierList {
        resp.List = append(resp.List, &SupplierInfo{SupplierId: int32(v.ID), SupplierName: v.Name})
    }
    return resp, nil
}