package logic import ( "app.yhyue.com/moapp/jyInfo/rpc/model" "app.yhyue.com/moapp/jyInfo/rpc/util" se "app.yhyue.com/moapp/jybase/encrypt" "context" "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumer" "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc" mc "app.yhyue.com/moapp/jybase/common" "github.com/zeromicro/go-zero/core/logx" ) type InfoRelatedLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewInfoRelatedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoRelatedLogic { return &InfoRelatedLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 关联公告 func (l *InfoRelatedLogic) InfoRelated(in *consumer.UserIdReq) (*consumer.InfoRelatedResp, error) { // todo: add your logic here and delete this line var ( queryName string resp consumer.InfoRelatedResp ) queryName = ` and type=` + mc.InterfaceToStr(in.MsgType) if in.Match != "" { queryName = ` and title LIKE '%` + in.Match + `%' ` } if in.AppId != "" { queryName = ` and app_id = ` + util.StrFormat(in.AppId) } 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`) if allData == nil || len(*allData) == 0 { return &resp, nil } for _, v := range *allData { var data consumer.InfoData data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密 data.Title = mc.InterfaceToStr(v["title"]) resp.Data = append(resp.Data, &data) } return &resp, nil }