infodetaillogic.go 4.1 KB

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