| package com.xzx.gc.system.controller;  | 
|   | 
| import cn.hutool.core.convert.Convert;  | 
| import cn.jpush.api.push.model.audience.Audience;  | 
| import com.xzx.gc.common.Result;  | 
| import com.xzx.gc.common.annotations.PassToken;  | 
| import com.xzx.gc.common.constant.CommonEnum;  | 
| import com.xzx.gc.common.request.BaseController;  | 
| import com.xzx.gc.common.utils.JGUtil;  | 
| import com.xzx.gc.model.MapDto;  | 
| import com.xzx.gc.system.dto.PushDto;  | 
| import io.swagger.annotations.Api;  | 
| import io.swagger.annotations.ApiOperation;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.validation.annotation.Validated;  | 
| import org.springframework.web.bind.annotation.GetMapping;  | 
| import org.springframework.web.bind.annotation.RequestMapping;  | 
| import org.springframework.web.bind.annotation.RestController;  | 
|   | 
| import java.util.HashMap;  | 
| import java.util.Map;  | 
|   | 
| /**  | 
|  * @author :zz  | 
|  */  | 
| @RestController  | 
| @RequestMapping("/push")  | 
| @Api(tags = {"推送管理"})  | 
| @Validated  | 
| public class PushController extends BaseController {  | 
|     @Autowired  | 
|     private JGUtil jgUtil;  | 
|   | 
|   | 
|     @GetMapping("/jg")  | 
|     @ApiOperation(value = "极光推送")  | 
|     @PassToken  | 
|     public Result add(PushDto pushDto){  | 
|         String msg=null;  | 
|         MapDto mapDto = pushDto.getMapDto();  | 
|         Map<String,String> extra=new HashMap<>();  | 
|         if(mapDto!=null){  | 
|             extra.put(mapDto.getKey(),mapDto.getValue());  | 
|         }  | 
|         if(CommonEnum.点对点.getValue().equals(Convert.toStr(pushDto.getType()))){  | 
|             msg= jgUtil.sendByAnroid(pushDto.getAlert(), pushDto.getTitle(), extra, Audience.alias(pushDto.getId()));  | 
|         }else if(CommonEnum.群发.getValue().equals(Convert.toStr(pushDto.getType()))){  | 
|             msg=jgUtil.sendByAnroid(pushDto.getAlert(), pushDto.getTitle(), extra, Audience.tag(pushDto.getId()));  | 
|         }  | 
|         if(msg==null){  | 
|             return Result.success("推送成功");  | 
|         }else {  | 
|             return Result.error(-1,"推送失败:"+msg);  | 
|         }  | 
|     }  | 
| }  |