12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package cn.com.qmth.examcloud.tool.service;
- import cn.com.qmth.examcloud.tool.config.SysProperty;
- import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.CourseVO;
- import cn.com.qmth.examcloud.tool.utils.HttpHelper;
- import cn.com.qmth.examcloud.tool.utils.JsonMapper;
- import cn.com.qmth.examcloud.tool.vo.Pager;
- import cn.com.qmth.examcloud.tool.vo.User;
- import com.fasterxml.jackson.core.type.TypeReference;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @Component
- public class CommonService {
- private final static Logger log = LoggerFactory.getLogger(CommonService.class);
- @Autowired
- private SysProperty sysProperty;
- public User login(String domain, String loginName, String password) {
- Map<String, Object> params = new HashMap<>();
- // params.put("rootOrgId", 0L);
- params.put("domain", domain);
- params.put("accountType", "COMMON_LOGIN_NAME");
- params.put("accountValue", loginName);
- params.put("password", password);
- String url = sysProperty.getServerUrl() + "/api/ecs_core/auth/login";
- String result = HttpHelper.post(url, null, params);
- log.info("LOGIN_IN {}", result);
- return new JsonMapper().parseJson(result, User.class);
- }
- /**
- * 获取考试相关的课程列表
- */
- public List<CourseVO> getExamCourseList(String key, String token, Long examId) {
- Map<String, Object> params = new HashMap<>();
- params.put("examId", examId);
- params.put("pageNo", 1);
- params.put("pageSize", 1000);
- Map<String, String> headers = new HashMap<>();
- headers.put("key", key);
- headers.put("token", token);
- String url = sysProperty.getServerUrl() + "/api/ecs_exam_work/exam/course/list";
- String json = HttpHelper.post(url, headers, params);
- JsonMapper jsonMapper = new JsonMapper();
- Pager<CourseVO> page = jsonMapper.parseJson(json, new TypeReference<Pager<CourseVO>>() {
- });
- if (page != null && page.getContent() != null) {
- return page.getContent();
- }
- return new ArrayList<>();
- }
- }
|