infodetaillogic.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. err = T.ClickhouseConn.QueryRow(context.TODO(), sql, req.InfoId).ScanStruct(&info)
  41. if err == nil {
  42. info.DataJsonId = encrypt.CommonEncodeArticle("content", info.DataJsonId)
  43. binfo, b := T.MgoBidding.FindById("bidding", info.DataJsonId, map[string]interface{}{"title": 1, "projectname": 1})
  44. if b && binfo != nil && len(*binfo) > 0 {
  45. info.ProjectName = common.ObjToString((*binfo)["projectname"])
  46. info.Href = fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", info.DataJsonId))
  47. }
  48. resp.Data = info
  49. } else {
  50. resp.Error_code = -1
  51. resp.Error_msg = "未查询到情报信息"
  52. }
  53. return
  54. }