forked from lanyulei/ferry
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
129 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package dashboard | ||
|
||
import ( | ||
"ferry/global/orm" | ||
"ferry/models/process" | ||
"ferry/models/system" | ||
"ferry/pkg/pagination" | ||
"ferry/pkg/service" | ||
"ferry/tools/app" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
/* | ||
@Author : lanyulei | ||
*/ | ||
|
||
func InitData(c *gin.Context) { | ||
var ( | ||
err error | ||
panelGroup struct { | ||
UserTotalCount int `json:"user_total_count"` | ||
WorkOrderTotalCount int `json:"work_order_total_count"` | ||
UpcomingTotalCount int `json:"upcoming_total_count"` | ||
MyUpcomingCount int `json:"my_upcoming_count"` | ||
} | ||
result interface{} | ||
) | ||
|
||
// 查询用户总数 | ||
err = orm.Eloquent.Model(&system.SysUser{}).Count(&panelGroup.UserTotalCount).Error | ||
if err != nil { | ||
app.Error(c, -1, err, "") | ||
return | ||
} | ||
|
||
// 查询工单总数 | ||
err = orm.Eloquent.Model(&process.WorkOrderInfo{}).Count(&panelGroup.WorkOrderTotalCount).Error | ||
if err != nil { | ||
app.Error(c, -1, err, "") | ||
return | ||
} | ||
|
||
// 查询待办总数 | ||
err = orm.Eloquent.Model(&process.WorkOrderInfo{}). | ||
Where("is_end = 0"). | ||
Count(&panelGroup.UpcomingTotalCount).Error | ||
if err != nil { | ||
app.Error(c, -1, err, "") | ||
return | ||
} | ||
|
||
// 查询我的待办 | ||
w := service.WorkOrder{ | ||
Classify: 1, | ||
GinObj: c, | ||
} | ||
result, err = w.PureWorkOrderList() | ||
if err != nil { | ||
app.Error(c, -1, err, "") | ||
return | ||
} | ||
panelGroup.MyUpcomingCount = result.(*pagination.Paginator).TotalCount | ||
|
||
app.OK(c, panelGroup, "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dashboard | ||
|
||
import ( | ||
"ferry/apis/dashboard" | ||
"ferry/middleware" | ||
jwt "ferry/pkg/jwtauth" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
/* | ||
@Author : lanyulei | ||
*/ | ||
|
||
func RegisterDashboardRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { | ||
classify := v1.Group("/dashboard").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) | ||
{ | ||
classify.GET("", dashboard.InitData) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters