123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347 |
- package controllers
- import (
- //"bufio"
- //"io"
- //"path"
- //"rdluck_tools/http"
- "bufio"
- "io"
- "io/ioutil"
- //"bufio"
- "encoding/json"
- "fmt"
- "github.com/medivhzhan/weapp/v2"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "html"
- "rdluck_tools/http"
- //"rdluck_tools/http"
- //"io"
- nhttp "net/http"
- "os"
- //"rdluck_tools/http"
- //"path"
- //"rdluck_tools/http"
- "regexp"
- "strconv"
- "strings"
- "time"
- )
- type ArticleController struct {
- BaseAuthController
- }
- type ArticleCommonController struct {
- BaseCommonController
- }
- // @Title 获取报告详情
- // @Description 获取报告详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /detail [get]
- func (this *ArticleController) Detail() {
- 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.ArticleDetail)
- hasPermission := 0
- hasFree := 0
- var haveResearch bool
- //判断是否已经申请过
- 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.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- detail.Body = html.UnescapeString(detail.Body)
- detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
- //detail.Abstract = html.UnescapeString(detail.Abstract)
- detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
- if companyPermission == "" {
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 2
- }
- hasFree = 2
- goto Loop
- } else {
- hasFree = 1
- var articlePermissionPermissionName string
- if detail.CategoryId > 0 {
- articlePermission, err := models.GetArticlePermission(detail.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if articlePermission == nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- articlePermissionPermissionName = articlePermission.PermissionName
- } else {
- articlePermissionPermissionName = detail.CategoryName
- }
- var hasPersion bool
- slice := strings.Split(articlePermissionPermissionName, ",")
- for _, v := range slice {
- if strings.Contains(companyPermission, v) {
- hasPersion = true
- }
- }
- if strings.Contains(detail.CategoryName, "研选") {
- detail.IsResearch = true
- }
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
- hasPersion = false
- }
- 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
- recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
- if recordCount == 0 {
- go models.AddCygxArticleHistoryRecord(historyRecord)
- } else {
- detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if detailNew.StopTime > 0 {
- 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)
- }
- }
- }
- collectCount, err := models.GetArticleCollectCount(uid, articleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if collectCount > 0 {
- detail.IsCollect = true
- }
- interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
- detail.IsInterviewApply = true
- detail.InterviewApplyStatus = interviewApplyItem.Status
- }
- //获取销售手机号
- sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售数据失败2,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if sellerItem != nil {
- detail.SellerMobile = sellerItem.Mobile
- detail.SellerName = sellerItem.RealName
- }
- sellerList, err := models.GetSellerList(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- fmt.Println(detail.SellerAndMobile)
- if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
- strnum := strings.Index(detail.SellerAndMobile, "-")
- detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
- fmt.Println(detail.SellerAndMobile)
- if strnum > 0 {
- nickName := detail.SellerAndMobile[0:strnum]
- sellerAndMobile := &models.SellerRep{
- SellerMobile: "",
- SellerName: nickName,
- }
- sellerList = append(sellerList, sellerAndMobile)
- }
- }
- detail.SellerList = sellerList
- } else { //潜在客户
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 4
- }
- }
- Loop:
- if hasPermission != 1 {
- detail.Body = ""
- detail.BodyText = ""
- } else {
- articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
- return
- }
- detail.FollowNum = articleFollowdetail.DNum
- detail.CollectionNum = articleFollowdetail.AcNum
- if articleFollowdetail.MdNum > 0 {
- detail.IsFollow = true
- }
- if detail.IsSummary == 1 {
- detail.IsBelongSummary = true
- }
- if detail.IsReport == 1 {
- detail.IsBelongReport = true
- }
- haveResearch = true
- }
- resp := new(models.ArticleDetailResp)
- resp.HasPermission = hasPermission
- resp.HaveResearch = haveResearch
- resp.HasFree = hasFree
- resp.Detail = detail
- if user.Mobile != "" {
- resp.Mobile = user.Mobile
- } else {
- resp.Mobile = user.Email
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 收藏
- // @Description 收藏
- // @Param request body models.ArticleCollectReq true "type json string"
- // @Success 200 {object} models.FontsCollectResp
- // @router /collect [post]
- func (this *ArticleController) 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.ArticleCollectReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- count, err := models.GetArticleCollectCount(uid, req.ArticleId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxArticleCollect)
- item.ArticleId = req.ArticleId
- item.UserId = uid
- item.CreateTime = time.Now()
- _, err = models.AddCygxArticleCollect(item)
- if err != nil {
- br.Msg = "收藏失败"
- br.ErrMsg = "收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "收藏成功"
- resp.Status = 1
- } else {
- err = models.RemoveArticleCollect(uid, req.ArticleId)
- if err != nil {
- br.Msg = "取消收藏失败"
- br.ErrMsg = "取消收藏失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消收藏"
- resp.Status = 2
- }
- collectTotal, err := models.GetArticleCollectUsersCount(req.ArticleId)
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.CollectCount = collectTotal
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 访谈申请
- // @Description 访谈申请
- // @Param request body models.ArticleInterviewApplyReq true "type json string"
- // @Success 200 {object} models.FontsCollectResp
- // @router /interview/apply [post]
- func (this *ArticleController) InterviewApply() {
- 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.ArticleInterviewApplyReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- article, err := models.GetArticleDetailById(req.ArticleId)
- if err != nil {
- br.Msg = "获取纪要失败!"
- br.ErrMsg = "获取纪要失败,Err:" + err.Error()
- return
- }
- count, err := models.GetArticleInterviewApplyCount(uid, req.ArticleId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleInterviewApplyResp)
- if count <= 0 {
- item := new(models.CygxInterviewApply)
- item.ArticleId = req.ArticleId
- item.UserId = uid
- item.CompanyId = user.CompanyId
- item.Status = "待邀请"
- item.Sort = 1
- item.ArticleTitle = article.Title
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- item.ArticleIdMd5 = article.ArticleIdMd5
- _, err = models.AddCygxInterviewApply(item)
- if err != nil {
- br.Msg = "申请失败"
- br.ErrMsg = "申请失败,Err:" + err.Error()
- return
- }
- br.Msg = "申请成功"
- resp.Status = 1
- //发送模板消息
- if user.CompanyId > 1 {
- mobile := user.Mobile
- if mobile == "" {
- mobile = user.Email
- }
- sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
- if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
- openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
- if openIpItem != nil && openIpItem.OpenId != "" {
- go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
- }
- }
- }
- } else {
- err = models.RemoveArticleInterviewApply(uid, req.ArticleId)
- if err != nil {
- br.Msg = "取消申请失败"
- br.ErrMsg = "取消申请失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消申请"
- resp.Status = 2
- if user.CompanyId > 1 {
- mobile := user.Mobile
- if mobile == "" {
- mobile = user.Email
- }
- sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
- if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
- openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
- if openIpItem != nil && openIpItem.OpenId != "" {
- go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
- }
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 获取报告详情
- // @Description 获取报告详情接口
- // @Param ArticleIdMd5 query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /look/detail [get]
- func (this *ArticleCommonController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- articleIdMd5 := this.GetString("ArticleIdMd5")
- if articleIdMd5 == "" {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ArticleDetailResp)
- detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if detail == nil {
- resp.HasPermission = 2
- } else {
- resp.HasPermission = 1
- }
- if detail != nil {
- detail.Body = html.UnescapeString(detail.Body)
- detail.Abstract = html.UnescapeString(detail.Abstract)
- }
- sellerList, err := models.GetSellerList(detail.ArticleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(detail.ArticleId)
- return
- }
- if detail.ArticleId > 1000000 {
- var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
- match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
- if match != nil {
- for _, v := range match {
- sellerAndMobile := &models.SellerRep{
- SellerMobile: v,
- SellerName: strings.Replace(detail.SellerAndMobile, v, "", -1),
- }
- sellerList = append(sellerList, sellerAndMobile)
- }
- }
- }
- detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
- detail.SellerList = sellerList
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上传文章阅读时间
- // @Description 上传文章阅读时间接口
- // @Param request body models.AddStopTimeRep true "type json string"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /addStopTime [post]
- func (this *ArticleController) AddStopTime() {
- 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
- }
- var req models.AddStopTimeRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- uid := user.UserId
- articleId := req.ArticleId
- stopTime := req.StopTime
- if articleId <= 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- if stopTime == 0 {
- stopTime = 1
- //br.Msg = "时间格式错误"
- //br.ErrMsg = "时间错误"
- //return
- }
- detail := new(models.ArticleDetail)
- 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.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if companyPermission == "" {
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 2
- }
- hasFree = 2
- goto Loop
- } else {
- hasFree = 1
- var articlePermissionPermissionName string
- if detail.CategoryId > 0 {
- articlePermission, err := models.GetArticlePermission(detail.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- if articlePermission == nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- articlePermissionPermissionName = articlePermission.PermissionName
- } else {
- articlePermissionPermissionName = detail.CategoryName
- }
- var hasPersion bool
- slice := strings.Split(articlePermissionPermissionName, ",")
- for _, v := range slice {
- if strings.Contains(companyPermission, v) {
- hasPersion = true
- }
- }
- if hasPersion {
- detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
- if err == nil {
- //br.Msg = "获取信息失败"
- //br.ErrMsg = "获取最新阅读信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- //return
- hasPermission = 1
- historyRecord := new(models.AddStopTimeNewRep)
- historyRecord.StopTime = detailNew.StopTime + stopTime
- historyRecord.Id = detailNew.Id
- go models.AddArticleStopTime(historyRecord)
- }
- } else { //无该行业权限
- hasPermission = 3
- }
- }
- } else { //潜在客户
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 4
- }
- }
- Loop:
- resp := new(models.ArticleDetailAddStopTimeRep)
- resp.HasPermission = hasPermission
- resp.HasFree = hasFree
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.Data = resp
- }
- // @Title 文章带问
- // @Description 新增文章带问接口
- // @Param request body models.AddArticleAskRep true "type json string"
- // @Success Ret=200 新增成功
- // @router /askAdd [post]
- func (this *ArticleController) AskAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req models.AddArticleAskRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Content == "" {
- br.Msg = "建议内容不可为空"
- return
- }
- content := req.Content
- itemToken, err := services.WxGetToken()
- if err != nil {
- br.Msg = "GetWxAccessToken Err:" + err.Error()
- return
- }
- if itemToken.AccessToken == "" {
- br.Msg = "accessToken is empty"
- return
- }
- commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
- if err != nil {
- br.Msg = "内容校验失败!"
- br.ErrMsg = "内容校验失败,Err:" + err.Error()
- return
- }
- if commerr.ErrCode != 0 {
- br.Msg = "内容违规,请重新提交!"
- br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
- return
- }
- articleId := req.ArticleId
- count, _ := models.GetArticleCountById(articleId)
- if count == 0 {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在 articleId:" + strconv.Itoa(articleId)
- return
- }
- companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
- if err != nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail == nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
- return
- }
- item := new(models.CygxArticleAsk)
- item.UserId = user.UserId
- item.ArticleId = req.ArticleId
- item.CompanyId = user.CompanyId
- item.CompanyName = companyDetail.CompanyName
- item.CreateTime = time.Now()
- item.Mobile = user.Mobile
- item.Email = user.Email
- item.Content = content
- _, err = models.AddArticleAsk(item)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交失败,Err:" + err.Error()
- return
- }
- companyItem, err := models.GetSellerDetailAllByCompanyId(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取所属销售信息失败,Err:" + err.Error()
- return
- }
- var mobile string
- if utils.WxMsgTemplateIdAskMsgMobile == "" {
- //mobile = utils.WxMsgTemplateIdAskMsgMobileAll + "," + companyItem.Mobile
- mobile = utils.WxMsgTemplateIdAskMsgMobileAll
- } else {
- mobile = utils.WxMsgTemplateIdAskMsgMobile
- }
- openIdList, err := models.GetWxOpenIdByMobileList(mobile)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交失败,Err:" + err.Error()
- return
- }
- detail, err := models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- companyName := user.CompanyName + "-" + user.RealName + "(" + companyItem.SellerName + ")"
- go services.SendWxMsgWithAsk(companyName, time.Now().Format(utils.FormatDateTime), content, detail.Title, openIdList, req.ArticleId)
- br.Ret = 200
- br.Success = true
- br.Msg = "提交成功"
- }
- // @Title 下载PDF打水印
- // @Description 下载PDF打水印接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailFileLink
- // @router /pdfwatermark [get]
- func (this *ArticleController) Pdfwatermark() {
- 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
- }
- articleId, err := this.GetInt("ArticleId")
- if articleId <= 0 {
- br.Msg = "文章不存在"
- br.ErrMsg = "文章不存在,文章ID错误"
- return
- }
- detail := new(models.ArticleDetail)
- detail, err = models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- fileLink := detail.FileLink
- if fileLink == "" {
- br.Msg = "下载失败"
- br.ErrMsg = "下载失败,报告链接不存在"
- return
- }
- mobile := user.Mobile
- if mobile == "" {
- mobile = user.Email
- }
- dataMap := make(map[string]interface{})
- dataMap["Mobile"] = mobile
- //dataMap["Name"] = user.RealName
- dataMap["Name"] = ""
- pdfPath := "static/"
- pdfUrl := fileLink
- fileName := utils.GetRandStringNoSpecialChar(28) + ".pdf"
- res, err := nhttp.Get(pdfUrl)
- if err != nil {
- fmt.Println("A error occurred!")
- return
- }
- defer res.Body.Close()
- // 获得get请求响应的reader对象
- reader := bufio.NewReaderSize(res.Body, 32*1024)
- file, err := os.Create(pdfPath + fileName)
- if err != nil {
- panic(err)
- }
- //获得文件的writer对象
- writer := bufio.NewWriter(file)
- written, _ := io.Copy(writer, reader)
- fmt.Printf("Total length: %d", written)
- str, _ := os.Getwd()
- fileLink = str + "/" + pdfPath + fileName
- dataMap["FileLink"] = fileLink
- postUrl := "http://127.0.0.1:5007/pdfwatermark/" //
- fmt.Println("postUrl:", postUrl)
- postData, err := json.Marshal(dataMap)
- if err != nil {
- br.Msg = "下载失败"
- br.ErrMsg = "解析,Marshal,Err:" + err.Error()
- return
- }
- fmt.Println("publish ppt param:", string(postData))
- result, err := http.Post(postUrl, string(postData))
- if err != nil {
- br.Msg = "下载失败"
- br.ErrMsg = "Marshal,Err:" + err.Error()
- return
- }
- fmt.Println("publish pdf result:", string(result))
- var pdfResult PublishPdfResult
- err = json.Unmarshal(result, &pdfResult)
- if err != nil {
- br.Msg = "下载失败"
- br.ErrMsg = "Unmarshal,Err:" + err.Error()
- return
- }
- //fmt.Println(pdfResult)
- resp := new(models.ArticleDetailFileLink)
- filePathName := strings.TrimLeft(pdfResult.FilePath, ".")
- //filePathOldName := strings.TrimLeft(pdfResult.FileOldPath, ".")
- filePath := pdfResult.Pdfpath + filePathName
- //filePathOld := pdfResult.Pdfpath + filePathOldName
- randStr := utils.GetRandStringNoSpecialChar(28)
- fileName = randStr + ".pdf"
- hzUploadDir := "static/pdf/"
- savePath := hzUploadDir + time.Now().Format("200601/20060102/")
- savePath += fileName
- //上传到阿里云
- err = services.UploadFileToAliyun(fileName, filePath, savePath)
- if err != nil {
- br.Msg = "下载失败"
- br.ErrMsg = "文件上传失败,Err:" + err.Error()
- return
- }
- utils.FileLog.Info("%s:", time.Now().Format(utils.FormatDateTime))
- utils.FileLog.Info("end update oss ")
- fileHost := "https://hzstatic.hzinsights.com/"
- resourceUrl := fileHost + savePath
- defer func() {
- os.Remove(filePath)
- os.Remove(fileLink)
- }()
- resp.FileLink = resourceUrl
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- type PublishPdfResult struct {
- Result string `json:"result"`
- FilePath string `json:"file_path"`
- FileOldPath string `json:"file_old_path"`
- Pdfpath string `json:"pdfpath"`
- }
- // @Title 同步策略报告内容
- // @Description 同步策略报告内容接口
- // @Param ArticleIdMd5 query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /look/listApi [get]
- func (this *ArticleCommonController) ListApi() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- url := "https://vmp.hzinsights.com/v2api/articles/mp?take=20&skip=0&publish_status=1"
- url = ""
- method := "GET"
- client := &nhttp.Client{}
- req, err := nhttp.NewRequest(method, url, nil)
- if err != nil {
- fmt.Println(err)
- return
- }
- req.Header.Add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag")
- res, err := client.Do(req)
- if err != nil {
- fmt.Println(err)
- return
- }
- defer res.Body.Close()
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- fmt.Println(err)
- return
- }
- var pdfResult models.ArticleResultApi
- err = json.Unmarshal(body, &pdfResult)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "Unmarshal,Err:" + err.Error()
- return
- }
- exitMap := make(map[int]int)
- listMap, err := models.GetArticleApiMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取映射关系失败,Err:" + err.Error()
- return
- }
- //新旧分类 反向隐射
- for _, v := range listMap {
- exitMap[v.Id] = v.OldId
- }
- listData := pdfResult.Data
- var list []*models.Tactics2
- var listAuthor []*models.CygxArticleAuthor
- for _, v := range listData {
- if exitMap[v.SeriesId] > 0 {
- item := new(models.Tactics2)
- itemAuthor := new(models.CygxArticleAuthor)
- item.ArticleId = v.ArticleId
- item.Title = v.Title
- item.TitleEn = v.TitleEn
- if v.Frequency == "日度" {
- item.UpdateFrequency = "daily"
- } else if v.Frequency == "周度" {
- item.UpdateFrequency = "weekly"
- } else if v.Frequency == "月度" {
- item.UpdateFrequency = "monthly"
- } else if v.Frequency == "季度" {
- item.UpdateFrequency = "quarterly"
- } else if v.Frequency == "年度" {
- item.UpdateFrequency = "yearly"
- } else {
- item.UpdateFrequency = "unknow"
- }
- item.CreateDate = v.CreateDate
- item.PublishDate = v.PublishDate
- item.PublishStatus = v.PublishStatus
- item.Body = v.Content.Body
- item.Abstract = v.Content.Abstract
- item.CategoryName = v.Industry.Name
- item.CategoryId = exitMap[v.SeriesId]
- item.SubCategoryName = v.Series.Name
- list = append(list, item)
- itemAuthor.ArticleId = v.ArticleId
- itemAuthor.Name = v.Author.Name
- itemAuthor.Mobile = v.Author.PhoneNumber
- listAuthor = append(listAuthor, itemAuthor)
- }
- }
- //同步作者
- for _, v := range listAuthor {
- count, err := models.GetActivityAuthorCount(v.ArticleId, v.Mobile)
- if err != nil {
- fmt.Println("GetCount Err:", err.Error())
- return
- }
- if count == 0 {
- _, err := models.AddCygxActivityAuthor(v)
- if err != nil {
- fmt.Println("AddCygxActivityAuthor Err:", err.Error())
- return
- }
- }
- }
- fmt.Println("同步文章条数:", len(list))
- listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
- if err != nil {
- fmt.Println("GetTacticsList Err:", err.Error())
- return
- }
- listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
- if errMatch != nil {
- fmt.Println("GetTacticsList Err:", errMatch.Error())
- return
- }
- fmt.Println("list len:", len(list))
- summaryCategoryIds := "28,32,45,50,57,62,72,74,79,84,86,88,90,93,95,96" //纪要库的文章类型categoty_id
- listSummary := strings.Split(summaryCategoryIds, ",")
- noSummaryArticleIds := "3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470" //非纪要库类型的文章ID
- listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
- listPermission, errper := models.GetPermissionMappingCategoryID()
- if errper != nil {
- fmt.Println("GetTacticsList Err:", errper.Error())
- return
- }
- summaryMap := make(map[int]int)
- for _, vSum := range listSummary {
- vSumInt, _ := strconv.Atoi(vSum)
- summaryMap[vSumInt] = 1
- }
- for k, v := range list {
- //同步匹配类型
- matchTypeName := ""
- for _, vMatch := range listGetMatchTypeName {
- if v.CategoryId == vMatch.CategoryId {
- matchTypeName = vMatch.MatchTypeName
- }
- }
- //是否属于纪要库的数据
- if _, has := summaryMap[v.CategoryId]; has {
- v.IsSummary = 1
- }
- //排除不属于纪要库类型的文章
- for _, vArt := range listNoSummaryArticleIds {
- vArtInt, _ := strconv.Atoi(vArt)
- if v.ArticleId == vArtInt {
- v.IsSummary = 0
- }
- }
- for _, vPer := range listPermission {
- if v.CategoryId == vPer.CategoryId {
- v.IsReport = 1
- }
- }
- if v.IsReport > 0 {
- //是否属于策略 策略自动归类
- //是否属于行业报告 行业报告自动归类
- if v.CategoryId == 7 || v.CategoryId == 9 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 || v.CategoryId == 64 || v.CategoryId == 80 || v.CategoryId == 87 {
- v.IsClass = 1
- v.ReportType = 1 //是否属于行业报告
- } else {
- v.ReportType = 2 //是否属于产业报告
- }
- }
- v.Department = "弘则权益研究"
- fmt.Println(k, v.ArticleId)
- hh, _ := time.ParseDuration("8h")
- //pDate := publishDate.Add(hh)
- v.PublishDate = v.PublishDate.Add(hh)
- //判断是否已经存在
- if v.ArticleId < 0 {
- fmt.Println("AddCygxArticle Err:")
- return
- }
- count, err := models.GetArticleCountById(v.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("AddCygxArticle Err:", err.Error())
- return
- }
- v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
- expertNumStr, expertContentStr, interviewDateStr, fileLink, bodyReturn := services.BodyAnalysis2(v.Body)
- if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
- v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
- v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
- v.Body = strings.Replace(v.Body, "):", "", -1)
- }
- var titleNew string
- titleNew = v.Title
- // 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
- if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
- if v.UpdateFrequency == "daily" {
- var daystr string
- daystr = strconv.Itoa(v.PublishDate.Day())
- if len(daystr) == 1 {
- daystr = "0" + daystr
- }
- titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
- } else if v.UpdateFrequency == "weekly" {
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
- }
- }
- if v.CategoryId == 80 {
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
- }
- if count > 0 {
- fmt.Println(k, v.ArticleId, "edit")
- var isCustom bool
- bodyText, _ := services.GetReportContentTextSub(v.Body)
- updateParams := make(map[string]interface{})
- //updateParams["Title"] = v.Title
- updateParams["Title"] = titleNew
- updateParams["TitleEn"] = v.TitleEn
- updateParams["UpdateFrequency"] = v.UpdateFrequency
- updateParams["CreateDate"] = v.CreateDate
- updateParams["PublishDate"] = v.PublishDate
- //updateParams["Body"] = html.EscapeString(v.Body)
- updateParams["Body"] = html.EscapeString(bodyReturn)
- updateParams["BodyText"] = bodyText
- updateParams["Abstract"] = html.EscapeString(v.Abstract)
- updateParams["CategoryName"] = v.CategoryName
- for _, vCustom := range listCustomArticle {
- if v.ArticleId == vCustom.ArticleId {
- fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
- isCustom = true
- }
- }
- if isCustom == false {
- updateParams["CategoryId"] = v.CategoryId
- updateParams["MatchTypeName"] = matchTypeName
- updateParams["IsSummary"] = v.IsSummary
- updateParams["IsReport"] = v.IsReport
- updateParams["ReportType"] = v.ReportType
- updateParams["SubCategoryName"] = v.SubCategoryName
- }
- //updateParams["CategoryId"] = v.CategoryId
- updateParams["PublishStatus"] = v.PublishStatus
- updateParams["ExpertBackground"] = expertContentStr
- updateParams["ExpertNumber"] = expertNumStr
- updateParams["InterviewDate"] = interviewDateStr
- //updateParams["IsClass"] = v.IsClass
- if v.Department != "弘则权益研究" {
- v.Department = "弘则权益研究"
- }
- updateParams["Department"] = v.Department
- updateParams["FileLink"] = fileLink
- whereParam := map[string]interface{}{"article_id": v.ArticleId}
- err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
- if err != nil {
- fmt.Println("UpdateByExpr Err:" + err.Error())
- }
- } else {
- fmt.Println(k, v.ArticleId, "add")
- item := new(models.CygxArticle)
- articleIdInt := v.ArticleId
- item.ArticleId = articleIdInt
- //item.Title = v.Title
- item.Title = titleNew
- item.TitleEn = v.TitleEn
- item.UpdateFrequency = v.UpdateFrequency
- item.CreateDate = v.CreateDate
- item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
- //item.Body = html.EscapeString(v.Body)
- item.Body = html.EscapeString(bodyReturn)
- item.Abstract = html.EscapeString(v.Abstract)
- item.CategoryName = v.CategoryName
- item.SubCategoryName = v.SubCategoryName
- item.CategoryId = v.CategoryId
- item.PublishStatus = v.PublishStatus
- item.ExpertBackground = expertContentStr
- item.ExpertNumber = expertNumStr
- item.InterviewDate = interviewDateStr
- item.Department = v.Department
- item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdInt))
- item.IsClass = v.IsClass
- item.IsSummary = v.IsSummary
- item.IsReport = v.IsReport
- item.ReportType = v.ReportType
- item.FileLink = fileLink
- item.MatchTypeName = matchTypeName
- _, err = models.AddCygxArticles(item)
- if err != nil {
- fmt.Println("AddCygxArticle Err:", err.Error())
- return
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = string(body)
- }
- // @Title 同步参会记录
- // @Description 获取报告详情接口
- // @Param ArticleIdMd5 query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /look/detaisl [get]
- func (this *ArticleCommonController) Detaisl() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- var condition string
- fmt.Println(condition)
- //list, err := models.GetOfflineMeetingDetailList()
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //
- //for _, v := range list {
- // item := new(models.CygxActivityMeetDetailLog)
- // item.ActivityId = v.ActivityId
- // item.RealName = v.RealName
- // item.Mobile = v.Mobile
- // item.CompanyName = v.CompanyName
- // item.CompanyId = v.CompanyId
- // item.CreateTime = v.CreateTime
- // newId, err := models.AddCygxActivityMeetDetailLog(item)
- // if err != nil {
- // br.Msg = "同步失败"
- // br.ErrMsg = "新增优化建议失败,Err:" + err.Error()
- // return
- // }
- // fmt.Println(newId)
- //}
- //list, err := models.GetActivityMeetDetailLog()
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //for _, v := range list {
- // condition = ` AND company_name = '` + v.CompanyName + `' `
- // total, err := models.GetActivityMeetDetailLogCount(condition)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- // }
- // fmt.Println(v.CompanyName, total)
- // err = models.UpdateActivityMeetDetailLog(v.CompanyName, total)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- // }
- //}
- //list, err := models.GetActivityMeetDetailLogByMobile()
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //for _, v := range list {
- // condition = ` AND mobile = '` + v.Mobile + `' `
- // total, err := models.GetActivityMeetDetailLogCount(condition)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- // }
- // fmt.Println(v.Mobile, total)
- // err = models.UpdateActivityMeetDetailLogByUser(v.Mobile, total)
- // if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- // }
- //}
- resp := new(models.ArticleDetailResp)
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 同步策略报告分类
- // @Description 同步策略报告内容接口
- // @Param ArticleIdMd5 query int true "报告ID"
- // @Success 200 {object} models.ArticleDetailResp
- // @router /look/industry [get]
- func (this *ArticleCommonController) Industry() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- url := "https://vmp.hzinsights.com/v2api/articles/industry"
- method := "GET"
- client := &nhttp.Client{}
- req, err := nhttp.NewRequest(method, url, nil)
- if err != nil {
- fmt.Println(err)
- return
- }
- req.Header.Add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag")
- res, err := client.Do(req)
- if err != nil {
- fmt.Println(err)
- return
- }
- defer res.Body.Close()
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- fmt.Println(err)
- return
- }
- var pdfResult models.ArticleIndustryApi
- err = json.Unmarshal(body, &pdfResult)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "Unmarshal,Err:" + err.Error()
- return
- }
- listData := pdfResult.Data
- //var list []*models.Tactics2
- for _, v := range listData {
- item := new(models.Tactics2)
- for _, v2 := range v.Series {
- fmt.Println(v2.Name)
- item.Body = v2.Name
- //fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
- //fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
- //fmt.Println(v.Name, "+", v2.Name, "+", v2.Id)
- }
- //list = append(list, item)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = string(body)
- }
|