Browse Source

优化需求257提测

gmy 5 months ago
parent
commit
9b30ed5735
3 changed files with 20 additions and 11 deletions
  1. 3 9
      controllers/eta_trial.go
  2. 12 0
      models/eta_trial/eta_trial.go
  3. 5 2
      models/eta_trial/eta_trial_approval.go

+ 3 - 9
controllers/eta_trial.go

@@ -451,12 +451,6 @@ func (this *ETATrialController) ApplyEnable() {
 		return
 	}
 
-	if len(req.MobileList) <= 0 {
-		br.Msg = "至少选中一条记录"
-		br.ErrMsg = "至少选中一条记录"
-		return
-	}
-
 	seller, e := system.GetSysAdminById(sysUser.AdminId)
 	if e != nil {
 		err = e
@@ -467,20 +461,20 @@ func (this *ETATrialController) ApplyEnable() {
 	var pars []interface{}
 	if req.IsCheckAll {
 		if len(req.MobileList) > 0 {
-			condition += " and mobile not in (" + strings.Join(req.MobileList, ",") + ")"
+			condition += " and mobile not in (" + utils.GetOrmInReplace(len(req.MobileList)) + ")"
 			for _, mobile := range req.MobileList {
 				pars = append(pars, mobile)
 			}
 		}
 	} else {
 		if len(req.MobileList) > 0 {
-			condition += " and mobile in (" + strings.Join(req.MobileList, ",") + ")"
+			condition += " and mobile in (" + utils.GetOrmInReplace(len(req.MobileList)) + ")"
 			for _, mobile := range req.MobileList {
 				pars = append(pars, mobile)
 			}
 		}
 	}
-	trialApprovalList, err := eta_trial.GetETATrialApprovalByCondition(condition, pars)
+	trialApprovalList, err := eta_trial.GetETATrialByCondition(condition, pars)
 	if err != nil {
 		return
 	}

+ 12 - 0
models/eta_trial/eta_trial.go

@@ -163,3 +163,15 @@ func TransferETATrial(item *TrialAccountTransferReq) (err error) {
 
 	return
 }
+
+func GetETATrialByCondition(condition string, pars []interface{}) (item []*EtaTrial, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM eta_trial WHERE 1=1 `
+
+	sql += condition
+	_, err = o.Raw(sql, pars...).QueryRows(&item)
+	if err != nil {
+		return nil, err
+	}
+	return item, nil
+}

+ 5 - 2
models/eta_trial/eta_trial_approval.go

@@ -36,8 +36,11 @@ func GetETATrialApprovalByCondition(condition string, pars []interface{}) (item
 	sql := `SELECT * FROM eta_trial_approval WHERE 1=1 `
 
 	sql += condition
-	err = o.Raw(sql, pars).QueryRow(&item)
-	return
+	_, err = o.Raw(sql, pars...).QueryRows(&item)
+	if err != nil {
+		return nil, err
+	}
+	return item, nil
 }
 
 // AddETATrialApproval 新增审批