123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "html"
- "strconv"
- "strings"
- "time"
- )
- //报告
- type ReportController struct {
- BaseAuthController
- }
- type ReportCommonController struct {
- BaseCommonController
- }
- // @Title 行业报告分类列表接口
- // @Description 获取行业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /home/tradeList [get]
- func (this *ReportController) TradeList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- if ChartPermissionId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- list, err := models.GetTradeAll(ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
- count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
- list[k].IsRed = true
- }
- }
- resp := new(models.TradeReportMappingResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业报告分类列表接口
- // @Description 获取产业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
- // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
- // @Param KeyWord query string true "搜索关键词"
- // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /home/industryList [get]
- func (this *ReportController) IndustryList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- fmt.Println(uid)
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- orderColumn := this.GetString("OrderColumn")
- orderColumnNew := this.GetString("OrderColumn")
- isNewLabel := this.GetString("IsNewLabel")
- isDeepLabel := this.GetString("IsDeepLabel")
- keyWord := this.GetString("KeyWord")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var orderSrt string
- var condition string
- var startSize int
- resp := new(models.IndustrialManagementList)
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- if isNewLabel == "1" {
- condition += ` AND is_new_label = ` + isNewLabel
- }
- if isDeepLabel == "1" {
- condition += ` AND is_deep_label = ` + isDeepLabel
- }
- if keyWord != "" {
- //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- // return
- //}
- //var conditionkeyWord string
- //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
- //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
- //keyWordLen := len(keyWordArr)
- //if keyWordLen <= 0 {
- // keyWordArr = append(keyWordArr, keyWord)
- // keyWordLen = len(keyWordArr)
- //}
- //for _, v := range keyWordArr {
- // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
- //}
- //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- // return
- //}
- //if industrialManagementIds == "" {
- // br.Ret = 200
- // br.Success = true
- // br.Msg = "获取成功"
- // br.Data = resp
- // return
- //}
- //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
- condition += ` AND subject_names LIKE '%` + keyWord + `%'`
- }
- var sqlChartPermissionId string
- if ChartPermissionId > 0 {
- sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
- condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
- }
- var list []*models.IndustrialManagement
- total, err := models.GetIndustrialManagementAllCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取数量失败,Err:" + err.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- if orderColumn == "" {
- orderColumn = "NewTime"
- }
- if orderColumn == "NewTime" {
- orderSrt = "update_time DESC"
- } else {
- orderSrt = "man.recommended_index DESC,update_time DESC"
- }
- if ChartPermissionId == 0 {
- ChartPermissionId = 20
- }
- detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
- return
- }
- if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
- list[k].IsRed = true
- }
- if v.ArticleReadNum >= detailHot3.ArticleReadNum {
- list[k].IsHot = true
- }
- }
- //记录用户搜索的筛选条件
- if orderColumnNew != "" {
- item := new(models.CygxReportIndustrialSeaarchHistory)
- item.UserId = user.UserId
- item.Mobile = user.Mobile
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.CreateTime = time.Now()
- item.IsDeepLabel = isDeepLabel
- item.IsNewLabel = isNewLabel
- item.ChartPermissionId = ChartPermissionId
- if orderColumnNew == "NewTime" {
- item.OrderColumn = "0"
- } else {
- item.OrderColumn = "1"
- }
- go models.AddCygxReportIndustrialSeaarchHistory(item)
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业下所关联的文章分类列表
- // @Description 产业下所关联的文章分类列表接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.IndustrialToArticleCategoryListRep
- // @router /toArticleCategoryList [get]
- func (this *ReportController) ArticleCategoryList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- if industrialManagementId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
- list[k].IsRed = true
- }
- }
- //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + err.Error()
- // return
- //}
- resp := new(models.IndustrialToArticleCategoryListRep)
- resp.List = list
- resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
- resp.IndustryName = detail.IndustryName
- resp.IndustrialManagementId = industrialManagementId
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口
- // @Description 获取产业文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param CategoryId query int true "分类ID"
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.TacticsListResp
- // @router /industry/ArticleList [get]
- func (this *ReportController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- categoryId, _ := this.GetInt("CategoryId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.TacticsListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- if categoryId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- if industrialManagementId < 1 {
- br.Msg = "请输入产业ID"
- return
- }
- //获取该产业下所对应的行业图片
- detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
- if errCategory != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
- return
- }
- //对应行业的图片
- detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
- mapChartPermission := make(map[string]string)
- var permissionName string
- var imgUrlChartPermission string
- for _, v := range chartPermissionUrlList {
- vslice := strings.Split(v, "_")
- permissionName = vslice[0]
- imgUrlChartPermission = vslice[len(vslice)-1]
- mapChartPermission[permissionName] = imgUrlChartPermission
- }
- total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- //对应分类的所图片
- detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
- mapCategoryUrl := make(map[string]string)
- var categoryIdStr string
- var imgUrlChart string
- for _, v := range categoryUrlList {
- vslice := strings.Split(v, "_")
- categoryIdStr = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapCategoryUrl[categoryIdStr] = imgUrlChart
- }
- lenList := len(list)
- for i := 0; i < lenList; i++ {
- item := list[i]
- list[i].Body, _ = services.GetReportContentTextSub(item.Body)
- //list[i].Abstract = html.UnescapeString(item.Abstract)
- list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
- }
- for k, v := range list {
- if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
- list[k].IsRed = true
- }
- if v.VideoUrl != "" {
- list[k].IsHaveVideo = true
- }
- list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- }
- resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 置顶/取消置顶
- // @Description 置顶
- // @Param request body models.CygxIndustryTopRep true "type json string"
- // @Success 200
- // @router /top [post]
- func (this *ReportController) ArticleCollect() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxIndustryTopRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- industrialManagementId := req.IndustrialManagementId
- countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countIndustrial == 0 {
- br.Msg = "产业不存在!"
- br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
- return
- }
- count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxIndustryTop)
- item.IndustrialManagementId = req.IndustrialManagementId
- item.UserId = uid
- item.CreateTime = time.Now()
- _, err = models.AddCygxIndustryTop(item)
- if err != nil {
- br.Msg = "置顶失败"
- br.ErrMsg = "置顶失败,Err:" + err.Error()
- return
- }
- br.Msg = "置顶成功"
- resp.Status = 1
- } else {
- err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
- if err != nil {
- br.Msg = "取消置顶失败"
- br.ErrMsg = "取消置顶失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消置顶"
- resp.Status = 2
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 关注/取消关注产业
- // @Description 关注/取消关注 接口
- // @Param request body models.CygxIndustryFllowRep true "type json string"
- // @Success 200
- // @router /fllow [post]
- func (this *ReportController) Fllow() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxIndustryFllowRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- industrialManagementId := req.IndustrialManagementId
- var condition string
- countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countIndustrial == 0 {
- br.Msg = "产业不存在!"
- br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
- return
- }
- count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxIndustryFllowResp)
- countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
- if countUser == 0 {
- resp.GoFollow = true
- }
- if count == 0 {
- item := new(models.CygxIndustryFllow)
- item.IndustrialManagementId = industrialManagementId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.Type = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = models.AddCygxIndustryFllow(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.Status = 1
- } else {
- var doType int
- condition = ` AND type = 1`
- count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if count == 1 {
- resp.Status = 2
- doType = 2
- } else {
- resp.Status = 1
- doType = 1
- }
- err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- }
- br.Msg = "操作成功"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 产业报告分类关联作者列表接口
- // @Description 获取产业报告分类关联作者列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.CygxArticleDepartmentList
- // @router /industryListByDepartment [get]
- func (this *ReportController) IndustryListByDepartment() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- //chartPermissionId, _ := this.GetInt("ChartPermissionId")
- var startSize int
- var condition string
- //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
- condition = ` AND a.publish_status=1 `
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- total, err := models.GetArticleDepartmentCount(condition)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.CygxArticleDepartmentList)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- //获取作者信息,并排序
- list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- subjectNames, err := models.GetSubjectNames(v2.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v2.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- artList[k2].SubjectName = subjectNamesNew
- artList[k2].DepartmentId = v.DepartmentId
- if subjectNamesNew == "" {
- artList[k2].IndustryName = industryName
- } else {
- artList[k2].IndustryName = industryName + "-" + subjectNamesNew
- }
- if artList[k2].IsReport == "1" {
- artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
- } else {
- artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
- }
- }
- list[k].List = artList
- if v.FollowNum > 0 {
- list[k].IsMyFollow = true
- }
- }
- listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if len(listnNew) > 0 {
- for _, v := range listnNew {
- firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
- Management := new(models.IndustrialManagementIdInt)
- if firstStr == 0 {
- Management.IndustryName = v.IndustryName
- } else {
- listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- for _, v1 := range listSub {
- subjectNamesNew += v1.SubjectName + "/"
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- Management.IndustryName = subjectNamesNew
- }
- Management.IndustrialManagementId = v.IndustrialManagementId
- Management.ArticleId = v.ArticleId
- resp.ListnNew = append(resp.ListnNew, Management)
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 关注作者/取消关注作者
- // @Description 关注作者/取消关注作者 接口
- // @Param request body models.CygxArticleDepartmentId true "type json string"
- // @Success 200
- // @router /fllowDepartment [post]
- func (this *ReportController) FllowDepartment() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxArticleDepartmentId
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- departmentId := req.DepartmentId
- var condition string
- countDepartment, err := models.GetDepartmentCount(departmentId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countDepartment == 0 {
- br.Msg = "作者不存在!"
- br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
- return
- }
- countUser, err := models.GetArticleDepartmentFollowByUid(uid)
- count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxArticleDepartmentFollowResp)
- if countUser == 0 {
- resp.GoFollow = true
- }
- if count == 0 {
- item := new(models.CygxArticleDepartmentFollow)
- item.DepartmentId = departmentId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.Type = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = models.AddArticleDepartmentFollow(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.Status = 1
- } else {
- var doType int
- condition = ` AND type = 1`
- count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if count == 1 {
- resp.Status = 2
- doType = 2
- } else {
- resp.Status = 1
- doType = 1
- }
- err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- }
- br.Msg = "操作成功"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 研选文章列表接口
- // @Description 获取研选文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ArticleId query int true "文章id"
- // @Param DepartmentId query int true "作者ID"
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
- // @router /industry/reportList [get]
- func (this *ReportController) ReportList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- departmentId, _ := this.GetInt("DepartmentId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- articleId, _ := this.GetInt("ArticleId")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.ReportArticleWhichIndustrialRepList)
- page := paging.GetPaging(currentIndex, pageSize, total)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- if departmentId > 0 {
- condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
- detail, err := models.GetArticleDepartmentDateilById(departmentId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- resp.NickName = detail.NickName
- }
- if industrialManagementId > 0 {
- condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
- }
- if articleId > 0 {
- detail, err := models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
- }
- total, err = models.GetWhichDepartmentCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
- list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.Readnum == 0 {
- list[k].IsRed = true
- }
- list[k].IsResearch = true
- subjectNames, err := models.GetSubjectNames(v.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- list[k].SubjectName = subjectNamesNew
- if subjectNamesNew != "" {
- list[k].IndustryName = industryName + "-" + subjectNamesNew
- } else {
- list[k].IndustryName = industryName
- }
- resp.IndustryName = industryName
- list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 研选最新主题关键词文章列表接口
- // @Description 获取研选最新主题关键词文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ArticleId query int true "文章id"
- // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
- // @router /industry/reportListNew [get]
- func (this *ReportController) ReportListNew() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- articleId, _ := this.GetInt("ArticleId")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.ReportArticleWhichIndustrialRepList)
- page := paging.GetPaging(currentIndex, pageSize, total)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- if articleId > 0 {
- detail, err := models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
- if firstStr == 0 {
- condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
- } else {
- condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
- }
- }
- total, err = models.GetWhichDepartmentCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
- list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.Readnum == 0 {
- list[k].IsRed = true
- }
- list[k].IsResearch = true
- list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
- subjectNames, err := models.GetSubjectNames(v.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- list[k].SubjectName = subjectNamesNew
- if subjectNamesNew != "" {
- list[k].IndustryName = industryName + "-" + subjectNamesNew
- } else {
- list[k].IndustryName = industryName
- }
- resp.IndustryName = industryName
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 是否展示绝密内参
- // @Description 获取是否展示绝密内参接口
- // @Param request body models.IsShow true "type json string"
- // @Success 200
- // @router /isShow [get]
- func (this *ReportController) IsShow() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- var resp models.IsShow
- resp.IsShowChart = true
- resp.IsShowResearch = true
- mobile := user.Mobile
- if mobile == "" {
- br.Ret = 200
- br.Success = true
- br.Data = resp
- return
- }
- total, _ := models.GetUserIsAdminCount(mobile)
- if total > 0 {
- resp.IsShow = true
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 报告精选、本周研究汇总、上周纪要汇总列表
- // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
- // @Success 200 {object} models.CygxReportSelectionListPublicRep
- // @router /reportList/byType [get]
- func (this *ReportController) ReportListByType() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- reportType := this.GetString("ReportType")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.CygxReportSelectionListPublicRep)
- page := paging.GetPaging(currentIndex, pageSize, total)
- var tbdb string
- var readSql string
- var reportTypeStr string
- if reportType == "1" {
- tbdb = "cygx_report_selection"
- reportTypeStr = "bgjx"
- } else if reportType == "2" {
- tbdb = "cygx_research_summary"
- reportTypeStr = "bzyjhz"
- } else if reportType == "3" {
- tbdb = "cygx_minutes_summary"
- reportTypeStr = "szjyhz"
- } else {
- br.Msg = "请选择报告类型"
- return
- }
- fmt.Println(tbdb)
- condition = ` AND publish_status = 1`
- total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if reportType == "1" {
- list[k].Abstract = v.UpdateDescription
- }
- list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
- if v.ReadNum == 0 {
- list[k].IsRed = true
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取报告精选详情
- // @Description 获取报告精选详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ReportSelectionLetailResp
- // @router /reportSelection/detail [get]
- func (this *ReportController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ReportSelectionLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxReportSelectionInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- existMap := make(map[int]int)
- var items []*models.ReportSelectionChartPermission
- listLog, err := models.GetReportSelectionlogListAll(articleId)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- //var itemLogs []*models.CygxReportSelectionLogDetail
- for _, v := range listLog {
- item := new(models.ReportSelectionChartPermission)
- if existMap[v.ChartPermissionId] == 0 {
- item.PermissionName = v.PermissionName + "领域深度报告和调研"
- item.IcoLink = v.IcoLink
- listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSonLog {
- if v2.IndustrialManagementId != "" {
- listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listSonLog[k2].List = listIndustrial
- }
- }
- item.List = listSonLog
- items = append(items, item)
- //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
- }
- existMap[v.ChartPermissionId] = v.ChartPermissionId
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "bgjx"
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = items
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取本周研究汇总详情
- // @Description 获取本周研究汇总详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ResearchSummaryLetailResp
- // @router /researchSummary/detail [get]
- func (this *ReportController) ResearchDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ResearchSummaryLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetResearchSummarylogListFirst(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
- listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- listSecond[k2].PermissionName = "研选纪要"
- } else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
- listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- listSecond[k2].PermissionName = "研选观点"
- }
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "SDBG" {
- listFirst[k].ListName = "深度报告"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
- } else if v.Type == "BZCHJH" {
- listFirst[k].ListName = "本周晨会精华"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
- } else if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "SJDP" {
- listFirst[k].ListName = "事件点评"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "研选"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "bzyjhz"
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总内容详情
- // @Description 获取上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.MinutesSummaryLetailResp
- // @router /minutesSummary/detailv4 [get]
- func (this *ReportController) MinutesDetailV4() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.MinutesSummaryLetailRespV4)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "研选纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "szjyhz"
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总内容详情
- // @Description 获取上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.MinutesSummaryLetailResp
- // @router /minutesSummary/detail [get]
- func (this *ReportController) MinutesDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.MinutesSummaryLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listLog, err := models.GetMinutesSummarylogListAll(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listLog {
- listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listSonLog) > 0 {
- listLog[k].List = listSonLog
- for k2, v2 := range listSonLog {
- if v2.ReportLink == "0" {
- listSonLog[k2].ReportLink = ""
- }
- }
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "szjyhz"
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listLog
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取路演精华详情
- // @Description 获取路演精华详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.RoadshowDetailResp
- // @router /roadshowEssence/detail [get]
- func (this *ReportController) RoadshowDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, err := this.GetInt("ArticleId")
- if articleId <= 0 {
- br.Msg = "文章不存在"
- br.ErrMsg = "文章不存在,文章ID错误"
- return
- }
- detail := new(models.ReportDetailRoadshow)
- hasPermission := 0
- hasFree := 0
- //判断是否已经申请过
- applyCount, err := models.GetApplyRecordCount(uid)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
- if user.CompanyId > 1 {
- companyPermission, err := models.GetCompanyPermission(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- detail, err = models.GetReportRoadshowDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- detail.Body = html.UnescapeString(detail.Body)
- detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- if detail.ReportLink == "0" {
- detail.ReportLink = ""
- }
- if companyPermission == "" {
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 2
- }
- hasFree = 2
- goto Loop
- } else {
- hasFree = 1
- var articlePermissionPermissionName string
- articlePermissionPermissionName = detail.CategoryName
- var hasPersion bool
- slice := strings.Split(articlePermissionPermissionName, ",")
- for _, v := range slice {
- if strings.Contains(companyPermission, v) {
- hasPersion = true
- }
- }
- if hasPersion {
- hasPermission = 1
- historyRecord := new(models.CygxArticleHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- go models.AddCygxArticleHistoryRecord(historyRecord)
- } else { //无该行业权限
- hasPermission = 3
- }
- if hasPermission == 1 {
- key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
- if !utils.Rc.IsExist(key) {
- //新增浏览记录
- record := new(models.CygxArticleViewRecord)
- record.UserId = uid
- record.ArticleId = articleId
- record.CreateTime = time.Now()
- record.Mobile = user.Mobile
- record.Email = user.Email
- record.CompanyId = user.CompanyId
- record.CompanyName = user.CompanyName
- go models.AddCygxArticleViewRecord(record)
- utils.Rc.Put(key, 1, 5*time.Second)
- models.ModifyReportLastViewTime(uid)
- }
- }
- }
- } else { //潜在客户
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 4
- }
- }
- Loop:
- if hasPermission != 1 {
- detail.Body = ""
- detail.Abstract = ""
- }
- resp := new(models.RoadshowDetailResp)
- resp.HasPermission = hasPermission
- resp.HasFree = hasFree
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口
- // @Description 获取产业文章列表接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.CygxIndustrySearchList
- // @router /industryAndArticle/list [get]
- func (this *ReportController) IndustryAndArticleList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- keyWord := this.GetString("KeyWord")
- orderSrt := "update_time DESC"
- condition := ` AND subject_names LIKE '%` + keyWord + `%'`
- list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- }
- artList, err := models.GetCygxIndustryAndArticleList(keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- subjectNames, err := models.GetSubjectNames(v2.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v2.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- artList[k2].SubjectName = subjectNamesNew
- if subjectNamesNew == "" {
- artList[k2].IndustryName = industryName
- } else {
- artList[k2].IndustryName = industryName + "-" + subjectNamesNew
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp := new(models.CygxIndustrySearchList)
- resp.ArtList = artList
- resp.IndList = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业报告分类关联作者列表接口Pc端
- // @Description 获取产业报告分类关联作者列表接口Pc端
- // @Param ChartPermissionId query int true "分类ID"
- // @Param KeyWord query string true "搜索关键词"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.CygxArticleDepartmentListPc
- // @router /industryListByDepartmentPc [get]
- func (this *ReportController) IndustryListByDepartmentPc() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- keyWord := this.GetString("KeyWord")
- var startSize int
- var condition string
- condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- var articleIdGroup string
- if keyWord != "" {
- //获取标的关联的文章ID
- articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- //获取产业关联的标的
- articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
- return
- }
- if articleIdSub != "" && articleIdInd != "" {
- articleIdGroup = articleIdSub + "," + articleIdInd
- } else if articleIdSub != "" && articleIdInd == "" {
- articleIdGroup = articleIdSub
- } else if articleIdSub == "" && articleIdInd != "" {
- articleIdGroup = articleIdInd
- }
- slice := strings.Split(keyWord, "/")
- if len(slice) > 1 {
- var subjectIds string
- for _, v := range slice {
- subjectId, err := models.GetcygxIndustrialSubjectByName(v)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- if subjectId != "" {
- subjectIds += subjectId + ","
- }
- }
- subjectIds = strings.TrimRight(subjectIds, ",")
- if len(subjectIds) > 0 {
- articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
- return
- }
- if articleIdGroup != "" {
- if articleBySub != "" {
- articleIdGroup += "," + articleBySub
- }
- } else {
- articleIdGroup = articleBySub
- }
- }
- }
- }
- if articleIdGroup != "" {
- condition += ` AND a.article_id IN (` + articleIdGroup + `)`
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- total, err := models.GetArticleDepartmentCount(condition)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.CygxArticleDepartmentListPc)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- //获取作者信息,并排序
- list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- if artList[k2].IsReport == "1" {
- artList[k2].Title = v2.Title
- } else {
- artList[k2].Title = v2.Title
- }
- artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
- }
- list[k].List = artList
- if v.FollowNum > 0 {
- list[k].IsMyFollow = true
- }
- }
- listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if len(listnNew) > 0 {
- for _, v := range listnNew {
- firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
- Management := new(models.IndustrialManagementIdInt)
- if firstStr == 0 {
- Management.IndustryName = v.IndustryName
- } else {
- listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- for _, v1 := range listSub {
- subjectNamesNew += v1.SubjectName + "/"
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- Management.IndustryName = subjectNamesNew
- }
- Management.IndustrialManagementId = v.IndustrialManagementId
- Management.ArticleId = v.ArticleId
- resp.ListnNew = append(resp.ListnNew, Management)
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口Pc端
- // @Description 获取产业文章列表接口Pc端
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.CygxIndustrySearchListPc
- // @router /industryAndArticle/listPc [get]
- func (this *ReportController) IndustryAndArticleListPc() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- keyWord := this.GetString("KeyWord")
- resp := new(models.CygxIndustrySearchListPc)
- orderSrt := "update_time DESC"
- condition := ` AND subject_names LIKE '%` + keyWord + `%'`
- list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- }
- artList, err := models.GetCygxIndustryAndArticleList(keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if len(artList) > 0 {
- var articleIds string
- for _, v := range artList {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- articleIds = strings.TrimRight(articleIds, ",")
- if articleIds != "" {
- condition = ` AND a.article_id IN (` + articleIds + `)`
- DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range DepartmentList {
- artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- if artList[k2].IsReport == "1" {
- artList[k2].Title = v2.Title
- } else {
- artList[k2].Title = v2.Title
- }
- artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
- }
- DepartmentList[k].List = artList
- if v.FollowNum > 0 {
- DepartmentList[k].IsMyFollow = true
- }
- }
- resp.DepartmentList = DepartmentList
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp.IndList = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告搜索
- // @Description 报告搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.ReoprtSearchResp
- // @router /searchReport [get]
- func (this *ReportController) SearchReport() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- keyWord := this.GetString("KeyWord")
- var condition string
- //匹配报告标题、对应产业名称、标的名称。
- condition = `AND (
- a.title LIKE '%` + keyWord + `%'
- OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
- OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
- )
- GROUP BY a.article_id ORDER BY a.publish_date DESC `
- listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range listYx {
- if v.MyCollectNum > 0 {
- listYx[k].IsCollect = true
- }
- }
- listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range listHz {
- if v.MyCollectNum > 0 {
- listHz[k].IsCollect = true
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp := new(models.ReoprtSearchResp)
- resp.ListYx = listYx
- resp.ListHz = listHz
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 资源包搜索
- // @Description 资源包搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.SearchResourceResp
- // @router /searchResource [get]
- func (this *ReportController) SearchResource() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- keyWord := this.GetString("KeyWord")
- var condition string
- condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id != 31 GROUP BY m.industrial_management_id `
- listHz, err := models.GetSearchResourceList(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id = 31 GROUP BY m.industrial_management_id `
- listYx, err := models.GetSearchResourceList(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- //合并产业关联的标的
- listSubjcet, err := models.GetThemeHeatSubjectList("")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listHz {
- for _, v2 := range listSubjcet {
- if v2.IndustrialManagementId == v.IndustrialManagementId {
- listHz[k].IndustrialSubjectList = append(listHz[k].IndustrialSubjectList, v2)
- }
- }
- }
- for k, v := range listYx {
- for _, v2 := range listSubjcet {
- if v2.IndustrialManagementId == v.IndustrialManagementId {
- listYx[k].IndustrialSubjectList = append(listYx[k].IndustrialSubjectList, v2)
- }
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp := new(models.SearchResourceResp)
- resp.ListYx = listYx
- resp.ListHz = listHz
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|