struct.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. package p
  2. import (
  3. "encoding/json"
  4. "strings"
  5. util "app.yhyue.com/moapp/jybase/common"
  6. . "app.yhyue.com/moapp/jybase/mongodb"
  7. "bp.jydev.jianyu360.cn/BaseService/pushpkg/dfa"
  8. "github.com/donnie4w/go-logger/logger"
  9. )
  10. //
  11. type MgoConf struct {
  12. Address string
  13. Size int
  14. DbName string
  15. ReplSet string
  16. UserName string
  17. Password string
  18. Collection string
  19. ExperienceDbName string
  20. }
  21. //
  22. type RedisConf struct {
  23. Address string
  24. }
  25. //
  26. type MysqlConf struct {
  27. DbName string
  28. Address string
  29. UserName string
  30. PassWord string
  31. MaxOpenConns int
  32. MaxIdleConns int
  33. }
  34. //
  35. type EsConf struct {
  36. Address string
  37. Size int
  38. }
  39. //
  40. type MemberService struct {
  41. IsBuy bool
  42. Services map[int]*memberService
  43. }
  44. //
  45. type memberService struct {
  46. Id int
  47. StartTime string
  48. }
  49. //关键词
  50. type KeySet struct {
  51. Item string `json:"item"` //分类名称
  52. Keys []string `json:"key"` //关键词
  53. NotKeys []string `json:"notkey"` //排除词
  54. SubTypes []string `json:"infotype"` //信息类型
  55. Areas []string `json:"area"` //地区
  56. AppendKeys []string `json:"appendkey"` //附加词
  57. MatchWay int `json:"matchway"` //匹配模式 0:精准匹配 1:模糊匹配
  58. }
  59. //解析订阅词
  60. type SubSet struct {
  61. MatchWay int //匹配方式 1-标题 2-正文
  62. Matchbuyerclass_other int //是否开启其他按钮
  63. ProjectMatch int //项目关联推送
  64. Items []string //关键词分类
  65. Keys []string //过滤后的关键词
  66. Notkeys []string //排除词
  67. Key_item map[string]string //关键词对应的分类名称
  68. Key_notkey map[string]map[string]bool //关键词所对应的排除词
  69. Key_area map[string]map[string]bool //关键词所对应的信息范围
  70. Key_subtype map[string]map[string]bool //关键词所对应的信息类型
  71. OriginalKeys []string //原始关键词
  72. Areas []string //区域-省份
  73. Area map[string]interface{} //区域-省份
  74. Subtype []interface{} //信息类型-二级分类
  75. Subtypes []string //信息类型-二级分类
  76. Buyerclass []interface{} //采购单位行业
  77. Buyerclasss []string //采购单位行业
  78. IsUpgrade bool //免费用户是否订阅升级
  79. MaxPushSize int //推送最大条数
  80. MaxMailSize int //邮件最大条数
  81. }
  82. //推送设置
  83. type PushSet struct {
  84. Email string //邮箱
  85. SubSet *PushSetChild //订阅推送设置
  86. WeekReport *PushSetChild //周报推送设置
  87. MonthReport *PushSetChild //月报推送设置
  88. NewprojectForecast *PushSetChild //潜在项目预测推送设置
  89. EntInfo *PushSetChild //企业情报监控-企业工商变动推送设置
  90. FollowProject *PushSetChild //项目进度监控推送设置
  91. FollowEnt *PushSetChild //企业情报监控-企业中标动态推送设置
  92. }
  93. type PushSetChild struct {
  94. RateMode int //推送时间
  95. Times []string //自定义推送时间
  96. WxPush int //是否开启微信推送
  97. AppPush int //是否开启app推送
  98. MailPush int //是否开启邮箱推送
  99. }
  100. //用户基本信息
  101. type UserInfo struct {
  102. Id string //mongoid
  103. BaseUserId int64 //mysql用户id
  104. S_m_openid string //公众号openid
  105. A_m_openid string //app微信登录openid
  106. Phone string //app手机号登录
  107. Jpushid string //极光推送id
  108. Opushid string //厂商推送id
  109. AppPhoneType string //手机型号
  110. Subscribe int //是否关注
  111. VipStatus int //超级订阅 1--试用 2--正式
  112. MemberStatus int //大会员
  113. NicheStatus int //商机管理
  114. IsMainAccount bool //是否是主账号
  115. SonAccountStatus int //子账号状态 0-禁用 1-启用
  116. MainId string //主账号id
  117. Entniche *Entniche
  118. MemberMainid string
  119. WxTplMsg *WxTplMsg
  120. SubSet *SubSet
  121. PushSet *PushSet
  122. Extend *UserInfoExtend
  123. }
  124. /*
  125. *获取用户信息
  126. *temp 用户数据
  127. *tp 1-免费 2-超级订阅 3-大会员
  128. */
  129. func NewUserInfo(temp map[string]interface{}, tp int) *UserInfo {
  130. ui := &UserInfo{
  131. Id: BsonIdToSId(temp["_id"]),
  132. BaseUserId: util.Int64All(temp["base_user_id"]),
  133. S_m_openid: util.ObjToString(temp["s_m_openid"]),
  134. A_m_openid: util.ObjToString(temp["a_m_openid"]),
  135. Phone: GetPhone(temp),
  136. Jpushid: util.ObjToString(temp["s_jpushid"]),
  137. Opushid: util.ObjToString(temp["s_opushid"]),
  138. AppPhoneType: util.ObjToString(temp["s_appponetype"]),
  139. Subscribe: util.IntAllDef(temp["i_ispush"], 1),
  140. VipStatus: util.IntAll(temp["i_vip_status"]),
  141. MemberStatus: util.IntAll(temp["i_member_status"]),
  142. }
  143. if ui.MemberStatus > 0 {
  144. ui.IsMainAccount = util.IntAll(temp["i_mainaccount"]) == 1
  145. ui.SonAccountStatus = util.IntAllDef(temp["i_member_sub_status"], -1)
  146. ui.MemberMainid = util.ObjToString(temp["s_member_mainid"])
  147. }
  148. var obj map[string]interface{}
  149. if tp == 3 {
  150. obj, _ = temp["o_member_jy"].(map[string]interface{})
  151. } else if tp == 2 {
  152. obj, _ = temp["o_vipjy"].(map[string]interface{})
  153. } else {
  154. obj, _ = temp["o_jy"].(map[string]interface{})
  155. }
  156. ui.GetSubSet(tp == 1, ui.Id, obj)
  157. o_pushset, _ := temp["o_pushset"].(map[string]interface{})
  158. ui.GetPushSet(o_pushset)
  159. return ui
  160. }
  161. //解析用户的推送设置
  162. func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
  163. subSet, _ := obj["o_subset"].(map[string]interface{})
  164. times, _ := subSet["a_times"].([]interface{})
  165. weekReport, _ := obj["o_week_report"].(map[string]interface{})
  166. monthReport, _ := obj["o_month_report"].(map[string]interface{})
  167. newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
  168. entInfo, _ := obj["o_entinfo"].(map[string]interface{})
  169. followProject, _ := obj["o_follow_project"].(map[string]interface{})
  170. followEnt, _ := obj["o_follow_ent"].(map[string]interface{})
  171. u.PushSet = &PushSet{
  172. Email: strings.TrimSpace(util.ObjToString(obj["s_email"])),
  173. SubSet: &PushSetChild{
  174. WxPush: util.IntAllDef(subSet["i_wxpush"], 1),
  175. AppPush: util.IntAllDef(subSet["i_apppush"], 1),
  176. MailPush: util.IntAll(subSet["i_mailpush"]),
  177. RateMode: util.IntAllDef(subSet["i_ratemode"], 5),
  178. Times: util.ObjArrToStringArr(times),
  179. },
  180. WeekReport: &PushSetChild{
  181. WxPush: util.IntAllDef(weekReport["i_wxpush"], 1),
  182. AppPush: util.IntAllDef(weekReport["i_apppush"], 1),
  183. MailPush: util.IntAll(weekReport["i_mailpush"]),
  184. },
  185. MonthReport: &PushSetChild{
  186. WxPush: util.IntAllDef(monthReport["i_wxpush"], 1),
  187. AppPush: util.IntAllDef(monthReport["i_apppush"], 1),
  188. MailPush: util.IntAll(monthReport["i_mailpush"]),
  189. },
  190. NewprojectForecast: &PushSetChild{
  191. WxPush: util.IntAllDef(newprojectForecast["i_wxpush"], 1),
  192. AppPush: util.IntAllDef(newprojectForecast["i_apppush"], 1),
  193. MailPush: util.IntAll(newprojectForecast["i_mailpush"]),
  194. },
  195. EntInfo: &PushSetChild{
  196. WxPush: util.IntAllDef(entInfo["i_wxpush"], 1),
  197. AppPush: util.IntAllDef(entInfo["i_apppush"], 1),
  198. MailPush: util.IntAll(entInfo["i_mailpush"]),
  199. },
  200. FollowProject: &PushSetChild{
  201. WxPush: util.IntAllDef(followProject["i_wxpush"], 1),
  202. AppPush: util.IntAllDef(followProject["i_apppush"], 1),
  203. MailPush: util.IntAll(followProject["i_mailpush"]),
  204. },
  205. FollowEnt: &PushSetChild{
  206. WxPush: util.IntAllDef(followEnt["i_wxpush"], 1),
  207. AppPush: util.IntAllDef(followEnt["i_apppush"], 1),
  208. MailPush: util.IntAll(followEnt["i_mailpush"]),
  209. },
  210. }
  211. if u.Subscribe == 0 || u.S_m_openid == "" {
  212. u.PushSet.SubSet.WxPush = -1
  213. u.PushSet.WeekReport.WxPush = -1
  214. u.PushSet.MonthReport.WxPush = -1
  215. u.PushSet.NewprojectForecast.WxPush = -1
  216. u.PushSet.EntInfo.WxPush = -1
  217. u.PushSet.FollowProject.WxPush = -1
  218. u.PushSet.FollowEnt.WxPush = -1
  219. }
  220. if u.Jpushid == "" && u.Opushid == "" {
  221. u.PushSet.SubSet.AppPush = -1
  222. u.PushSet.WeekReport.AppPush = -1
  223. u.PushSet.MonthReport.AppPush = -1
  224. u.PushSet.NewprojectForecast.AppPush = -1
  225. u.PushSet.EntInfo.AppPush = -1
  226. u.PushSet.FollowProject.AppPush = -1
  227. u.PushSet.FollowEnt.AppPush = -1
  228. }
  229. mailPush := true
  230. if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid == "" {
  231. mailPush = false
  232. } else if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid != "" && u.Jpushid == "" && u.Opushid == "" {
  233. mailPush = false
  234. } else if !MailReg.MatchString(u.PushSet.Email) {
  235. mailPush = false
  236. }
  237. if !mailPush {
  238. u.PushSet.SubSet.MailPush = -1
  239. u.PushSet.WeekReport.MailPush = -1
  240. u.PushSet.MonthReport.MailPush = -1
  241. u.PushSet.NewprojectForecast.MailPush = -1
  242. u.PushSet.EntInfo.MailPush = -1
  243. u.PushSet.FollowProject.MailPush = -1
  244. u.PushSet.FollowEnt.MailPush = -1
  245. }
  246. }
  247. //解析用户的订阅设置
  248. func (u *UserInfo) GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) {
  249. subSet := &SubSet{
  250. Keys: []string{},
  251. Notkeys: []string{},
  252. Key_item: map[string]string{},
  253. Key_notkey: map[string]map[string]bool{},
  254. Key_area: map[string]map[string]bool{},
  255. Key_subtype: map[string]map[string]bool{},
  256. OriginalKeys: []string{},
  257. Areas: []string{},
  258. Subtypes: []string{},
  259. Buyerclasss: []string{},
  260. MatchWay: util.IntAllDef(obj["i_matchway"], 1),
  261. Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
  262. ProjectMatch: util.IntAll(obj["i_projectmatch"]),
  263. MaxPushSize: util.IntAll(obj["i_maxpushsize"]),
  264. MaxMailSize: util.IntAll(obj["i_maxmailsize"]),
  265. }
  266. var keySets []*KeySet
  267. if isFreeUser {
  268. var err error
  269. keySets, err = u.GetKeySets(obj["a_key"])
  270. if err != nil {
  271. logger.Error("获取用户关键词错误!", userId, obj["a_key"], err)
  272. return
  273. }
  274. area := obj["o_area"]
  275. if ppStatus := util.IntAll(obj["i_ppstatus"]); ppStatus == 1 {
  276. area = obj["o_area_p"]
  277. }
  278. if newFree := util.IntAll(obj["i_newfree"]); newFree == 1 && area != nil {
  279. subSet.IsUpgrade = true
  280. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  281. subSet.Area, _ = area.(map[string]interface{})
  282. }
  283. } else {
  284. items, _ := obj["a_items"].([]interface{})
  285. for _, v := range items {
  286. item, _ := v.(map[string]interface{})
  287. itemName := strings.TrimSpace(util.ObjToString(item["s_item"]))
  288. subSet.Items = append(subSet.Items, itemName)
  289. kss, err := u.GetKeySets(item["a_key"])
  290. if err != nil {
  291. logger.Error("获取用户关键词错误!", userId, item["a_key"], err)
  292. continue
  293. }
  294. for _, vv := range kss {
  295. if vv == nil {
  296. continue
  297. }
  298. if vv.MatchWay == 1 {
  299. for _, vvv := range vv.Keys {
  300. keySets = append(keySets, &KeySet{
  301. Item: itemName,
  302. Keys: []string{vvv},
  303. NotKeys: vv.NotKeys,
  304. })
  305. }
  306. for _, vvv := range vv.AppendKeys {
  307. keySets = append(keySets, &KeySet{
  308. Item: itemName,
  309. Keys: []string{vvv},
  310. NotKeys: vv.NotKeys,
  311. })
  312. }
  313. } else {
  314. vv.Item = itemName
  315. keySets = append(keySets, vv)
  316. }
  317. }
  318. }
  319. subSet.Buyerclass, _ = obj["a_buyerclass"].([]interface{})
  320. subSet.Subtype, _ = obj["a_infotype"].([]interface{})
  321. subSet.Area, _ = obj["o_area"].(map[string]interface{})
  322. }
  323. for _, v := range subSet.Buyerclass {
  324. s_v, _ := v.(string)
  325. if s_v == "" {
  326. continue
  327. }
  328. subSet.Buyerclasss = append(subSet.Buyerclasss, s_v)
  329. }
  330. for _, v := range subSet.Subtype {
  331. s_v, _ := v.(string)
  332. if s_v == "" {
  333. continue
  334. }
  335. subSet.Subtypes = append(subSet.Subtypes, s_v)
  336. }
  337. for area, _ := range subSet.Area {
  338. if area == "" {
  339. continue
  340. }
  341. subSet.Areas = append(subSet.Areas, area)
  342. }
  343. ////////////////
  344. for _, vs := range keySets {
  345. if vs == nil {
  346. logger.Error(userId, "关键词设置异常")
  347. continue
  348. }
  349. var vs_keys []string
  350. for _, vs_v := range [][]string{vs.Keys, vs.AppendKeys} {
  351. for _, vs_vv := range vs_v {
  352. vs_vv = strings.TrimSpace(vs_vv)
  353. if vs_vv == "" {
  354. continue
  355. }
  356. vs_keys = append(vs_keys, vs_vv)
  357. }
  358. }
  359. if len(vs_keys) == 0 {
  360. continue
  361. }
  362. key := strings.Join(vs_keys, "+")
  363. subSet.OriginalKeys = append(subSet.OriginalKeys, key)
  364. if KeyFilterReg.MatchString(key) {
  365. continue
  366. } else if !KeyRetainReg.MatchString(key) {
  367. continue
  368. }
  369. subSet.Keys = append(subSet.Keys, key)
  370. subSet.Notkeys = append(subSet.Notkeys, vs.NotKeys...)
  371. //转大写
  372. upperKey := strings.ToUpper(key)
  373. subSet.Key_item[upperKey] = vs.Item
  374. //建立与排除词的对应关系
  375. for _, notkey := range vs.NotKeys {
  376. upperNotkey := strings.ToUpper(notkey)
  377. if subSet.Key_notkey[upperKey] == nil {
  378. subSet.Key_notkey[upperKey] = map[string]bool{}
  379. }
  380. subSet.Key_notkey[upperKey][upperNotkey] = true
  381. }
  382. //免费用户需要进行映射
  383. if isFreeUser {
  384. //建立与信息范围的对应关系
  385. for _, area := range vs.Areas {
  386. if subSet.Key_area[upperKey] == nil {
  387. subSet.Key_area[upperKey] = map[string]bool{}
  388. }
  389. subSet.Key_area[upperKey][area] = true
  390. }
  391. //建立与信息类型的对应关系
  392. for _, subtype := range vs.SubTypes {
  393. if subSet.Key_subtype[upperKey] == nil {
  394. subSet.Key_subtype[upperKey] = map[string]bool{}
  395. }
  396. subSet.Key_subtype[upperKey][subtype] = true
  397. }
  398. }
  399. }
  400. u.SubSet = subSet
  401. }
  402. //得到用户的关键词
  403. func (u *UserInfo) GetKeySets(a_key interface{}) ([]*KeySet, error) {
  404. var keySets []*KeySet
  405. if a_key == nil {
  406. return keySets, nil
  407. }
  408. _bs, err := json.Marshal(a_key)
  409. if err == nil {
  410. err = json.Unmarshal(_bs, &keySets)
  411. }
  412. if err != nil {
  413. return keySets, err
  414. }
  415. for _, v := range keySets {
  416. if v == nil {
  417. continue
  418. }
  419. keys, appendKeys, notKeys := []string{}, []string{}, []string{}
  420. for _, vv := range v.Keys {
  421. keys = append(keys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  422. }
  423. for _, vv := range v.AppendKeys {
  424. appendKeys = append(appendKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  425. }
  426. for _, vv := range v.NotKeys {
  427. notKeys = append(notKeys, SpaceReg.Split(strings.TrimSpace(vv), -1)...)
  428. }
  429. v.Keys = keys
  430. v.AppendKeys = appendKeys
  431. v.NotKeys = notKeys
  432. }
  433. return keySets, err
  434. }
  435. //
  436. type Entniche struct {
  437. EntId int //企业id
  438. EntName string //企业名称
  439. DeptId int //部门id
  440. DisId string //分发id
  441. UserId int
  442. Unique string
  443. OnlyPush int
  444. IsNew int
  445. PowerSource int //权益来源
  446. ProductType string //产品类型
  447. Mail string //邮箱
  448. IsDis int //是否是分发
  449. DisMember int //分发-超级订阅
  450. DisVip int //分发-大会员
  451. }
  452. //用户基本信息-扩展
  453. type UserInfoExtend struct {
  454. CreateTime int64 //
  455. Size int
  456. }
  457. func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
  458. mk := (*m)[k]
  459. if mk == nil {
  460. mk = map[*UserInfo]bool{}
  461. }
  462. mk[u] = true
  463. (*m)[k] = mk
  464. }
  465. //添加信息类型映射关系
  466. func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
  467. if len(u.SubSet.Subtypes) == 0 {
  468. u.Add("", m)
  469. } else {
  470. for _, v := range u.SubSet.Subtypes {
  471. u.Add(v, m)
  472. }
  473. }
  474. }
  475. //添加采购单位类型映射关系
  476. func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
  477. //如果有关键词 有采购单位行业,行业加上“其它”
  478. if len(u.SubSet.Buyerclasss) == 0 {
  479. u.Add("", m)
  480. } else {
  481. if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
  482. u.Add("其它", m)
  483. }
  484. for _, v := range u.SubSet.Buyerclasss {
  485. u.Add(v, m)
  486. }
  487. }
  488. }
  489. //添加区域映射关系
  490. func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
  491. if len(u.SubSet.Areas) == 0 {
  492. u.Add("", m)
  493. } else {
  494. for _, v := range u.SubSet.Areas {
  495. u.Add(v, m)
  496. }
  497. }
  498. }
  499. //添加区域城市映射关系
  500. func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
  501. if len(u.SubSet.Area) == 0 {
  502. u.Add("", area)
  503. } else {
  504. for k, v := range u.SubSet.Area {
  505. if k == "" {
  506. continue
  507. }
  508. vs, _ := v.([]interface{})
  509. if len(vs) == 0 {
  510. u.Add(k, area)
  511. } else {
  512. for _, vv := range vs {
  513. s_vv, _ := vv.(string)
  514. if s_vv == "" {
  515. continue
  516. }
  517. u.Add(s_vv, city)
  518. }
  519. }
  520. }
  521. }
  522. }
  523. //把用户挂在词下面
  524. func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
  525. mp := map[string]bool{}
  526. for _, key := range keys {
  527. v := strings.ToUpper(key)
  528. if v == "" || mp[v] {
  529. continue
  530. }
  531. mp[v] = true
  532. arr := (*key_user)[v]
  533. if arr == nil {
  534. arr = &[]*UserInfo{}
  535. }
  536. *arr = append(*arr, u)
  537. (*key_user)[v] = arr
  538. }
  539. }
  540. type WxTplMsg struct {
  541. Key string
  542. Area string
  543. }
  544. type SortList []*MatchInfo
  545. func (s SortList) Len() int {
  546. return len(s)
  547. }
  548. func (s SortList) Less(i, j int) bool {
  549. return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
  550. }
  551. func (s SortList) Swap(i, j int) {
  552. s[i], s[j] = s[j], s[i]
  553. }
  554. type CSortList []map[string]interface{}
  555. func (s CSortList) Len() int {
  556. return len(s)
  557. }
  558. func (s CSortList) Less(i, j int) bool {
  559. return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
  560. }
  561. func (s CSortList) Swap(i, j int) {
  562. s[i], s[j] = s[j], s[i]
  563. }
  564. type MatchInfo struct {
  565. Info *map[string]interface{}
  566. Keys []string
  567. Items []string
  568. MatchWays []string
  569. DisId string
  570. }
  571. type KeyDfa struct {
  572. Key *dfa.DFA
  573. NotKey *dfa.DFA
  574. Key_user *map[string]*[]*UserInfo
  575. Notkey_user *map[string]*[]*UserInfo
  576. }
  577. //所有用户的关键词和排除词
  578. func (p *KeyDfa) CreateDaf() {
  579. //关键词
  580. p.Key = &dfa.DFA{}
  581. keys := make([]string, 0)
  582. for k, _ := range *p.Key_user {
  583. keys = append(keys, k)
  584. }
  585. p.Key.AddWord(keys...)
  586. //排除关键词
  587. p.NotKey = &dfa.DFA{}
  588. notKeys := make([]string, 0)
  589. for k, _ := range *p.Notkey_user {
  590. notKeys = append(notKeys, k)
  591. }
  592. p.NotKey.AddWord(notKeys...)
  593. }
  594. //
  595. type MatchUser struct {
  596. Keys []string
  597. MatchWays []string
  598. MatchWay map[string]bool
  599. }
  600. //
  601. type RelationProjectUser struct {
  602. TopTypes []string
  603. }
  604. //
  605. type PushInfo struct {
  606. Ids []interface{}
  607. Info map[string]interface{}
  608. }
  609. //推送返回结果
  610. type PushResult struct {
  611. WxStatus int
  612. AppStatus int
  613. MailStatus int
  614. PushDate int64
  615. Infos *SortList
  616. }
  617. //
  618. type PushParam struct {
  619. JpushTitle string
  620. LastInfoDate int64
  621. TitleArray []string
  622. Infos *SortList
  623. InfosLength int
  624. MailHtml string
  625. PushDate int64
  626. PushCount int
  627. IsPush bool
  628. }
  629. //
  630. type BiddingInfo struct {
  631. Id string
  632. Title string
  633. ClearTitle string
  634. HighlightTitle string
  635. AreaTitle string
  636. Area string
  637. Publishtime int64
  638. PublishtimeDiff string
  639. PublishtimeYMD string
  640. Buyerclass string
  641. Subscopeclass string
  642. Bidamount interface{}
  643. Budget interface{}
  644. Acount string
  645. Subtype string
  646. Toptype string
  647. Infotype string
  648. }
  649. //身份信息
  650. type IdentityInfo struct {
  651. Name string
  652. PersonId int64
  653. UserName string
  654. AccountId int64
  655. EntAccountId int64
  656. PositionId int64
  657. PositionType int64
  658. EntId int64
  659. EntUserId int64
  660. EntUserName string
  661. UserId int64
  662. }