Roc 1 anno fa
parent
commit
3bf0aa6cbe
3 ha cambiato i file con 43 aggiunte e 29 eliminazioni
  1. 28 20
      controllers/report.go
  2. 3 3
      models/system/sys_admin.go
  3. 12 6
      services/report.go

+ 28 - 20
controllers/report.go

@@ -147,16 +147,18 @@ func (this *ReportController) ListReport() {
 		pvMap := make(map[int]int, 0)
 		uvMap := make(map[int]int, 0)
 		if len(syncReportIdArr) > 0 {
-			puvList, e := models.GetPUVByResearchReportIds(syncReportIdArr)
-			if e != nil {
-				br.Msg = "获取失败"
-				br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
-				return
-			}
-			puvLen := len(puvList)
-			for i := 0; i < puvLen; i++ {
-				pvMap[puvList[i].ResearchReportId] = puvList[i].Pv
-				uvMap[puvList[i].ResearchReportId] = puvList[i].Uv
+			if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+				puvList, e := models.GetPUVByResearchReportIds(syncReportIdArr)
+				if e != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取同步报告对应的PV、UV失败, Err: " + e.Error()
+					return
+				}
+				puvLen := len(puvList)
+				for i := 0; i < puvLen; i++ {
+					pvMap[puvList[i].ResearchReportId] = puvList[i].Pv
+					uvMap[puvList[i].ResearchReportId] = puvList[i].Uv
+				}
 			}
 		}
 		// 晨周报音频列表
@@ -688,11 +690,14 @@ func (this *ReportController) Detail() {
 		if len(tmpChapterList) > 0 {
 			// 获取更新规则
 			researchType := tmpChapterList[0].ReportType
-			chapterTypeList, tmpErr := models.GetAllReportChapterTypeListByResearchType(researchType)
-			if tmpErr != nil {
-				br.Msg = "获取更新规则失败"
-				br.ErrMsg = "获取更新规则失败, Err: " + tmpErr.Error()
-				return
+			chapterTypeList := make([]*models.ReportChapterType, 0)
+			if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+				chapterTypeList, err = models.GetAllReportChapterTypeListByResearchType(researchType)
+				if err != nil {
+					br.Msg = "获取更新规则失败"
+					br.ErrMsg = "获取更新规则失败, Err: " + err.Error()
+					return
+				}
 			}
 			// 调整章节更新
 			nowTime := time.Now().Local()
@@ -1357,11 +1362,14 @@ func (this *ReportController) GetReportChapterList() {
 	if len(chapterList) > 0 {
 		// 获取更新规则
 		researchType := chapterList[0].ReportType
-		chapterTypeList, tmpErr := models.GetAllReportChapterTypeListByResearchType(researchType)
-		if tmpErr != nil {
-			br.Msg = "获取更新规则失败"
-			br.ErrMsg = "获取更新规则失败, Err: " + tmpErr.Error()
-			return
+		chapterTypeList := make([]*models.ReportChapterType, 0)
+		if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+			chapterTypeList, err = models.GetAllReportChapterTypeListByResearchType(researchType)
+			if err != nil {
+				br.Msg = "获取更新规则失败"
+				br.ErrMsg = "获取更新规则失败, Err: " + err.Error()
+				return
+			}
 		}
 		// 调整章节更新
 		nowTime := time.Now().Local()

+ 3 - 3
models/system/sys_admin.go

@@ -42,14 +42,14 @@ type AdminItem struct {
 
 func GetSysAdminByName(adminName string) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_name=? `
-	o := orm.NewOrmUsingDB("weekly")
+	o := orm.NewOrm()
 	err = o.Raw(sql, adminName).QueryRow(&item)
 	return
 }
 
 func GetSysAdminById(adminId int) (item *Admin, err error) {
 	sql := `SELECT * FROM admin WHERE admin_id=? `
-	o := orm.NewOrmUsingDB("weekly")
+	o := orm.NewOrm()
 	err = o.Raw(sql, adminId).QueryRow(&item)
 	return
 }
@@ -60,7 +60,7 @@ func GetSysAdminByIdSlice(adminIdList []string) (items []*Admin, err error) {
 		return
 	}
 	sql := `SELECT * FROM admin WHERE admin_id in (` + strings.Join(adminIdList, ",") + `) `
-	o := orm.NewOrmUsingDB("weekly")
+	o := orm.NewOrm()
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 12 - 6
services/report.go

@@ -191,9 +191,12 @@ func UpdateReportEs(reportId int, publishState int) (err error) {
 		if len(chapterList) > 0 {
 			for i := 0; i < len(chapterList); i++ {
 				// 章节对应的品种
-				permissionList, tmpErr := models.GetChapterTypePermissionByTypeIdAndResearchType(chapterList[i].TypeId, chapterList[i].ReportType)
-				if tmpErr != nil {
-					return
+				permissionList := make([]*models.ReportChapterTypePermission, 0)
+				if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+					permissionList, tmpErr = models.GetChapterTypePermissionByTypeIdAndResearchType(chapterList[i].TypeId, chapterList[i].ReportType)
+					if tmpErr != nil {
+						return
+					}
 				}
 				categoryArr := make([]string, 0)
 				if len(permissionList) > 0 {
@@ -310,9 +313,12 @@ func UpdateReportChapterEs(reportChapterId int) (err error) {
 		return
 	}
 	// 章节对应的品种
-	permissionList, tmpErr := models.GetChapterTypePermissionByTypeIdAndResearchType(chapterInfo.TypeId, chapterInfo.ReportType)
-	if tmpErr != nil {
-		return
+	permissionList := make([]*models.ReportChapterTypePermission, 0)
+	if utils.BusinessCode == utils.BusinessCodeRelease || utils.BusinessCode == utils.BusinessCodeSandbox {
+		permissionList, err = models.GetChapterTypePermissionByTypeIdAndResearchType(chapterInfo.TypeId, chapterInfo.ReportType)
+		if err != nil {
+			return
+		}
 	}
 	categoryArr := make([]string, 0)
 	if len(permissionList) > 0 {