diff --git a/pom.xml b/pom.xml index 1b125cb..f339660 100644 --- a/pom.xml +++ b/pom.xml @@ -117,17 +117,18 @@ true - + + io.jsonwebtoken jjwt 0.9.1 - --> + org.springframework.boot @@ -159,12 +160,12 @@ test - com.alibaba fastjson - 1.2.78 + 2.0.48 + diff --git a/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java b/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java index 40078f3..3c55ac2 100644 --- a/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java +++ b/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java @@ -1,18 +1,11 @@ package cn.teammodel.controller.admin.controller; import cn.teammodel.common.R; -import cn.teammodel.controller.admin.service.AdminIndexDutyService; import cn.teammodel.controller.admin.service.ArtService; -import cn.teammodel.model.dto.admin.appraise.TimeRangeDto; import cn.teammodel.model.dto.admin.art.ArtFindDto; -import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto; -import cn.teammodel.model.dto.weekDuty.LessonRecordDto; +import cn.teammodel.model.dto.admin.common.GroupDto; +import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.vo.admin.ArtElementsVo; -import cn.teammodel.model.vo.admin.DutyIndexData; -import cn.teammodel.model.vo.admin.DutyNodeRankVo; -import cn.teammodel.model.vo.admin.DutyRankPo; -import cn.teammodel.model.vo.weekDuty.DutyRecordVo; -import cn.teammodel.service.DutyService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -21,7 +14,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.util.List; -import java.util.Map; @RestController @RequestMapping("admin/art") @@ -37,5 +29,11 @@ public class ArtController { List res = ArtService.getArtList(artFindDto,request); return R.success(res); } + @PostMapping("getGroupList") + @ApiOperation("获取当前学校指定成员名单详细信息") + public R> findGroups(@Valid @RequestBody GroupDto groupDto, HttpServletRequest request) { + List res = ArtService.getGroupList(groupDto,request); + return R.success(res); + } } diff --git a/src/main/java/cn/teammodel/controller/admin/service/ArtService.java b/src/main/java/cn/teammodel/controller/admin/service/ArtService.java index a57726c..cd962bc 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/ArtService.java +++ b/src/main/java/cn/teammodel/controller/admin/service/ArtService.java @@ -1,12 +1,14 @@ package cn.teammodel.controller.admin.service; import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.common.GroupDto; +import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.vo.admin.ArtElementsVo; import javax.servlet.http.HttpServletRequest; import java.util.List; -import java.util.Map; public interface ArtService { List getArtList(ArtFindDto artFindDto, HttpServletRequest request); + List getGroupList(GroupDto groupDto, HttpServletRequest request); } diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminIndexDutyServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminIndexDutyServiceImpl.java index 155363e..8477e81 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminIndexDutyServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminIndexDutyServiceImpl.java @@ -21,6 +21,7 @@ import cn.teammodel.repository.DutyRecordRepository; import cn.teammodel.repository.SchoolRepository; import cn.teammodel.repository.TeacherRepository; import cn.teammodel.security.utils.SecurityUtil; +import cn.teammodel.utils.GroupUtil; import cn.teammodel.utils.JsonUtil; import cn.teammodel.utils.SchoolDateUtil; import com.azure.spring.data.cosmos.core.query.CosmosPageRequest; @@ -228,50 +229,14 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService { public Map getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) { Map mapper = new HashMap<>(); - String apiUrl = env.getProperty("ies.server-url"); + String url = env.getProperty("ies.server-url"); if(lessonRecordDto.isClassMeeting()) { List subjects = schoolRepository.findSubjectById(lessonRecordDto.getSchool(), lessonRecordDto.getPeriodId()); List subjectIds = subjects.stream().filter(subject -> "班会".equals(subject.getName())) .map(School.Subject::getId).collect(Collectors.toList()); lessonRecordDto.setSubjectId(subjectIds); } - - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - // 创建HttpPost对象 - HttpPost httpPost = new HttpPost(apiUrl); - - // 添加请求头 - httpPost.setHeader("Authorization", request.getHeader("Authorization")); - httpPost.setHeader("X-Auth-Authtoken", request.getHeader("X-Auth-Authtoken")); - httpPost.setHeader("Accept", "application/json"); - httpPost.setHeader("Content-Type", "application/json; charset=utf-8"); - - // 设置请求体 - JsonUtil.convertToJson(lessonRecordDto); - //String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId); - httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(lessonRecordDto))); - - // 发送请求 - try (CloseableHttpResponse response = httpClient.execute(httpPost)) { - // 获取响应实体 - HttpEntity entity = response.getEntity(); - - if (entity != null) { - // 解析响应内容 - String jsonString = EntityUtils.toString(entity); - ObjectMapper objectMapper = new ObjectMapper(); - mapper = objectMapper.readValue(jsonString, TypeFactory.defaultInstance().constructMapType(Map.class, String.class, Object.class)); - } - - // 检查响应状态码 - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode != 200) throw new RuntimeException("Failed : HTTP error code : " + statusCode); - } catch (IOException e) { - log.error("Failed : HTTP error code : {}", e.getMessage()); - } - } catch (IOException e) { - log.error("Failed : HTTP error code : {}", e.getMessage()); - } + mapper = GroupUtil.getGroupId(lessonRecordDto,new GroupUtil(env), request,url); return mapper; } } diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java index 140609f..7abe6e6 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java @@ -1,12 +1,10 @@ package cn.teammodel.controller.admin.service.impl; -import cn.teammodel.common.PK; import cn.teammodel.controller.admin.service.ArtService; import cn.teammodel.model.dto.admin.art.ArtFindDto; import cn.teammodel.model.dto.admin.common.GroupDto; import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.dto.admin.common.RMember; -import cn.teammodel.model.entity.school.ClassInfo; import cn.teammodel.model.vo.admin.ArtElementsVo; import cn.teammodel.repository.ArtRepository; import cn.teammodel.repository.ClassRepository; @@ -42,8 +40,9 @@ public class ArtServiceImpl implements ArtService { GroupDto groupDto = new GroupDto(); groupDto.setIds(classIds); groupDto.setSchoolId(artFindDto.getCode()); + String url = env.getProperty("ies.server-url-group"); //List classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds); - Map groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request); + Map groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request,url); List rGroupList = new ArrayList<>(); List rMembers = new ArrayList<>(); for (Map.Entry entry : groupId.entrySet()) { @@ -79,4 +78,27 @@ public class ArtServiceImpl implements ArtService { } return artElementsVos; } + + @Override + public List getGroupList(GroupDto groupDto, HttpServletRequest request) { + List rGroupList = new ArrayList<>(); + String url = env.getProperty("ies.server-url-group"); + try { + Map groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request,url); + //List rMembers = new ArrayList<>(); + for (Map.Entry entry : groupId.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (key.equals("groups")) { + String jsonGroups = JSON.toJSONString(value); + rGroupList = JSON.parseObject(jsonGroups, new TypeReference>() {}); + } + } + + }catch (Exception e) { + throw new RuntimeException(e); + + } + return rGroupList; + } } diff --git a/src/main/java/cn/teammodel/utils/GroupUtil.java b/src/main/java/cn/teammodel/utils/GroupUtil.java index a4d8c6f..58975d4 100644 --- a/src/main/java/cn/teammodel/utils/GroupUtil.java +++ b/src/main/java/cn/teammodel/utils/GroupUtil.java @@ -28,9 +28,18 @@ public class GroupUtil { public GroupUtil(Environment env) { this.env = env; } - public static Map getGroupId(GroupDto dto, GroupUtil groupUtil, HttpServletRequest request) { + public static Map getGroupId(Object obj, GroupUtil groupUtil, HttpServletRequest request,String url) { Map mapper = new HashMap<>(); - String apiUrl = groupUtil.env.getProperty("ies.server-url-group"); + String evnStr = groupUtil.env.getProperty("spring.env"); + String apiUrl = ""; + if (evnStr != null && evnStr.equalsIgnoreCase("dev")) { + apiUrl = "https://test.teammodel.cn" + url; + + }else { + + apiUrl = "https://www.teammodel.cn" + url; + } + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { // 创建HttpPost对象 HttpPost httpPost = new HttpPost(apiUrl); @@ -44,7 +53,7 @@ public class GroupUtil { // 设置请求体 //JsonUtil.convertToJson(dto); //String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId); - httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(dto))); + httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(obj))); // 发送请求 try (CloseableHttpResponse response = httpClient.execute(httpPost)) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3eb25b0..635bb41 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -68,5 +68,5 @@ ding: server-url: https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6 #IES 课堂记录 ies: - server-url: https://www.teammodel.cn/common/lesson-record/get-lesson-record - server-url-group: https://www.teammodel.cn/grouplist/get-members-listids \ No newline at end of file + server-url: /common/lesson-record/get-lesson-record + server-url-group: /grouplist/get-members-listids \ No newline at end of file