package logic import ( MI "app.yhyue.com/moapp/jyInfo/rpc/manager/init" "app.yhyue.com/moapp/jyInfo/rpc/manager/internal/svc" "app.yhyue.com/moapp/jyInfo/rpc/manager/type/manager" "app.yhyue.com/moapp/jyInfo/rpc/model" "app.yhyue.com/moapp/jyInfo/rpc/util" mc "app.yhyue.com/moapp/jybase/common" se "app.yhyue.com/moapp/jybase/encrypt" "context" "fmt" "github.com/zeromicro/go-zero/core/logx" ) type InfoOneKeyActionLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewInfoOneKeyActionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoOneKeyActionLogic { return &InfoOneKeyActionLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 管理后台一键操作 1:管理后台一键敏感词过滤;2:管理后台一键发布;3管理后台一键删除; func (l *InfoOneKeyActionLogic) InfoOneKeyAction(in *manager.OneKeyActionReq) (*manager.InfoResp, error) { var resp = &manager.InfoResp{} if in.UserId != "" && MI.MUserIdMap[in.UserId] { msgId := se.SE.DecodeString(in.MsgId) var tname = mc.If(in.MsgType == "3", "supply_info", "information") data := model.Mysql.SelectBySql(`SELECT a.title,a.detail,a.attach FROM ? a WHERE a.id = ? AND a.type = ?`, tname, msgId, in.MsgType) if len(*data) > 0 { res := (*data)[0] switch in.Type { case 1: //一键敏感词过滤 appendInfo := make(map[string]interface{}) if res["title"] != nil { appendInfo["title"] = mc.InterfaceToStr(res["title"]) } if res["detail"] != nil { appendInfo["detail"] = mc.InterfaceToStr(res["detail"]) } if res["attach"] != nil && mc.InterfaceToStr(res["attach"]) != "{}" { appendInfo["attach"] = mc.StringToMap(mc.InterfaceToStr(res["attach"])) } nsq, err := util.NewNsqInfo(model.NsqConfig.Ip, model.NsqConfig.Topic, msgId, "1", mc.InterfaceToStr(in.MsgType), false, appendInfo) if err != nil || nsq.NsqPushInfo() != nil { resp.ErrCode = -1 resp.ErrMsg = fmt.Sprintf("nsq 发布异常:%s", res["id"]) logx.Info(resp.ErrMsg) } case 2: //一键信息发布 switch in.MsgType { case "3": //供应信息 case "1", "2": //招标信息,采购信息 //nsq发布信息 nsq, err := util.NewNsqInfo(model.NsqConfig.Ip, model.NsqConfig.Topic, msgId, "2", mc.InterfaceToStr(in.MsgType), false, res) if err != nil || nsq.NsqPushInfo() != nil { resp.ErrCode = -1 resp.ErrMsg = "调用nsq失败" } if model.Mysql.UpdateOrDeleteBySql(``) < 1 { resp.ErrCode = -1 resp.ErrMsg = resp.ErrMsg + "更新信息失败" } } } } } return resp, nil }