inforelatedlogic.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. "log"
  10. mc "app.yhyue.com/moapp/jybase/common"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type InfoRelatedLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewInfoRelatedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoRelatedLogic {
  19. return &InfoRelatedLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 关联公告
  26. func (l *InfoRelatedLogic) InfoRelated(in *consumerclient.UserIdReq) (*consumerclient.InfoRelatedResp, error) {
  27. // todo: add your logic here and delete this line
  28. var (
  29. queryName string
  30. resp consumerclient.InfoRelatedResp
  31. )
  32. log.Println("关联公告接口调用", in)
  33. queryName = ` and type=` + mc.InterfaceToStr(in.MsgType)
  34. if in.Match != "" {
  35. queryName = queryName + ` and title LIKE '%` + in.Match + `%' `
  36. }
  37. if in.AppId != "" {
  38. queryName = queryName + ` and app_id = ` + util.StrFormat(in.AppId)
  39. }
  40. if in.EntId != 0 {
  41. queryName = queryName + ` and ent_id = ` + mc.InterfaceToStr(in.EntId)
  42. }
  43. 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`)
  44. if allData == nil || len(*allData) == 0 {
  45. return &resp, nil
  46. }
  47. for _, v := range *allData {
  48. var data consumerclient.InfoData
  49. data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密
  50. data.Title = mc.InterfaceToStr(v["title"])
  51. resp.Data = append(resp.Data, &data)
  52. }
  53. return &resp, nil
  54. }