Browse Source

标签拆分成两个

ziwen 1 year ago
parent
commit
adef5490bf
5 changed files with 85 additions and 63 deletions
  1. 2 1
      controllers/research.go
  2. 48 35
      controllers/yanxuan_special.go
  3. 27 23
      models/cygx_yanxuan_special.go
  4. 2 1
      models/home.go
  5. 6 3
      models/report.go

+ 2 - 1
controllers/research.go

@@ -163,7 +163,8 @@ func (this *MobileResearchController) ArticleNewList() {
 			ButtonStyle:     styleMap[v.ArticleTypeId],
 			List:            v.List,
 			IsSpecial:       v.IsSpecial,
-			SpecialTags:     strings.Split(v.SpecialTags, ","),
+			IndustryTags:     strings.Split(v.IndustryTags, ","),
+			CompanyTags:     strings.Split(v.CompanyTags, ","),
 			SpecialColumnId: v.SpecialColumnId,
 		}
 		if v.ArticleTypeId == -1 {

+ 48 - 35
controllers/yanxuan_special.go

@@ -96,12 +96,19 @@ func (this *YanxuanSpecialController) List() {
 		} else {
 			v.ImgUrlList = []string{}
 		}
-		if v.Tags != "" {
-			tagList := strings.Split(v.Tags, ",")
+		if v.CompanyTags != "" {
+			tagList := strings.Split(v.CompanyTags, ",")
 			for _, s := range tagList {
 				v.TagList = append(v.TagList, s)
 			}
-		} else {
+		}
+		if v.IndustryTags != "" {
+			tagList := strings.Split(v.IndustryTags, ",")
+			for _, s := range tagList {
+				v.TagList = append(v.TagList, s)
+			}
+		}
+		if len(v.TagList) == 0 {
 			v.TagList = []string{}
 		}
 	}
@@ -155,16 +162,16 @@ func (this *YanxuanSpecialController) Detail() {
 		item.IsCollect = 1
 	}
 
-	industryTagList, tmpErr := models.GetYanxuanSpecialIndustry("")
-	if tmpErr != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
-		return
-	}
-	industryTagMap := make(map[string]int, 0)
-	for _, v := range industryTagList {
-		industryTagMap[v] = 1
-	}
+	//industryTagList, tmpErr := models.GetYanxuanSpecialIndustry("")
+	//if tmpErr != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+	//	return
+	//}
+	//industryTagMap := make(map[string]int, 0)
+	//for _, v := range industryTagList {
+	//	industryTagMap[v] = 1
+	//}
 
 	var resp models.CygxYanxuanSpecialResp
 	resp.CygxYanxuanSpecialItem = *item
@@ -186,19 +193,22 @@ func (this *YanxuanSpecialController) Detail() {
 	} else {
 		resp.ImgUrlList = []string{}
 	}
-	if item.Tags != "" {
-		tagList := strings.Split(item.Tags, ",")
-		for _, s := range tagList {
-			if _,ok := industryTagMap[s]; ok{
-				resp.IndustryTags = append(resp.IndustryTags, s)
-			} else {
-				resp.CompanyTags = append(resp.CompanyTags, s)
-			}
+	if item.CompanyTags != "" {
+		cTagList := strings.Split(item.CompanyTags, ",")
+		for _, s := range cTagList {
+			resp.CompanyTags = append(resp.CompanyTags, s)
 		}
 	} else {
-		resp.IndustryTags = []string{}
 		resp.CompanyTags = []string{}
 	}
+	if item.IndustryTags != "" {
+		iTagList := strings.Split(item.IndustryTags, ",")
+		for _, s := range iTagList {
+			resp.IndustryTags = append(resp.IndustryTags, s)
+		}
+	} else {
+		resp.IndustryTags = []string{}
+	}
 
 	go services.AddSpecialRecord(this.User, specialId)
 
@@ -319,7 +329,8 @@ func (this *YanxuanSpecialController) Save() {
 		br.Msg = "请输入内容"
 		return
 	}
-	if len(req.Tags) > 0 && req.DoType == 2 {
+
+	if len(req.CompanyTags) == 0 && len(req.CompanyTags) == 0 && req.DoType == 2 {
 		br.Msg = "请至少输入一个标签"
 		return
 	}
@@ -328,19 +339,21 @@ func (this *YanxuanSpecialController) Save() {
 		return
 	}
 	imgUrls := strings.Join(req.ImgUrl, ",")
-	tags := strings.Join(req.Tags, ",")
+	cTags := strings.Join(req.CompanyTags, ",")
+	iTags := strings.Join(req.IndustryTags, ",")
 	item := models.CygxYanxuanSpecial{
-		Id:          req.Id,
-		UserId:      sysUser.UserId,
-		CreateTime:  time.Now(),
-		ModifyTime:  time.Now(),
-		PublishTime: time.Now(),
-		Content:     req.Content,
-		Tags:        tags,
-		ImgUrl:      imgUrls,
-		DocUrl:      string(docUrl),
-		Title:       req.Title,
-		Type:        req.Type,
+		Id:           req.Id,
+		UserId:       sysUser.UserId,
+		CreateTime:   time.Now(),
+		ModifyTime:   time.Now(),
+		PublishTime:  time.Now(),
+		Content:      req.Content,
+		CompanyTags:  cTags,
+		IndustryTags: iTags,
+		ImgUrl:       imgUrls,
+		DocUrl:       string(docUrl),
+		Title:        req.Title,
+		Type:         req.Type,
 	}
 	if req.DoType == 1 {
 		item.Status = 1

+ 27 - 23
models/cygx_yanxuan_special.go

@@ -6,19 +6,20 @@ import (
 )
 
 type CygxYanxuanSpecial struct {
-	Id          int       `orm:"column(id);pk"`
-	UserId      int       // 用户ID
-	CreateTime  time.Time // 创建时间
-	ModifyTime  time.Time // 修改时间
-	PublishTime time.Time // 提审过审或驳回时间
-	Content     string    // 内容
-	Tags        string    // 标签
-	Status      int       // 1:未发布,2:审核中 3:已发布 4:驳回
-	ImgUrl      string    // 图片链接
-	DocUrl      string    // 文档链接
-	Reason      string    // 理由
-	Title       string    // 标题
-	Type        int       // 类型1:笔记,2:观点
+	Id           int       `orm:"column(id);pk"`
+	UserId       int       // 用户ID
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	PublishTime  time.Time // 提审过审或驳回时间
+	Content      string    // 内容
+	CompanyTags  string    // 标签
+	IndustryTags string    // 标签
+	Status       int       // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl       string    // 图片链接
+	DocUrl       string    // 文档链接
+	Reason       string    // 理由
+	Title        string    // 标题
+	Type         int       // 类型1:笔记,2:观点
 }
 
 type CygxYanxuanSpecialItem struct {
@@ -50,6 +51,8 @@ type CygxYanxuanSpecialItem struct {
 	MyCollectNum    int
 	IsCollect       int
 	ContentHasImg   int //正文是否包含图片 1包含 0不包含
+	CompanyTags     string
+	IndustryTags    string
 	Docs            []Doc
 }
 
@@ -124,14 +127,15 @@ JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
 }
 
 type CygxYanxuanSpecialReq struct {
-	Id      int      `orm:"column(id);pk"`
-	Content string   // 内容
-	Tags    []string // 标签
-	DoType  int      // 1保存 2发布
-	ImgUrl  []string // 图片链接
-	Docs    []DocReq // 文档链接
-	Title   string   // 标题
-	Type    int      // 类型1:笔记,2:观点
+	Id           int      `orm:"column(id);pk"`
+	Content      string   // 内容
+	IndustryTags []string // 行业标签
+	CompanyTags  []string // 公司标签
+	DoType       int      // 1保存 2发布
+	ImgUrl       []string // 图片链接
+	Docs         []DocReq // 文档链接
+	Title        string   // 标题
+	Type         int      // 类型1:笔记,2:观点
 }
 
 func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
@@ -143,9 +147,9 @@ func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
 func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
 	o := orm.NewOrm()
 	sql := ``
-	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,tags=?,img_url=?,doc_url=?,type=?,status=?,
+	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,company_tags=?,industry_tags=?,img_url=?,doc_url=?,type=?,status=?,
 	modify_time=NOW(),publish_time=NOW() WHERE id = ? `
-	_, err = o.Raw(sql, item.Title, item.Content, item.Tags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
+	_, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
 	return
 }
 

+ 2 - 1
models/home.go

@@ -76,7 +76,8 @@ type ArticleListResp struct {
 	Cover               string   `description:"封面图片"`
 	BodyHighlight       []string `description:"搜索高亮展示结果"`
 	IsSpecial           int      `description:"是否为研选专栏"`
-	SpecialTags         string   `description:"研选专栏标签"`
+	IndustryTags        string   `description:"研选专栏行业标签"`
+	CompanyTags         string   `description:"研选专栏公司标签"`
 	SpecialColumnId     int      `description:"专栏栏目id"`
 	SpecialType         int      `description:"专栏类型 1:笔记,2:观点"`
 	List                []*IndustrialManagementIdInt

+ 6 - 3
models/report.go

@@ -831,7 +831,8 @@ type ArticleResearchResp struct {
 	List            []*IndustrialManagementIdInt `description:"产业列表"`
 	ListSubject     []*IndustrialSubject         `description:"标的列表"`
 	IsSpecial       int                          `description:"是否为研选专栏"`
-	SpecialTags     []string                       `description:"研选专栏标签"`
+	IndustryTags    []string                       `description:"研选专栏行业标签"`
+	CompanyTags     []string                       `description:"研选专栏公司标签"`
 	SpecialColumnId int                          `description:"专栏栏目id"`
 }
 
@@ -872,7 +873,8 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 			0 AS is_special,
 			0 AS special_type,
 			0 AS special_column_id,
-			'' AS special_tags 
+			'' AS company_tags, 
+			'' AS industry_tags 
 		FROM
 			cygx_article AS a
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
@@ -902,7 +904,8 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 		1 AS is_special,
 		a.type AS special_type,
 		b.id AS special_column_id,
-		a.tags AS special_tags 
+		a.company_tags AS company_tags, 
+		a.industry_tags AS industry_tags 
 	FROM
 	cygx_yanxuan_special AS a
 	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id