infodetaillogic.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyInfo/rpc/model"
  4. se "app.yhyue.com/moapp/jybase/encrypt"
  5. "context"
  6. "log"
  7. "strings"
  8. "app.yhyue.com/moapp/jybase/common"
  9. "app.yhyue.com/moapp/jyInfo/rpc/manager/internal/svc"
  10. "app.yhyue.com/moapp/jyInfo/rpc/manager/type/manager"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type InfoDetailLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoDetailLogic {
  19. return &InfoDetailLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. //InfoDetail 信息详情
  26. func (l *InfoDetailLogic) InfoDetail(in *manager.InfoDetailReq) (*manager.InfoDetailResp, error) {
  27. //userid := in.UserId
  28. var (
  29. dataRes manager.InfoDetailResp
  30. )
  31. //appid := in.AppId
  32. var (
  33. //公用信息
  34. infoData manager.InfoData
  35. applyInfo manager.ApplyInfo //申请人信息
  36. review manager.Review //审核信息
  37. contact manager.Contact //联系人信息
  38. sensitive manager.Sensitive //敏感词信息
  39. )
  40. log.Println("管理平台信息查询:", in)
  41. data := make(map[string]interface{})
  42. msgId := se.SE.DecodeString(in.MsgId)
  43. switch in.Type {
  44. case 1, 2, 4, 5, 6:
  45. if _d := model.Mysql.SelectBySql(`SELECT a.*,b.title as relatedTitle FROM information a
  46. LEFT JOIN information b on (a.related_id =b.id) where a.id =? and a.app_id = ?`, msgId, in.AppId); _d != nil && len(*_d) > 0 {
  47. data = (*_d)[0]
  48. var (
  49. related manager.Related
  50. )
  51. infoData.Code = common.InterfaceToStr(data["project_code"])
  52. infoData.Industry = strings.Split(common.InterfaceToStr(data["industry"]), ",")
  53. infoData.Buyer = common.InterfaceToStr(data["buyer"])
  54. infoData.Budget = common.Float64All(data["budget"])
  55. infoData.Winner = common.InterfaceToStr(data["winner"])
  56. infoData.Amount = common.Float64All(data["amount"])
  57. infoData.Detail = common.InterfaceToStr(data["detail"])
  58. infoData.JyPublishingMedia = common.Int64All(data["publishing_media"])
  59. infoData.RecommendedService = common.Int64All(data["recommended_service"])
  60. if data["related_id"] != nil && common.IntAll(data["related_id"]) != 0 {
  61. related.Id = se.SE.EncodeString(common.InterfaceToStr(data["related_id"])) //关联信息id加密
  62. related.Title = common.InterfaceToStr(data["relatedTitle"])
  63. infoData.Related = &related
  64. }
  65. } else {
  66. dataRes.ErrCode = -1
  67. dataRes.ErrMsg = "查询数据失败"
  68. goto env
  69. }
  70. case 3:
  71. if _d := model.Mysql.SelectBySql(`SELECT * FROM supply_info where id = ? and app_id =? `, msgId, in.AppId); _d != nil && len(*_d) > 0 {
  72. data = (*_d)[0]
  73. infoData.ValidityTime = common.InterfaceToStr(data["validity_time"])
  74. } else {
  75. dataRes.ErrCode = -1
  76. dataRes.ErrMsg = "查询数据失败"
  77. goto env
  78. }
  79. default:
  80. dataRes.ErrCode = -1
  81. dataRes.ErrMsg = "数据类型有误"
  82. return &dataRes, nil
  83. }
  84. infoData.Province = common.InterfaceToStr(data["province"])
  85. infoData.City = common.InterfaceToStr(data["city"])
  86. infoData.AppId = common.InterfaceToStr(data["app_id"])
  87. infoData.Title = common.InterfaceToStr(data["title"])
  88. infoData.MsgType = common.Int64All(data["type"])
  89. infoData.Detail = common.InterfaceToStr(data["detail"])
  90. infoData.Attach = common.InterfaceToStr(data["attach"])
  91. infoData.PublishStatus = common.Int64All(data["published"])
  92. infoData.Phone = common.InterfaceToStr(data["phone"])
  93. infoData.IsDel = common.Int64All(data["is_del"])
  94. applyInfo.UserId = common.InterfaceToStr(data["user_id"]) //用户id加密
  95. applyInfo.Time = common.InterfaceToStr(data["create_time"])
  96. applyInfo.EntId = common.Int64All(data["ent_id"])
  97. applyInfo.EntName = common.InterfaceToStr(data["ent_name"])
  98. applyInfo.Phone = common.InterfaceToStr(data["phone"])
  99. infoData.ApplyInfo = &applyInfo
  100. review.Status = common.Int64All(data["status"])
  101. review.Time = common.InterfaceToStr(data["review_time"])
  102. review.Detail = common.InterfaceToStr(data["review_desc"])
  103. review.Name = common.InterfaceToStr(data["review_name"])
  104. infoData.Review = &review
  105. contact.Name = common.InterfaceToStr(data["contact_person"])
  106. contact.Phone = common.InterfaceToStr(data["contact_phone"])
  107. contact.Overt = common.Int64All(data["contact_overt"])
  108. infoData.Contact = &contact
  109. sensitive.Detail = common.InterfaceToStr(data["sensitive_detail"])
  110. sensitive.Title = common.InterfaceToStr(data["sensitive_title"])
  111. sensitive.Attach = common.InterfaceToStr(data["sensitive_attach"])
  112. log.Println("管理平台信息详情返回log信息:", infoData.ApplyInfo)
  113. infoData.Sensitive = &sensitive
  114. dataRes.Data = &infoData
  115. env:
  116. return &dataRes, nil
  117. }