infodetaillogic.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. logx.Info(fmt.Sprintf("%+v", req))
  37. resp = &types.Reply{}
  38. sql := `SELECT title, summary, content, basis, area, city, datajson_id FROM information.information WHERE id = ?`
  39. info := Infomation{}
  40. row := T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId)
  41. err1 := row.ScanStruct(&info)
  42. if err1 == nil {
  43. info.DataJsonId = encrypt.EncodeArticleId2ByCheck(info.DataJsonId)
  44. binfo, b := T.MgoBidding.FindById("bidding", info.DataJsonId, map[string]interface{}{"title": 1, "projectname": 1})
  45. if b && binfo != nil && len(*binfo) > 0 {
  46. info.ProjectName = common.ObjToString((*binfo)["projectname"])
  47. info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.EncodeArticleId2ByCheck(info.DataJsonId))
  48. }
  49. resp.Data = info
  50. } else {
  51. resp.Error_code = -1
  52. resp.Error_msg = "未查询到情报信息"
  53. }
  54. return
  55. }