mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
feign服务封装
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
package com.xboe.api;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.boe.feign.api.courseweb.entity.ExamTestDto;
|
||||
import com.boe.feign.api.courseweb.entity.ProjectStudyDto;
|
||||
import com.boe.feign.api.courseweb.remote.OffCourseRemoteClient;
|
||||
import com.boe.feign.api.courseweb.remote.ProjectAdminRemoteClient;
|
||||
import com.boe.feign.api.courseweb.remote.ProjectRemoteClient;
|
||||
import com.xboe.api.vo.*;
|
||||
import com.xboe.module.course.vo.StudyCourseVo;
|
||||
import com.xboe.module.course.vo.TeacherInfoVo;
|
||||
@@ -18,9 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -37,7 +45,6 @@ public class ThirdApi {
|
||||
@Value("${orgTree.orgChildTreeList}")
|
||||
private String orgChildTreeListUrl;
|
||||
|
||||
|
||||
@Value("${audience.usersByAudienceList}")
|
||||
private String usersByAudienceList;
|
||||
|
||||
@@ -53,25 +60,24 @@ public class ThirdApi {
|
||||
@Value("${infrasApi.dict}")
|
||||
private String infarasApiUrl;
|
||||
|
||||
@Value("${manageApi.stu.offcourse}")
|
||||
private String manageApiStu;
|
||||
|
||||
@Value("${audience.getOrgUsers}")
|
||||
private String searchOrgUsersUrl;
|
||||
|
||||
@Value("${userBasic.getTeacherIds}")
|
||||
private String getTeacherIds;
|
||||
|
||||
|
||||
@Value("${coursesuilt.getStudyStatus}")
|
||||
private String getStudyStatus;
|
||||
|
||||
@Value("${manageApi.editExam}")
|
||||
private String editExam;
|
||||
|
||||
@Value("${userBasic.getUserBasicInfo}")
|
||||
private String getUserBasicInfo;
|
||||
|
||||
@Resource
|
||||
private ProjectAdminRemoteClient projectAdminRemoteClient;
|
||||
|
||||
@Resource
|
||||
private OffCourseRemoteClient offCourseRemoteClient;
|
||||
|
||||
@Resource
|
||||
private ProjectRemoteClient projectRemoteClient;
|
||||
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId() {
|
||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl + "?pid=316&type=1").execute() //prod 316
|
||||
@@ -97,9 +103,10 @@ public class ThirdApi {
|
||||
//获取面授课id
|
||||
public List<String> getOffCourseId(String userId, String token) {
|
||||
log.info("正在获取面授课id");
|
||||
String s = Optional.ofNullable(HttpRequest.get(manageApiStu + "?userId=" + userId).header("token", token).execute()
|
||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
return Opt.ofBlankAble(s).map(t -> JSONUtil.toBean(t, StringResult.class)).map(StringResult::getData).orElseThrow();
|
||||
return offCourseRemoteClient.getOffCourseId(userId);
|
||||
// String s = Optional.ofNullable(HttpRequest.get("?userId=" + userId).header("token", token).execute()
|
||||
// .body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
// return Opt.ofBlankAble(s).map(t -> JSONUtil.toBean(t, StringResult.class)).map(StringResult::getData).orElseThrow();
|
||||
}
|
||||
|
||||
//获取离职教师信息
|
||||
@@ -213,20 +220,30 @@ public class ThirdApi {
|
||||
StudyCourseVo studyCourseVo = new StudyCourseVo();
|
||||
studyCourseVo.setStudyId(studyId);
|
||||
studyCourseVo.setCourseId(courseId);
|
||||
String resp = Optional.ofNullable(
|
||||
HttpRequest.post(getStudyStatus).body(JSONUtil.toJsonStr(studyCourseVo)).header("token", token).execute()
|
||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
StudyCourseResult studyCourseResult = JSONUtil.toBean(resp, StudyCourseResult.class);
|
||||
log.info("getTeacherIdsResult = " + studyCourseResult);
|
||||
return studyCourseResult.getResult();
|
||||
ProjectStudyDto projectStudyDto = new ProjectStudyDto();
|
||||
BeanUtil.copyProperties(studyCourseVo, studyCourseVo);
|
||||
projectRemoteClient.updateStudyStatus(null, projectStudyDto);
|
||||
return new ArrayList<>();
|
||||
// String resp = Optional.ofNullable(
|
||||
// HttpRequest.post(getStudyStatus).body(JSONUtil.toJsonStr(studyCourseVo)).header("token", token).execute()
|
||||
// .body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
// StudyCourseResult studyCourseResult = JSONUtil.toBean(resp, StudyCourseResult.class);
|
||||
// log.info("getTeacherIdsResult = " + studyCourseResult);
|
||||
// return studyCourseResult.getResult();
|
||||
}
|
||||
|
||||
public void sqlUpdate(ExamTest examTest, String token) {
|
||||
examTest.setSysUpdateTime(null);
|
||||
examTest.setSysCreateTime(null);
|
||||
examTest.setPublishTime(null);
|
||||
String resp = Optional.ofNullable(HttpRequest.post(editExam).body(JSONUtil.toJsonStr(examTest)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
Opt.ofBlankAble(resp).map(t -> JSONUtil.toBean(t, DynamicBean.class).success());
|
||||
ExamTestDto examTestDto = new ExamTestDto();
|
||||
|
||||
BeanUtil.copyProperties(examTest, examTestDto);
|
||||
examTestDto.setShowAnswer(examTest.getShowAnswer() ? "true" : "false");
|
||||
|
||||
projectAdminRemoteClient.editExam(examTestDto);
|
||||
// String resp = Optional.ofNullable(HttpRequest.post(editExam).body(JSONUtil.toJsonStr(examTest)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
// Opt.ofBlankAble(resp).map(t -> JSONUtil.toBean(t, DynamicBean.class).success());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user