infodetaillogic.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. T "bp.jydev.jianyu360.cn/CRM/application/api/common"
  6. "context"
  7. "fmt"
  8. "bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
  9. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type InfoDetailLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoDetailLogic {
  18. return &InfoDetailLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. type Infomation struct {
  25. Title string `ch:"title"`
  26. Summary string `ch:"summary"`
  27. Content string `ch:"content"`
  28. Basis string `ch:"basis"`
  29. Area string `ch:"area"`
  30. City string `ch:"city"`
  31. DataJsonId string `ch:"datajson_id"`
  32. ProjectName string `json:"project_name"`
  33. Href string `json:"href"`
  34. }
  35. func (l *InfoDetailLogic) InfoDetail(req *types.InfoDetailReq) (resp *types.Reply, err error) {
  36. resp = &types.Reply{}
  37. sql := `SELECT title, summary, content, basis, area, city, datajson_id FROM information.information WHERE id = ?`
  38. info := Infomation{}
  39. err = T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId).ScanStruct(&info)
  40. if err == nil {
  41. info.DataJsonId = encrypt.CommonEncodeArticle("content", info.DataJsonId)
  42. binfo, b := T.MgoBidding.FindById("bidding", info.DataJsonId, map[string]interface{}{"title": 1, "projectname": 1})
  43. if b && binfo != nil && len(*binfo) > 0 {
  44. info.ProjectName = common.ObjToString((*binfo)["projectname"])
  45. info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", info.DataJsonId))
  46. }
  47. resp.Data = info
  48. } else {
  49. resp.Error_code = -1
  50. resp.Error_msg = "未查询到情报信息"
  51. }
  52. return
  53. }