package com.skyline.user.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;
import com.skyline.user.model.User;
import com.skyline.user.type.Sex;
//TODO:加注释
public class PersonalIfonMapper implements RowMapper<User> {
private final static String COLUMN_BIRTHDAY = "birthday";
private final static String COLUMN_CITY = "city";
private final static String COLUMN_COUNTRY = "country";
private final static String COLUMN_EMAIL = "email";
private final static String COLUMN_GRADUATE_SCHOOL = "graduateSchool";
private final static String COLUMN_JOB = "job";
private final static String COLUMN_MOBILE_PHONE = "mobilephone";
private final static String COLUMN_MSN = "msn";
private final static String COLUMN_NAME = "name";
private final static String COLUMN_NICKNAME = "nickname";
private final static String COLUMN_PROVINCE = "province";
private final static String COLUMN_QQ = "qq";
private final static String COLUMN_SEX = "sex";
private final static String COLUMN_SITE_ID = "siteId";
private final static String COLUMN_ID = "id";
private final static String COLUMN_PORTRAIT = "portrait";
private final static PersonalIfonMapper MAPPER = new PersonalIfonMapper();
public static PersonalIfonMapper getMapper() {
return MAPPER;
}
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User();
user.setBirthday(rs.getDate(COLUMN_BIRTHDAY));
user.setCity(rs.getString(COLUMN_CITY));
user.setCountry(rs.getString(COLUMN_COUNTRY));
user.setEmail(rs.getString(COLUMN_EMAIL));
user.setGraduateSchool(rs.getString(COLUMN_GRADUATE_SCHOOL));
user.setJob(rs.getString(COLUMN_JOB));
user.setNickname(rs.getString(COLUMN_NICKNAME));
user.setName(rs.getString(COLUMN_NAME));
user.setProvince(rs.getString(COLUMN_PROVINCE));
if (rs.getString(COLUMN_SEX) != null)
user.setSex(Sex.valueOf(rs.getString(COLUMN_SEX)));
user.setSiteId(rs.getString(COLUMN_SITE_ID));
user.setMobilephone(rs.getString(COLUMN_MOBILE_PHONE));
user.setMsn(rs.getString(COLUMN_MSN));
user.setQq(rs.getString(COLUMN_QQ));
user.setId(rs.getLong(COLUMN_ID));
user.setPortrait(rs.getString(COLUMN_PORTRAIT));
return user;
}
}