模版管理。
This commit is contained in:
parent
6f15042888
commit
704c865924
@ -29,7 +29,7 @@ func CreateClassify(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断创建的分类是否存在
|
// 判断创建的分类是否存在
|
||||||
err = orm.Eloquent.Table("process_classify").
|
err = orm.Eloquent.Table("p_process_classify").
|
||||||
Where("name = ?", classifyValue.Name).
|
Where("name = ?", classifyValue.Name).
|
||||||
Count(&classifyCount).Error
|
Count(&classifyCount).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -41,7 +41,7 @@ func CreateClassify(c *gin.Context) {
|
|||||||
|
|
||||||
classifyValue.Creator = tools.GetUserId(c)
|
classifyValue.Creator = tools.GetUserId(c)
|
||||||
|
|
||||||
err = orm.Eloquent.Table("process_classify").Create(&classifyValue).Error
|
err = orm.Eloquent.Table("p_process_classify").Create(&classifyValue).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tools.HasError(err, "", -1)
|
tools.HasError(err, "", -1)
|
||||||
}
|
}
|
||||||
@ -66,14 +66,14 @@ func ClassifyList(c *gin.Context) {
|
|||||||
"like": pagination.RequestParams(c),
|
"like": pagination.RequestParams(c),
|
||||||
}
|
}
|
||||||
|
|
||||||
db := orm.Eloquent.Model(&process2.Classify{}).Joins("left join sys_user on sys_user.user_id = process_classify.creator").
|
db := orm.Eloquent.Model(&process2.Classify{}).Joins("left join sys_user on sys_user.user_id = p_process_classify.creator").
|
||||||
Select("process_classify.*, sys_user.username as create_user, sys_user.nick_name as create_name").
|
Select("p_process_classify.*, sys_user.username as create_user, sys_user.nick_name as create_name").
|
||||||
Where("process_classify.`delete_time` IS NULL")
|
Where("p_process_classify.`delete_time` IS NULL")
|
||||||
|
|
||||||
result, err := pagination.Paging(&pagination.Param{
|
result, err := pagination.Paging(&pagination.Param{
|
||||||
C: c,
|
C: c,
|
||||||
DB: db,
|
DB: db,
|
||||||
}, &classifyList, SearchParams, "process_classify")
|
}, &classifyList, SearchParams, "p_process_classify")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tools.HasError(err, "", -1)
|
tools.HasError(err, "", -1)
|
||||||
|
@ -34,15 +34,15 @@ package process
|
|||||||
//
|
//
|
||||||
// db := connection.DB.Self.
|
// db := connection.DB.Self.
|
||||||
// Model(&process2.Info{}).
|
// Model(&process2.Info{}).
|
||||||
// Joins("left join user_info on user_info.id = process_info.creator").
|
// Joins("left join user_info on user_info.id = p_process_info.creator").
|
||||||
// Joins("left join process_classify on process_classify.id = process_info.classify").
|
// Joins("left join p_process_classify on p_process_classify.id = p_process_info.classify").
|
||||||
// Select("process_info.id, process_info.create_time, process_info.update_time, process_info.name, process_info.creator, process_classify.name as classify_name, user_info.username as create_user, user_info.nickname as create_name").
|
// Select("p_process_info.id, p_process_info.create_time, p_process_info.update_time, p_process_info.name, p_process_info.creator, p_process_classify.name as classify_name, user_info.username as create_user, user_info.nickname as create_name").
|
||||||
// Where("process_info.`delete_time` IS NULL")
|
// Where("p_process_info.`delete_time` IS NULL")
|
||||||
//
|
//
|
||||||
// result, err := pagination.Paging(&pagination.Param{
|
// result, err := pagination.Paging(&pagination.Param{
|
||||||
// C: c,
|
// C: c,
|
||||||
// DB: db,
|
// DB: db,
|
||||||
// }, &processList, SearchParams, "process_info")
|
// }, &processList, SearchParams, "p_process_info")
|
||||||
//
|
//
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// Response(c, code.SelectError, nil, fmt.Sprintf("查询流程列表失败,%v", err.Error()))
|
// Response(c, code.SelectError, nil, fmt.Sprintf("查询流程列表失败,%v", err.Error()))
|
||||||
|
@ -1,154 +1,147 @@
|
|||||||
package process
|
package process
|
||||||
|
|
||||||
//import (
|
import (
|
||||||
// "ferry/models/tpl"
|
"errors"
|
||||||
// "ferry/pkg/connection"
|
"ferry/global/orm"
|
||||||
// "ferry/pkg/pagination"
|
"ferry/models/process"
|
||||||
// "ferry/pkg/response/code"
|
"ferry/pkg/pagination"
|
||||||
// . "ferry/pkg/response/response"
|
"ferry/tools"
|
||||||
// "fmt"
|
"ferry/tools/app"
|
||||||
//
|
|
||||||
// "github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
//)
|
)
|
||||||
//
|
|
||||||
///*
|
/*
|
||||||
// @Author : lanyulei
|
@Author : lanyulei
|
||||||
//*/
|
*/
|
||||||
//
|
|
||||||
//// 模板列表
|
// 模板列表
|
||||||
//func TemplateList(c *gin.Context) {
|
func TemplateList(c *gin.Context) {
|
||||||
// type templateUserValue struct {
|
type templateUserValue struct {
|
||||||
// tpl.Info
|
process.TplInfo
|
||||||
// CreateUser string `json:"create_user"`
|
CreateUser string `json:"create_user"`
|
||||||
// CreateName string `json:"create_name"`
|
CreateName string `json:"create_name"`
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// var (
|
var (
|
||||||
// err error
|
err error
|
||||||
// templateList []*templateUserValue
|
templateList []*templateUserValue
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// SearchParams := map[string]map[string]interface{}{
|
SearchParams := map[string]map[string]interface{}{
|
||||||
// "like": pagination.RequestParams(c),
|
"like": pagination.RequestParams(c),
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// db := connection.DB.Self.Model(&tpl.Info{}).Joins("left join user_info on user_info.id = tpl_info.creator").
|
db := orm.Eloquent.Model(&process.TplInfo{}).Joins("left join sys_user on sys_user.user_id = p_tpl_info.creator").
|
||||||
// Select("tpl_info.id, tpl_info.create_time, tpl_info.update_time, tpl_info.`name`, tpl_info.`creator`, user_info.username as create_user, user_info.nickname as create_name").Where("tpl_info.`delete_time` IS NULL")
|
Select("p_tpl_info.id, p_tpl_info.create_time, p_tpl_info.update_time, p_tpl_info.`name`, p_tpl_info.`creator`, sys_user.username as create_user, sys_user.nick_name as create_name")
|
||||||
//
|
|
||||||
// result, err := pagination.Paging(&pagination.Param{
|
result, err := pagination.Paging(&pagination.Param{
|
||||||
// C: c,
|
C: c,
|
||||||
// DB: db,
|
DB: db,
|
||||||
// }, &templateList, SearchParams, "tpl_info")
|
}, &templateList, SearchParams, "p_tpl_info")
|
||||||
//
|
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// Response(c, code.SelectError, nil, fmt.Sprintf("查询模版失败,%v", err.Error()))
|
tools.HasError(err, "")
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
//
|
app.OK(c, result, "获取模版列表成功")
|
||||||
// Response(c, nil, result, "")
|
}
|
||||||
//}
|
|
||||||
//
|
// 创建模版
|
||||||
//// 创建模版
|
func CreateTemplate(c *gin.Context) {
|
||||||
//func CreateTemplate(c *gin.Context) {
|
var (
|
||||||
// var (
|
err error
|
||||||
// err error
|
templateValue process.TplInfo
|
||||||
// templateValue tpl.Info
|
templateCount int
|
||||||
// templateCount int
|
)
|
||||||
// )
|
|
||||||
//
|
err = c.ShouldBind(&templateValue)
|
||||||
// err = c.ShouldBind(&templateValue)
|
if err != nil {
|
||||||
// if err != nil {
|
tools.HasError(err, "")
|
||||||
// Response(c, code.BindError, nil, err.Error())
|
}
|
||||||
// return
|
|
||||||
// }
|
// 确认模版名称是否存在
|
||||||
//
|
err = orm.Eloquent.Model(&templateValue).
|
||||||
// // 确定修改的分类是否存在
|
Where("name = ?", templateValue.Name).
|
||||||
// err = connection.DB.Self.Model(&templateValue).
|
Count(&templateCount).Error
|
||||||
// Where("name = ?", templateValue.Name).
|
if err != nil {
|
||||||
// Count(&templateCount).Error
|
tools.HasError(err, "")
|
||||||
// if err != nil {
|
}
|
||||||
// Response(c, code.SelectError, nil, fmt.Sprintf("查询模版数量失败,%v", err.Error()))
|
if templateCount > 0 {
|
||||||
// return
|
tools.HasError(errors.New("模版名称已存在"), "")
|
||||||
// }
|
}
|
||||||
// if templateCount > 0 {
|
|
||||||
// Response(c, code.InternalServerError, nil, "模版名称出现重复,请换一个名称")
|
templateValue.Creator = tools.GetUserId(c) // 当前登陆用户ID
|
||||||
// return
|
err = orm.Eloquent.Create(&templateValue).Error
|
||||||
// }
|
if err != nil {
|
||||||
//
|
tools.HasError(err, "")
|
||||||
// templateValue.Creator = c.GetInt("userId") // 当前登陆用户ID
|
}
|
||||||
// err = connection.DB.Self.Create(&templateValue).Error
|
|
||||||
// if err != nil {
|
app.OK(c, "", "创建模版成功")
|
||||||
// Response(c, code.CreateError, nil, fmt.Sprintf("创建模板失败,%v", err.Error()))
|
}
|
||||||
// return
|
|
||||||
// }
|
// 模版详情
|
||||||
//
|
func TemplateDetails(c *gin.Context) {
|
||||||
// Response(c, nil, nil, "")
|
var (
|
||||||
//}
|
err error
|
||||||
//
|
templateDetailsValue process.TplInfo
|
||||||
//// 模版详情
|
)
|
||||||
//func TemplateDetails(c *gin.Context) {
|
|
||||||
// var (
|
templateId := c.DefaultQuery("template_id", "")
|
||||||
// err error
|
if templateId == "" {
|
||||||
// templateDetailsValue tpl.Info
|
tools.HasError(err, "")
|
||||||
// )
|
}
|
||||||
//
|
|
||||||
// templateId := c.DefaultQuery("template_id", "")
|
err = orm.Eloquent.Model(&templateDetailsValue).
|
||||||
// if templateId == "" {
|
Where("id = ?", templateId).
|
||||||
// Response(c, code.ParamError, nil, fmt.Sprintf("参数不正确,请确认template_id是否传递"))
|
Find(&templateDetailsValue).Error
|
||||||
// return
|
if err != nil {
|
||||||
// }
|
tools.HasError(err, "")
|
||||||
//
|
}
|
||||||
// err = connection.DB.Self.Model(&templateDetailsValue).Where("id = ?", templateId).Find(&templateDetailsValue).Error
|
|
||||||
// if err != nil {
|
app.OK(c, templateDetailsValue, "")
|
||||||
// Response(c, code.SelectError, nil, fmt.Sprintf("查询模版数据失败,%v", err.Error()))
|
}
|
||||||
// return
|
|
||||||
// }
|
// 更新模版
|
||||||
//
|
func UpdateTemplate(c *gin.Context) {
|
||||||
// Response(c, nil, templateDetailsValue, "")
|
var (
|
||||||
//}
|
err error
|
||||||
//
|
templateValue process.TplInfo
|
||||||
//// 更新模版
|
)
|
||||||
//func UpdateTemplate(c *gin.Context) {
|
err = c.ShouldBind(&templateValue)
|
||||||
// var (
|
if err != nil {
|
||||||
// err error
|
tools.HasError(err, "")
|
||||||
// templateValue tpl.Info
|
}
|
||||||
// )
|
|
||||||
// err = c.ShouldBind(&templateValue)
|
err = orm.Eloquent.Model(&templateValue).
|
||||||
// if err != nil {
|
Where("id = ?", templateValue.Id).
|
||||||
// Response(c, code.BindError, nil, fmt.Sprintf("参数绑定失败,%v", err.Error()))
|
Updates(map[string]interface{}{
|
||||||
// return
|
"name": templateValue.Name,
|
||||||
// }
|
"remarks": templateValue.Remarks,
|
||||||
//
|
"form_structure": templateValue.FormStructure,
|
||||||
// err = connection.DB.Self.Model(&templateValue).Where("id = ?", templateValue.Id).Updates(map[string]interface{}{
|
}).Error
|
||||||
// "name": templateValue.Name,
|
if err != nil {
|
||||||
// "remarks": templateValue.Remarks,
|
tools.HasError(err, "")
|
||||||
// "form_structure": templateValue.FormStructure,
|
}
|
||||||
// }).Error
|
|
||||||
// if err != nil {
|
app.OK(c, templateValue, "")
|
||||||
// Response(c, code.UpdateError, nil, fmt.Sprintf("更新模版失败,%v", err.Error()))
|
}
|
||||||
// return
|
|
||||||
// }
|
// 删除模版
|
||||||
//
|
func DeleteTemplate(c *gin.Context) {
|
||||||
// Response(c, nil, templateValue, "")
|
var (
|
||||||
//}
|
err error
|
||||||
//
|
)
|
||||||
//// 删除模版
|
|
||||||
//func DeleteTemplate(c *gin.Context) {
|
templateId := c.DefaultQuery("templateId", "")
|
||||||
// var (
|
if templateId == "" {
|
||||||
// err error
|
tools.HasError(errors.New("参数不正确,请确认templateId是否传递"), "")
|
||||||
// )
|
}
|
||||||
//
|
|
||||||
// templateId := c.DefaultQuery("template_id", "")
|
err = orm.Eloquent.Delete(process.TplInfo{}, "id = ?", templateId).Error
|
||||||
// if templateId == "" {
|
if err != nil {
|
||||||
// Response(c, code.ParamError, nil, fmt.Sprintf("参数不正确,请确认template_id是否传递"))
|
tools.HasError(err, "")
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
//
|
app.OK(c, "", "删除模版成功")
|
||||||
// err = connection.DB.Self.Delete(tpl.Info{}, "id = ?", templateId).Error
|
}
|
||||||
// if err != nil {
|
|
||||||
// Response(c, code.DeleteError, nil, fmt.Sprintf("模版删除失败,%v", err.Error()))
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Response(c, nil, nil, "")
|
|
||||||
//}
|
|
||||||
|
@ -23,5 +23,12 @@ func AutoMigrate(db *gorm.DB) error {
|
|||||||
|
|
||||||
// 流程中心
|
// 流程中心
|
||||||
new(process.Classify),
|
new(process.Classify),
|
||||||
|
new(process.TplInfo),
|
||||||
|
new(process.TplData),
|
||||||
|
new(process.WorkOrderInfo),
|
||||||
|
new(process.TaskInfo),
|
||||||
|
new(process.Info),
|
||||||
|
new(process.History),
|
||||||
|
new(process.CirculationHistory),
|
||||||
).Error
|
).Error
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ type CirculationHistory struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (CirculationHistory) TableName() string {
|
func (CirculationHistory) TableName() string {
|
||||||
return "work_order_circulation_history"
|
return "p_work_order_circulation_history"
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,5 @@ type Classify struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (Classify) TableName() string {
|
func (Classify) TableName() string {
|
||||||
return "process_classify"
|
return "p_process_classify"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ type History struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (History) TableName() string {
|
func (History) TableName() string {
|
||||||
return "task_history"
|
return "p_task_history"
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,5 @@ type Info struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (Info) TableName() string {
|
func (Info) TableName() string {
|
||||||
return "process_info"
|
return "p_process_info"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ type TaskInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (TaskInfo) TableName() string {
|
func (TaskInfo) TableName() string {
|
||||||
return "task_info"
|
return "p_task_info"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ type TplInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (TplInfo) TableName() string {
|
func (TplInfo) TableName() string {
|
||||||
return "tpl_info"
|
return "p_tpl_info"
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ type TplData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (TplData) TableName() string {
|
func (TplData) TableName() string {
|
||||||
return "work_order_tpl_data"
|
return "p_work_order_tpl_data"
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,5 @@ type WorkOrderInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (WorkOrderInfo) TableName() string {
|
func (WorkOrderInfo) TableName() string {
|
||||||
return "work_order_info"
|
return "p_work_order_info"
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
package process
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"ferry/apis/process"
|
||||||
|
"ferry/middleware"
|
||||||
|
|
||||||
//"ferry/apis/process"
|
//"ferry/apis/process"
|
||||||
//"ferry/middleware"
|
//"ferry/middleware"
|
||||||
jwt "ferry/pkg/jwtauth"
|
jwt "ferry/pkg/jwtauth"
|
||||||
@ -13,12 +16,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func RegisterTplRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
func RegisterTplRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||||
//tplRouter := v1.Group("/tpl").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
tplRouter := v1.Group("/tpl").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||||
//{
|
{
|
||||||
// tplRouter.GET("", process.TemplateList)
|
tplRouter.GET("", process.TemplateList)
|
||||||
// tplRouter.POST("", process.CreateTemplate)
|
tplRouter.POST("", process.CreateTemplate)
|
||||||
// tplRouter.PUT("", process.UpdateTemplate)
|
tplRouter.PUT("", process.UpdateTemplate)
|
||||||
// tplRouter.DELETE("", process.DeleteTemplate)
|
tplRouter.DELETE("", process.DeleteTemplate)
|
||||||
// tplRouter.GET("/details", process.TemplateDetails)
|
tplRouter.GET("/details", process.TemplateDetails)
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user