infodetaillogic.go 4.3 KB

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