feat:完善项目
This commit is contained in:
40
app/model/manage_material_supplier.go
Normal file
40
app/model/manage_material_supplier.go
Normal file
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
"ArmedPolice/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageMaterialSupplier struct {
|
||||
*model.ManageMaterialSupplier
|
||||
}
|
||||
|
||||
type ManageMaterialSupplierBasic struct {
|
||||
ID uint64 `json:"id"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
}
|
||||
|
||||
// Basic 基本信息
|
||||
func (m *ManageMaterialSupplier) Basic(where ...*model.ModelWhere) ([]*ManageMaterialSupplierBasic, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" m_s").
|
||||
Select("m_s.id", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m_s.supplier_id = s.id", model.NewManageSupplier().TableName())).
|
||||
Where("m_s.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageMaterialSupplierBasic, 0)
|
||||
|
||||
if err := db.Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageMaterSupplier() *ManageMaterialSupplier {
|
||||
return &ManageMaterialSupplier{}
|
||||
}
|
Reference in New Issue
Block a user