|
@@ -0,0 +1,58 @@
|
|
|
+package controller
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+ "lims-extend/common"
|
|
|
+ "lims-extend/model"
|
|
|
+ "lims-extend/response"
|
|
|
+)
|
|
|
+
|
|
|
+func GetStatisticsInfoForAdmin(c *gin.Context) {
|
|
|
+ userId := c.Params.ByName("userId")
|
|
|
+ db := common.GetDB()
|
|
|
+
|
|
|
+
|
|
|
+ var totalSendCount int64
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("plan.creator_id = ?", userId).Count(&totalSendCount)
|
|
|
+
|
|
|
+ var totalRecvCount int64
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("plan.creator_id = ? and task.state <> 3", userId).Count(&totalRecvCount)
|
|
|
+
|
|
|
+
|
|
|
+ var totalFinishedCount int64
|
|
|
+ db.Model(&model.Task{}).Joins("left join plan on task.plan_id = plan.id").
|
|
|
+ Where("plan.creator_id = ? and task.state = 2", userId).Count(&totalFinishedCount)
|
|
|
+
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "totalSendCount": totalSendCount,
|
|
|
+ "totalRecvCount": totalRecvCount,
|
|
|
+ "totalFinishedCount": totalFinishedCount,
|
|
|
+ }, "success")
|
|
|
+}
|
|
|
+
|
|
|
+func GetStatisticsInfoForUser(c *gin.Context) {
|
|
|
+ userId := c.Params.ByName("userId")
|
|
|
+ db := common.GetDB()
|
|
|
+
|
|
|
+
|
|
|
+ var totalWaitingCount int64
|
|
|
+ db.Model(&model.Task{}).
|
|
|
+ Where("executor_id = ? and state = 3", userId).Count(&totalWaitingCount)
|
|
|
+
|
|
|
+ var totalRecvCount int64
|
|
|
+ db.Model(&model.Task{}).
|
|
|
+ Where("executor_id = ? and task.state <> 3", userId).Count(&totalRecvCount)
|
|
|
+
|
|
|
+
|
|
|
+ var totalFinishedCount int64
|
|
|
+ db.Model(&model.Task{}).
|
|
|
+ Where("executor_id= ? and task.state = 2", userId).Count(&totalFinishedCount)
|
|
|
+
|
|
|
+ response.Success(c, gin.H{
|
|
|
+ "totalWaitingCount": totalWaitingCount,
|
|
|
+ "totalRecvCount": totalRecvCount,
|
|
|
+ "totalFinishedCount": totalFinishedCount,
|
|
|
+ }, "success")
|
|
|
+}
|