inforelatedlogic.go 1.5 KB

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