|
@@ -12,8 +12,12 @@ import (
|
|
|
|
|
|
func ShowPlans(c *gin.Context) {
|
|
|
db := common.GetDB()
|
|
|
+ userId := c.Params.ByName("userId")
|
|
|
var plans []model.Plan
|
|
|
- db.Model(&model.Plan{}).Where("plan.delete <> 1").Find(&plans)
|
|
|
+
|
|
|
+ db.Model(&model.Plan{}).Joins("left join plan_groups on plan.id = plan_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)
|
|
|
|
|
|
response.Success(c, gin.H{"planlists": plans}, "success")
|
|
|
}
|
|
@@ -108,6 +112,9 @@ func TakePlan(c *gin.Context) {
|
|
|
response.Success(c, gin.H{"task": task}, "success")
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func AssignPlan(c *gin.Context) {
|
|
|
|
|
|
var groupVo vo.GroupVo
|
|
@@ -160,6 +167,9 @@ func AssignPlan(c *gin.Context) {
|
|
|
response.Success(c, gin.H{"groupIdList": groupVo}, "分配成功")
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func GetPlanAssignedGroups(c *gin.Context) {
|
|
|
db := common.GetDB()
|
|
|
planId := c.Params.ByName("planId")
|
|
@@ -176,3 +186,54 @@ func GetPlanAssignedGroups(c *gin.Context) {
|
|
|
response.Success(c, gin.H{"groupList": groupList}, "success")
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+func Test(c *gin.Context) {
|
|
|
+
|
|
|
+ response.Success(c, gin.H{"count": IsJoinedInCurrentPlan("TestLaboratory_V1_User_9", "TestLaboratory_V1_Plan_7")}, "success")
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func GetPlanTotalUserAmount(planId string) int {
|
|
|
+ totalAmount := 0
|
|
|
+ var plan2groups []model.Plan2Group
|
|
|
+ db := common.GetDB()
|
|
|
+ db.Model(&model.Plan2Group{}).Where("plan_id = ?", planId).Find(&plan2groups)
|
|
|
+ for _, group := range plan2groups {
|
|
|
+ totalAmount += GetGroupUserAmount(group.GroupId)
|
|
|
+ }
|
|
|
+ return totalAmount
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func GetGroupUserAmount(groupId string) int {
|
|
|
+ var count int64
|
|
|
+ db := common.GetDB()
|
|
|
+ db.Model(&model.Group2Users{}).Where("group_id = ?", groupId).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
|
|
|
+ }
|
|
|
+
|
|
|
+}
|