feat:完善项目
This commit is contained in:
22
app/common/model/manage_material.go
Normal file
22
app/common/model/manage_material.go
Normal file
@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
// ManageMaterial 维修器材数据模型
|
||||
type ManageMaterial struct {
|
||||
Model
|
||||
ModelTenant
|
||||
SupplierID uint64 `gorm:"column:supplier_id;type:int;default:0;comment:供应商ID" json:"supplier_id"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||
Image
|
||||
Unit int `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageMaterial) TableName() string {
|
||||
return "manage_material"
|
||||
}
|
||||
|
||||
func NewManageMaterial() *ManageMaterial {
|
||||
return &ManageMaterial{}
|
||||
}
|
21
app/common/model/manage_material_purchase.go
Normal file
21
app/common/model/manage_material_purchase.go
Normal file
@ -0,0 +1,21 @@
|
||||
package model
|
||||
|
||||
// ManageMaterialPurchase 维修器材采购数据明细
|
||||
type ManageMaterialPurchase struct {
|
||||
Model
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialID uint64 `gorm:"column:material_id;type:int(6);default:0;comment:器材ID" json:"material_id"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:采购单价" json:"price"`
|
||||
Number int `gorm:"column:number;type:int(6);default:0;comment:采购数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:采购备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageMaterialPurchase) TableName() string {
|
||||
return "manage_material_purchase"
|
||||
}
|
||||
|
||||
func NewManageMaterialPurchase() *ManageMaterialPurchase {
|
||||
return &ManageMaterialPurchase{}
|
||||
}
|
20
app/common/model/manage_material_warehouse.go
Normal file
20
app/common/model/manage_material_warehouse.go
Normal file
@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
// ManageMaterialWarehouse 维修器材采购入库明细
|
||||
type ManageMaterialWarehouse struct {
|
||||
Model
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"material_purchase_id"`
|
||||
Number int `gorm:"column:number;type:int(6);default:0;comment:入库数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:入库备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageMaterialWarehouse) TableName() string {
|
||||
return "manage_material_warehouse"
|
||||
}
|
||||
|
||||
func NewManageMaterialWarehouse() *ManageMaterialWarehouse {
|
||||
return &ManageMaterialWarehouse{}
|
||||
}
|
15
app/common/model/manage_material_work.go
Normal file
15
app/common/model/manage_material_work.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type ManageMaterialWork struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *ManageMaterialWork) TableName() string {
|
||||
return "manage_material_work"
|
||||
}
|
||||
|
||||
func NewManageMaterialWork() *ManageMaterialWork {
|
||||
return &ManageMaterialWork{}
|
||||
}
|
16
app/common/model/work_instance.go
Normal file
16
app/common/model/work_instance.go
Normal file
@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
type WorkInstance struct {
|
||||
Model
|
||||
Title string `json:"title"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *WorkInstance) TableName() string {
|
||||
return "manage_instance"
|
||||
}
|
||||
|
||||
func NewWorkInstance() *WorkInstance {
|
||||
return &WorkInstance{}
|
||||
}
|
15
app/common/model/work_schedule.go
Normal file
15
app/common/model/work_schedule.go
Normal file
@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type WorkSchedule struct {
|
||||
Model
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *WorkSchedule) TableName() string {
|
||||
return "work_schedule"
|
||||
}
|
||||
|
||||
func NewWorkSchedule() *WorkSchedule {
|
||||
return &WorkSchedule{}
|
||||
}
|
@ -5,3 +5,9 @@ type PageDataResponse struct {
|
||||
Data interface{} `json:"data"`
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
||||
type (
|
||||
CommonIDString struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
)
|
||||
|
156
app/controller/manage/equipment.go
Normal file
156
app/controller/manage/equipment.go
Normal file
@ -0,0 +1,156 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
model2 "ArmedPolice/app/common/model"
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
"ArmedPolice/config"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Equipment struct{ *service.Session }
|
||||
|
||||
type EquipmentHandle func(session *service.Session) *Equipment
|
||||
|
||||
type (
|
||||
// EquipmentInfo 装备信息
|
||||
EquipmentInfo struct {
|
||||
basic.CommonIDString
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
// EquipmentDetail 装备详细信息
|
||||
EquipmentDetail struct {
|
||||
basic.CommonIDString
|
||||
*model2.ManageEquipment
|
||||
Image string `json:"image"`
|
||||
}
|
||||
// EquipmentParams 装备参数信息
|
||||
EquipmentParams struct {
|
||||
ID uint64
|
||||
Title, Image, Config, Remark string
|
||||
}
|
||||
)
|
||||
|
||||
func (c *EquipmentParams) isExist(iModel model2.IModel) (bool, error) {
|
||||
var count int64
|
||||
|
||||
if err := model2.Count(iModel, &count, model2.NewWhere("title", c.Title)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *Equipment) List(title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
out := make([]*model2.ManageEquipment, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhereLike("title", title),
|
||||
})
|
||||
}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "title", "image", "created_at"},
|
||||
page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*EquipmentInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &EquipmentInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
CreatedAt: v.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Equipment) Detail(id uint64) (*EquipmentDetail, error) {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
mManageEquipment.ID = id
|
||||
|
||||
if isExist, err := model2.FirstWhere(mManageEquipment.ManageEquipment); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("")
|
||||
}
|
||||
return &EquipmentDetail{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageEquipment.GetEncodeID()},
|
||||
ManageEquipment: mManageEquipment.ManageEquipment,
|
||||
Image: mManageEquipment.Analysis(config.SettingInfo.Domain),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Form 数据处理
|
||||
func (c *Equipment) Form(params *EquipmentParams) error {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
|
||||
if params.ID > 0 {
|
||||
mManageEquipment.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstWhere(mManageEquipment.ManageEquipment)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,装备信息不存在")
|
||||
}
|
||||
|
||||
if params.Title != mManageEquipment.Title {
|
||||
if isExist, err = params.isExist(mManageEquipment.ManageEquipment); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在相应的装备信息")
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageEquipment.Title = params.Title
|
||||
mManageEquipment.Image.Image = params.Image
|
||||
mManageEquipment.Config = params.Config
|
||||
mManageEquipment.Remark = params.Remark
|
||||
|
||||
if mManageEquipment.ID > 0 {
|
||||
mManageEquipment.UpdatedAt = time.Now()
|
||||
return model2.Updates(mManageEquipment.ManageEquipment, mManageEquipment.ManageEquipment)
|
||||
}
|
||||
// 查询装备信息是否存在
|
||||
if isExist, err := params.isExist(mManageEquipment.ManageEquipment); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,已存在相应的装备信息")
|
||||
}
|
||||
mManageEquipment.TenantID = c.TenantID
|
||||
return model2.Create(mManageEquipment.ManageEquipment)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Equipment) Delete(id uint64) error {
|
||||
mManageEquipment := model.NewManageEquipment()
|
||||
mManageEquipment.ID = id
|
||||
|
||||
if err := model2.Delete(mManageEquipment.ManageEquipment); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewEquipment() EquipmentHandle {
|
||||
return func(session *service.Session) *Equipment {
|
||||
return &Equipment{session}
|
||||
}
|
||||
}
|
38
app/controller/manage/material.go
Normal file
38
app/controller/manage/material.go
Normal file
@ -0,0 +1,38 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
model2 "ArmedPolice/app/common/model"
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
)
|
||||
|
||||
type Material struct{ *service.Session }
|
||||
|
||||
type MaterialHandle func(session *service.Session) *Material
|
||||
|
||||
func (c *Material) List(title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
out := make([]*model2.ManageMaterial, 0)
|
||||
|
||||
var count int64
|
||||
|
||||
model2.PagesFields(mManageMaterial.ManageMaterial, &out, []string{"id", "title"}, page, pageSize, &count)
|
||||
|
||||
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||
}
|
||||
|
||||
func (c *Material) Form() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Material) Delete() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewMaterial() MaterialHandle {
|
||||
return func(session *service.Session) *Material {
|
||||
return &Material{session}
|
||||
}
|
||||
}
|
28
app/controller/user/menu.go
Normal file
28
app/controller/user/menu.go
Normal file
@ -0,0 +1,28 @@
|
||||
package user
|
||||
|
||||
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}
|
||||
}
|
||||
}
|
11
app/model/manage_equipment.go
Normal file
11
app/model/manage_equipment.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "ArmedPolice/app/common/model"
|
||||
|
||||
type ManageEquipment struct {
|
||||
*model.ManageEquipment
|
||||
}
|
||||
|
||||
func NewManageEquipment() *ManageEquipment {
|
||||
return &ManageEquipment{model.NewManageEquipment()}
|
||||
}
|
22
app/model/manage_material.go
Normal file
22
app/model/manage_material.go
Normal file
@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
"ArmedPolice/serve/orm"
|
||||
)
|
||||
|
||||
type ManageMaterial struct {
|
||||
*model.ManageMaterial
|
||||
}
|
||||
|
||||
type ManageMaterialInfo struct {
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
func (m *ManageMaterial) Materials() {
|
||||
orm.GetDB().Table(m.TableName() + " AS m").Select("")
|
||||
}
|
||||
|
||||
func NewManageMaterial() *ManageMaterial {
|
||||
return &ManageMaterial{model.NewManageMaterial()}
|
||||
}
|
Reference in New Issue
Block a user