update
This commit is contained in:
@@ -6,7 +6,8 @@ import cn.pluss.platform.api.ResultGenerator;
|
||||
import cn.pluss.platform.entitiy.PushCidAlias;
|
||||
import cn.pluss.platform.entity.UserApp;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.MobV2PushUtil;
|
||||
import cn.pluss.platform.util.MobV2PushUtilAndroid;
|
||||
import cn.pluss.platform.util.MobV2PushUtilIOS;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Setter;
|
||||
@@ -20,9 +21,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -68,15 +69,28 @@ public class PushController {
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
@PostMapping("/bindalias")
|
||||
public Result<Object> bindAlias(@RequestBody Map<String, Object> param) throws IOException, NoSuchAlgorithmException {
|
||||
public Result<Object> bindAlias(@RequestBody Map<String, Object> param, HttpServletRequest httpServletRequest) throws IOException, NoSuchAlgorithmException {
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
String uid = userApp.getUserId().toString();
|
||||
String cid = param.get("cid").toString();
|
||||
|
||||
MobV2PushUtil mobV2PushUtil = new MobV2PushUtil();
|
||||
String token = mobV2PushUtil.getToken();
|
||||
String deviceType = httpServletRequest.getHeader("type");
|
||||
|
||||
String token = "";
|
||||
String aliasUrl = "";
|
||||
|
||||
if (deviceType.equals("1")) {
|
||||
MobV2PushUtilAndroid mobV2PushUtil = new MobV2PushUtilAndroid();
|
||||
token = mobV2PushUtil.getToken();
|
||||
aliasUrl = "https://restapi.getui.com/v2/" + MobV2PushUtilAndroid.appId + "/user/alias";
|
||||
|
||||
} else if (deviceType.equals("2")) {
|
||||
MobV2PushUtilIOS mobV2PushUtilIOS = new MobV2PushUtilIOS();
|
||||
token = mobV2PushUtilIOS.getToken();
|
||||
aliasUrl = "https://restapi.getui.com/v2/" + MobV2PushUtilIOS.appId + "/user/alias";
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
@@ -99,8 +113,7 @@ public class PushController {
|
||||
// 设置为UTF8编码
|
||||
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||
|
||||
String tokenInfo = restTemplate.postForObject(
|
||||
"https://restapi.getui.com/v2/" + MobV2PushUtil.appId + "/user/alias", httpEntity,
|
||||
String tokenInfo = restTemplate.postForObject(aliasUrl, httpEntity,
|
||||
String.class);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -122,15 +135,28 @@ public class PushController {
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
@PostMapping("/unbindingAlias")
|
||||
public Result<Object> unbindingAlias(@RequestBody Map<String, Object> param) throws IOException, NoSuchAlgorithmException {
|
||||
public Result<Object> unbindingAlias(@RequestBody Map<String, Object> param,HttpServletRequest httpServletRequest) throws IOException, NoSuchAlgorithmException {
|
||||
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
|
||||
String uid = userApp.getUserId().toString();
|
||||
String cid = param.get("cid").toString();
|
||||
|
||||
MobV2PushUtil mobV2PushUtil = new MobV2PushUtil();
|
||||
String token = mobV2PushUtil.getToken();
|
||||
String deviceType = httpServletRequest.getHeader("type");
|
||||
|
||||
String token = "";
|
||||
String aliasUrl = "";
|
||||
|
||||
if (deviceType.equals("1")) {
|
||||
MobV2PushUtilAndroid mobV2PushUtil = new MobV2PushUtilAndroid();
|
||||
token = mobV2PushUtil.getToken();
|
||||
aliasUrl = "https://restapi.getui.com/v2/" + MobV2PushUtilAndroid.appId + "/user/alias";
|
||||
|
||||
} else if (deviceType.equals("2")) {
|
||||
MobV2PushUtilIOS mobV2PushUtilIOS = new MobV2PushUtilIOS();
|
||||
token = mobV2PushUtilIOS.getToken();
|
||||
aliasUrl = "https://restapi.getui.com/v2/" + MobV2PushUtilIOS.appId + "/user/alias";
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
@@ -155,7 +181,7 @@ public class PushController {
|
||||
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||
|
||||
// delete, entity直接设为null即可
|
||||
ResponseEntity<Map> resultEntity = restTemplate.exchange("https://restapi.getui.com/v2/" + MobV2PushUtil.appId + "/user/alias",
|
||||
ResponseEntity<Map> resultEntity = restTemplate.exchange(aliasUrl,
|
||||
HttpMethod.DELETE,
|
||||
httpEntity,
|
||||
Map.class);
|
||||
|
||||
Reference in New Issue
Block a user