123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package logic
- import (
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerclient"
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
- "app.yhyue.com/moapp/jyInfo/rpc/model"
- "app.yhyue.com/moapp/jyInfo/rpc/util"
- se "app.yhyue.com/moapp/jybase/encrypt"
- "context"
- 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 *consumerclient.UserIdReq) (*consumerclient.InfoRelatedResp, error) {
- // todo: add your logic here and delete this line
- var (
- queryName string
- resp consumerclient.InfoRelatedResp
- )
- queryName = ` and type=` + mc.InterfaceToStr(in.MsgType)
- if in.Match != "" {
- queryName = queryName + ` and title LIKE '%` + in.Match + `%' `
- }
- if in.AppId != "" {
- queryName = 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 consumerclient.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
- }
|