inforelatedlogic.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package logic
  2. import (
  3. se "app.yhyue.com/moapp/jybase/encrypt"
  4. "context"
  5. "jyInfo/rpc/model"
  6. "jyInfo/rpc/consumer/consumer"
  7. "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. quryname string
  28. resq consumer.InfoRelatedResp
  29. )
  30. quryname = ` and type=` + mc.InterfaceToStr(in.MsqType)
  31. if in.Match != "" {
  32. quryname = ` and title LIKE '%` + in.Match + `%' `
  33. }
  34. allData := model.Mysql.SelectBySql(`SELECT id,title from information WHERE user_id="` + in.UserId + `" and published=2 and is_del=1` + quryname + ` order by create_time desc limit 50`)
  35. if allData == nil || len(*allData) == 0 {
  36. return &resq, nil
  37. }
  38. for _, v := range *allData {
  39. var data consumer.InfoData
  40. data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密
  41. data.Title = mc.InterfaceToStr(v["title"])
  42. resq.Data = append(resq.Data, &data)
  43. }
  44. return &resq, nil
  45. }