feat:完善项目
This commit is contained in:
@ -48,7 +48,8 @@ func initModel() {
|
|||||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||||
// 功能信息
|
// 功能信息
|
||||||
&synchronized{iModel: model.NewManageSupplier()},
|
&synchronized{iModel: model.NewManageSupplier()},
|
||||||
&synchronized{iModel: model.NewManageMaterial()}, &synchronized{iModel: model.NewManageMaterialPurchase()},
|
&synchronized{iModel: model.NewManageMaterial()}, &synchronized{iModel: model.NewManageMaterialSupplier()},
|
||||||
|
&synchronized{iModel: model.NewManageMaterialPurchase()}, &synchronized{iModel: model.NewManageMaterialWarehouse()},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func initCacheMode() {
|
func initCacheMode() {
|
||||||
|
@ -4,8 +4,9 @@ package model
|
|||||||
type ManageEquipment struct {
|
type ManageEquipment struct {
|
||||||
Model
|
Model
|
||||||
ModelTenant
|
ModelTenant
|
||||||
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
|
||||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
||||||
|
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||||
Image
|
Image
|
||||||
Config string `gorm:"column:config;type:varchar(255);default:null;comment:配置" json:"config"`
|
Config string `gorm:"column:config;type:varchar(255);default:null;comment:配置" json:"config"`
|
||||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||||
|
18
app/common/model/manage_equipment_material.go
Normal file
18
app/common/model/manage_equipment_material.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// ManageEquipmentMaterial 装备器材数据模型
|
||||||
|
type ManageEquipmentMaterial struct {
|
||||||
|
Model
|
||||||
|
EquipmentID uint64 `gorm:"column:equipment_id;type:int(11);default:0;comment:装备ID" json:"-"`
|
||||||
|
MaterialID uint64 `gorm:"column:material_id;type:int(11);default:0;comment:器材ID" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageEquipmentMaterial) TableName() string {
|
||||||
|
return "manage_equipment_material"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewManageEquipmentMaterial() *ManageEquipmentMaterial {
|
||||||
|
return &ManageEquipmentMaterial{}
|
||||||
|
}
|
20
app/common/model/manage_material_supplier.go
Normal file
20
app/common/model/manage_material_supplier.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// ManageMaterialSupplier 器材供应商数据模型
|
||||||
|
type ManageMaterialSupplier struct {
|
||||||
|
Model
|
||||||
|
MaterialID uint64 `gorm:"column:material_id;type:int(11);default:0;comment:器材ID" json:"material_id"`
|
||||||
|
SupplierID uint64 `gorm:"column:supplier_id;type:int;default:0;comment:供应商ID" json:"-"`
|
||||||
|
Stock int `gorm:"column:stock;type:int(8);default:0;comment:库存数" json:"stock"`
|
||||||
|
FrozenStock int `gorm:"column:frozen_stock;type:int(8);default:0;comment:冻结的库存数" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ManageMaterialSupplier) TableName() string {
|
||||||
|
return "manage_material_supplier"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewManageMaterialSupplier() *ManageMaterialSupplier {
|
||||||
|
return &ManageMaterialSupplier{}
|
||||||
|
}
|
@ -4,11 +4,12 @@ package model
|
|||||||
type ManageSupplier struct {
|
type ManageSupplier struct {
|
||||||
Model
|
Model
|
||||||
ModelTenant
|
ModelTenant
|
||||||
Kind ManageSupplierKind `gorm:"column:kind;type:tinyint(1);default:1;comment:类型" json:"kind"`
|
Kind ManageSupplierKind `gorm:"column:kind;type:tinyint(1);default:1;comment:类型" json:"kind"`
|
||||||
Name string `gorm:"column:name;type:varchar(100);default:null;comment:名称" json:"name"`
|
Name string `gorm:"column:name;type:varchar(100);default:null;comment:名称" json:"name"`
|
||||||
Mobile string `gorm:"column:mobile;type:varchar(20);default:null;comment:联系方式" json:"mobile"`
|
Mobile string `gorm:"column:mobile;type:varchar(20);default:null;comment:联系方式" json:"mobile"`
|
||||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:联系地址" json:"address"`
|
Contacts string `gorm:"column:contacts;type:varchar(20);default:null;comment:联系人" json:"contacts"`
|
||||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息 " json:"remark"`
|
Address string `gorm:"column:address;type:varchar(255);default:null;comment:联系地址" json:"address"`
|
||||||
|
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息 " json:"remark"`
|
||||||
ModelDeleted
|
ModelDeleted
|
||||||
ModelAt
|
ModelAt
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,23 @@ type (
|
|||||||
// EquipmentInfo 装备信息
|
// EquipmentInfo 装备信息
|
||||||
EquipmentInfo struct {
|
EquipmentInfo struct {
|
||||||
basic.CommonIDString
|
basic.CommonIDString
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
Children []*EquipmentInfo `json:"children"`
|
||||||
}
|
}
|
||||||
// EquipmentDetail 装备详细信息
|
// EquipmentDetail 装备详细信息
|
||||||
EquipmentDetail struct {
|
EquipmentDetail struct {
|
||||||
basic.CommonIDString
|
basic.CommonIDString
|
||||||
*model2.ManageEquipment
|
*model2.ManageEquipment
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
|
Materials []*EquipmentMaterialDetail `json:"materials"`
|
||||||
|
}
|
||||||
|
// EquipmentMaterialDetail 装备器材信息
|
||||||
|
EquipmentMaterialDetail struct {
|
||||||
|
*model.ManageEquipmentMaterialInfo
|
||||||
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
// EquipmentParams 装备参数信息
|
// EquipmentParams 装备参数信息
|
||||||
EquipmentParams struct {
|
EquipmentParams struct {
|
||||||
@ -45,8 +52,26 @@ func (c *EquipmentParams) isExist(iModel model2.IModel) (bool, error) {
|
|||||||
return count > 0, nil
|
return count > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Equipment) tree(src []*model2.ManageEquipment, parentID uint64) []*EquipmentInfo {
|
||||||
|
out := make([]*EquipmentInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range src {
|
||||||
|
if v.ParentID == parentID {
|
||||||
|
out = append(out, &EquipmentInfo{
|
||||||
|
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||||
|
Code: v.Code,
|
||||||
|
Title: v.Title,
|
||||||
|
Image: v.Analysis(config.SettingInfo.Domain),
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
Children: c.tree(src, v.ID),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// List 列表信息
|
// List 列表信息
|
||||||
func (c *Equipment) List(title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
func (c *Equipment) List(title string, page, pageSize int) ([]*EquipmentInfo, error) {
|
||||||
mManageEquipment := model.NewManageEquipment()
|
mManageEquipment := model.NewManageEquipment()
|
||||||
|
|
||||||
out := make([]*model2.ManageEquipment, 0)
|
out := make([]*model2.ManageEquipment, 0)
|
||||||
@ -61,23 +86,12 @@ func (c *Equipment) List(title string, page, pageSize int) (*basic.PageDataRespo
|
|||||||
Where: model2.NewWhereLike("title", title),
|
Where: model2.NewWhereLike("title", title),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var count int64
|
if err := model2.ScanFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||||
|
where...); err != nil {
|
||||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
|
||||||
page, pageSize, &count, where...); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list := make([]*EquipmentInfo, 0)
|
|
||||||
|
|
||||||
for _, v := range out {
|
return c.tree(out, 0), nil
|
||||||
list = append(list, &EquipmentInfo{
|
|
||||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
|
||||||
Code: v.Code, Title: v.Title,
|
|
||||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
|
||||||
CreatedAt: v.CreatedAt,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detail 详细信息
|
// Detail 详细信息
|
||||||
@ -85,16 +99,35 @@ func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
|||||||
mManageEquipment := model.NewManageEquipment()
|
mManageEquipment := model.NewManageEquipment()
|
||||||
mManageEquipment.ID = id
|
mManageEquipment.ID = id
|
||||||
|
|
||||||
if isExist, err := model2.FirstWhere(mManageEquipment.ManageEquipment); err != nil {
|
isExist, err := model2.FirstWhere(mManageEquipment.ManageEquipment)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return nil, errors.New("")
|
return nil, errors.New("操作错误,数据不存在")
|
||||||
}
|
}
|
||||||
return &EquipmentDetail{
|
out := &EquipmentDetail{
|
||||||
CommonIDString: basic.CommonIDString{ID: mManageEquipment.GetEncodeID()},
|
CommonIDString: basic.CommonIDString{ID: mManageEquipment.GetEncodeID()},
|
||||||
ManageEquipment: mManageEquipment.ManageEquipment,
|
ManageEquipment: mManageEquipment.ManageEquipment,
|
||||||
Image: mManageEquipment.Analysis(config.SettingInfo.Domain),
|
Image: mManageEquipment.Analysis(config.SettingInfo.Domain),
|
||||||
}, nil
|
Materials: make([]*EquipmentMaterialDetail, 0),
|
||||||
|
}
|
||||||
|
mManageEquipmentMaterial := model.NewManageEquipmentMaterial()
|
||||||
|
|
||||||
|
materials := make([]*model.ManageEquipmentMaterialInfo, 0)
|
||||||
|
|
||||||
|
if materials, err = mManageEquipmentMaterial.Materials(id); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range materials {
|
||||||
|
mManageEquipmentMaterial.ID = v.ID
|
||||||
|
|
||||||
|
out.Materials = append(out.Materials, &EquipmentMaterialDetail{
|
||||||
|
ManageEquipmentMaterialInfo: v,
|
||||||
|
ID: mManageEquipmentMaterial.GetEncodeID(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form 数据处理
|
// Form 数据处理
|
||||||
|
77
app/controller/manage/material_purchase.go
Normal file
77
app/controller/manage/material_purchase.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package manage
|
||||||
|
|
||||||
|
import (
|
||||||
|
model2 "ArmedPolice/app/common/model"
|
||||||
|
"ArmedPolice/app/controller/basic"
|
||||||
|
"ArmedPolice/app/model"
|
||||||
|
"ArmedPolice/app/service"
|
||||||
|
"ArmedPolice/lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MaterialPurchase struct{ *service.Session }
|
||||||
|
|
||||||
|
type MaterialPurchaseHandle func(session *service.Session) *MaterialPurchase
|
||||||
|
|
||||||
|
type (
|
||||||
|
// MaterialPurchaseInfo 采购信息
|
||||||
|
MaterialPurchaseInfo struct {
|
||||||
|
basic.CommonIDString
|
||||||
|
*model.ManageMaterialPurchaseInfo
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *MaterialPurchase) List(orderNo, supplierName, materialTitle string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||||
|
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||||
|
|
||||||
|
where := make([]*model2.ModelWhere, 0)
|
||||||
|
|
||||||
|
if orderNo != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("p.order_no", orderNo))
|
||||||
|
}
|
||||||
|
if supplierName != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("s.name", supplierName))
|
||||||
|
}
|
||||||
|
if materialTitle != "" {
|
||||||
|
where = append(where, model2.NewWhereLike("m.title", materialTitle))
|
||||||
|
}
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
out, err := mManageMaterialPurchase.Purchases(page, pageSize, &count, where...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*MaterialPurchaseInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &MaterialPurchaseInfo{
|
||||||
|
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||||
|
ManageMaterialPurchaseInfo: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch 采购发起
|
||||||
|
func (c *MaterialPurchase) Launch(materialSupplierID uint64, price float64, number int, remark string) error {
|
||||||
|
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||||
|
mManageMaterialPurchase.UID = c.UID
|
||||||
|
mManageMaterialPurchase.OrderNo = lib.OrderNo()
|
||||||
|
mManageMaterialPurchase.MaterialSupplierID = materialSupplierID
|
||||||
|
mManageMaterialPurchase.Price = price
|
||||||
|
mManageMaterialPurchase.Number = number
|
||||||
|
mManageMaterialPurchase.Remark = remark
|
||||||
|
return model2.Create(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *MaterialPurchase) Delete(id uint64) error {
|
||||||
|
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||||
|
mManageMaterialPurchase.ID = id
|
||||||
|
return model2.Delete(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMaterialPurchase() MaterialPurchaseHandle {
|
||||||
|
return func(session *service.Session) *MaterialPurchase {
|
||||||
|
return &MaterialPurchase{session}
|
||||||
|
}
|
||||||
|
}
|
66
app/controller/manage/material_warehouse.go
Normal file
66
app/controller/manage/material_warehouse.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package manage
|
||||||
|
|
||||||
|
import (
|
||||||
|
model2 "ArmedPolice/app/common/model"
|
||||||
|
"ArmedPolice/app/controller/basic"
|
||||||
|
"ArmedPolice/app/model"
|
||||||
|
"ArmedPolice/app/service"
|
||||||
|
"ArmedPolice/serve/orm"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MaterialWarehouse struct{ *service.Session }
|
||||||
|
|
||||||
|
type MaterialWarehouseHandle func(session *service.Session) *MaterialWarehouse
|
||||||
|
|
||||||
|
func (c *MaterialWarehouse) List() (*basic.PageDataResponse, error) {
|
||||||
|
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch 入库发起
|
||||||
|
func (c *MaterialWarehouse) Launch(materialPurchaseID uint64, number int, remark string) error {
|
||||||
|
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||||
|
mManageMaterialPurchase.ID = materialPurchaseID
|
||||||
|
|
||||||
|
isExist, err := model2.FirstWhere(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,未找到相应的采购单")
|
||||||
|
}
|
||||||
|
mManageMaterialWarehouse := model.NewManageMaterialWarehouse()
|
||||||
|
mManageMaterialWarehouse.UID = c.UID
|
||||||
|
mManageMaterialWarehouse.MaterialPurchaseID = materialPurchaseID
|
||||||
|
mManageMaterialWarehouse.Number = number
|
||||||
|
mManageMaterialWarehouse.Remark = remark
|
||||||
|
|
||||||
|
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
|
if err = model2.Create(mManageMaterialWarehouse.ManageMaterialWarehouse); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 同步库存
|
||||||
|
mManageMaterial := model.NewManageMaterial()
|
||||||
|
|
||||||
|
if err = model2.Updates(mManageMaterial.ManageMaterial, map[string]interface{}{
|
||||||
|
"stock": gorm.Expr("stock + ?", number),
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除操作
|
||||||
|
func (c *MaterialWarehouse) Delete(id uint64) error {
|
||||||
|
mManageMaterialWarehouse := model.NewManageMaterialWarehouse()
|
||||||
|
mManageMaterialWarehouse.ID = id
|
||||||
|
return model2.Delete(mManageMaterialWarehouse.ManageMaterialWarehouse)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMaterialWarehouse() MaterialWarehouseHandle {
|
||||||
|
return func(session *service.Session) *MaterialWarehouse {
|
||||||
|
return &MaterialWarehouse{session}
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,11 @@ type Supplier struct{ *service.Session }
|
|||||||
type SupplierHandle func(session *service.Session) *Supplier
|
type SupplierHandle func(session *service.Session) *Supplier
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// SupplierBasic 基本 信息
|
||||||
|
SupplierBasic struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
// SupplierInfo 基本信息
|
// SupplierInfo 基本信息
|
||||||
SupplierInfo struct {
|
SupplierInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
@ -72,12 +77,25 @@ func (c *Supplier) List(name, mobile string, kind model2.ManageSupplierKind, pag
|
|||||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Supplier) Manufacturer() {
|
// Select 筛选信息
|
||||||
|
func (c *Supplier) Select(kind int) ([]*SupplierBasic, error) {
|
||||||
|
out := make([]*model2.ManageSupplier, 0)
|
||||||
|
|
||||||
}
|
if err := model2.ScanFields(model.NewManageSupplier().ManageSupplier, &out, []string{"id", "name"},
|
||||||
|
&model2.ModelWhereOrder{
|
||||||
func (c *Supplier) Partner() {
|
Where: model2.NewWhere("kind", kind),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*SupplierBasic, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &SupplierBasic{
|
||||||
|
ID: v.GetEncodeID(),
|
||||||
|
Name: v.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form 数据处理
|
// Form 数据处理
|
||||||
|
28
app/controller/role/auth.go
Normal file
28
app/controller/role/auth.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package role
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ArmedPolice/app/controller/basic"
|
||||||
|
"ArmedPolice/app/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Auth struct{ *service.Session }
|
||||||
|
|
||||||
|
type AuthHandle func(session *service.Session) *Auth
|
||||||
|
|
||||||
|
func (c *Auth) List() (*basic.PageDataResponse, error) {
|
||||||
|
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Auth) Form() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Auth) Delete() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAuth() AuthHandle {
|
||||||
|
return func(session *service.Session) *Auth {
|
||||||
|
return &Auth{session}
|
||||||
|
}
|
||||||
|
}
|
28
app/controller/role/menu.go
Normal file
28
app/controller/role/menu.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package role
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ArmedPolice/app/controller/basic"
|
||||||
|
"ArmedPolice/app/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Menu struct{ *service.Session }
|
||||||
|
|
||||||
|
type MenuHandle func(session *service.Session) *Menu
|
||||||
|
|
||||||
|
func (c *Menu) List() (*basic.PageDataResponse, error) {
|
||||||
|
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Menu) Form() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Menu) Delete() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMenu() MenuHandle {
|
||||||
|
return func(session *service.Session) *Menu {
|
||||||
|
return &Menu{session}
|
||||||
|
}
|
||||||
|
}
|
34
app/model/manage_equipment_material.go
Normal file
34
app/model/manage_equipment_material.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"ArmedPolice/app/common/model"
|
||||||
|
"ArmedPolice/serve/orm"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ManageEquipmentMaterial struct {
|
||||||
|
*model.ManageEquipmentMaterial
|
||||||
|
}
|
||||||
|
type ManageEquipmentMaterialInfo struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
ManageMaterialBasic
|
||||||
|
}
|
||||||
|
|
||||||
|
// Materials 器材信息
|
||||||
|
func (m *ManageEquipmentMaterial) Materials(equipmentID uint64) ([]*ManageEquipmentMaterialInfo, error) {
|
||||||
|
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||||
|
Select("e.id", "m.code", "m.title", "m.unit", "s.name AS manufacturer_name").
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON e.material_id = m.id", model.NewManageMaterial().TableName())).
|
||||||
|
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m.supplier_id = s.id", model.NewManageSupplier().TableName())).
|
||||||
|
Where("e.equipment_id = ? AND e.is_deleted = ?", equipmentID, model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
out := make([]*ManageEquipmentMaterialInfo, 0)
|
||||||
|
|
||||||
|
err := db.Scan(&out).Error
|
||||||
|
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewManageEquipmentMaterial() *ManageEquipmentMaterial {
|
||||||
|
return &ManageEquipmentMaterial{model.NewManageEquipmentMaterial()}
|
||||||
|
}
|
@ -10,10 +10,19 @@ type ManageMaterial struct {
|
|||||||
*model.ManageMaterial
|
*model.ManageMaterial
|
||||||
}
|
}
|
||||||
|
|
||||||
type ManageMaterialInfo struct {
|
type (
|
||||||
*model.ManageMaterial
|
// ManageMaterialBasic 基本信息
|
||||||
SupplierName string `json:"supplier_name"`
|
ManageMaterialBasic struct {
|
||||||
}
|
Code string `json:"code"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Unit int `json:"unit"`
|
||||||
|
ManufacturerName string `json:"manufacturer_name"`
|
||||||
|
}
|
||||||
|
ManageMaterialInfo struct {
|
||||||
|
*model.ManageMaterial
|
||||||
|
SupplierName string `json:"supplier_name"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func (m *ManageMaterial) Materials(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageMaterialInfo, error) {
|
func (m *ManageMaterial) Materials(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageMaterialInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||||
|
Reference in New Issue
Block a user