struct.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. VipStatus int //超级订阅 1--试用 2--正式
  109. MemberStatus int //大会员
  110. NicheStatus int //商机管理
  111. IsMainAccount bool //是否是主账号
  112. SonAccountStatus int //子账号状态 0-禁用 1-启用
  113. MainId string //主账号id
  114. Entniche *Entniche
  115. MemberMainid string
  116. WxTplMsg *WxTplMsg
  117. SubSet *SubSet
  118. PushSet *PushSet
  119. Extend *UserInfoExtend
  120. }
  121. //
  122. type Entniche struct {
  123. EntId int //企业id
  124. EntName string //企业名称
  125. DeptId int //部门id
  126. //DeptName string //部门名称
  127. DisId string //分发id
  128. UserId int
  129. Unique string
  130. OnlyPush int
  131. IsNew int
  132. PowerSource int //权益来源
  133. ProductType string //产品类型
  134. Mail string //邮箱
  135. IsDis int //是否是分发
  136. DisMember int //分发-超级订阅
  137. DisVip int //分发-大会员
  138. }
  139. //用户基本信息-扩展
  140. type UserInfoExtend struct {
  141. CreateTime int64 //
  142. Size int
  143. }
  144. func (u *UserInfo) Add(k string, m *map[string]map[*UserInfo]bool) {
  145. mk := (*m)[k]
  146. if mk == nil {
  147. mk = map[*UserInfo]bool{}
  148. }
  149. mk[u] = true
  150. (*m)[k] = mk
  151. }
  152. //添加信息类型映射关系
  153. func (u *UserInfo) AddSbuype(m *map[string]map[*UserInfo]bool) {
  154. if len(u.SubSet.Subtypes) == 0 {
  155. u.Add("", m)
  156. } else {
  157. for _, v := range u.SubSet.Subtypes {
  158. u.Add(v, m)
  159. }
  160. }
  161. }
  162. //添加采购单位类型映射关系
  163. func (u *UserInfo) AddBuyerclass(m *map[string]map[*UserInfo]bool) {
  164. //如果有关键词 有采购单位行业,行业加上“其它”
  165. if len(u.SubSet.Buyerclasss) == 0 {
  166. u.Add("", m)
  167. } else {
  168. if u.SubSet.Matchbuyerclass_other == 1 && len(u.SubSet.Keys) > 0 {
  169. u.Add("其它", m)
  170. }
  171. for _, v := range u.SubSet.Buyerclasss {
  172. u.Add(v, m)
  173. }
  174. }
  175. }
  176. //添加区域映射关系
  177. func (u *UserInfo) AddArea(m *map[string]map[*UserInfo]bool) {
  178. if len(u.SubSet.Areas) == 0 {
  179. u.Add("", m)
  180. } else {
  181. for _, v := range u.SubSet.Areas {
  182. u.Add(v, m)
  183. }
  184. }
  185. }
  186. //添加区域城市映射关系
  187. func (u *UserInfo) AddAreaCity(area, city *map[string]map[*UserInfo]bool) {
  188. if len(u.SubSet.Area) == 0 {
  189. u.Add("", area)
  190. } else {
  191. for k, v := range u.SubSet.Area {
  192. if k == "" {
  193. continue
  194. }
  195. vs, _ := v.([]interface{})
  196. if len(vs) == 0 {
  197. u.Add(k, area)
  198. } else {
  199. for _, vv := range vs {
  200. s_vv, _ := vv.(string)
  201. if s_vv == "" {
  202. continue
  203. }
  204. u.Add(s_vv, city)
  205. }
  206. }
  207. }
  208. }
  209. }
  210. //把用户挂在词下面
  211. func (u *UserInfo) MakeKeyUser(keys []string, key_user *map[string]*[]*UserInfo) {
  212. mp := map[string]bool{}
  213. for _, key := range keys {
  214. v := strings.ToUpper(key)
  215. if v == "" || mp[v] {
  216. continue
  217. }
  218. mp[v] = true
  219. arr := (*key_user)[v]
  220. if arr == nil {
  221. arr = &[]*UserInfo{}
  222. }
  223. *arr = append(*arr, u)
  224. (*key_user)[v] = arr
  225. }
  226. }
  227. type WxTplMsg struct {
  228. Key string
  229. Area string
  230. }
  231. type SortList []*MatchInfo
  232. func (s SortList) Len() int {
  233. return len(s)
  234. }
  235. func (s SortList) Less(i, j int) bool {
  236. return util.Int64All((*s[i].Info)["publishtime"]) > util.Int64All((*s[j].Info)["publishtime"])
  237. }
  238. func (s SortList) Swap(i, j int) {
  239. s[i], s[j] = s[j], s[i]
  240. }
  241. type CSortList []map[string]interface{}
  242. func (s CSortList) Len() int {
  243. return len(s)
  244. }
  245. func (s CSortList) Less(i, j int) bool {
  246. return util.Int64All(s[i]["publishtime"]) > util.Int64All(s[j]["publishtime"])
  247. }
  248. func (s CSortList) Swap(i, j int) {
  249. s[i], s[j] = s[j], s[i]
  250. }
  251. type MatchInfo struct {
  252. Info *map[string]interface{}
  253. Keys []string
  254. Items []string
  255. MatchWays []string
  256. DisId string
  257. }
  258. type KeyDfa struct {
  259. Key *dfa.DFA
  260. NotKey *dfa.DFA
  261. Key_user *map[string]*[]*UserInfo
  262. Notkey_user *map[string]*[]*UserInfo
  263. }
  264. //所有用户的关键词和排除词
  265. func (p *KeyDfa) CreateDaf() {
  266. //关键词
  267. p.Key = &dfa.DFA{}
  268. keys := make([]string, 0)
  269. for k, _ := range *p.Key_user {
  270. keys = append(keys, k)
  271. }
  272. p.Key.AddWord(keys...)
  273. //排除关键词
  274. p.NotKey = &dfa.DFA{}
  275. notKeys := make([]string, 0)
  276. for k, _ := range *p.Notkey_user {
  277. notKeys = append(notKeys, k)
  278. }
  279. p.NotKey.AddWord(notKeys...)
  280. }
  281. //
  282. type MatchUser struct {
  283. Keys []string
  284. MatchWays []string
  285. MatchWay map[string]bool
  286. }
  287. //
  288. type RelationProjectUser struct {
  289. TopTypes []string
  290. }
  291. //
  292. type PushInfo struct {
  293. Ids []interface{}
  294. Info map[string]interface{}
  295. }
  296. //推送返回结果
  297. type PushResult struct {
  298. WxStatus int
  299. AppStatus int
  300. MailStatus int
  301. PushDate int64
  302. Infos *SortList
  303. }
  304. //
  305. type PushParam struct {
  306. JpushTitle string
  307. LastInfoDate int64
  308. TitleArray []string
  309. Infos *SortList
  310. InfosLength int
  311. MailHtml string
  312. PushDate int64
  313. PushCount int
  314. IsPush bool
  315. }
  316. //
  317. type BiddingInfo struct {
  318. Id string
  319. Title string
  320. ClearTitle string
  321. HighlightTitle string
  322. AreaTitle string
  323. Area string
  324. Publishtime int64
  325. PublishtimeDiff string
  326. PublishtimeYMD string
  327. Buyerclass string
  328. Subscopeclass string
  329. Bidamount interface{}
  330. Budget interface{}
  331. Acount string
  332. Subtype string
  333. Toptype string
  334. Infotype string
  335. }
  336. //身份信息
  337. type IdentityInfo struct {
  338. Name string
  339. PersonId int64
  340. UserName string
  341. AccountId int64
  342. EntAccountId int64
  343. PositionId int64
  344. PositionType int64
  345. EntId int64
  346. EntUserId int64
  347. EntUserName string
  348. UserId int64
  349. }