|
@@ -6,19 +6,23 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.qmth.boot.core.enums.Platform;
|
|
import com.qmth.boot.core.enums.Platform;
|
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
import com.qmth.distributed.print.business.bean.auth.AuthBean;
|
|
import com.qmth.distributed.print.business.bean.auth.AuthBean;
|
|
|
|
+import com.qmth.distributed.print.business.bean.auth.ExpireTimeBean;
|
|
import com.qmth.distributed.print.business.bean.dto.OrgDto;
|
|
import com.qmth.distributed.print.business.bean.dto.OrgDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PrivilegeCacheDto;
|
|
import com.qmth.distributed.print.business.bean.dto.PrivilegeCacheDto;
|
|
|
|
+import com.qmth.distributed.print.business.bean.result.LoginResult;
|
|
import com.qmth.distributed.print.business.bean.result.PrivilegeResult;
|
|
import com.qmth.distributed.print.business.bean.result.PrivilegeResult;
|
|
import com.qmth.distributed.print.business.bean.result.RolePrivilegeResult;
|
|
import com.qmth.distributed.print.business.bean.result.RolePrivilegeResult;
|
|
import com.qmth.distributed.print.business.config.DictionaryConfig;
|
|
import com.qmth.distributed.print.business.config.DictionaryConfig;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
import com.qmth.distributed.print.business.enums.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
-import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.util.AuthUtil;
|
|
import com.qmth.distributed.print.business.util.OssUtil;
|
|
import com.qmth.distributed.print.business.util.OssUtil;
|
|
import com.qmth.distributed.print.business.util.RedisUtil;
|
|
import com.qmth.distributed.print.business.util.RedisUtil;
|
|
import com.qmth.distributed.print.business.util.ServletUtil;
|
|
import com.qmth.distributed.print.business.util.ServletUtil;
|
|
|
|
+import com.qmth.distributed.print.common.SignatureEntityTest;
|
|
import com.qmth.distributed.print.common.contant.SpringContextHolder;
|
|
import com.qmth.distributed.print.common.contant.SpringContextHolder;
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
@@ -82,21 +86,15 @@ public class CommonServiceImpl implements CommonService {
|
|
@Autowired
|
|
@Autowired
|
|
private ExamDetailService examDetailService;
|
|
private ExamDetailService examDetailService;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ExamDetailCourseService examDetailCourseService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- TBTaskService tbTaskService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- AsyncCreatePdfTempleteService asyncCreatePdfTempleteService;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysOrgService sysOrgService;
|
|
private SysOrgService sysOrgService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private BasicAttachmentService basicAttachmentService;
|
|
private BasicAttachmentService basicAttachmentService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CommonService commonService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新增用户权限
|
|
* 新增用户权限
|
|
*
|
|
*
|
|
@@ -364,36 +362,36 @@ public class CommonServiceImpl implements CommonService {
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
String filePath = (String) jsonObject.get(SystemConstant.PATH);
|
|
String filePath = (String) jsonObject.get(SystemConstant.PATH);
|
|
// 有htmlPath
|
|
// 有htmlPath
|
|
- if(jsonObject.containsKey(SystemConstant.HTML_PATH)){
|
|
|
|
|
|
+ if (jsonObject.containsKey(SystemConstant.HTML_PATH)) {
|
|
htmlPath = (String) jsonObject.get(SystemConstant.HTML_PATH);
|
|
htmlPath = (String) jsonObject.get(SystemConstant.HTML_PATH);
|
|
}
|
|
}
|
|
// 有pdfPath
|
|
// 有pdfPath
|
|
- if(jsonObject.containsKey(SystemConstant.PDF_PATH)){
|
|
|
|
|
|
+ if (jsonObject.containsKey(SystemConstant.PDF_PATH)) {
|
|
pdfPath = (String) jsonObject.get(SystemConstant.PDF_PATH);
|
|
pdfPath = (String) jsonObject.get(SystemConstant.PDF_PATH);
|
|
}
|
|
}
|
|
if (Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
if (Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
pathUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
|
|
pathUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
|
|
- if(StringUtils.isNotBlank(htmlPath)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(htmlPath)) {
|
|
htmlUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + htmlPath;
|
|
htmlUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + htmlPath;
|
|
}
|
|
}
|
|
- if(StringUtils.isNotBlank(pdfPath)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(pdfPath)) {
|
|
pdfUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + pdfPath;
|
|
pdfUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + pdfPath;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (isExpire) {
|
|
if (isExpire) {
|
|
pathUrl = ossUtil.getPrivateUrl(filePath);
|
|
pathUrl = ossUtil.getPrivateUrl(filePath);
|
|
- if(StringUtils.isNotBlank(htmlPath)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(htmlPath)) {
|
|
htmlUrl = ossUtil.getPrivateUrl(htmlPath);
|
|
htmlUrl = ossUtil.getPrivateUrl(htmlPath);
|
|
}
|
|
}
|
|
- if(StringUtils.isNotBlank(pdfPath)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(pdfPath)) {
|
|
pdfUrl = ossUtil.getPrivateUrl(pdfPath);
|
|
pdfUrl = ossUtil.getPrivateUrl(pdfPath);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- pathUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + filePath;
|
|
|
|
- if(StringUtils.isNotBlank(htmlPath)){
|
|
|
|
|
|
+ pathUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + filePath;
|
|
|
|
+ if (StringUtils.isNotBlank(htmlPath)) {
|
|
htmlUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + htmlPath;
|
|
htmlUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + htmlPath;
|
|
}
|
|
}
|
|
- if(StringUtils.isNotBlank(pdfPath)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(pdfPath)) {
|
|
pdfUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + pdfPath;
|
|
pdfUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + pdfPath;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -411,7 +409,7 @@ public class CommonServiceImpl implements CommonService {
|
|
JSONObject object = JSONObject.parseObject(path);
|
|
JSONObject object = JSONObject.parseObject(path);
|
|
String filePath = object.getString(SystemConstant.PATH);
|
|
String filePath = object.getString(SystemConstant.PATH);
|
|
String type = object.getString(SystemConstant.TYPE);
|
|
String type = object.getString(SystemConstant.TYPE);
|
|
- if (filePath.endsWith(SystemConstant.HTML_PREFIX) || filePath.endsWith(SystemConstant.FTL_PREFIX) ) {
|
|
|
|
|
|
+ if (filePath.endsWith(SystemConstant.HTML_PREFIX) || filePath.endsWith(SystemConstant.FTL_PREFIX)) {
|
|
StringBuffer sb = new StringBuffer();
|
|
StringBuffer sb = new StringBuffer();
|
|
try {
|
|
try {
|
|
InputStream fis;
|
|
InputStream fis;
|
|
@@ -638,6 +636,53 @@ public class CommonServiceImpl implements CommonService {
|
|
return stringSet;
|
|
return stringSet;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 登录公用
|
|
|
|
+ *
|
|
|
|
+ * @param password
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @return
|
|
|
|
+ * @throws NoSuchAlgorithmException
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public LoginResult login(String password, SysUser sysUser) throws NoSuchAlgorithmException {
|
|
|
|
+ //密码不正确
|
|
|
|
+ if (!Objects.equals(password, sysUser.getPassword())) {
|
|
|
|
+ throw ExceptionResultEnum.PASSWORD_ERROR.exception();
|
|
|
|
+ }
|
|
|
|
+ //停用
|
|
|
|
+ if (!sysUser.getEnable()) {
|
|
|
|
+ throw ExceptionResultEnum.USER_ENABLE.exception();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Platform platform = ServletUtil.getRequestPlatform();
|
|
|
|
+ String deviceId = ServletUtil.getRequestDeviceId();
|
|
|
|
+ AuthBean authBean = commonService.getUserAuth(sysUser.getId());
|
|
|
|
+ //添加用户鉴权缓存
|
|
|
|
+ if (Objects.isNull(authBean)) {
|
|
|
|
+ throw ExceptionResultEnum.ROLE_ENABLE_AUTHORIZATION.exception();
|
|
|
|
+ }
|
|
|
|
+ //生成token
|
|
|
|
+ String token = SystemConstant.getUuid();
|
|
|
|
+ cacheService.userCache(sysUser.getId());
|
|
|
|
+ //添加用户会话缓存
|
|
|
|
+ Set<RoleTypeEnum> roleType = authBean.getRoleList().stream().map(s -> s.getType()).collect(Collectors.toSet());
|
|
|
|
+ String sessionId = SessionUtil.digest(sysUser.getId(), Math.abs(roleType.toString().hashCode()), platform.name());
|
|
|
|
+ //TODO 测试用
|
|
|
|
+ String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
|
|
|
|
+ ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
|
|
|
|
+ TBSession tbSession = new TBSession(sessionId, String.valueOf(sysUser.getId()), roleType.toString(),
|
|
|
|
+ platform.name(), platform.name(), deviceId, ServletUtil.getRequest().getLocalAddr(), token,
|
|
|
|
+ expireTime.getDate().getTime());
|
|
|
|
+ tbSessionService.saveOrUpdate(tbSession);
|
|
|
|
+ redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
|
|
|
|
+
|
|
|
|
+ LoginResult loginResult = new LoginResult(sysUser, sessionId, test, roleType);
|
|
|
|
+ loginResult.setSchoolInfo(Objects.nonNull(authBean.getSchool()) ? loginResult.new SchoolNativeBean(authBean.getSchool()) : null);
|
|
|
|
+ loginResult.setOrgInfo(Objects.nonNull(authBean.getOrg()) ? loginResult.new OrgNativeBean(authBean.getOrg()) : null);
|
|
|
|
+ return loginResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
private Set<Long> getOrgIds(Set<Long> stringSet, List<OrgDto> orgDtos, Long parentId) {
|
|
private Set<Long> getOrgIds(Set<Long> stringSet, List<OrgDto> orgDtos, Long parentId) {
|
|
for (OrgDto orgDto : orgDtos) {
|
|
for (OrgDto orgDto : orgDtos) {
|
|
Long tempParentId = orgDto.getParentId();
|
|
Long tempParentId = orgDto.getParentId();
|