struct.go 9.3 KB

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