package me.notify.notifyServer.controller;
import me.notify.notifyServer.service.RegService;
import me.notify.notifyServer.util.JPushService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
public class NotifyController {
@Resource
RegService regService;
@Resource
JPushService pushService;
@RequestMapping("/notify")
public String saveRegId(HttpServletRequest request) {
String id = request.getParameter("id");
if (null == id || id.isEmpty()){
return "参数错误";
}
List<String> list = regService.selectRegID();
if (null == list || list.size() == 0){
return "没有设备id";
}
if (pushService.sendJPush(id, list)) {
return "按钮["+id+"]发送成功";
} else {
return "按钮["+id+"]发送失败";
}
}
}