@ -13,6 +13,7 @@ import com.yipin.liuwanr.mapper.StaffMapper;
import com.yipin.liuwanr.mapper.StudentMapper ;
import com.yipin.liuwanr.mapper.StudentMapper ;
import com.yipin.liuwanr.mapper.UserInfoMapper ;
import com.yipin.liuwanr.mapper.UserInfoMapper ;
import com.yipin.liuwanr.vo.UserInfoReceiveVo ;
import com.yipin.liuwanr.vo.UserInfoReceiveVo ;
import org.apache.poi.ss.formula.functions.T ;
import org.jboss.logging.Logger ;
import org.jboss.logging.Logger ;
import org.springframework.beans.factory.BeanFactory ;
import org.springframework.beans.factory.BeanFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -443,13 +444,15 @@ public class UserInfoService {
String token = user . getToken ( ) ;
String token = user . getToken ( ) ;
Integer userId = user . getUserId ( ) ;
Integer userId = user . getUserId ( ) ;
obj . put ( "user" , user ) ;
obj . put ( "user" , user ) ;
SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; //设置日期格式
String date = df . format ( new Date ( ) ) ; // new Date()为获取当前系统时间,也可使用当前时间戳
if ( id ! = null ) {
if ( id ! = null ) {
List < Staff > staffList = userInfoMapper . queryStaffAll ( id , roleId , schoolId ) ;
List < Staff > staffList = userInfoMapper . queryStaffAll ( id , roleId , schoolId ) ;
obj . put ( "staffList" , staffList ) ;
obj . put ( "staffList" , staffList ) ;
List < Student > studentList = userInfoMapper . queryStudentAll ( id , roleId , schoolId ) ;
List < Student > studentList = userInfoMapper . queryStudentAll ( id , roleId , schoolId ) ;
obj . put ( "studentList" , studentList ) ;
obj . put ( "studentList" , studentList ) ;
ValueOperations < String , String > redis = stringRedisTemplate . opsForValue ( ) ;
ValueOperations < String , String > redis = stringRedisTemplate . opsForValue ( ) ;
redis . set ( token , userId + "" , 30 * 60 , TimeUnit . SECONDS ) ;
redis . set ( token , date , 30 * 60 , TimeUnit . SECONDS ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
} else {
} else {
@ -774,4 +777,26 @@ public class UserInfoService {
}
}
return resp ;
return resp ;
}
}
//查询token
public HashMap < String , Object > queryToken ( String token ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
boolean tokens = stringRedisTemplate . hasKey ( token ) ;
String data = stringRedisTemplate . opsForValue ( ) . get ( token ) ;
if ( ! tokens ) {
resp . put ( "retvalue" , data ) ;
resp . put ( "retcode" , 200 ) ;
} else {
resp . put ( "retvalue" , data ) ;
resp . put ( "retcode" , 200 ) ;
}
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "查询token失败!" ) ;
return resp ;
}
return resp ;
}
}
}