user_service.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package user
  2. import (
  3. "encoding/json"
  4. "errors"
  5. logger "eta/eta_mini_ht_api/common/component/log"
  6. "eta/eta_mini_ht_api/common/exception"
  7. "eta/eta_mini_ht_api/common/utils/page"
  8. permissionService "eta/eta_mini_ht_api/domian/config"
  9. analystService "eta/eta_mini_ht_api/domian/financial_analyst"
  10. reportDomian "eta/eta_mini_ht_api/domian/report"
  11. userService "eta/eta_mini_ht_api/domian/user"
  12. merchantDao "eta/eta_mini_ht_api/models/merchant"
  13. userDao "eta/eta_mini_ht_api/models/user"
  14. "eta/eta_mini_ht_api/service/config"
  15. "gorm.io/gorm"
  16. "sort"
  17. "sync"
  18. "time"
  19. )
  20. const (
  21. RiskValid = "valid"
  22. RiskExpired = "expired"
  23. RiskUnTest = "unTest"
  24. SubscribeExpired = "expired"
  25. UnSubscribe = "unSubscribe"
  26. Subscribing = "Subscribing"
  27. ReportBookMark = "report"
  28. ChartBookMark = "chart"
  29. )
  30. type User struct {
  31. Id int `json:"id"`
  32. Username string `json:"username"`
  33. AreaCode string `json:"areaCode"`
  34. Mobile string `json:"mobile"`
  35. OpenId string `json:"openId,omitempty"`
  36. }
  37. type AnalystDetail struct {
  38. AnalystName string `json:"analystName"`
  39. HeadImgUrl string `json:"headImgUrl"`
  40. HeadOriginImgUrl string `json:"headOriginImgUrl"`
  41. Introduction string `json:"introduction"`
  42. Followed string `json:"followed"`
  43. Position string `json:"position"`
  44. InvestmentCertificate string `json:"investmentCertificate"`
  45. ProfessionalCertificate string `json:"professionalCertificate"`
  46. Status bool `json:"status"`
  47. }
  48. type UserProfile struct {
  49. Mobile string `json:"mobile"`
  50. RiskLevel string `json:"riskLevel"`
  51. RiskLevelStatus string `json:"riskLevelStatus"`
  52. UserName string `json:"userName"`
  53. AccountStatus string `json:"accountStatus"`
  54. }
  55. func CheckUserRiskMatchStatus(userId int) (riskLevel string, userRiskLevelStatus string, err error) {
  56. if userId <= 0 {
  57. err = exception.New(exception.IllegalTemplateUserId)
  58. return
  59. }
  60. userProfile, userErr := GetUserProfile(userId)
  61. if userErr != nil {
  62. if errors.Is(userErr, gorm.ErrRecordNotFound) {
  63. err = exception.New(exception.TemplateUserNotFound)
  64. } else {
  65. err = exception.New(exception.TemplateUserFoundFailed)
  66. }
  67. logger.Error("获取临时客户信息失败:%v", err)
  68. return
  69. }
  70. userRiskLevelStatus = userProfile.RiskLevelStatus
  71. //获取产品风险等级
  72. if userProfile.RiskLevelStatus == RiskUnTest {
  73. logger.Warn("客户未做风险等级测评,mobile:%v", userProfile.Mobile)
  74. }
  75. if userProfile.RiskLevelStatus == RiskExpired {
  76. logger.Warn("客户风险等级已过期,mobile:%v", userProfile.Mobile)
  77. }
  78. if userProfile.RiskLevel != "" && userProfile.RiskLevelStatus == RiskValid {
  79. var mapping permissionService.CustomerProductRiskMappingDTO
  80. mapping, err = permissionService.GetRiskMappingByCustomerRiskLevel(userProfile.RiskLevel)
  81. if err != nil {
  82. logger.Error("查询产品风险等级映射失败:%v", err)
  83. return
  84. }
  85. riskLevel = mapping.ProductRiskLevel
  86. }
  87. return
  88. }
  89. // GetRiskLevelPermissionList 删选掉没有配置风险等级的品种,并校验客户的风险等级,riskLevel只有在客户
  90. func GetRiskLevelPermissionList(permissionIds []int, isLogin bool, userId int) (filterPermissionIds []int, riskLevel string, userRiskStatus string, err error) {
  91. if isLogin {
  92. userProfile, userErr := GetUserProfile(userId)
  93. if userErr != nil {
  94. if errors.Is(userErr, gorm.ErrRecordNotFound) {
  95. err = exception.New(exception.TemplateUserNotFound)
  96. } else {
  97. err = exception.New(exception.TemplateUserFoundFailed)
  98. }
  99. logger.Error("获取临时客户信息失败:%v", err)
  100. return
  101. }
  102. var permissionList []permissionService.PermissionDTO
  103. if len(permissionIds) == 0 {
  104. //获取所有设置风险等级的品种
  105. permissionList, err = permissionService.GetPermissionListWithRisk()
  106. } else {
  107. //更具id过滤设置了风险等级的品种
  108. permissionList, err = permissionService.GetPermissionListByIds(permissionIds)
  109. }
  110. if err != nil {
  111. logger.Error("查询有风险等级的品种列表失败:%v", err)
  112. return
  113. }
  114. userRiskStatus = userProfile.RiskLevelStatus
  115. //获取产品风险等级
  116. if userProfile.RiskLevelStatus == RiskUnTest {
  117. logger.Warn("客户未做风险等级测评,mobile:%v", userProfile.Mobile)
  118. //err = exception.New(exception.RiskUnTestError)
  119. }
  120. if userProfile.RiskLevelStatus == RiskExpired {
  121. logger.Warn("客户风险等级已过期,mobile:%v", userProfile.Mobile)
  122. //err = exception.New(exception.RiskExpiredError)
  123. }
  124. if userProfile.RiskLevel != "" && userProfile.RiskLevelStatus == RiskValid {
  125. var mapping permissionService.CustomerProductRiskMappingDTO
  126. mapping, err = permissionService.GetRiskMappingByCustomerRiskLevel(userProfile.RiskLevel)
  127. if err != nil {
  128. logger.Error("查询产品风险等级映射失败:%v", err)
  129. return
  130. }
  131. permissionList = filterPermissionsByRisk(permissionList, mapping.ProductRiskLevel)
  132. riskLevel = mapping.ProductRiskLevel
  133. }
  134. for _, permission := range permissionList {
  135. filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
  136. }
  137. return
  138. } else { //没有登录的时候展示所有设置了风险等级的品种报告,筛选的时候过滤传入ID中没有设置风险等级的品种
  139. var permissionList []permissionService.PermissionDTO
  140. if len(permissionIds) == 0 {
  141. //获取所有设置风险等级的品种
  142. permissionList, err = permissionService.GetPermissionListWithRisk()
  143. } else {
  144. //更具id过滤设置了风险等级的品种
  145. permissionList, err = permissionService.GetPermissionListByIds(permissionIds)
  146. }
  147. if err != nil {
  148. logger.Error("查询有风险等级的品种列表失败:%v", err)
  149. return
  150. }
  151. for _, permission := range permissionList {
  152. filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
  153. }
  154. return
  155. }
  156. }
  157. func filterPermissionsByRisk(permissionList []permissionService.PermissionDTO, riskLevel string) (resultList []permissionService.PermissionDTO) {
  158. if riskLevel != "" {
  159. riskLevelNum, err := config.ParseRiskLevel(riskLevel)
  160. if err != nil {
  161. logger.Error("风险等级解析失败:%v", err)
  162. return
  163. }
  164. for _, permission := range permissionList {
  165. pRiskNum, riskErr := config.ParseRiskLevel(permission.RiskLevel)
  166. if riskErr != nil {
  167. logger.Error("解析品种风险等级失败 permission:%d,risk:%v", permission.PermissionId, permission.RiskLevel)
  168. continue
  169. }
  170. if pRiskNum <= riskLevelNum {
  171. resultList = append(resultList, permission)
  172. }
  173. }
  174. } else {
  175. resultList = permissionList
  176. }
  177. return
  178. }
  179. func convertUserDTOToProfile(dto userService.UserDTO) (profile UserProfile) {
  180. profile = UserProfile{
  181. Mobile: dto.Mobile,
  182. RiskLevel: dto.RiskLevel,
  183. UserName: dto.Username,
  184. }
  185. if profile.UserName == "" {
  186. profile.UserName = dto.Mobile
  187. }
  188. if dto.RiskLevel == "" {
  189. profile.RiskLevelStatus = RiskUnTest
  190. return
  191. }
  192. date, err := time.Parse(time.DateOnly, dto.RiskValidEndDate)
  193. if err != nil {
  194. logger.Error("解析日期失败:%v", err)
  195. profile.RiskLevelStatus = RiskExpired
  196. return
  197. }
  198. currentDate := time.Now().Truncate(24 * time.Hour)
  199. expiryDate := date.Truncate(24 * time.Hour)
  200. if expiryDate.Before(currentDate) {
  201. profile.RiskLevelStatus = RiskExpired
  202. return
  203. }
  204. profile.RiskLevelStatus = RiskValid
  205. return
  206. }
  207. func GetUserProfile(userId int) (userProfile UserProfile, err error) {
  208. userDTO, err := userService.GetUserById(userId)
  209. if err != nil {
  210. if errors.Is(err, gorm.ErrRecordNotFound) {
  211. logger.Error("用户不存在,用户Id:%d", userId)
  212. err = exception.New(exception.TemplateUserNotFound)
  213. } else {
  214. logger.Error("获取用户信息失败:%v", err)
  215. err = exception.New(exception.TemplateUserFoundFailed)
  216. }
  217. return
  218. }
  219. OfficialUser, err := userService.GetUserByTemplateUserId(userId)
  220. if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
  221. logger.Error("获取用户信息失败:%v", err)
  222. err = exception.New(exception.OfficialUserFoundError)
  223. return
  224. }
  225. userProfile = convertUserDTOToProfile(userDTO)
  226. if errors.Is(err, gorm.ErrRecordNotFound) {
  227. userProfile.AccountStatus = "unopen"
  228. err = nil
  229. return
  230. } else {
  231. userProfile.AccountStatus = OfficialUser.AccountStatus
  232. }
  233. return
  234. }
  235. func GetAnalystDetail(userId int, analystId int) (analystDetail AnalystDetail, err error) {
  236. analyst, err := analystService.GetAnalystById(analystId)
  237. if err != nil {
  238. logger.Error("研究员信息不存在:%v", err)
  239. err = exception.New(exception.AnalystNotFound)
  240. }
  241. analystDetail = convertToAnalystDetail(analyst)
  242. //研究员关注状态
  243. analystDetail.Followed = userService.GetFollowed(userId, analystId)
  244. return
  245. }
  246. func convertToAnalystDetail(dto analystService.FinancialAnalystDTO) AnalystDetail {
  247. return AnalystDetail{
  248. AnalystName: dto.Name,
  249. HeadImgUrl: dto.HeadImgUrl,
  250. HeadOriginImgUrl: dto.HeadOriginImgUrl,
  251. Introduction: dto.Introduction,
  252. Position: dto.Position,
  253. InvestmentCertificate: dto.InvestmentCertificate,
  254. ProfessionalCertificate: dto.ProfessionalCertificate,
  255. Status: dto.Status,
  256. }
  257. }
  258. func FollowAnalystsByName(userId int, analystNames []string, followType string) (err error) {
  259. var followlist []userService.FollowDTO
  260. for _, analystName := range analystNames {
  261. FinancialAnalystDTO, followErr := analystService.GetAnalystByName(analystName)
  262. if followErr != nil {
  263. err = exception.New(exception.AnalystNotFound)
  264. }
  265. if FinancialAnalystDTO.Id == 0 || FinancialAnalystDTO.Name == "" {
  266. continue
  267. }
  268. followDTO := userService.FollowDTO{
  269. UserId: userId,
  270. AnalystId: FinancialAnalystDTO.Id,
  271. AnalystName: FinancialAnalystDTO.Name,
  272. FollowType: followType,
  273. }
  274. followlist = append(followlist, followDTO)
  275. }
  276. err = userService.FollowAnalystsByName(userId, followlist, followType)
  277. if err != nil {
  278. logger.Error("批量关注研究员失败:%v", err)
  279. err = exception.New(exception.BatchFollowingAnalystFailed)
  280. }
  281. return
  282. }
  283. func CheckFollowStatusByNames(userId int, names []string) (list []userService.FollowDTO, err error) {
  284. list, err = userService.CheckFollowStatusByNames(userId, names)
  285. if err != nil {
  286. logger.Error("获取关注状态失败:%v", err)
  287. err = exception.New(exception.CheckFollowStatusByNamesFailed)
  288. }
  289. return
  290. }
  291. func FollowAnalyst(userId int, analystId int, followType string) (err error) {
  292. FinancialAnalystDTO, err := analystService.GetAnalystById(analystId)
  293. if err != nil {
  294. err = exception.New(exception.AnalystNotFound)
  295. }
  296. if FinancialAnalystDTO.Id == 0 || FinancialAnalystDTO.Name == "" {
  297. err = exception.New(exception.AnalystNotFound)
  298. return
  299. }
  300. followDTO := userService.FollowDTO{
  301. UserId: userId,
  302. AnalystId: analystId,
  303. AnalystName: FinancialAnalystDTO.Name,
  304. FollowType: followType,
  305. }
  306. err = userService.FollowAnalyst(followDTO)
  307. if err != nil {
  308. logger.Error("关注研究员失败:%v", err)
  309. err = exception.New(exception.UserFollowAnalystFailed)
  310. }
  311. return
  312. }
  313. func GetFollowingAnalystList(userId int) (followedList []FollowAnalystDTO, err error) {
  314. logger.Info("用户ID:%d", userId)
  315. dtoList, err := userService.GetFollowingAnalystList(userId)
  316. if err != nil {
  317. logger.Error("获取关注列表失败:%v", err)
  318. err = exception.New(exception.GetFollowingAnalystListFailed)
  319. return
  320. }
  321. followedList = make([]FollowAnalystDTO, 0)
  322. if len(dtoList) == 0 {
  323. return
  324. }
  325. analysts, err := convertToAnalystList(dtoList)
  326. var wg sync.WaitGroup
  327. wg.Add(len(analysts))
  328. for i := 0; i < len(analysts); i++ {
  329. go func(followDTo *FollowAnalystDTO) {
  330. defer wg.Done()
  331. followDTo.NeedNotice = userService.NeedNotice(userId, followDTo.AnalystId)
  332. var analystsDTO analystService.FinancialAnalystDTO
  333. analystsDTO, err = analystService.GetAnalystById(followDTo.AnalystId)
  334. if err != nil {
  335. logger.Error("获取研究员信息失败")
  336. followDTo.AnalystId = -1
  337. } else {
  338. followDTo.HeadImgUrl = analystsDTO.HeadImgUrl
  339. }
  340. if analystsDTO.Status {
  341. followedList = append(followedList, *followDTo)
  342. }
  343. }(&analysts[i])
  344. }
  345. wg.Wait()
  346. //排序
  347. sort.Slice(followedList, func(i, j int) bool {
  348. // 首先按 NeedNotice 排序
  349. if followedList[i].NeedNotice == followedList[j].NeedNotice {
  350. // 对于 NeedNotice 相同的情况下,进行倒序排列
  351. return followedList[i].FollowedTime.After(followedList[j].FollowedTime)
  352. }
  353. // NeedNotice 为 true 的排在 false 的前面
  354. return followedList[i].NeedNotice
  355. })
  356. //if err != nil {
  357. // logger.Error("转换研究员列表失败:%v", err)
  358. // err = exception.New(exception.TransferFollowingAnalystListFailed)
  359. //}
  360. return
  361. }
  362. func GetUnReadMessageList(userId int) (messages []userService.MyMessage, err error) {
  363. messages, err = userService.GetUnReadMessageList(userId)
  364. if err != nil {
  365. err = exception.New(exception.GetUserUnReadMsgFailed)
  366. }
  367. return
  368. }
  369. func ReadMessage(userId int, messageId int) bool {
  370. return userService.ReadMessage(userId, messageId)
  371. }
  372. func ReadMessages(userId int, analystId int) bool {
  373. return userService.ReadMessages(userId, analystId)
  374. }
  375. type FollowAnalystDTO struct {
  376. AnalystId int `json:"analystId"`
  377. AnalystName string `json:"analystName"`
  378. HeadImgUrl string `json:"headImgUrl"`
  379. FollowedTime time.Time `json:"followedTime"`
  380. NeedNotice bool `json:"needNotice"`
  381. }
  382. func convertToAnalystList(dtoList []userService.FollowDTO) (list []FollowAnalystDTO, err error) {
  383. for _, dto := range dtoList {
  384. analyst := FollowAnalystDTO{
  385. AnalystId: dto.AnalystId,
  386. AnalystName: dto.AnalystName,
  387. FollowedTime: dto.FollowedTime,
  388. NeedNotice: false,
  389. }
  390. list = append(list, analyst)
  391. }
  392. return
  393. }
  394. func FollowAnalystByName(userId int, analystName string, followType string) (err error) {
  395. FinancialAnalystDTO, err := analystService.GetAnalystByName(analystName)
  396. if err != nil {
  397. err = exception.New(exception.AnalystNotFound)
  398. }
  399. if FinancialAnalystDTO.Id == 0 || FinancialAnalystDTO.Name == "" {
  400. err = exception.New(exception.AnalystNotFound)
  401. return
  402. }
  403. followDTO := userService.FollowDTO{
  404. UserId: userId,
  405. AnalystId: FinancialAnalystDTO.Id,
  406. AnalystName: FinancialAnalystDTO.Name,
  407. FollowType: followType,
  408. }
  409. err = userService.FollowAnalyst(followDTO)
  410. if err != nil {
  411. logger.Error("关注研究员失败:%v", err)
  412. err = exception.New(exception.UserFollowAnalystFailed)
  413. }
  414. return
  415. }
  416. func FeedBack(userId int, mobile string, message string) (err error) {
  417. feedback := userService.FeedbackDTO{
  418. UserId: userId,
  419. Mobile: mobile,
  420. Message: message,
  421. }
  422. err = userService.FeedBack(feedback)
  423. if err != nil {
  424. err = exception.New(exception.FeedBackError)
  425. }
  426. return
  427. }
  428. func GetUserByMobile(mobile string) (user User, err error) {
  429. userDTO, err := userService.GetUserByMobile(mobile)
  430. if err != nil {
  431. if errors.Is(err, gorm.ErrRecordNotFound) {
  432. err = exception.New(exception.TemplateUserNotFound)
  433. } else {
  434. err = exception.New(exception.TemplateUserFoundFailed)
  435. }
  436. }
  437. user = convertToUser(userDTO)
  438. return
  439. }
  440. func GetUserByOpenId(openId string) (user User, err error) {
  441. userDTO, err := userService.GetUserByOpenId(openId)
  442. if err != nil {
  443. return
  444. }
  445. user = convertToUser(userDTO)
  446. return
  447. }
  448. func convertToUser(userDTO userService.UserDTO) User {
  449. return User{
  450. Id: userDTO.Id,
  451. Username: userDTO.Username,
  452. OpenId: userDTO.OpenId,
  453. AreaCode: userDTO.AreaCode,
  454. Mobile: userDTO.Mobile,
  455. }
  456. }
  457. func GetUserByTemplateUserId(templateUserId int) (officialUser userService.OfficialUserDTO, err error) {
  458. officialUser, err = userService.GetUserByTemplateUserId(templateUserId)
  459. if err != nil {
  460. if errors.Is(err, gorm.ErrRecordNotFound) {
  461. err = exception.New(exception.OfficialUserNotFound)
  462. logger.Info("用户未开户:%v", templateUserId)
  463. } else {
  464. err = exception.NewWithException(exception.OfficialUserFoundError, err.Error())
  465. logger.Error("获取正式用户信息失败:%v", err)
  466. }
  467. }
  468. return
  469. }
  470. func GetUserScribeStatus(productId int, templateUserId int) (subscribe string) {
  471. userSubscribe, err := userService.GetUserSubscribe([]int{productId}, templateUserId)
  472. if err != nil {
  473. logger.Error("获取用户订阅状态失败:%v", err)
  474. return UnSubscribe
  475. }
  476. if len(userSubscribe) == 0 {
  477. return UnSubscribe
  478. }
  479. if userSubscribe[0].ProductType != merchantDao.Package && userSubscribe[0].Status == merchantDao.SubscribeExpired {
  480. logger.Error("用户订阅状态异常:%v,单品状态为过期,productId:%d", productId)
  481. return UnSubscribe
  482. }
  483. switch userSubscribe[0].Status {
  484. case
  485. merchantDao.SubscribeClose:
  486. return UnSubscribe
  487. case merchantDao.SubscribeExpired:
  488. return SubscribeExpired
  489. case merchantDao.SubscribeValid:
  490. return Subscribing
  491. default:
  492. return UnSubscribe
  493. }
  494. }
  495. func BookMark(templateUserId int, sourceId int, sourceType string) error {
  496. return userService.BookMark(templateUserId, sourceId, sourceType)
  497. }
  498. func UnBookMark(templateUserId int, sourceId int, sourceType string) error {
  499. return userService.UnBookMark(templateUserId, sourceId, sourceType)
  500. }
  501. func CheckBookMarkStatus(templateUserId int, sourceId int, sourceType string) (isBookMarked bool, err error) {
  502. status, err := userService.CheckBookMarkStatus(templateUserId, sourceId, sourceType)
  503. if err != nil {
  504. logger.Error("获取收藏状态失败:%v", err)
  505. return
  506. }
  507. isBookMarked = status == string(userDao.Marked)
  508. return
  509. }
  510. func GetTotalBookMarkPageBySourceType(userId int, sourceType string) (total int64, sourceIds []int, err error) {
  511. return userService.GetTotalBookMarkPageBySourceType(userId, sourceType)
  512. }
  513. func GetBookMarkPageBySourceType(userId int, pageInfo page.PageInfo, sourceType string) (sourceIds []int, err error) {
  514. return userService.GetBookMarkPageBySourceType(userId, sourceType, pageInfo)
  515. }
  516. func GetBookMarkListBySourceType(userId int, sourceType string) (sourceIds []int, err error) {
  517. return userService.GetBookMarkListBySourceType(userId, sourceType)
  518. }
  519. func GetBookMarkPageRangeBySourceType(userId int, pageInfo page.PageInfo, sourceType string, sourceIds []int) (filterSourceIds []int, err error) {
  520. return userService.GetBookMarkPageRangeBySourceType(userId, sourceType, pageInfo, sourceIds)
  521. }
  522. func GetReportBookMarked(sourceId int, templateUserId int) (collected bool, err error) {
  523. bookMark, err := userService.GetBookMarkedBySource(sourceId, templateUserId, ReportBookMark)
  524. if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
  525. return
  526. }
  527. if errors.Is(err, gorm.ErrRecordNotFound) {
  528. err = nil
  529. return
  530. }
  531. collected = bookMark.Status == string(userDao.Marked)
  532. return
  533. }
  534. type BookMarkChart struct {
  535. ChartName string `json:"chartName"`
  536. ChartImage string `json:"chartImage"`
  537. UniqueCode string `json:"uniqueCode"`
  538. ChartInfoId int `json:"chartInfoId"`
  539. }
  540. type BookMarkInterface interface {
  541. GetID() int
  542. GetSourceType() string
  543. }
  544. type BookMarkReport struct {
  545. Type string `json:"type"`
  546. ReportID int `json:"reportId"`
  547. OrgId int `json:"orgId"`
  548. Title string `json:"title"`
  549. Author string `json:"author"`
  550. AuthorInfo []reportDomian.Anthor `json:"authorInfo"`
  551. Source string `json:"source"`
  552. Abstract string `json:"abstract"`
  553. PublishedTime string `json:"publishedTime"`
  554. RiskLevel string `json:"riskLevel"`
  555. PlateName string `json:"-"`
  556. ClassifyId int `json:"-"`
  557. SecondPermission map[int]string `json:"-"`
  558. Permissions map[int]string `json:"-"`
  559. PermissionNames interface {
  560. } `json:"permissionNames"`
  561. Highlight []string `json:"highlight"`
  562. Detail json.RawMessage `json:"detail"`
  563. PdfUrl string `json:"pdfUrl"`
  564. CoverSrc int `json:"coverSrc"`
  565. CoverUrl string `json:"coverUrl"`
  566. Login bool `json:"login"`
  567. RiskLevelStatus string `json:"riskLevelStatus"`
  568. IsFree bool `json:"isFree"`
  569. IsSubscribe bool `json:"isSubscribe"`
  570. SubscribeStatus string `json:"subscribeStatus"`
  571. Price string `json:"price"`
  572. ProductId int `json:"productId"`
  573. IsPackage bool `json:"isPackage"`
  574. Score float64 `json:"score"`
  575. Show bool `json:"-"`
  576. }
  577. func (bk BookMarkReport) GetID() int {
  578. return bk.ReportID
  579. }
  580. func (bk BookMarkReport) GetSourceType() string {
  581. return ReportBookMark
  582. }
  583. func (bk BookMarkChart) GetID() int {
  584. return bk.ChartInfoId
  585. }
  586. func (bk BookMarkChart) GetSourceType() string {
  587. return ChartBookMark
  588. }
  589. // func SearchBookMark(key string, sourceType string, ids []int, pageInfo page.PageInfo, userId int) (list []BookMarkInterface, err error) {
  590. //
  591. // }