feat:完善项目
This commit is contained in:
@ -134,7 +134,7 @@ func (*Manage) EquipmentSelect(c *gin.Context) {
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} [id="''"] 区域标识
|
||||
* @apiParam {String} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
@ -325,3 +325,120 @@ func (*Manage) MaterialDelete(c *gin.Context) {
|
||||
err := manage.NewMaterial()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/supplier/select 器材供应商信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialSupplierSelect
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} material_id 器材ID
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id ID
|
||||
* @apiSuccess (200) {String} data.supplier_name 供应商名称
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "supplier_name": "供应商名称",
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (*Manage) MaterialSupplierSelect(c *gin.Context) {
|
||||
form := &struct {
|
||||
MaterialID string `json:"material_id" form:"material_id" binding:"required"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &IDStringForm{ID: form.MaterialID}
|
||||
data, err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Select(obj.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/supplier/bind 器材供应商绑定
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialSupplierBind
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} material_id 器材ID
|
||||
* @apiParam {String} supplier_id 供应商ID
|
||||
* @apiParam {Float} stock 库存数
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Manage) MaterialSupplierBind(c *gin.Context) {
|
||||
form := &struct {
|
||||
MaterialID string `json:"material_id" form:"material_id" binding:"required"`
|
||||
SupplierID string `json:"supplier_id" form:"supplier_id" binding:"required"`
|
||||
Stock float64 `json:"stock" form:"stock"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := &IDStringForm{ID: form.MaterialID}
|
||||
materialID := obj.Convert()
|
||||
obj.ID = form.SupplierID
|
||||
supplierID := obj.Convert()
|
||||
err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Form(materialID, supplierID, form.Stock)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} /api/v1/manage/material/supplier/delete 器材供应商删除
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName ManageMaterialSupplierDelete
|
||||
* @apiGroup Manage
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (*Manage) MaterialSupplierDelete(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := manage.NewMaterialSuppler()(getSession()(c).(*service.Session)).Delete(form.Convert())
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ 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:"-"`
|
||||
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 float64 `gorm:"column:stock;type:decimal(10,2);default:0;comment:库存数" json:"stock"`
|
||||
FrozenStock float64 `gorm:"column:frozen_stock;type:decimal(10,2);default:0;comment:冻结的库存数" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
18
app/common/model/work_repair.go
Normal file
18
app/common/model/work_repair.go
Normal file
@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
// WorkRepair 工单维修数据模型
|
||||
type WorkRepair struct {
|
||||
Model
|
||||
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"-"`
|
||||
Status int `json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *WorkRepair) TableName() string {
|
||||
return "work_repair"
|
||||
}
|
||||
|
||||
func NewWorkRepair() *WorkRepair {
|
||||
return &WorkRepair{}
|
||||
}
|
74
app/controller/manage/material_suppler.go
Normal file
74
app/controller/manage/material_suppler.go
Normal file
@ -0,0 +1,74 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
model2 "ArmedPolice/app/common/model"
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
)
|
||||
|
||||
type MaterialSuppler struct{ *service.Session }
|
||||
|
||||
type MaterialSupplerHandle func(session *service.Session) *MaterialSuppler
|
||||
|
||||
type (
|
||||
// MaterialSupplerBasic 基本信息
|
||||
MaterialSupplerBasic struct {
|
||||
basic.CommonIDString
|
||||
*model.ManageMaterialSupplierBasic
|
||||
}
|
||||
)
|
||||
|
||||
func (c *MaterialSuppler) List() (*basic.PageDataResponse, error) {
|
||||
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *MaterialSuppler) Select(materialID uint64) ([]*MaterialSupplerBasic, error) {
|
||||
mManageMaterSupplier := model.NewManageMaterSupplier()
|
||||
out, err := mManageMaterSupplier.Basic(model2.NewWhere("m_s.material_id", materialID))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*MaterialSupplerBasic, 0)
|
||||
|
||||
for _, v := range out {
|
||||
mManageMaterSupplier.SetID(v.ID)
|
||||
|
||||
list = append(list, &MaterialSupplerBasic{
|
||||
CommonIDString: basic.CommonIDString{ID: mManageMaterSupplier.GetEncodeID()},
|
||||
ManageMaterialSupplierBasic: v,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *MaterialSuppler) Form(materialID, supplierID uint64, stock float64) error {
|
||||
mManageMaterSupplier := model.NewManageMaterSupplier()
|
||||
|
||||
var count int64
|
||||
|
||||
if err := model2.Count(mManageMaterSupplier.ManageMaterialSupplier, &count, model2.NewWhere("material_id", materialID),
|
||||
model2.NewWhere("supplier_id", supplierID)); err != nil {
|
||||
return err
|
||||
}
|
||||
mManageMaterSupplier.MaterialID = materialID
|
||||
mManageMaterSupplier.SupplierID = supplierID
|
||||
mManageMaterSupplier.Stock = stock
|
||||
return model2.Create(mManageMaterSupplier.ManageMaterialSupplier)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *MaterialSuppler) Delete(id uint64) error {
|
||||
mManageMaterSupplier := model.NewManageMaterSupplier()
|
||||
mManageMaterSupplier.SetID(id)
|
||||
return model2.Delete(mManageMaterSupplier.ManageMaterialSupplier)
|
||||
}
|
||||
|
||||
func NewMaterialSuppler() MaterialSupplerHandle {
|
||||
return func(session *service.Session) *MaterialSuppler {
|
||||
return &MaterialSuppler{session}
|
||||
}
|
||||
}
|
107
app/controller/work/schedule.go
Normal file
107
app/controller/work/schedule.go
Normal file
@ -0,0 +1,107 @@
|
||||
package work
|
||||
|
||||
import (
|
||||
model2 "ArmedPolice/app/common/model"
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Schedule struct{ *service.Session }
|
||||
|
||||
type ScheduleHandle func(session *service.Session) *Schedule
|
||||
|
||||
type (
|
||||
// ScheduleInfo 流程信息
|
||||
ScheduleInfo struct {
|
||||
Kind model2.WorkScheduleKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Schedules []*ScheduleDetailInfo `json:"schedules"`
|
||||
}
|
||||
// ScheduleDetailInfo 流程详细信息
|
||||
ScheduleDetailInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.WorkSchedules
|
||||
}
|
||||
// ScheduleParams 流程参数信息
|
||||
ScheduleParams struct {
|
||||
ID uint64
|
||||
Title string
|
||||
Stage, Step, Target, IsCountersign int
|
||||
TargetValue []string
|
||||
}
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *Schedule) List() ([]*ScheduleInfo, error) {
|
||||
mWorkSchedule := model.NewWorkSchedule()
|
||||
|
||||
out, err := mWorkSchedule.Schedules()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ScheduleInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
|
||||
isExist := false
|
||||
|
||||
if len(list) <= 0 {
|
||||
goto CONTINUE
|
||||
}
|
||||
for _, val := range list {
|
||||
if val.Kind == v.Kind {
|
||||
val.Schedules = append(val.Schedules, &ScheduleDetailInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
WorkSchedules: v,
|
||||
})
|
||||
isExist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isExist {
|
||||
goto CONTINUE
|
||||
}
|
||||
continue
|
||||
CONTINUE:
|
||||
list = append(list, &ScheduleInfo{
|
||||
Kind: v.Kind,
|
||||
Title: v.KindTitle(),
|
||||
Schedules: []*ScheduleDetailInfo{&ScheduleDetailInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
WorkSchedules: v,
|
||||
}},
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Schedule) Form(params *ScheduleParams) error {
|
||||
if params.ID > 0 {
|
||||
mWorkSchedule := model.NewWorkSchedule()
|
||||
mWorkSchedule.ID = params.ID
|
||||
mWorkSchedule.SetTargetValueAttribute(params.TargetValue)
|
||||
return model2.Updates(mWorkSchedule.WorkSchedule, map[string]interface{}{
|
||||
"title": params.Title, "target": params.Target, "target_value": mWorkSchedule.TargetValue,
|
||||
"updated_at": time.Now(),
|
||||
})
|
||||
}
|
||||
return errors.New("操作错误,暂不支持新增流程")
|
||||
}
|
||||
|
||||
// Delete 数据删除
|
||||
func (c *Schedule) Delete(id uint64) error {
|
||||
mWorkSchedule := model.NewWorkSchedule()
|
||||
mWorkSchedule.ID = id
|
||||
return model2.Delete(mWorkSchedule.WorkSchedule)
|
||||
}
|
||||
|
||||
func NewSchedule() ScheduleHandle {
|
||||
return func(session *service.Session) *Schedule {
|
||||
return &Schedule{session}
|
||||
}
|
||||
}
|
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{}
|
||||
}
|
@ -153,6 +153,9 @@ func (this *Router) registerAPI() {
|
||||
manageV1.POST("/material/add", _api.MaterialAdd)
|
||||
manageV1.POST("/material/edit", _api.MaterialEdit)
|
||||
manageV1.POST("/material/delete", _api.MaterialDelete)
|
||||
manageV1.POST("/material/supplier/select", _api.MaterialSupplierSelect)
|
||||
manageV1.POST("/material/supplier/bind", _api.MaterialSupplierBind)
|
||||
manageV1.POST("/material/supplier/delete", _api.MaterialSupplierDelete)
|
||||
}
|
||||
// Work 工单管理
|
||||
workV1 := v1.Group("/work")
|
||||
|
Reference in New Issue
Block a user