1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package model
- import (
- MC "app.yhyue.com/moapp/jybase/common"
- ME "app.yhyue.com/moapp/jybase/encrypt"
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXBase/rpc/bxbase"
- IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXBase/rpc/init"
- "strings"
- )
- // 标题判重
- func DuplicatedByTitle(list []*bxbase.NewestList) (res []*bxbase.NewestList) {
- var (
- i int64 = 0
- duplicateMap = map[string]bool{}
- )
- for _, v := range list {
- //判重
- if i >= IC.C.NewsLimitNum {
- break
- }
- if duplicateMap[v.Title] {
- continue
- }
- i++
- res = append(res, v)
- }
- return
- }
- // 是否收藏
- func MakeCollection(userId string, list []*bxbase.NewestList) {
- var (
- param = []interface{}{userId}
- wh = []string{}
- )
- for _, v := range list {
- array := ME.DecodeArticleId2ByCheck(v.Id)
- if len(array) == 1 && array[0] != "" {
- param = append(param, array[0])
- wh = append(wh, "?")
- }
- }
- if len(wh) > 0 {
- result := IC.MainMysql.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
- bid_map := map[string]bool{}
- if result != nil {
- for _, v := range *result {
- bid_map[ME.EncodeArticleId2ByCheck(MC.ObjToString(v["bid"]))] = true
- }
- }
- for _, v := range list {
- if !IC.C.FileSignBool {
- v.FileExists = false
- }
- if bid_map[v.Id] {
- v.IsCol = true
- }
- }
- }
- }
|