struct.go 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. package p
  2. import (
  3. "strings"
  4. util "app.yhyue.com/moapp/jybase/common"
  5. "bp.jydev.jianyu360.cn/BaseService/pushpkg/dfa"
  6. )
  7. //
  8. type MgoConf struct {
  9. Address string
  10. Size int
  11. DbName string
  12. ReplSet string
  13. UserName string
  14. Password string
  15. Collection string
  16. ExperienceDbName string
  17. }
  18. //
  19. type RedisConf struct {
  20. Address string
  21. }
  22. //
  23. type MysqlConf struct {
  24. DbName string
  25. Address string
  26. UserName string
  27. PassWord string
  28. MaxOpenConns int
  29. MaxIdleConns int
  30. }
  31. //
  32. type EsConf struct {
  33. Address string
  34. Size int
  35. }
  36. //
  37. type MemberService struct {
  38. IsBuy bool
  39. Services map[int]*memberService
  40. }
  41. //
  42. type memberService struct {
  43. Id int
  44. StartTime string
  45. }
  46. //关键词
  47. type KeySet struct {
  48. Item string `json:"item"` //分类名称
  49. Keys []string `json:"key"` //关键词
  50. NotKeys []string `json:"notkey"` //排除词
  51. SubTypes []string `json:"infotype"` //信息类型
  52. Areas []string `json:"area"` //地区
  53. AppendKeys []string `json:"appendkey"` //附加词
  54. MatchWay int `json:"matchway"` //匹配模式 0:精准匹配 1:模糊匹配
  55. }
  56. //解析订阅词
  57. type SubSet struct {
  58. MatchWay int //匹配方式 1-标题 2-正文
  59. Matchbuyerclass_other int //是否开启其他按钮
  60. ProjectMatch int //项目关联推送
  61. Items []string //关键词分类
  62. Keys []string //过滤后的关键词
  63. Notkeys []string //排除词
  64. Key_item map[string]string //关键词对应的分类名称
  65. Key_notkey map[string]map[string]bool //关键词所对应的排除词
  66. Key_area map[string]map[string]bool //关键词所对应的信息范围
  67. Key_subtype map[string]map[string]bool //关键词所对应的信息类型
  68. OriginalKeys []string //原始关键词
  69. Areas []string //区域-省份
  70. Area map[string]interface{} //区域-省份
  71. Subtype []interface{} //信息类型-二级分类
  72. Subtypes []string //信息类型-二级分类
  73. Buyerclass []interface{} //采购单位行业
  74. Buyerclasss []string //采购单位行业
  75. IsUpgrade bool //免费用户是否订阅升级
  76. MaxPushSize int //推送最大条数
  77. MaxMailSize int //邮件最大条数
  78. }
  79. //推送设置
  80. type PushSet struct {
  81. Email string //邮箱
  82. SubSet *PushSetChild //订阅推送设置
  83. WeekReport *PushSetChild //周报推送设置
  84. MonthReport *PushSetChild //月报推送设置
  85. NewprojectForecast *PushSetChild //潜在项目预测推送设置
  86. EntInfo *PushSetChild //企业情报监控-企业工商变动推送设置
  87. FollowProject *PushSetChild //项目进度监控推送设置
  88. FollowEnt *PushSetChild //企业情报监控-企业中标动态推送设置
  89. }
  90. type PushSetChild struct {
  91. RateMode int //推送时间
  92. Times []string //自定义推送时间
  93. WxPush int //是否开启微信推送
  94. AppPush int //是否开启app推送
  95. MailPush int //是否开启邮箱推送
  96. }
  97. //用户基本信息
  98. type UserInfo struct {
  99. Id string //mongoid
  100. BaseUserId int64 //mysql用户id
  101. S_m_openid string //公众号openid
  102. A_m_openid string //app微信登录openid
  103. Phone string //app手机号登录
  104. Jpushid string //极光推送id
  105. Opushid string //厂商推送id
  106. AppPhoneType string //手机型号
  107. Subscribe int //是否关注
  108. UserType int //用户类型
  109. VipStatus int //超级订阅 1--试用 2--正式
  110. MemberStatus int //大会员
  111. NicheStatus int //商机管理
  112. IsMainAccount bool //是否是主账号
  113. SonAccountStatus int //子账号状态 0-禁用 1-启用
  114. MainId string //主账号id
  115. Entniche *Entniche
  116. MemberMainid string
  117. WxTplMsg *WxTplMsg
  118. SubSet *SubSet
  119. PushSet *PushSet
  120. Extend *UserInfoExtend
  121. }
  122. //
  123. type Entniche struct {
  124. EntId int //企业id
  125. EntName string //企业名称
  126. DeptId int //部门id
  127. //DeptName string //部门名称
  128. DisId string //分发id
  129. UserId int
  130. Unique string
  131. OnlyPush int
  132. IsNew int
  133. PowerSource int //权益来源
  134. ProductType string //产品类型
  135. Mail string //邮箱
  136. IsDis int //是否是分发
  137. DisMember int //分发-超级订阅
  138. DisVip int //分发-大会员
  139. }
  140. //用户基本信息-扩展
  141. type UserInfoExtend struct {
  142. CreateTime int64 //
  143. Size int
  144. }
  145. func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
  146. mk := (*m)[k]
  147. if mk == nil {
  148. mk = map[*UserInfo]bool{}
  149. }
  150. mk[u] = true
  151. (*m)[k] = mk
  152. }
  153. //添加信息类型映射关系
  154. func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
  155. if len(u.SubSet.Subtypes) == 0 {
  156. u.Add("", m)
  157. } else {
  158. for _, v := range u.SubSet.Subtypes {
  159. u.Add(v, m)
  160. }
  161. }
  162. }
  163. //添加采购单位类型映射关系
  164. func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
  165. //如果有关键词 有采购单位行业,行业加上“其它”
  166. if len(u.SubSet.Buyerclasss) == 0 {
  167. u.Add("", m)
  168. } else {
  169. if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
  170. u.Add("其它", m)
  171. }
  172. for _, v := range u.SubSet.Buyerclasss {
  173. u.Add(v, m)
  174. }
  175. }
  176. }
  177. //添加区域映射关系
  178. func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
  179. if len(u.SubSet.Areas) == 0 {
  180. u.Add("", m)
  181. } else {
  182. for _, v := range u.SubSet.Areas {
  183. u.Add(v, m)
  184. }
  185. }
  186. }
  187. //添加区域城市映射关系
  188. func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
  189. if len(u.SubSet.Area) == 0 {
  190. u.Add("", area)
  191. } else {
  192. for k, v := range u.SubSet.Area {
  193. if k == "" {
  194. continue
  195. }
  196. vs, _ := v.([]interface{})
  197. if len(vs) == 0 {
  198. u.Add(k, area)
  199. } else {
  200. for _, vv := range vs {
  201. s_vv, _ := vv.(string)
  202. if s_vv == "" {
  203. continue
  204. }
  205. u.Add(s_vv, city)
  206. }
  207. }
  208. }
  209. }
  210. }
  211. //把用户挂在词下面
  212. func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
  213. mp := map[string]bool{}
  214. for _, key := range keys {
  215. v := strings.ToUpper(key)
  216. if v == "" || mp[v] {
  217. continue
  218. }
  219. mp[v] = true
  220. arr := (*key_user)[v]
  221. if arr == nil {
  222. arr = &[]*UserInfo{}
  223. }
  224. *arr = append(*arr, u)
  225. (*key_user)[v] = arr
  226. }
  227. }
  228. type WxTplMsg struct {
  229. Key string
  230. Area string
  231. }
  232. type SortList []*MatchInfo
  233. func (s SortList) Len() int {
  234. return len(s)
  235. }
  236. func (s SortList) Less(i, j int) bool {
  237. return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
  238. }
  239. func (s SortList) Swap(i, j int) {
  240. s[i], s[j] = s[j], s[i]
  241. }
  242. type CSortList []map[string]interface{}
  243. func (s CSortList) Len() int {
  244. return len(s)
  245. }
  246. func (s CSortList) Less(i, j int) bool {
  247. return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
  248. }
  249. func (s CSortList) Swap(i, j int) {
  250. s[i], s[j] = s[j], s[i]
  251. }
  252. type MatchInfo struct {
  253. Info *map[string]interface{}
  254. Keys []string
  255. Items []string
  256. MatchWays []string
  257. DisId string
  258. }
  259. type KeyDfa struct {
  260. Key *dfa.DFA
  261. NotKey *dfa.DFA
  262. Key_user *map[string]*[]*UserInfo
  263. Notkey_user *map[string]*[]*UserInfo
  264. }
  265. //所有用户的关键词和排除词
  266. func (p *KeyDfa) CreateDaf() {
  267. //关键词
  268. p.Key = &dfa.DFA{}
  269. keys := make([]string, 0)
  270. for k, _ := range *p.Key_user {
  271. keys = append(keys, k)
  272. }
  273. p.Key.AddWord(keys...)
  274. //排除关键词
  275. p.NotKey = &dfa.DFA{}
  276. notKeys := make([]string, 0)
  277. for k, _ := range *p.Notkey_user {
  278. notKeys = append(notKeys, k)
  279. }
  280. p.NotKey.AddWord(notKeys...)
  281. }
  282. //
  283. type MatchUser struct {
  284. Keys []string
  285. MatchWays []string
  286. MatchWay map[string]bool
  287. }
  288. //
  289. type RelationProjectUser struct {
  290. TopTypes []string
  291. }
  292. //
  293. type PushInfo struct {
  294. Ids []interface{}
  295. Info map[string]interface{}
  296. }
  297. //推送返回结果
  298. type PushResult struct {
  299. WxStatus int
  300. AppStatus int
  301. MailStatus int
  302. PushDate int64
  303. Infos *SortList
  304. }
  305. //
  306. type PushWay struct {
  307. WxPush bool
  308. AppPush bool
  309. MailPush bool
  310. }
  311. //
  312. type PushParam struct {
  313. JpushTitle string
  314. LastInfoDate int64
  315. TitleArray []string
  316. Infos *SortList
  317. InfosLength int
  318. MailHtml string
  319. PushDate int64
  320. PushCount int
  321. IsPush bool
  322. }
  323. //
  324. type BiddingInfo struct {
  325. Id string
  326. Title string
  327. ClearTitle string
  328. HighlightTitle string
  329. AreaTitle string
  330. Area string
  331. Publishtime int64
  332. PublishtimeDiff string
  333. PublishtimeYMD string
  334. Buyerclass string
  335. Subscopeclass string
  336. Bidamount interface{}
  337. Budget interface{}
  338. Acount string
  339. Subtype string
  340. Toptype string
  341. Infotype string
  342. }
  343. //身份信息
  344. type IdentityInfo struct {
  345. Name string
  346. PersonId int64
  347. UserName string
  348. AccountId int64
  349. EntAccountId int64
  350. PositionId int64
  351. PositionType int64
  352. EntId int64
  353. EntUserId int64
  354. EntUserName string
  355. UserId int64
  356. }