package logic import ( "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerinfo" "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" "log" 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 *consumerinfo.UserIdReq) (*consumerinfo.InfoRelatedResp, error) { // todo: add your logic here and delete this line var ( queryName string resp consumerinfo.InfoRelatedResp ) log.Println("关联公告接口调用", in) queryName = ` and type=` + mc.InterfaceToStr(in.MsgType) if in.AppId != "" { queryName = queryName + ` and app_id = ` + util.StrFormat(in.AppId) } if in.EntId != 0 { queryName = queryName + ` and ent_id = ` + mc.InterfaceToStr(in.EntId) } switch in.MsgId { case 0: if in.Match != "" { queryName = queryName + ` and title LIKE '%` + in.Match + `%' ` } allData := model.Mysql.SelectBySql(`SELECT * 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 consumerinfo.InfoData data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密 data.Title = mc.InterfaceToStr(v["title"]) data.Person = mc.InterfaceToStr(v["contact_person"]) data.Phone = mc.InterfaceToStr(v["contact_phone"]) data.Overt = mc.Int64All(v["contact_overt"]) data.RecommendedService = mc.Int64All(v["recommended_service"]) resp.Data = append(resp.Data, &data) } case 1: var allData *[]map[string]interface{} switch in.MsgType { case 1, 2, 4, 5, 6: allData = model.Mysql.SelectBySql(`SELECT * from information WHERE user_id="` + in.UserId + `"` + queryName + ` order by create_time desc limit 1`) case 3: allData = model.Mysql.SelectBySql(`SELECT * from supply_info WHERE user_id="` + in.UserId + `"` + queryName + ` order by create_time desc limit 1`) } if allData == nil || len(*allData) == 0 { return &resp, nil } for _, v := range *allData { var data consumerinfo.InfoData data.Id = se.SE.EncodeString(mc.InterfaceToStr(v["id"])) //关联信息加密 data.Title = mc.InterfaceToStr(v["title"]) data.Person = mc.InterfaceToStr(v["contact_person"]) data.Phone = mc.InterfaceToStr(v["contact_phone"]) data.Overt = mc.Int64All(v["contact_overt"]) data.RecommendedService = mc.Int64All(v["recommended_service"]) resp.Data = append(resp.Data, &data) } } return &resp, nil }