Browse Source

feature:修改数据权限规则缺陷:连表查询未加别名

ZZH-wl 1 year ago
parent
commit
e0fe0e2023

+ 1 - 1
opms_parent/app/dao/base/internal/base_distributor.go

@@ -834,7 +834,7 @@ func (d *BaseDistributorDao) checkColumnsName(dataScope map[string]interface{},
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/base/internal/base_distributor_contact.go

@@ -774,7 +774,7 @@ func (d *BaseDistributorContactDao) checkColumnsName(dataScope map[string]interf
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/base/internal/base_distributor_dynamics.go

@@ -768,7 +768,7 @@ func (d *BaseDistributorDynamicsDao) checkColumnsName(dataScope map[string]inter
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/base/internal/base_distributor_record.go

@@ -783,7 +783,7 @@ func (d *BaseDistributorRecordDao) checkColumnsName(dataScope map[string]interfa
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/base/internal/base_distributor_target.go

@@ -771,7 +771,7 @@ func (d *BaseDistributorTargetDao) checkColumnsName(dataScope map[string]interfa
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/contract/internal/ctr_contract.go

@@ -871,7 +871,7 @@ func (d *CtrContractDao) checkColumnsName(dataScope map[string]interface{}, args
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/contract/internal/ctr_contract_collection_plan.go

@@ -784,7 +784,7 @@ func (d *CtrContractCollectionPlanDao) checkColumnsName(dataScope map[string]int
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/contract/internal/ctr_contract_product.go

@@ -811,7 +811,7 @@ func (d *CtrContractProductDao) checkColumnsName(dataScope map[string]interface{
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/partner/internal/partner_company.go

@@ -753,7 +753,7 @@ func (d *PartnerCompanyDao) checkColumnsName(dataScope map[string]interface{}, a
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/partner/internal/partner_company_contact.go

@@ -765,7 +765,7 @@ func (d *PartnerCompanyContactDao) checkColumnsName(dataScope map[string]interfa
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/plat/internal/plat_followup.go

@@ -807,7 +807,7 @@ func (d *PlatFollowupDao) checkColumnsName(dataScope map[string]interface{}, arg
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/work/internal/deliver_order_imp_plan.go

@@ -771,7 +771,7 @@ func (d *DeliverOrderImpPlanDao) checkColumnsName(dataScope map[string]interface
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/work/internal/deliver_order_imp_progress.go

@@ -897,7 +897,7 @@ func (d *DeliverOrderImpProgressDao) checkColumnsName(dataScope map[string]inter
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/work/internal/deliver_order_product.go

@@ -789,7 +789,7 @@ func (d *DeliverOrderProductDao) checkColumnsName(dataScope map[string]interface
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/work/internal/deliver_progress_product.go

@@ -795,7 +795,7 @@ func (d *DeliverProgressProductDao) checkColumnsName(dataScope map[string]interf
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 1 - 1
opms_parent/app/dao/work/internal/work_order_feedback_trial.go

@@ -774,7 +774,7 @@ func (d *WorkOrderFeedbackTrialDao) checkColumnsName(dataScope map[string]interf
 		}
 	}
 	if len(args) > 0 {
-		userCols = []string{"created_by"}
+		userCols = []string{tableAs + "created_by"}
 		if column, ok := args[0].(string); ok {
 			userCols = []string{tableAs + column}
 		}

+ 5 - 5
opms_parent/app/service/plat/plat_followup.go

@@ -182,7 +182,7 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 			filter["orcols"] = orCols
 		}
 	}
-	followupModel := s.Dao.DataScope(s.Ctx, filter)
+	followupModel := s.Dao.As("plat_followup").DataScope(s.Ctx, filter)
 	// 用户仅有销售工程师角色展示自己的数据,其他人可以看到所有数据
 	//if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("SalesEngineer") {
 	//	followupModel = followupModel.WhereIn("created_by", s.DataScope["userIds"])
@@ -206,14 +206,14 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 		followupModel = followupModel.WhereLike("target_name", "%"+req.TargetName+"%")
 	}
 	if req.CreatedName != "" {
-		followupModel = followupModel.WhereLike("created_name", "%"+req.CreatedName+"%")
+		followupModel = followupModel.WhereLike("plat_followup.created_name", "%"+req.CreatedName+"%")
 	}
 	// 负责人查询
 	if req.ManagerId != "" {
-		followupModel = followupModel.Where("created_by", req.ManagerId)
+		followupModel = followupModel.Where("plat_followup.created_by", req.ManagerId)
 	}
 	if req.IsMyself == "1" {
-		followupModel = followupModel.Where("created_by", s.GetCxtUserId())
+		followupModel = followupModel.Where("plat_followup.created_by", s.GetCxtUserId())
 	}
 	// 日期条件
 	if req.DaysBeforeToday > 0 { // 获取前N天的跟进记录
@@ -233,7 +233,7 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 	//跟进记录销售 添加销售人权限
 	arr := garray.NewStrArrayFrom(s.CxtUser.Roles, true)
 	if arr.Len() == 1 && arr.Contains("SalesEngineer") && req.Sell != "" {
-		followupModel = followupModel.Where("created_by", s.CxtUser.Id)
+		followupModel = followupModel.Where("plat_followup.created_by", s.CxtUser.Id)
 	}
 	//total, err = followupModel.Count()
 	//if err != nil {