feat:完善项目

This commit is contained in:
henry
2021-11-19 18:21:12 +08:00
parent c5f4a5d281
commit 83a2d64ee6
10 changed files with 191 additions and 32 deletions

View File

@ -5,8 +5,6 @@ import (
"ArmedPolice/config"
"ArmedPolice/lib"
"ArmedPolice/serve/orm"
"ArmedPolice/utils"
"fmt"
)
type synchronized struct {
@ -21,6 +19,40 @@ type caches struct {
toCache func(values interface{})
}
type (
// structForSysConfig 系统配置
structForSysConfig struct {
ID uint64 `json:"id"`
Kind int `json:"kind"`
Name string `json:"name"`
Key string `json:"key"`
Value string `json:"value"`
IsDeleted int `json:"is_deleted"`
}
// structForSysRole 角色配置
structForSysRole struct {
ID uint64 `json:"id"`
TenantID uint64 `json:"tenant_id"`
ParentID uint64 `json:"parent_id"`
Name string `json:"name"`
Remark string `json:"remark"`
Sort int `json:"sort"`
IsDeleted int `json:"is_deleted"`
}
// structForWorkSchedule 工单流程配置
structForWorkSchedule struct {
ID uint64 `json:"id"`
Kind int `json:"kind"`
Title string `json:"title"`
Stage int `json:"stage"`
Step int `json:"step"`
Target int `json:"target"`
TargetValue string `json:"target_value"`
IsCountersign int `json:"is_countersign"`
IsDeleted int `json:"is_deleted"`
}
)
func initModel() {
db := orm.GetDB()
@ -40,10 +72,23 @@ func initModel() {
function(
&synchronized{iModel: model.NewSysTenant()},
&synchronized{iModel: model.NewSysConfig(), iValues: func() interface{} {
values := make([]*model.SysConfig, 0)
lib.LoadConfig("./json/sys_config.json", &values)
fmt.Println(utils.AnyToJSON(values))
return values
values := make([]*structForSysConfig, 0)
out := make([]*model.SysConfig, 0)
lib.LoadConfig("./json/sys_config.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.SysConfig{
Model: model.Model{ID: v.ID},
Kind: model.SysConfigKind(v.Kind),
Name: v.Name,
Key: v.Key,
Value: v.Value,
ModelDeleted: model.ModelDeleted{IsDeleted: model.DeleteStatus(v.IsDeleted)},
})
}
})
return out
}},
&synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()},
&synchronized{iModel: model.NewSysUser(), iValues: func() interface{} {
@ -51,9 +96,23 @@ func initModel() {
IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"}
}},
&synchronized{iModel: model.NewSysRole(), iValues: func() interface{} {
values := make([]*model.SysRole, 0)
lib.LoadConfig("./json/sys_role.json", &values)
return values
out := make([]*model.SysRole, 0)
values := make([]*structForSysRole, 0)
lib.LoadConfig("./json/sys_role.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.SysRole{
Model: model.Model{ID: v.ID},
ModelTenant: model.ModelTenant{TenantID: v.TenantID},
ParentID: v.ParentID,
Name: v.Name,
Remark: v.Remark,
Sort: v.Sort,
ModelDeleted: model.ModelDeleted{IsDeleted: model.DeleteStatus(v.IsDeleted)},
})
}
})
return out
}}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
&synchronized{iModel: model.NewSysUserRole()},
// 日志管理
@ -68,10 +127,28 @@ func initModel() {
&synchronized{iModel: model.NewManageMaterialPurchase()}, &synchronized{iModel: model.NewManageMaterialWarehouse()},
&synchronized{iModel: model.NewWorkInstance()}, &synchronized{iModel: model.NewWorkMaterial()}, &synchronized{iModel: model.NewWorkProgress()},
&synchronized{iModel: model.NewWorkSchedule(), iValues: func() interface{} {
values := make([]*model.WorkSchedule, 0)
lib.LoadConfig("./json/work_schedule.json", &values)
return values
}}, &synchronized{iModel: model.NewWorkPurchase()},
out := make([]*model.WorkSchedule, 0)
values := make([]*structForWorkSchedule, 0)
lib.LoadConfig("./json/work_schedule.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.WorkSchedule{
Model: model.Model{ID: v.ID},
Kind: model.WorkScheduleKind(v.Kind),
Title: v.Title,
Stage: v.Stage,
Step: v.Step,
Target: model.WorkScheduleTarget(v.Target),
TargetValue: v.TargetValue,
IsCountersign: model.WorkScheduleCountersign(v.IsCountersign),
ModelDeleted: model.ModelDeleted{IsDeleted: model.DeleteStatus(v.IsDeleted)},
})
}
})
return out
},
}, &synchronized{iModel: model.NewWorkPurchase()},
&synchronized{iModel: model.NewWorkRepair()}, &synchronized{iModel: model.NewWorkRepairDetail()},
)
}

View File

@ -7,7 +7,7 @@ type WorkRepair struct {
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"-"`
Status WorkRepairStatus `gorm:"column:status;type:tinyint(1);default:0;comment:维修工单状态" json:"status"`
IsEvaluate WorkRepairStatusEvaluate `gorm:"column:is_evaluate;type:tinyint(1);default:0;comment:评价状态" json:"is_evaluate"`
EvaluateScore int `gorm:"column:evaluate_score;type:decimal(10,2);default:0;comment:评价分数" json:"evaluate_score"`
EvaluateScore float64 `gorm:"column:evaluate_score;type:decimal(10,2);default:0;comment:评价分数" json:"evaluate_score"`
ModelDeleted
ModelAt
}