|
@@ -1,16 +1,13 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.TokenCheckDTO;
|
|
|
import com.diagbot.dto.TokenHospitaDTO;
|
|
|
import com.diagbot.entity.TokenHospital;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.enums.StatusEnum;
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.TokenHospitalServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
-import com.diagbot.util.StringUtil;
|
|
|
-import com.diagbot.util.SysJwtUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.vo.TokenHospitalVO;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -24,7 +21,6 @@ import java.util.Date;
|
|
|
@Component
|
|
|
public class TokenHospitalFacade extends TokenHospitalServiceImpl {
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param tokenHospitalVO
|
|
|
* @return
|
|
@@ -43,8 +39,8 @@ public class TokenHospitalFacade extends TokenHospitalServiceImpl {
|
|
|
* @param token
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean checkTokenHospitals(String token) {
|
|
|
- Date date = new Date();
|
|
|
+ public TokenCheckDTO checkTokenHospitals(String token) {
|
|
|
+ Date now = DateUtil.now();
|
|
|
boolean res = true;
|
|
|
//根据token获取用户id
|
|
|
TokenHospitalVO tokenHospitalVO = new TokenHospitalVO();
|
|
@@ -54,17 +50,21 @@ public class TokenHospitalFacade extends TokenHospitalServiceImpl {
|
|
|
Date startTime = tokenHospitals.getStartTime();
|
|
|
Date endTime = tokenHospitals.getEndTime();
|
|
|
if (validDays < 0) {
|
|
|
- return res = false;
|
|
|
+ res = false;
|
|
|
//throw new CommonException(CommonErrorCode.NOT_EXISTS, "已超过有效期");
|
|
|
}
|
|
|
- if (date.getTime() > startTime.getTime() ? false : true) {
|
|
|
- return res = false;
|
|
|
+ if (DateUtil.before(now, startTime)) {
|
|
|
+ res = false;
|
|
|
//throw new CommonException(CommonErrorCode.NOT_EXISTS, "已超过有效期");
|
|
|
}
|
|
|
- if (date.getTime() < endTime.getTime() ? false : true) {
|
|
|
- return res = false;
|
|
|
+ if (DateUtil.after(now, endTime)) {
|
|
|
+ res = false;
|
|
|
// throw new CommonException(CommonErrorCode.NOT_EXISTS, "已超过有效期");
|
|
|
}
|
|
|
- return res;
|
|
|
+
|
|
|
+ TokenCheckDTO tokenCheckDTO = new TokenCheckDTO();
|
|
|
+ tokenCheckDTO.setRes(res);
|
|
|
+ tokenCheckDTO.setHospitalId(tokenHospitals.getHospitalId());
|
|
|
+ return tokenCheckDTO;
|
|
|
}
|
|
|
}
|