|
@ -5,6 +5,7 @@ import com.yihu.jw.security.model.WlyyUserDetails;
|
|
|
import com.yihu.jw.security.model.WlyyUserSimple;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.support.JdbcDaoSupport;
|
|
@ -19,10 +20,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.sql.DataSource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
@ -37,6 +35,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
|
|
|
|
|
|
private static final String DEFAULT_PATIENT_DETAILS_STATEMENT = "SELECT * FROM base_patient p WHERE p.mobile = ? OR p.idcard = ?";
|
|
|
|
|
|
private static final String BespeakRegist = "bespeakRegist:";
|
|
|
|
|
|
@Autowired
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
public WlyyUserDetailsService(DataSource dataSource) {
|
|
|
this.setDataSource(dataSource);
|
|
@ -97,13 +99,21 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
|
|
|
//1或默认查找user表,为平台管理员账号
|
|
|
if(StringUtils.isBlank(loginType)||"1".equals(loginType)){
|
|
|
users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username, username);
|
|
|
//如果users为空,可能为预注册用户,从redis查找
|
|
|
//todo cyx
|
|
|
//2.为医生登录账号
|
|
|
}else if("2".equals(loginType)){
|
|
|
users = this.getJdbcTemplate().query(DEFAULT_DOCTOR_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
|
|
|
//3.患者登录
|
|
|
}else if("3".equals(loginType)){
|
|
|
//查找是否存在预注册 用户
|
|
|
String userName = redisTemplate.opsForValue().get(BespeakRegist + username);
|
|
|
if(StringUtils.isNotBlank(userName)){
|
|
|
//保存到数据库
|
|
|
String uuid = UUID.randomUUID().toString().replace("-","");
|
|
|
this.getJdbcTemplate().update("insert into base_patient(id,mobile,locked,enabled,del,patient_status,login_failure_count) values(?,?,?,?,?,?)",
|
|
|
new Object[]{uuid,username,0,1,1,"1",0});
|
|
|
redisTemplate.opsForValue().get(BespeakRegist + username);
|
|
|
redisTemplate.delete(BespeakRegist+username);
|
|
|
}
|
|
|
users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
|
|
|
}//..
|
|
|
return users;
|