fix: rebuild MES as compilable go-zero+ent backend (renamed bj_power_mes), restore 3 workstation projects from pristine original, align naming; all Go projects go build clean
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package mom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/producttype"
|
||||
)
|
||||
|
||||
// MatchProductType 通过 product_type.name 匹配 MOM 的 ProdModel(V_WO_PROD.PROD_MODEL)。
|
||||
// 返回 nil 表示未找到匹配的产品类型。
|
||||
func MatchProductType(ctx context.Context, client *ent.Client, prodModel string) (*ent.ProductType, error) {
|
||||
pt, err := client.ProductType.Query().
|
||||
Where(producttype.NameEQ(prodModel), producttype.IsActive(true)).
|
||||
First(ctx)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("match product type %s: %w", prodModel, err)
|
||||
}
|
||||
return pt, nil
|
||||
}
|
||||
Reference in New Issue
Block a user