更新名单接口,优化内容访问接口的方式,新增工具类操作外部接口

11111
zhouj1203@hotmail.com 4 months ago
parent 678e7d302b
commit 5200ec6f8c

@ -117,17 +117,18 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- 修改后的jjwt --> <!-- 修改后的jjwt
<dependency> <dependency>
<groupId>jsonwebtoken</groupId> <groupId>jsonwebtoken</groupId>
<artifactId>habook-jjwt</artifactId> <artifactId>habook-jjwt</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
</dependency> </dependency>
<!-- <dependency> -->
<dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
<version>0.9.1</version> <version>0.9.1</version>
</dependency>--> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -159,12 +160,12 @@
<!-- 指定依赖的作用范围 --> <!-- 指定依赖的作用范围 -->
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--用于在Java对象和JSON数据之间进行快速、高效的转换-->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.78</version> <version>2.0.48</version>
</dependency> </dependency>
<!--用于在Java对象和JSON数据之间进行快速、高效的转换-->
</dependencies> </dependencies>
<!-- 私服 --> <!-- 私服 -->

@ -1,18 +1,11 @@
package cn.teammodel.controller.admin.controller; package cn.teammodel.controller.admin.controller;
import cn.teammodel.common.R; import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.AdminIndexDutyService;
import cn.teammodel.controller.admin.service.ArtService; 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.art.ArtFindDto;
import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto; import cn.teammodel.model.dto.admin.common.GroupDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto; import cn.teammodel.model.dto.admin.common.RGroupList;
import cn.teammodel.model.vo.admin.ArtElementsVo; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -21,7 +14,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("admin/art") @RequestMapping("admin/art")
@ -37,5 +29,11 @@ public class ArtController {
List<ArtElementsVo> res = ArtService.getArtList(artFindDto,request); List<ArtElementsVo> res = ArtService.getArtList(artFindDto,request);
return R.success(res); return R.success(res);
} }
@PostMapping("getGroupList")
@ApiOperation("获取当前学校指定成员名单详细信息")
public R<List<RGroupList>> findGroups(@Valid @RequestBody GroupDto groupDto, HttpServletRequest request) {
List<RGroupList> res = ArtService.getGroupList(groupDto,request);
return R.success(res);
}
} }

@ -1,12 +1,14 @@
package cn.teammodel.controller.admin.service; package cn.teammodel.controller.admin.service;
import cn.teammodel.model.dto.admin.art.ArtFindDto; 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 cn.teammodel.model.vo.admin.ArtElementsVo;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
public interface ArtService { public interface ArtService {
List<ArtElementsVo> getArtList(ArtFindDto artFindDto, HttpServletRequest request); List<ArtElementsVo> getArtList(ArtFindDto artFindDto, HttpServletRequest request);
List<RGroupList> getGroupList(GroupDto groupDto, HttpServletRequest request);
} }

@ -21,6 +21,7 @@ import cn.teammodel.repository.DutyRecordRepository;
import cn.teammodel.repository.SchoolRepository; import cn.teammodel.repository.SchoolRepository;
import cn.teammodel.repository.TeacherRepository; import cn.teammodel.repository.TeacherRepository;
import cn.teammodel.security.utils.SecurityUtil; import cn.teammodel.security.utils.SecurityUtil;
import cn.teammodel.utils.GroupUtil;
import cn.teammodel.utils.JsonUtil; import cn.teammodel.utils.JsonUtil;
import cn.teammodel.utils.SchoolDateUtil; import cn.teammodel.utils.SchoolDateUtil;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest; import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
@ -228,50 +229,14 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
public Map<String, Object> getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) { public Map<String, Object> getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) {
Map<String, Object> mapper = new HashMap<>(); Map<String, Object> mapper = new HashMap<>();
String apiUrl = env.getProperty("ies.server-url"); String url = env.getProperty("ies.server-url");
if(lessonRecordDto.isClassMeeting()) { if(lessonRecordDto.isClassMeeting()) {
List<School.Subject> subjects = schoolRepository.findSubjectById(lessonRecordDto.getSchool(), lessonRecordDto.getPeriodId()); List<School.Subject> subjects = schoolRepository.findSubjectById(lessonRecordDto.getSchool(), lessonRecordDto.getPeriodId());
List<String> subjectIds = subjects.stream().filter(subject -> "班会".equals(subject.getName())) List<String> subjectIds = subjects.stream().filter(subject -> "班会".equals(subject.getName()))
.map(School.Subject::getId).collect(Collectors.toList()); .map(School.Subject::getId).collect(Collectors.toList());
lessonRecordDto.setSubjectId(subjectIds); lessonRecordDto.setSubjectId(subjectIds);
} }
mapper = GroupUtil.getGroupId(lessonRecordDto,new GroupUtil(env), request,url);
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());
}
return mapper; return mapper;
} }
} }

@ -1,12 +1,10 @@
package cn.teammodel.controller.admin.service.impl; package cn.teammodel.controller.admin.service.impl;
import cn.teammodel.common.PK;
import cn.teammodel.controller.admin.service.ArtService; import cn.teammodel.controller.admin.service.ArtService;
import cn.teammodel.model.dto.admin.art.ArtFindDto; import cn.teammodel.model.dto.admin.art.ArtFindDto;
import cn.teammodel.model.dto.admin.common.GroupDto; import cn.teammodel.model.dto.admin.common.GroupDto;
import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.dto.admin.common.RGroupList;
import cn.teammodel.model.dto.admin.common.RMember; 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.model.vo.admin.ArtElementsVo;
import cn.teammodel.repository.ArtRepository; import cn.teammodel.repository.ArtRepository;
import cn.teammodel.repository.ClassRepository; import cn.teammodel.repository.ClassRepository;
@ -42,8 +40,9 @@ public class ArtServiceImpl implements ArtService {
GroupDto groupDto = new GroupDto(); GroupDto groupDto = new GroupDto();
groupDto.setIds(classIds); groupDto.setIds(classIds);
groupDto.setSchoolId(artFindDto.getCode()); groupDto.setSchoolId(artFindDto.getCode());
String url = env.getProperty("ies.server-url-group");
//List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds); //List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds);
Map<String, Object> groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request); Map<String, Object> groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request,url);
List<RGroupList> rGroupList = new ArrayList<>(); List<RGroupList> rGroupList = new ArrayList<>();
List<RMember> rMembers = new ArrayList<>(); List<RMember> rMembers = new ArrayList<>();
for (Map.Entry<String, Object> entry : groupId.entrySet()) { for (Map.Entry<String, Object> entry : groupId.entrySet()) {
@ -79,4 +78,27 @@ public class ArtServiceImpl implements ArtService {
} }
return artElementsVos; return artElementsVos;
} }
@Override
public List<RGroupList> getGroupList(GroupDto groupDto, HttpServletRequest request) {
List<RGroupList> rGroupList = new ArrayList<>();
String url = env.getProperty("ies.server-url-group");
try {
Map<String, Object> groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request,url);
//List<RMember> rMembers = new ArrayList<>();
for (Map.Entry<String, Object> 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<List<RGroupList>>() {});
}
}
}catch (Exception e) {
throw new RuntimeException(e);
}
return rGroupList;
}
} }

@ -28,9 +28,18 @@ public class GroupUtil {
public GroupUtil(Environment env) { public GroupUtil(Environment env) {
this.env = env; this.env = env;
} }
public static Map<String, Object> getGroupId(GroupDto dto, GroupUtil groupUtil, HttpServletRequest request) { public static Map<String, Object> getGroupId(Object obj, GroupUtil groupUtil, HttpServletRequest request,String url) {
Map<String, Object> mapper = new HashMap<>(); Map<String, Object> 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()) { try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 创建HttpPost对象 // 创建HttpPost对象
HttpPost httpPost = new HttpPost(apiUrl); HttpPost httpPost = new HttpPost(apiUrl);
@ -44,7 +53,7 @@ public class GroupUtil {
// 设置请求体 // 设置请求体
//JsonUtil.convertToJson(dto); //JsonUtil.convertToJson(dto);
//String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId); //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)) { try (CloseableHttpResponse response = httpClient.execute(httpPost)) {

@ -68,5 +68,5 @@ ding:
server-url: https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6 server-url: https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6
#IES 课堂记录 #IES 课堂记录
ies: ies:
server-url: https://www.teammodel.cn/common/lesson-record/get-lesson-record server-url: /common/lesson-record/get-lesson-record
server-url-group: https://www.teammodel.cn/grouplist/get-members-listids server-url-group: /grouplist/get-members-listids
Loading…
Cancel
Save