123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- package user
- import (
- "eta/eta_mini_ht_api/common/exception"
- "eta/eta_mini_ht_api/common/utils/page"
- "eta/eta_mini_ht_api/controllers"
- "eta/eta_mini_ht_api/service/analyst"
- "eta/eta_mini_ht_api/service/media"
- "eta/eta_mini_ht_api/service/report"
- "eta/eta_mini_ht_api/service/user"
- )
- type AnalystController struct {
- controllers.ListController
- }
- // AnalystList 研究员列表
- // @Summary 研究员列表
- // @Description 研究员列表
- // @Success 200 {object} controllers.BaseResponse
- // @router /list [get]
- func (an *AnalystController) AnalystList() {
- controllers.Wrap(&an.BaseController, func() (result *controllers.WrapData, err error) {
- result = an.InitWrapData("获取研究员列表失败")
- var userInfo user.User
- userInfo = an.Data["user"].(user.User)
- pageRes := page.Page{
- Current: an.PageInfo.Current,
- PageSize: an.PageInfo.PageSize,
- }
- if an.PageInfo.LatestId == 0 {
- pageRes.Total, pageRes.LatestId = analyst.GetAnalystCount()
- an.PageInfo.LatestId = pageRes.LatestId
- an.PageInfo.Total = pageRes.Total
- } else {
- pageRes.LatestId = an.PageInfo.LatestId
- pageRes.Total = an.PageInfo.Total
- }
- an.PageInfo.Total = pageRes.Total
- pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize)
- list, err := analyst.GetAnalystList(an.PageInfo, userInfo.Id)
- if err != nil {
- an.FailedResult("获取研究员列表失败", result)
- return
- }
- analystList := new(page.PageResult)
- analystList.Data = list
- analystList.Page = pageRes
- an.SuccessResult("获取研究员列表成功", analystList, result)
- return
- })
- }
- // AnalystDetail 研究员详情
- // @Summary 研究员详情
- // @Description 研究员详情
- // @Success 200 {object} controllers.BaseResponse
- // @router /analystDetail [get]
- func (an *AnalystController) AnalystDetail(analystId int) {
- controllers.Wrap(&an.BaseController, func() (result *controllers.WrapData, err error) {
- result = an.InitWrapData("获取研究员详情失败")
- userInfo := an.Data["user"].(user.User)
- detail, err := user.GetAnalystDetail(userInfo.Id, analystId)
- if err != nil {
- an.FailedResult("获取研究员详情失败", result)
- return
- }
- an.SuccessResult("获取研究员详情成功", detail, result)
- return
- })
- }
- // AnalystReportList @Title 获取研究员报告列表
- // @Description 获取研究员报告列表
- // @Success 200 {object}
- // @router /reportList [get]
- func (an *AnalystController) AnalystReportList(analystName string) {
- controllers.Wrap(&an.BaseController, func() (result *controllers.WrapData, err error) {
- result = an.InitWrapData("分页获取研究员报告列表失败")
- pageRes := page.Page{
- Current: an.PageInfo.Current,
- PageSize: an.PageInfo.PageSize,
- }
- userInfo := an.Data["user"].(user.User)
- var reportIds []int
- var mappingRiskLevel string
- var userRiskStatus string
- pageRes.Total, pageRes.LatestId, reportIds, mappingRiskLevel, userRiskStatus = report.RangeSearchByAnalyst(analystName, userInfo.Id)
- if len(reportIds) == 0 {
- reports := new(page.PageResult)
- reports.Data = []interface{}{}
- reports.Page = pageRes
- an.SuccessResult("分页获取研究员报告列表成功", reports, result)
- }
- if an.PageInfo.LatestId == 0 {
- //pageRes.Total, pageRes.LatestId = report.GetTotalPageCountByAnalyst(analystName)
- an.PageInfo.LatestId = pageRes.LatestId
- } else {
- pageRes.LatestId = an.PageInfo.LatestId
- pageRes.Total = an.PageInfo.Total
- }
- pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize)
- list, err := report.GetReportPageByAnalyst(an.PageInfo, analystName, reportIds, userInfo.Id, mappingRiskLevel, userRiskStatus)
- if err != nil {
- an.FailedResult("分页获取研究员报告列表失败", result)
- return
- }
- reports := new(page.PageResult)
- reports.Data = list
- reports.Page = pageRes
- an.SuccessResult("分页获取研究员报告列表成功", reports, result)
- return
- })
- }
- // MediaList 获取研究员媒体列表
- // @Description 获取研究员媒体列表
- // @Success 200 {object}
- // @router /mediaList [get]
- func (an *AnalystController) MediaList(mediaType string, analystId int) {
- controllers.Wrap(&an.BaseController, func() (result *controllers.WrapData, err error) {
- result = an.InitWrapData("分页查询研究员媒体列表失败")
- if mediaType == "" || !an.CheckMediaType(mediaType) {
- err = exception.New(exception.MediaTypeError)
- an.FailedResult("分页查询研究员媒体列表失败", result)
- return
- }
- pageRes := page.Page{
- Current: an.PageInfo.Current,
- PageSize: an.PageInfo.PageSize,
- }
- userInfo := an.Data["user"].(user.User)
- var mediaIds []int
- var mappingRiskLevel string
- var userRiskStatus string
- pageRes.Total, pageRes.LatestId, mediaIds, mappingRiskLevel, userRiskStatus = media.RangeSearchByAnalyst(mediaType, analystId, userInfo.Id)
- if len(mediaIds) == 0 {
- mediaList := new(page.PageResult)
- mediaList.Data = []interface{}{}
- mediaList.Page = pageRes
- an.SuccessResult("分页查询研究员媒体列表成功", mediaList, result)
- }
- if an.PageInfo.LatestId == 0 {
- // pageRes.Total, pageRes.LatestId = media.GetTotalPageCountByAnalystId(mediaType, analystId)
- an.PageInfo.LatestId = pageRes.LatestId
- an.PageInfo.Total = pageRes.Total
- } else {
- pageRes.LatestId = an.PageInfo.LatestId
- pageRes.Total = an.PageInfo.Total
- }
- pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize)
- list, err := media.GetMediaPageByAnalystId(mediaType, an.PageInfo, analystId, mediaIds, userInfo.Id, mappingRiskLevel, userRiskStatus)
- if err != nil {
- an.FailedResult("分页查询研究员媒体列表失败", result)
- return
- }
- mediaList := new(page.PageResult)
- mediaList.Data = list
- mediaList.Page = pageRes
- an.SuccessResult("分页查询研究员媒体列表成功", mediaList, result)
- return
- })
- }
|