|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
@ -14,14 +15,11 @@ import com.auth0.jwt.JWTVerifier;
|
|
|
|
|
import com.auth0.jwt.algorithms.Algorithm;
|
|
|
|
|
import com.auth0.jwt.interfaces.Claim;
|
|
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.jlw.dao.ResourcesApplicationCourseDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.ResourcesApplicationDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.UniversitiesCollegesJurisdictionExperimentalSystemDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.LoginTodo;
|
|
|
|
|
import com.ibeetl.jlw.entity.ResourcesApplication;
|
|
|
|
|
import com.ibeetl.jlw.entity.UniversitiesCollegesJurisdictionExperimentalSystem;
|
|
|
|
|
import com.ibeetl.jlw.dao.*;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.web.query.ResourcesApplicationQuery;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
@ -35,10 +33,12 @@ import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.defaultIfBlank;
|
|
|
|
|
import static com.ibeetl.jlw.entity.LoginTodo.jsonToEntity;
|
|
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ResourcesApplication Service
|
|
|
|
@ -54,10 +54,8 @@ public class ResourcesApplicationService extends CoreBaseService<ResourcesApplic
|
|
|
|
|
@Autowired private ResourcesApplicationCourseService resourcesApplicationCourseService;
|
|
|
|
|
@Autowired private ResourcesApplicationCourseDao resourcesApplicationCourseDao;
|
|
|
|
|
@Autowired private UniversitiesCollegesJurisdictionExperimentalSystemDao universitiesCollegesJurisdictionExperimentalSystemDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherService teacherService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentService studentService;
|
|
|
|
|
@Autowired private TeacherDao teacherDao;
|
|
|
|
|
@Autowired private StudentDao studentDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private LoginTodoService loginTodoService;
|
|
|
|
|
|
|
|
|
@ -75,6 +73,110 @@ public class ResourcesApplicationService extends CoreBaseService<ResourcesApplic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置是否带Token 的跳转链接
|
|
|
|
|
* @param condition
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @param list
|
|
|
|
|
*/
|
|
|
|
|
public void makeApplicationLinkRealUrl(ResourcesApplicationQuery condition, CoreUser coreUser, List<ResourcesApplication> list) {
|
|
|
|
|
// 这样 这个接口 也可以用于其他普通的查询
|
|
|
|
|
if (coreUser.isTeacher() || coreUser.isTeacher()) {
|
|
|
|
|
// 查询当前登录用户所有的应用ID
|
|
|
|
|
ResourcesApplicationQuery query = BeanUtil.copyProperties(condition, ResourcesApplicationQuery.class);
|
|
|
|
|
PageQuery pageQuery = query.getPageQuery();
|
|
|
|
|
pageQuery.setPageSize(Integer.MAX_VALUE); pageQuery.setPageNumber(1);
|
|
|
|
|
|
|
|
|
|
if (coreUser.isTeacher()) {
|
|
|
|
|
Teacher teacher = teacherDao.getByUserId(coreUser.getId());
|
|
|
|
|
if (teacher != null) {
|
|
|
|
|
pageQuery.setPara("teacherId", teacher.getTeacherId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (coreUser.isStudent()) {
|
|
|
|
|
Student student = studentDao.getByUserId(coreUser.getId());
|
|
|
|
|
if (student != null) {
|
|
|
|
|
pageQuery.setPara("studentId", student.getStudentId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PageQuery<ResourcesApplication> resultPage = queryMyApplicationByConditionQuery(pageQuery);
|
|
|
|
|
|
|
|
|
|
if (resultPage != null && CollectionUtil.isNotEmpty(resultPage.getList())) {
|
|
|
|
|
// 应用ID 对应 跳转链接
|
|
|
|
|
Map<Long, List<ResourcesApplication>> groupMap = CollectionUtil.emptyIfNull(resultPage.getList()).stream()
|
|
|
|
|
.collect(groupingBy(ResourcesApplication::getResourcesApplicationId));
|
|
|
|
|
Set<Long> ids = groupMap.keySet();
|
|
|
|
|
|
|
|
|
|
CollectionUtil.emptyIfNull(list).forEach(application -> {
|
|
|
|
|
// 选中应用,并拷贝过来跳转链接
|
|
|
|
|
final Long applicationId = application.getResourcesApplicationId();
|
|
|
|
|
|
|
|
|
|
// 是否包含在已经授权的应用中
|
|
|
|
|
if (ids.contains(applicationId)) {
|
|
|
|
|
List<ResourcesApplication> tempList = groupMap.get(applicationId);
|
|
|
|
|
ResourcesApplication first = CollectionUtil.getFirst(tempList);
|
|
|
|
|
if (first != null) {
|
|
|
|
|
application.setRealUrl(first.getRealUrl());
|
|
|
|
|
application.setCanUsed(first.getCanUsed());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置是否带Token 的跳转链接
|
|
|
|
|
* @param condition
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @param application
|
|
|
|
|
*/
|
|
|
|
|
public void makeApplicationLinkRealUrl(ResourcesApplicationQuery condition, CoreUser coreUser, ResourcesApplication application) {
|
|
|
|
|
// 这样 这个接口 也可以用于其他普通的查询
|
|
|
|
|
if (coreUser.isTeacher() || coreUser.isTeacher()) {
|
|
|
|
|
// 查询当前登录用户所有的应用ID
|
|
|
|
|
ResourcesApplicationQuery query = BeanUtil.copyProperties(condition, ResourcesApplicationQuery.class);
|
|
|
|
|
PageQuery pageQuery = query.getPageQuery();
|
|
|
|
|
pageQuery.setPageSize(Integer.MAX_VALUE); pageQuery.setPageNumber(1);
|
|
|
|
|
|
|
|
|
|
if (coreUser.isTeacher()) {
|
|
|
|
|
Teacher teacher = teacherDao.getByUserId(coreUser.getId());
|
|
|
|
|
if (teacher != null) {
|
|
|
|
|
pageQuery.setPara("teacherId", teacher.getTeacherId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (coreUser.isStudent()) {
|
|
|
|
|
Student student = studentDao.getByUserId(coreUser.getId());
|
|
|
|
|
if (student != null) {
|
|
|
|
|
pageQuery.setPara("studentId", student.getStudentId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PageQuery<ResourcesApplication> resultPage = queryMyApplicationByConditionQuery(pageQuery);
|
|
|
|
|
|
|
|
|
|
if (resultPage != null && CollectionUtil.isNotEmpty(resultPage.getList())) {
|
|
|
|
|
// 应用ID 对应 跳转链接
|
|
|
|
|
Map<Long, List<ResourcesApplication>> groupMap = CollectionUtil.emptyIfNull(resultPage.getList()).stream()
|
|
|
|
|
.collect(groupingBy(ResourcesApplication::getResourcesApplicationId));
|
|
|
|
|
Set<Long> ids = groupMap.keySet();
|
|
|
|
|
|
|
|
|
|
// 选中应用,并拷贝过来跳转链接
|
|
|
|
|
final Long applicationId = application.getResourcesApplicationId();
|
|
|
|
|
|
|
|
|
|
// 是否包含在已经授权的应用中
|
|
|
|
|
if (ids.contains(applicationId)) {
|
|
|
|
|
List<ResourcesApplication> tempList = groupMap.get(applicationId);
|
|
|
|
|
ResourcesApplication first = CollectionUtil.getFirst(tempList);
|
|
|
|
|
if (first != null) {
|
|
|
|
|
application.setRealUrl(first.getRealUrl());
|
|
|
|
|
application.setCanUsed(first.getCanUsed());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean add(ResourcesApplicationQuery resourcesApplicationQuery){
|
|
|
|
|
|
|
|
|
|
ResourcesApplication resourcesApplication = resourcesApplicationQuery.pojo();
|
|
|
|
@ -296,4 +398,14 @@ public class ResourcesApplicationService extends CoreBaseService<ResourcesApplic
|
|
|
|
|
return link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResourcesApplication getInfo (ResourcesApplicationQuery resourcesApplicationQuery){
|
|
|
|
|
List<ResourcesApplication> list = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|