소스 검색

标的重复bug 修改

xingzai 3 년 전
부모
커밋
cc9f79393b
4개의 변경된 파일16개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 3
      controllers/report.go
  2. 1 1
      models/article_department.go
  3. 1 0
      models/db.go
  4. 13 8
      models/report.go

+ 1 - 3
controllers/report.go

@@ -838,7 +838,6 @@ func (this *ReportController) ReportList() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	departmentId, _ := this.GetInt("DepartmentId")
 	industrialManagementId, _ := this.GetInt("IndustrialManagementId")
-
 	var condition string
 	var startSize int
 	if pageSize <= 0 {
@@ -880,7 +879,7 @@ func (this *ReportController) ReportList() {
 		return
 	}
 	page = paging.GetPaging(currentIndex, pageSize, total)
-	condition += ` ORDER BY art.publish_date DESC`
+	condition += ` 	GROUP BY art.article_id ORDER BY art.publish_date DESC`
 	list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -899,7 +898,6 @@ func (this *ReportController) ReportList() {
 			br.ErrMsg = "获取失败,Err:" + err.Error()
 			return
 		}
-		fmt.Println(len(listSubject))
 		if len(listSubject) > 0 {
 			list[k].SubjectName = ""
 			for _, v3 := range listSubject {

+ 1 - 1
models/article_department.go

@@ -150,7 +150,7 @@ func GetIndustrialSubjectNewList(condition string) (items []*IndustrialSubjectLi
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY s.create_time DESC LIMIT 4`
+	sql += ` GROUP BY s.industrial_subject_id ORDER BY s.create_time DESC LIMIT 4`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 1 - 0
models/db.go

@@ -60,5 +60,6 @@ func init() {
 		new(CygxIndustryFllow),
 		new(CygxArticleDepartmentFollow),
 		new(CygxArticleAsk),
+		new(CygxPageHistoryRecord),
 	)
 }

+ 13 - 8
models/report.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	"rdluck_tools/orm"
 	"rdluck_tools/paging"
 	"strconv"
@@ -181,17 +182,21 @@ FROM
 
 func GetWhichDepartmentCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT COUNT(1) count 
-FROM
-	cygx_article AS art
-	INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id 
-	INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
-	INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
-	WHERE 1 = 1 
-	AND art.publish_status = 1`
+	sql := `SELECT COUNT(*) count 
+			FROM(
+			SELECT COUNT(1) count 
+			FROM
+			cygx_article AS art
+			INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id 
+			INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
+			WHERE 1 = 1 
+			AND art.publish_status = 1`
 	if condition != "" {
 		sql += condition
 	}
+	sql += ` ) AS num`
+	fmt.Println(sql)
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }