|
@@ -19,18 +19,17 @@ func ShowPlans(c *gin.Context) {
|
|
Joins("left join group_users on plan_groups.group_id = group_users.group_id").
|
|
Joins("left join group_users on plan_groups.group_id = group_users.group_id").
|
|
Where("user_id = ? and plan.delete <> 1", userId).Distinct().Find(&plans)
|
|
Where("user_id = ? and plan.delete <> 1", userId).Distinct().Find(&plans)
|
|
planVos := make([]vo.PlanVo, len(plans))
|
|
planVos := make([]vo.PlanVo, len(plans))
|
|
- for i, v := range plans {
|
|
|
|
- planVos[i] = vo.PlanVo{
|
|
|
|
- Plan: v,
|
|
|
|
- IsJoined: IsJoinedInCurrentPlan(userId, v.Id),
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //for i, v := range plans {
|
|
|
|
+ // planVos[i] = vo.PlanVo{
|
|
|
|
+ // Plan: v,
|
|
|
|
+ // IsJoined: IsJoinedInCurrentPlan(userId, v.Id),
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
response.Success(c, gin.H{"planlists": planVos}, "success")
|
|
response.Success(c, gin.H{"planlists": planVos}, "success")
|
|
}
|
|
}
|
|
|
|
|
|
func ShowPlan(c *gin.Context) {
|
|
func ShowPlan(c *gin.Context) {
|
|
planId := c.Params.ByName("planId")
|
|
planId := c.Params.ByName("planId")
|
|
- userId := c.Params.ByName("userId")
|
|
|
|
db := common.GetDB()
|
|
db := common.GetDB()
|
|
var plan model.Plan
|
|
var plan model.Plan
|
|
if err := db.Model(&model.Plan{}).Where("id = ?", planId).First(&plan).Error; err != nil {
|
|
if err := db.Model(&model.Plan{}).Where("id = ?", planId).First(&plan).Error; err != nil {
|
|
@@ -41,22 +40,14 @@ func ShowPlan(c *gin.Context) {
|
|
response.Fail(c, nil, "当前计划已经被删除")
|
|
response.Fail(c, nil, "当前计划已经被删除")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- var file model.File
|
|
|
|
- db.Model(&model.File{}).Where("id = ?", plan.StatementFile).First(&file)
|
|
|
|
- var user model.User
|
|
|
|
- db.Model(&model.User{}).Where("id = ?", plan.CreatorId).First(&user)
|
|
|
|
|
|
|
|
planVo := vo.PlanVo{
|
|
planVo := vo.PlanVo{
|
|
- Plan: plan,
|
|
|
|
- IsJoined: IsJoinedInCurrentPlan(userId, planId),
|
|
|
|
- SendAmount: GetPlanTotalUserAmount(planId),
|
|
|
|
- ReceiveAmount: GetPlanTaskAmount(planId),
|
|
|
|
|
|
+ SendAmount: GetSendPacketAmount(planId),
|
|
|
|
+ ReceiveAmount: GetRecvPacketAmount(planId),
|
|
ReportAmount: GetPlanReportAmount(planId),
|
|
ReportAmount: GetPlanReportAmount(planId),
|
|
}
|
|
}
|
|
response.Success(c, gin.H{
|
|
response.Success(c, gin.H{
|
|
- "plan": planVo,
|
|
|
|
- "creator": user,
|
|
|
|
- "file": file,
|
|
|
|
|
|
+ "plan": planVo,
|
|
}, "success")
|
|
}, "success")
|
|
|
|
|
|
}
|
|
}
|
|
@@ -256,6 +247,27 @@ func Test(c *gin.Context) {
|
|
// GetPlanTotalUserAmount 获取当前计划总发包数
|
|
// GetPlanTotalUserAmount 获取当前计划总发包数
|
|
// 需要参数planId
|
|
// 需要参数planId
|
|
|
|
|
|
|
|
+func GetSendPacketAmount(planId string) int {
|
|
|
|
+ db := common.GetDB()
|
|
|
|
+ var amount int64
|
|
|
|
+ db.Model(&model.Task{}).Where("plan_id = ?", planId).Count(&amount)
|
|
|
|
+ return int(amount)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetRecvPacketAmount(planId string) int {
|
|
|
|
+ db := common.GetDB()
|
|
|
|
+ var amount int64
|
|
|
|
+ db.Model(&model.Task{}).Where("plan_id = ? and state <> 3", planId).Count(&amount)
|
|
|
|
+ return int(amount)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetPlanReportAmount(planId string) int {
|
|
|
|
+ var count int64
|
|
|
|
+ db := common.GetDB()
|
|
|
|
+ db.Model(&model.Task{}).Where("plan_id = ? and state = 2", planId).Count(&count)
|
|
|
|
+ return int(count)
|
|
|
|
+}
|
|
|
|
+
|
|
func GetPlanTotalUserAmount(planId string) int {
|
|
func GetPlanTotalUserAmount(planId string) int {
|
|
totalAmount := 0
|
|
totalAmount := 0
|
|
var plan2groups []model.Plan2Group
|
|
var plan2groups []model.Plan2Group
|
|
@@ -280,27 +292,20 @@ func GetGroupUserAmount(groupId string) int {
|
|
// GetGroupUserAmount 获取指定计划对接包数量
|
|
// GetGroupUserAmount 获取指定计划对接包数量
|
|
// 需要参数groupId
|
|
// 需要参数groupId
|
|
|
|
|
|
-func GetPlanTaskAmount(planId string) int {
|
|
|
|
- var count int64
|
|
|
|
- db := common.GetDB()
|
|
|
|
- db.Model(&model.Task{}).Where("plan_id = ?", planId).Count(&count)
|
|
|
|
- return int(count)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func IsJoinedInCurrentPlan(userId string, planId string) bool {
|
|
|
|
- var count int64
|
|
|
|
- db := common.GetDB()
|
|
|
|
- db.Model(&model.Task{}).Where("plan_id = ? and executor_id = ?", planId, userId).Count(&count)
|
|
|
|
- if count > 0 {
|
|
|
|
- return true
|
|
|
|
- } else {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func GetPlanReportAmount(planId string) int {
|
|
|
|
- var count int64
|
|
|
|
- db := common.GetDB()
|
|
|
|
- db.Model(&model.Task{}).Where("plan_id = ? and state = 2", planId).Count(&count)
|
|
|
|
- return int(count)
|
|
|
|
-}
|
|
|
|
|
|
+//func GetPlanTaskAmount(planId string) int {
|
|
|
|
+// var count int64
|
|
|
|
+// db := common.GetDB()
|
|
|
|
+// db.Model(&model.Task{}).Where("plan_id = ?", planId).Count(&count)
|
|
|
|
+// return int(count)
|
|
|
|
+//}
|
|
|
|
+//
|
|
|
|
+//func IsJoinedInCurrentPlan(userId string, planId string) bool {
|
|
|
|
+// var count int64
|
|
|
|
+// db := common.GetDB()
|
|
|
|
+// db.Model(&model.Task{}).Where("plan_id = ? and executor_id = ?", planId, userId).Count(&count)
|
|
|
|
+// if count > 0 {
|
|
|
|
+// return true
|
|
|
|
+// } else {
|
|
|
|
+// return false
|
|
|
|
+// }
|
|
|
|
+//}
|