|
@ -6,6 +6,7 @@ import com.yihu.jw.security.model.WlyyUserDetails;
|
|
|
import com.yihu.jw.security.model.WlyyUserSimple;
|
|
|
|
|
|
import com.yihu.jw.security.utils.HttpClientUtil;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
@ -181,11 +182,16 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
|
|
|
return users;
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
String salt = randomString(5);
|
|
|
String idcard = patient.getString("idcard");
|
|
|
String pw = idcard.substring(idcard.length()-6);
|
|
|
|
|
|
this.getJdbcTemplate().update(DEFAULT_PATIENT_INSERT_STATEMENT,
|
|
|
new Object[]{patient.getString("code"),
|
|
|
patient.getString("photo"),
|
|
|
patient.getString("idcard"),
|
|
|
patient.getString("password"),
|
|
|
MD5.md5Hex(pw + "{" + salt + "}"),
|
|
|
patient.getString("salt"),
|
|
|
patient.getString("name"),
|
|
|
patient.getDate("birthday"),
|
|
@ -478,4 +484,17 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
|
|
|
public void updateOpenId(String openid, String userId) {
|
|
|
this.getJdbcTemplate().update("update base_patient p set p.openid = ? where p.id= ?", openid, userId);
|
|
|
}
|
|
|
|
|
|
public String randomString(int length) {
|
|
|
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
Random random = new Random();
|
|
|
|
|
|
for(int i = 0; i < length; ++i) {
|
|
|
int pos = random.nextInt(str.length());
|
|
|
buffer.append(str.charAt(pos));
|
|
|
}
|
|
|
|
|
|
return buffer.toString();
|
|
|
}
|
|
|
}
|