infodetaillogic.go 1.5 KB

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