|
@@ -703,13 +703,20 @@ func (d *CtrContractCollectionPlanDao) Unscoped() *CtrContractCollectionPlanDao
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// DataScope enables the DataScope feature.
|
|
// DataScope enables the DataScope feature.
|
|
|
-func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ...string) *CtrContractCollectionPlanDao {
|
|
|
|
|
|
|
+func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, args ...interface{}) *CtrContractCollectionPlanDao {
|
|
|
cs := ctx.Value("contextService")
|
|
cs := ctx.Value("contextService")
|
|
|
dataScope := gconv.Map(cs)["dataScope"].(g.Map)
|
|
dataScope := gconv.Map(cs)["dataScope"].(g.Map)
|
|
|
if dataScope != nil {
|
|
if dataScope != nil {
|
|
|
- tableAs := d.TableAs
|
|
|
|
|
- if d.TableAs != "" {
|
|
|
|
|
- tableAs += "."
|
|
|
|
|
|
|
+ var specialFlag bool
|
|
|
|
|
+ var tableAs string
|
|
|
|
|
+ if d.TableAs != "" && len(args) <= 1 {
|
|
|
|
|
+ tableAs = d.TableAs + "."
|
|
|
|
|
+ }
|
|
|
|
|
+ if len(args) > 1 {
|
|
|
|
|
+ specialFlag = true
|
|
|
|
|
+ if val, ok := args[1].(string); ok {
|
|
|
|
|
+ tableAs = val + "."
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
userIds, ok := dataScope["userIds"]
|
|
userIds, ok := dataScope["userIds"]
|
|
|
delete(dataScope, "userIds")
|
|
delete(dataScope, "userIds")
|
|
@@ -717,10 +724,10 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
|
|
|
var orValues []interface{}
|
|
var orValues []interface{}
|
|
|
if ok && userIds != "-1" {
|
|
if ok && userIds != "-1" {
|
|
|
column := "created_by"
|
|
column := "created_by"
|
|
|
- if len(userCol) == 1 {
|
|
|
|
|
- column = userCol[0]
|
|
|
|
|
|
|
+ if len(args) > 0 {
|
|
|
|
|
+ column = args[0].(string)
|
|
|
}
|
|
}
|
|
|
- if ok, _ := d.M.HasField(column); ok {
|
|
|
|
|
|
|
+ if ok, _ := d.M.HasField(column); ok || specialFlag {
|
|
|
orColumns = append(orColumns, tableAs+column+" IN (?) ")
|
|
orColumns = append(orColumns, tableAs+column+" IN (?) ")
|
|
|
orValues = append(orValues, userIds)
|
|
orValues = append(orValues, userIds)
|
|
|
}
|
|
}
|
|
@@ -736,7 +743,7 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
|
|
|
// 非销售工程师权限加成
|
|
// 非销售工程师权限加成
|
|
|
if !salesEngineerFlag {
|
|
if !salesEngineerFlag {
|
|
|
bigColumns := "is_big"
|
|
bigColumns := "is_big"
|
|
|
- if ok, _ := d.M.HasField("is_big"); ok {
|
|
|
|
|
|
|
+ if ok, _ := d.M.HasField("is_big"); ok || specialFlag {
|
|
|
if val, ok := dataScope[bigColumns]; ok && val != "" {
|
|
if val, ok := dataScope[bigColumns]; ok && val != "" {
|
|
|
orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
|
|
orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
|
|
|
orValues = append(orValues, val)
|
|
orValues = append(orValues, val)
|
|
@@ -746,7 +753,7 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
|
|
|
var andColumns []string
|
|
var andColumns []string
|
|
|
var andValues []interface{}
|
|
var andValues []interface{}
|
|
|
for k, v := range dataScope {
|
|
for k, v := range dataScope {
|
|
|
- if ok, _ := d.M.HasField(k); ok {
|
|
|
|
|
|
|
+ if ok, _ := d.M.HasField(k); ok || specialFlag {
|
|
|
andColumns = append(andColumns, tableAs+k+" IN (?) ")
|
|
andColumns = append(andColumns, tableAs+k+" IN (?) ")
|
|
|
andValues = append(andValues, v)
|
|
andValues = append(andValues, v)
|
|
|
}
|
|
}
|