infodetaillogic.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyInfo/rpc/model"
  4. "app.yhyue.com/moapp/jyInfo/rpc/util"
  5. se "app.yhyue.com/moapp/jybase/encrypt"
  6. "context"
  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. data := make(map[string]interface{})
  41. msgId := se.SE.DecodeString(in.MsgId)
  42. switch in.Type {
  43. case 1, 2:
  44. if _d := model.Mysql.SelectBySql(`SELECT a.*,b.title as relatedTitle FROM information a
  45. LEFT JOIN information b on (a.related_id =b.id) where a.id =? and a.app_id = `+util.StrFormat(in.AppId), msgId); _d != nil && len(*_d) > 0 {
  46. data = (*_d)[0]
  47. var (
  48. related manager.Related
  49. )
  50. infoData.Code = common.InterfaceToStr(data["project_code"])
  51. infoData.Industry = strings.Split(common.InterfaceToStr(data["industry"]), ",")
  52. infoData.Buyer = common.InterfaceToStr(data["buyer"])
  53. infoData.Budget = common.Float64All(data["budget"])
  54. infoData.Winner = common.InterfaceToStr(data["winner"])
  55. infoData.Amount = common.Float64All(data["amount"])
  56. infoData.Detail = common.InterfaceToStr(data["detail"])
  57. if data["related_id"] != nil && common.IntAll(data["related_id"]) != 0 {
  58. related.Id = se.SE.EncodeString(common.InterfaceToStr(data["related_id"])) //关联信息id加密
  59. related.Title = common.InterfaceToStr(data["relatedTitle"])
  60. infoData.Related = &related
  61. }
  62. } else {
  63. dataRes.ErrCode = -1
  64. dataRes.ErrMsg = "查询数据失败"
  65. goto env
  66. }
  67. case 3:
  68. if _d := model.Mysql.SelectBySql(`SELECT * FROM supply_info where id = ? and app_id = `+util.StrFormat(in.AppId), msgId); _d != nil && len(*_d) > 0 {
  69. data = (*_d)[0]
  70. infoData.ValidityTime = common.InterfaceToStr(data["validity_time"])
  71. } else {
  72. dataRes.ErrCode = -1
  73. dataRes.ErrMsg = "查询数据失败"
  74. goto env
  75. }
  76. default:
  77. dataRes.ErrCode = -1
  78. dataRes.ErrMsg = "数据类型有误"
  79. return &dataRes, nil
  80. }
  81. infoData.Province = common.InterfaceToStr(data["province"])
  82. infoData.City = common.InterfaceToStr(data["city"])
  83. infoData.AppId = common.InterfaceToStr(data["app_id"])
  84. infoData.Title = common.InterfaceToStr(data["title"])
  85. infoData.MsgType = common.Int64All(data["type"])
  86. infoData.Detail = common.InterfaceToStr(data["detail"])
  87. infoData.Attach = common.InterfaceToStr(data["attach"])
  88. infoData.PublishStatus = common.Int64All(data["published"])
  89. infoData.Phone = common.InterfaceToStr(data["phone"])
  90. applyInfo.UserId = common.InterfaceToStr(data["user_id"]) //用户id加密
  91. applyInfo.Time = common.InterfaceToStr(data["create_time"])
  92. applyInfo.EntId = common.Int64All(data["ent_id"])
  93. applyInfo.Phone = common.InterfaceToStr(data["phone"])
  94. infoData.ApplyInfo = &applyInfo
  95. review.Status = common.Int64All(data["status"])
  96. review.Time = common.InterfaceToStr(data["review_time"])
  97. review.Detail = common.InterfaceToStr(data["review_desc"])
  98. review.Name = common.InterfaceToStr(data["review_name"])
  99. infoData.Review = &review
  100. contact.Name = common.InterfaceToStr(data["contact_person"])
  101. contact.Phone = common.InterfaceToStr(data["contact_phone"])
  102. contact.Overt = common.Int64All(data["contact_overt"])
  103. infoData.Contact = &contact
  104. sensitive.Detail = common.InterfaceToStr(data["sensitive_detail"])
  105. sensitive.Title = common.InterfaceToStr(data["sensitive_title"])
  106. sensitive.Attach = common.InterfaceToStr(data["sensitive_attach"])
  107. infoData.Sensitive = &sensitive
  108. dataRes.Data = &infoData
  109. env:
  110. return &dataRes, nil
  111. }