70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package work
|
|
|
|
import (
|
|
model2 "ArmedPolice/app/common/model"
|
|
"ArmedPolice/app/controller/basic"
|
|
"ArmedPolice/app/model"
|
|
"ArmedPolice/app/service"
|
|
)
|
|
|
|
type Instance struct{ *service.Session }
|
|
|
|
type InstanceHandle func(session *service.Session) *Instance
|
|
|
|
type (
|
|
// InstanceInfo 基本信息
|
|
InstanceInfo struct {
|
|
basic.CommonIDString
|
|
*model.WorkInstanceInfo
|
|
}
|
|
)
|
|
|
|
// List 列表信息
|
|
func (c *Instance) List(materialID uint64, kind, page, pageSize int) (*basic.PageDataResponse, error) {
|
|
mWorkInstance := model.NewWorkInstance()
|
|
|
|
where := make([]*model2.ModelWhere, 0)
|
|
|
|
if materialID > 0 {
|
|
where = append(where, model2.NewWhere("w.material_id", materialID))
|
|
}
|
|
if kind > 0 {
|
|
where = append(where, model2.NewWhere("w.kind", kind))
|
|
}
|
|
var count int64
|
|
|
|
out, err := mWorkInstance.Instances(page, pageSize, &count, where...)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
list := make([]*InstanceInfo, 0)
|
|
|
|
for _, v := range out {
|
|
mWorkInstance.ID = v.ID
|
|
|
|
list = append(list, &InstanceInfo{
|
|
CommonIDString: basic.CommonIDString{ID: mWorkInstance.GetEncodeID()}, WorkInstanceInfo: v,
|
|
})
|
|
}
|
|
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
|
}
|
|
|
|
func (c *Instance) ToDo() {
|
|
|
|
}
|
|
|
|
func (c *Instance) Form() error {
|
|
return nil
|
|
}
|
|
|
|
func (c *Instance) Delete() error {
|
|
return nil
|
|
}
|
|
|
|
func NewInstance() InstanceHandle {
|
|
return func(session *service.Session) *Instance {
|
|
return &Instance{session}
|
|
}
|
|
}
|