Browse Source

Merge branch 'feature/google_translate' into debug

xiexiaoyuan 2 years ago
parent
commit
997d339620

+ 0 - 83
models/tables/english_policy_report.go

@@ -3,8 +3,6 @@ package tables
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"hongze/hongze_open_api/utils"
-	"strings"
 	"time"
 )
 
@@ -33,13 +31,6 @@ type EnglishPolicyReport struct {
 	ReportCoverUrl     string    `description:"原始报告封面图"`
 }
 
-// AddEnglishPolicyReportMulti 批量新增report
-func AddEnglishPolicyReportMulti(list []*EnglishPolicyReport) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	_, err = o.InsertMulti(len(list), list)
-	return
-}
-
 // AddEnglishPolicyReport 新增report
 func AddEnglishPolicyReport(item *EnglishPolicyReport) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
@@ -112,40 +103,6 @@ type EnglishPolicyReportListResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-func GetEnglishPolicyReportListCount(condition string, pars []interface{}) (count int, err error) {
-	oRddp := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT COUNT(1) AS count  FROM english_policy_report WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	err = oRddp.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-func GetEnglishPolicyReportList(condition string, pars []interface{}, startSize, pageSize int) (items []*EnglishPolicyReportList, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	//产品权限
-	sql := `SELECT * 
-        FROM english_policy_report WHERE 1=1  `
-	if condition != "" {
-		sql += condition
-	}
-	sql += `ORDER BY  publish_time DESC LIMIT ?,?`
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetEnglishPolicyReportByCondition(condition string, pars []interface{}) (items []*EnglishPolicyReport, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * 
-        FROM english_policy_report WHERE 1=1  `
-	if condition != "" {
-		sql += condition
-	}
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
 type SyncEnglishPolicyReq struct {
     Id int `description:"策略报告id"`
 }
@@ -162,30 +119,6 @@ func SyncEnglishPolicyReportById(id, newReportId int) (err error) {
 	return
 }
 
-// 设置策略报告内容
-func SetEnglishPolicyReportContentBySourceReportId(sourceReportId int, content string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE english_policy_report SET content=?, modify_time=NOW() WHERE source_report_id = ? `
-	_, err = o.Raw(sql, content, sourceReportId).Exec()
-	return
-}
-
-//取消发布报告
-func SyncCancelEnglishPolicyReport(reportId int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` UPDATE english_policy_report SET state=1,sync_time=null,modify_time=NOW(), sync_report_id=0 WHERE id =?  `
-	_, err = o.Raw(sql, reportId).Exec()
-	return
-}
-
-//删除报告
-func DeleteEnglishPolicyReport(reportIds int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` DELETE FROM english_policy_report WHERE id =? `
-	_, err = o.Raw(sql, reportIds).Exec()
-	return
-}
-
 // Update 更新
 func (item *EnglishPolicyReport) Update(cols []string) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
@@ -193,19 +126,3 @@ func (item *EnglishPolicyReport) Update(cols []string) (err error) {
 	return
 }
 
-// GetEnglishPolicyReportByIds 根据IDs获取英文报告列表
-func GetEnglishPolicyReportByIds(reportIds []int, fieldArr []string) (list []*EnglishPolicyReport, err error) {
-	listLen := len(reportIds)
-	if listLen == 0 {
-		return
-	}
-	fields := ` * `
-	if len(fieldArr) > 0 {
-		fields = strings.Join(fieldArr, ",")
-	}
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT ` + fields + ` FROM english_policy_report WHERE id IN (` + utils.GetOrmInReplace(listLen) + `)`
-	_, err = o.Raw(sql, reportIds).QueryRows(&list)
-	return
-}
-

+ 0 - 429
models/tables/english_report.go

@@ -1,11 +1,8 @@
 package tables
 
 import (
-	"errors"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"hongze/hongze_open_api/utils"
-	"strings"
 	"time"
 )
 
@@ -53,19 +50,6 @@ func GetEnglishReportStage(classifyIdFirst, classifyIdSecond int) (count int, er
 	return
 }
 
-func GetEnglishReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ``
-	if classifyIdSecond > 0 {
-		sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_second=? AND id<>? "
-		o.Raw(sql, classifyIdSecond, reportId).QueryRow(&count)
-	} else {
-		sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_first=? AND id<>? "
-		o.Raw(sql, classifyIdFirst, reportId).QueryRow(&count)
-	}
-	return
-}
-
 func AddEnglishReport(item *EnglishReport) (lastId int64, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	lastId, err = o.Insert(item)
@@ -152,31 +136,6 @@ type ElasticEnglishReportDetail struct {
 	Overview           string `description:"英文概述部分"`
 }
 
-func EditEnglishReport(item *EnglishReport, reportId int64) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE english_report
-			SET
-			  classify_id_first =?,
-			  classify_name_first = ?,
-			  classify_id_second = ?,
-			  classify_name_second = ?,
-			  title = ?,
-			  abstract = ?,
-			  author = ?,
-			  frequency = ?,
-			  state = ?,
-			  content = ?,
-			  content_sub = ?,
-			  stage =?,
-			  create_time = ?,
-			  modify_time = ?,
-			  overview = ?
-			WHERE id = ? `
-	_, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
-		item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), item.Overview, reportId).Exec()
-	return
-}
-
 type EnglishReportDetail struct {
 	Id                 int    `orm:"column(id)" description:"报告Id"`
 	AddType            int    `description:"新增方式:1:新增报告,2:继承报告"`
@@ -206,20 +165,6 @@ type EnglishReportDetail struct {
 	KeyTakeaways       string `description:"关键点"`
 }
 
-func GetEnglishReportById(reportId int) (item *EnglishReportDetail, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * FROM english_report WHERE id=?`
-	err = o.Raw(sql, reportId).QueryRow(&item)
-	return
-}
-
-func GetEnglishReportItemById(reportId int) (item *EnglishReport, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * FROM english_report WHERE id = ? LIMIT 1`
-	err = o.Raw(sql, reportId).QueryRow(&item)
-	return
-}
-
 type EnglishReportList struct {
 	Id                 int       `description:"报告Id"`
 	AddType            int       `description:"新增方式:1:新增报告,2:继承报告"`
@@ -258,109 +203,6 @@ type EnglishReportListResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-func GetEnglishReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
-	//产品权限
-	companyTypeSqlStr := ``
-	if companyType == "ficc" {
-		companyTypeSqlStr = " AND classify_id_first != 40 "
-	} else if companyType == "权益" {
-		companyTypeSqlStr = " AND classify_id_first = 40 "
-	}
-
-	oRddp := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT COUNT(1) AS count  FROM english_report WHERE 1=1 ` + companyTypeSqlStr
-	if condition != "" {
-		sql += condition
-	}
-	err = oRddp.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
-func GetEnglishReportList(condition string, pars []interface{}, companyType string, startSize, pageSize int) (items []*EnglishReportList, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	//产品权限
-	companyTypeSqlStr := ``
-	if companyType == "ficc" {
-		companyTypeSqlStr = " AND classify_id_first != 40 "
-	} else if companyType == "权益" {
-		companyTypeSqlStr = " AND classify_id_first = 40 "
-	}
-
-	sql := `SELECT * 
-        FROM english_report WHERE 1=1  ` + companyTypeSqlStr
-	if condition != "" {
-		sql += condition
-	}
-	sql += `ORDER BY state ASC, modify_time DESC LIMIT ?,?`
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetEnglishReportByCondition(condition string, pars []interface{}) (items []*EnglishReport, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * 
-        FROM english_report WHERE 1=1  `
-	if condition != "" {
-		sql += condition
-	}
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-// 发布报告
-func PublishEnglishReportById(reportId int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE english_report SET state=2,publish_time=now(),modify_time=NOW() WHERE id = ? `
-	_, err = o.Raw(sql, reportId).Exec()
-	return
-}
-
-//取消发布报告
-func PublishCancelEnglishReport(reportIds int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` UPDATE english_report SET state=1,publish_time=null WHERE id =?  `
-	_, err = o.Raw(sql, reportIds).Exec()
-	return
-}
-
-// DeleteEnglishReportAndChapter 删除报告及章节
-func DeleteEnglishReportAndChapter(reportInfo *EnglishReportDetail) (err error) {
-	reportId := reportInfo.Id
-	if reportInfo.State == 2 {
-		err = errors.New("报告已发布,不可删除")
-		return
-	}
-	err = DeleteEnglishReport(reportId)
-	if err != nil {
-		err = errors.New("删除失败, Err: " + err.Error())
-		return
-	}
-
-	return
-}
-
-//删除报告
-func DeleteEnglishReport(reportIds int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` DELETE FROM english_report WHERE id =? `
-	_, err = o.Raw(sql, reportIds).Exec()
-	return
-}
-
-func EditEnglishReportContent(reportId int, content, contentSub string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` UPDATE english_report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
-	_, err = o.Raw(sql, content, contentSub, reportId).Exec()
-	return
-}
-
-func AddEnglishReportSaveLog(reportId, adminId int, content, contentSub, adminName string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` INSERT INTO english_report_save_log(report_id, content,content_sub,admin_id,admin_name) VALUES (?,?,?,?,?) `
-	_, err = o.Raw(sql, reportId, content, contentSub, adminId, adminName).Exec()
-	return
-}
-
 type EnglishClassifyList struct {
 	Id            int       `orm:"column(id);pk"`
 	ClassifyName  string    `description:"分类名称"`
@@ -380,86 +222,6 @@ type EnglishClassifyListResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-//获取分类列表
-func GetEnglishClassifyList(startSize, pageSize int, keyWord string, classifyType int) (items []*EnglishClassifyList, err error) {
-	sql := ``
-	o := orm.NewOrmUsingDB("rddp")
-	if keyWord != "" {
-		sql = `SELECT * FROM (
-                   SELECT * FROM english_classify
-                   WHERE parent_id=0 AND classify_name LIKE '%` + keyWord + `%' AND classify_type = ?
-                   UNION
-                   SELECT * FROM english_classify
-                   WHERE id IN(SELECT parent_id FROM english_classify
-                   WHERE parent_id>0 AND classify_name LIKE '%` + keyWord + `%') AND classify_type = ?
-                   )AS t
-                   ORDER BY sort ASC,create_time ASC
-                   LIMIT ?,? `
-		_, err = o.Raw(sql, classifyType, classifyType, startSize, pageSize).QueryRows(&items)
-	} else {
-		sql = `SELECT * FROM english_classify WHERE parent_id=0 AND classify_type = ? ORDER BY sort ASC,create_time ASC LIMIT ?,? `
-		_, err = o.Raw(sql, classifyType, startSize, pageSize).QueryRows(&items)
-	}
-	return
-}
-
-func GetEnglishClassifyListCount(keyWord string, classifyType int) (count int, err error) {
-	sqlCount := ``
-	o := orm.NewOrmUsingDB("rddp")
-	if keyWord != "" {
-		sqlCount = `SELECT  COUNT(1) AS count FROM (
-               SELECT * FROM english_classify
-               WHERE parent_id=0 AND classify_name LIKE '%` + keyWord + `%' AND classify_type = ?
-               UNION
-               SELECT * FROM english_classify
-               WHERE id IN(SELECT parent_id FROM english_classify
-               WHERE parent_id>0 AND classify_name LIKE '%` + keyWord + `%' AND classify_type = ?)
-               )AS t `
-		err = o.Raw(sqlCount, classifyType, classifyType).QueryRow(&count)
-	} else {
-		sqlCount = `SELECT COUNT(1) AS count FROM english_classify WHERE parent_id=0 AND classify_type = ?`
-		err = o.Raw(sqlCount, classifyType).QueryRow(&count)
-	}
-
-	return
-}
-
-func GetEnglishClassifyChild(parentId int, keyWord string, classifyType int) (items []*EnglishClassify, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ``
-	if keyWord != "" {
-		sql = `SELECT * FROM english_classify WHERE parent_id=? AND classify_type = ? AND classify_name LIKE '%` + keyWord + `%' ORDER BY create_time ASC `
-	} else {
-		sql = `SELECT * FROM english_classify WHERE parent_id=? AND classify_type = ? ORDER BY create_time ASC `
-	}
-	_, err = o.Raw(sql, parentId, classifyType).QueryRows(&items)
-	return
-}
-
-func GetEnglishClassifyChildByParentIds(parentIds []int, keyWord string, classifyType int) (items []*EnglishClassify, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ``
-	if keyWord != "" {
-		sql = `SELECT * FROM english_classify WHERE parent_id IN (` + utils.GetOrmInReplace(len(parentIds)) + `) AND classify_type = ? AND classify_name LIKE '%` + keyWord + `%' ORDER BY create_time ASC `
-	} else {
-		sql = `SELECT * FROM english_classify WHERE parent_id IN (` + utils.GetOrmInReplace(len(parentIds)) + `) AND classify_type = ? ORDER BY create_time ASC `
-	}
-	_, err = o.Raw(sql, parentIds, classifyType).QueryRows(&items)
-	return
-}
-
-func GetEnglishReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (item *EnglishReport, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT * FROM english_report WHERE 1=1 `
-	if classifyIdSecond > 0 {
-		sql = sql + ` AND classify_id_second=?   ORDER BY stage DESC LIMIT 1`
-		err = o.Raw(sql, classifyIdSecond).QueryRow(&item)
-	} else {
-		sql = sql + ` AND classify_id_first=?   ORDER BY stage DESC LIMIT 1`
-		err = o.Raw(sql, classifyIdFirst).QueryRow(&item)
-	}
-	return
-}
 
 // Update 更新
 func (item *EnglishReport) Update(cols []string) (err error) {
@@ -468,18 +230,6 @@ func (item *EnglishReport) Update(cols []string) (err error) {
 	return
 }
 
-// ModifyEnglishReportAuthor 更改英文报告作者
-func ModifyEnglishReportAuthor(condition string, pars []interface{}, authorName string) (count int, err error) {
-	//产品权限
-	oRddp := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE english_report set author = ? WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	err = oRddp.Raw(sql, authorName, pars).QueryRow(&count)
-	return
-}
-
 type EnglishClassify struct {
 	Id            int       `orm:"column(id);pk"`
 	ClassifyName  string    `description:"分类名称"`
@@ -493,25 +243,6 @@ type EnglishClassify struct {
 	ClassifyType  int       `description:"分类类型:0英文报告,1英文线上路演"`
 }
 
-func AddEnglishClassify(item *EnglishClassify) (lastId int64, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	lastId, err = o.Insert(item)
-	return
-}
-
-func ModifyEnglishClassify(item *EnglishClassify) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `UPDATE english_classify
-	SET
-	classify_name = ?,
-	sort = ?,
-	parent_id = ?,
-	modify_time = ? 
-	WHERE id = ? `
-	_, err = o.Raw(sql, item.ClassifyName, item.Sort, item.ParentId, item.ModifyTime, item.Id).Exec()
-	return
-}
-
 // UpdateClassify 更新分类
 func (classifyInfo *EnglishClassify) UpdateEnglishClassify(cols []string) (err error) {
 	o := orm.NewOrmUsingDB("rddp")
@@ -520,138 +251,6 @@ func (classifyInfo *EnglishClassify) UpdateEnglishClassify(cols []string) (err e
 	return
 }
 
-// DeleteEnglishClassify 删除英文分类
-func DeleteEnglishClassify(classifyId int) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` DELETE FROM english_classify WHERE id =? `
-	_, err = o.Raw(sql, classifyId).Exec()
-	return
-}
-
-func GetEnglishClassifyChildCounts(parentId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT COUNT(1) AS count FROM english_classify WHERE parent_id=? `
-	err = o.Raw(sql, parentId).QueryRow(&count)
-	return
-}
-
-func GetEnglishReportCounts(classifyId, parentId int) (count int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ``
-	if parentId == 0 {
-		sql = `SELECT COUNT(1) AS count FROM english_report WHERE classify_id_first=? `
-	} else {
-		sql = `SELECT COUNT(1) AS count FROM english_report WHERE classify_id_second=? `
-	}
-	err = o.Raw(sql, classifyId).QueryRow(&count)
-	return
-}
-
-func GetEnglishClassifyCountsByName(name string, parentId int, classifyType int) (count int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT COUNT(1) AS count FROM english_classify WHERE classify_name=? AND parent_id = ? AND classify_type = ? `
-	err = o.Raw(sql, name, parentId, classifyType).QueryRow(&count)
-	return
-}
-
-//获取分类列表
-func GetEnglishFirstClassifyList(classifyType, startSize, pageSize int) (items []*EnglishClassifyList, err error) {
-	sql := ``
-
-	sql = `SELECT * FROM english_classify WHERE parent_id=0 AND classify_type = ?  ORDER BY sort ASC,create_time ASC LIMIT ?,? `
-
-	o := orm.NewOrmUsingDB("rddp")
-	_, err = o.Raw(sql, classifyType, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetEnglishFirstClassifyListCount(classifyType int) (count int, err error) {
-	sqlCount := ``
-	sqlCount = `SELECT COUNT(1) AS count FROM english_classify WHERE parent_id=0 AND classify_type = ? `
-
-	o := orm.NewOrmUsingDB("rddp")
-	err = o.Raw(sqlCount, classifyType).QueryRow(&count)
-	return
-}
-
-func GetEnglishReportClassifyById(classifyId int) (item *EnglishClassify, err error) {
-	sql := `SELECT * FROM english_classify WHERE id=?`
-	o := orm.NewOrmUsingDB("rddp")
-	err = o.Raw(sql, classifyId).QueryRow(&item)
-	return
-}
-
-func GetEnglishReportClassifyByIds(classifyIds []int) (list []*EnglishClassify, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * FROM english_classify WHERE id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `)`
-	_, err = o.Raw(sql, classifyIds).QueryRows(&list)
-	return
-}
-
-// UpdateEnglishReportSecondClassifyNameByClassifyId 更新报告分类名称字段
-func UpdateEnglishReportSecondClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := " UPDATE english_report SET classify_name_second = ? WHERE classify_id_second = ? "
-	_, err = o.Raw(sql, classifyName, classifyId).Exec()
-	return
-}
-
-// UpdateEnglishReportFirstClassifyNameByClassifyId 更新报告分类名称字段
-func UpdateEnglishReportFirstClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := " UPDATE english_report SET classify_name_first = ? WHERE classify_id_first = ? "
-	_, err = o.Raw(sql, classifyName, classifyId).Exec()
-	return
-}
-
-// UpdateEnglishReportFirstClassifyNameByClassifyId 更新报告分类名称字段
-func UpdateEnglishReportByClassifyId(classifyFirstName, classifySecondName  string, firstClassifyId, secondClassifyId int, ids string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := " UPDATE english_report SET classify_name_first = ?,classify_name_second = ?,classify_id_first=?, classify_id_second =?  WHERE id IN ("+ids+") "
-	_, err = o.Raw(sql, classifyFirstName, classifySecondName, firstClassifyId, secondClassifyId).Exec()
-	return
-}
-
-// FetchEnglishReportById 主键获取英文报告
-func FetchEnglishReportById(reportId int) (item *EnglishReport, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT * FROM english_report WHERE id=?`
-	err = o.Raw(sql, reportId).QueryRow(&item)
-	return
-}
-
-// UpdateReport 更新英文报告
-func (reportInfo *EnglishReport) UpdateReport(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	_, err = o.Update(reportInfo, cols...)
-
-	return
-}
-
-// GetAllEnglishClassify 获取所有英文分类
-func GetAllEnglishClassify(classifyType int) (list []*EnglishClassify, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT * FROM english_classify where classify_type = ? `
-	_, err = o.Raw(sql, classifyType).QueryRows(&list)
-	return
-}
-
-// GetEnglishReportByIds 根据IDs获取英文报告列表
-func GetEnglishReportByIds(reportIds []int, fieldArr []string) (list []*EnglishReport, err error) {
-	listLen := len(reportIds)
-	if listLen == 0 {
-		return
-	}
-	fields := ` * `
-	if len(fieldArr) > 0 {
-		fields = strings.Join(fieldArr, ",")
-	}
-	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT ` + fields + ` FROM english_report WHERE id IN (` + utils.GetOrmInReplace(listLen) + `)`
-	_, err = o.Raw(sql, reportIds).QueryRows(&list)
-	return
-}
-
 // MarkEditEnReport 标记编辑英文研报的请求数据
 type MarkEditEnReport struct {
 	ReportId int `description:"研报id"`
@@ -676,32 +275,4 @@ func GetEnglishClassifyByClassifyNameAndParentName(parentClassiyName, classifyNa
 	sql := "SELECT c1.*, c2.classify_name as parent_classify_name FROM english_classify c1 LEFT JOIN english_classify c2 on c1.parent_id = c2.id where c1.parent_id > 0 and c2.classify_name = ? and c1.classify_name= ?"
 	err = o.Raw(sql, parentClassiyName, classifyName).QueryRow(&item)
 	return
-}
-
-type RSClassifyList []*EnglishClassifyList
-
-func (m RSClassifyList) Len() int {
-	return len(m)
-}
-
-func (m RSClassifyList) Less(i, j int) bool {
-	return m[i].Sort < m[j].Sort
-}
-
-func (m RSClassifyList) Swap(i, j int) {
-	m[i], m[j] = m[j], m[i]
-}
-
-type RSChildClassifyList []*EnglishClassify
-
-func (m RSChildClassifyList) Len() int {
-	return len(m)
-}
-
-func (m RSChildClassifyList) Less(i, j int) bool {
-	return m[i].Sort < m[j].Sort
-}
-
-func (m RSChildClassifyList) Swap(i, j int) {
-	m[i], m[j] = m[j], m[i]
 }

+ 1 - 141
services/english_policy_report.go

@@ -91,80 +91,6 @@ type EnPolicyReportDataListItemAuthor struct {
 	Name        string `json:"name"`
 }
 
-// PullEnglishPolicyReportAll 批量拉取最近的15天内的报告
-func PullEnglishPolicyReportAll() (ret tables.PullEnglishPolicyDataResp, err error, msg string)  {
-	defer func() {
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("批量拉取英文策略报告失败,Err:"+err.Error()+";msg:"+msg, 3)
-			utils.FileLog.Info(fmt.Sprintf("批量拉取英文策略报告失败 PullEnglishPolicyReportAll,Err:%s,%s", err.Error(), msg))
-		}
-	}()
-	//调用列表接口,批量插入数据
-	originData, err := getOriginPolicyReportList(false)
-	if err != nil {
-		msg = "调用英文策略报告列表接口失败"
-		return
-	}
-	condition := ""
-	var pars []interface{}
-	startDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
-	condition += ` AND publish_time >= ? `
-	pars = append(pars, startDate)
-	//获取已插入的报告ID,避免重复插入
-	existData, err := tables.GetEnglishPolicyReportByCondition(condition, pars)
-	if err != nil {
-		msg = "查询已存在的英文策略报告列表接口失败"
-		return
-	}
-	existIdsMap := make(map[int]struct{}, 0)
-	for _, v := range existData {
-		existIdsMap[v.SourceReportId] = struct{}{}
-	}
-	//组装数据,插入到policy_report表中
-	addItems := make([]*tables.EnglishPolicyReport, 0)
-	addIds := make([]int, 0)
-	for _, v := range originData {
-		if _, ok := existIdsMap[v.Id]; ok {
-			continue
-		}
-		addIds = append(addIds, v.Id)
-		tmp := &tables.EnglishPolicyReport{
-			ClassifyIdFirst:    v.Industry.Id,
-			ClassifyNameFirst:  v.Industry.Description,
-			ClassifyIdSecond:   v.FieldId,
-			ClassifyNameSecond: v.Field.Description,
-			Title:              v.TitleEn,
-			Abstract:           v.Content.Abstract,
-			Author:             v.Author.Name,
-			Frequency:          v.Frequency,
-			CreateTime:         time.Now(),
-			ModifyTime:         time.Now(),
-			State:              1,
-			PublishStatus:      v.PublishStatus,
-			PublishTime:        v.PublishDate,
-			KeyTakeaways: v.Content.Annotation,
-			AuthorMobile: v.Author.PhoneNumber,
-			SourceReportId: v.Id,
-			ReportCoverUrl: v.Cover,
-		}
-		addItems = append(addItems, tmp)
-	}
-	if len(addItems) > 0 {
-		err = tables.AddEnglishPolicyReportMulti(addItems)
-		if err != nil {
-			msg = "批量新增英文策略报告信息失败"
-			return
-		}
-		//根据原始ID调用详情接口,更新数据
-		if len(addIds) > 0 {
-			go setPolicyReportContent(addIds)
-		}
-	}
-	ret = tables.PullEnglishPolicyDataResp{
-		Num: len(addItems),
-	}
-	return
-}
 // PullEnglishPolicyReportSingle 根据报告ID 拉取报告
 func PullEnglishPolicyReportSingle(sourceId int) (ret tables.PullEnglishPolicyDataResp, err error, msg string)  {
 	defer func() {
@@ -222,44 +148,7 @@ func PullEnglishPolicyReportSingle(sourceId int) (ret tables.PullEnglishPolicyDa
 		return
 	}
 	//同步到英文研报
-	go EnglishPolicyReportSync(tmp.Id)
-
-	return
-}
-
-func getOriginPolicyReportList(initFlag bool) (list []EnPolicyReportDataListItem, err error) {
-	//组装请求字段
-	typeId := 9
-	//field_id=1 表示 Daily Check-in
-	fieldId := 1
-	take := 1000
-	skip := 0
-	publishStatus := 2
-	mode := "all"
-	startDt := ""
-	if !initFlag {
-		// 获取最近15天内的报告
-		startDt = time.Now().AddDate(0, 0, -15).Format(utils.FormatDate)
-	}
-	//设置接口地址
-	//处理返回值
-	url := utils.EN_POLICY_REPORT_URL + `articles/index?type_id=%d&field_id=%d&take=%d&skip=%d&publish_status=%d&mode=%s&start_dt=%s`
-	url = fmt.Sprintf(url, typeId, fieldId, take, skip, publishStatus, mode, startDt)
-	utils.FileLog.Info("url:%s", url)
-	body, err := http.Get(url)
-	fmt.Println("getOriginPolicyReportList body:")
-	fmt.Println(string(body))
-	item := new(EnPolicyReportDataListResp)
-	err = json.Unmarshal(body, &item)
-	if err != nil {
-		return
-	}
-	if item.Code != 0 {
-		err = fmt.Errorf("getOriginPolicyReportDetail ErrCode: %d, ErrMsg: %s", item.Code, item.Msg)
-		return
-	}
-
-	list = item.Data
+	err, msg = EnglishPolicyReportSync(tmp.Id)
 	return
 }
 
@@ -286,35 +175,6 @@ func getOriginPolicyReportDetail(id int) (detail EnPolicyReportDataListItem, err
 	return
 }
 
-func setPolicyReportContent(addIds []int) (err error, msg string) {
-	defer func() {
-		if err != nil {
-			go alarm_msg.SendAlarmMsg("设置英文策略报告内容失败,Err:"+err.Error()+";msg:"+msg, 3)
-			utils.FileLog.Info(fmt.Sprintf("设置英文策略报告内容失败 setPolicyReportContent,Err:%s,%s", err.Error(), msg))
-		}
-	}()
-	count := 0
-	for _, v := range addIds {
-		if count > 50 {
-			count = 0
-			time.Sleep(1*time.Second)
-		}
-		originDetail, e := getOriginPolicyReportDetail(v)
-		if e != nil {
-			msg = "拉取英文策略报告详情失败"
-			err = e
-			return
-		}
-		err = tables.SetEnglishPolicyReportContentBySourceReportId(v, originDetail.Content.Body)
-		if err != nil {
-			msg = "更新英文策略报告内容失败"
-			return
-		}
-		count ++
-	}
-	return
-}
-
 // EnglishPolicyReportSync 英文策略报告一键同步功能
 func EnglishPolicyReportSync(id int) (err error, errMsg string) {
 	//查询报告是否存在