inforelatedlogic.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerclient"
  4. "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
  5. "app.yhyue.com/moapp/jyInfo/rpc/model"
  6. "app.yhyue.com/moapp/jyInfo/rpc/util"
  7. se "app.yhyue.com/moapp/jybase/encrypt"
  8. "context"
  9. mc "app.yhyue.com/moapp/jybase/common"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type InfoRelatedLogic struct {
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. logx.Logger
  16. }
  17. func NewInfoRelatedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoRelatedLogic {
  18. return &InfoRelatedLogic{
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. Logger: logx.WithContext(ctx),
  22. }
  23. }
  24. // 关联公告
  25. func (l *InfoRelatedLogic) InfoRelated(in *consumerclient.UserIdReq) (*consumerclient.InfoRelatedResp, error) {
  26. // todo: add your logic here and delete this line
  27. var (
  28. queryName string
  29. resp consumerclient.InfoRelatedResp
  30. )
  31. queryName = ` and type=` + mc.InterfaceToStr(in.MsgType)
  32. if in.Match != "" {
  33. queryName = queryName + ` and title LIKE '%` + in.Match + `%' `
  34. }
  35. if in.AppId != "" {
  36. queryName = queryName + ` and app_id = ` + util.StrFormat(in.AppId)
  37. }
  38. allData := model.Mysql.SelectBySql(`SELECT id,title from information WHERE user_id="` + in.UserId + `" and published=2 and is_del=1` + queryName + ` order by create_time desc limit 50`)
  39. if allData == nil || len(*allData) == 0 {
  40. return &resp, nil
  41. }
  42. for _, v := range *allData {
  43. var data consumerclient.InfoData
  44. data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密
  45. data.Title = mc.InterfaceToStr(v["title"])
  46. resp.Data = append(resp.Data, &data)
  47. }
  48. return &resp, nil
  49. }