|
|
@@ -11,6 +11,8 @@ import com.chuanghai.mapper.PushProjectMapper;
|
|
|
import com.chuanghai.service.PushProjectService;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
+import com.sun.xml.internal.bind.v2.util.ByteArrayOutputStreamEx;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -26,7 +28,8 @@ import java.util.Map;
|
|
|
public class PushProjectServiceImpl extends ServiceImpl<PushProjectMapper, PushProject> implements PushProjectService {
|
|
|
|
|
|
@Override
|
|
|
- public void pushProject(WeixiaoPushDTO weixiaoPushDTO) {
|
|
|
+ public Boolean pushProject(WeixiaoPushDTO weixiaoPushDTO) {
|
|
|
+ Boolean flag = Boolean.FALSE;
|
|
|
|
|
|
String app_key = weixiaoPushDTO.getApp_key();
|
|
|
String school_code = weixiaoPushDTO.getSchool_code();
|
|
|
@@ -42,7 +45,8 @@ public class PushProjectServiceImpl extends ServiceImpl<PushProjectMapper, PushP
|
|
|
tokenParams.put("app_secret", app_secret);
|
|
|
|
|
|
List<PushProject> pushProjectList = this.queryPushProject();
|
|
|
- pushProjectList.forEach(pushProject -> {
|
|
|
+ for (int i = 0; i < pushProjectList.size(); i++) {
|
|
|
+ PushProject pushProject = pushProjectList.get(i);
|
|
|
try {
|
|
|
String tokenUrl = pushProject.getUrl();
|
|
|
RestTemplate client = new RestTemplate();
|
|
|
@@ -53,15 +57,19 @@ public class PushProjectServiceImpl extends ServiceImpl<PushProjectMapper, PushP
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
Map<String, Object> jsonMap = mapper.readValue(body, new TypeReference<Map<String, Object>>() {
|
|
|
});
|
|
|
- String code = (String) jsonMap.get("code");
|
|
|
-
|
|
|
+ Integer code = (Integer) jsonMap.get("code");
|
|
|
+ if (code == 0) {
|
|
|
+ flag = Boolean.TRUE;
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
throw new RRException(BizCodeEnume.FILE_IS_PUSH);
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 添加推送项目
|
|
|
*
|