package cn.iselab.mooctest.user.web.data.wrapper;

import cn.iselab.mooctest.user.model.User;
import cn.iselab.mooctest.user.web.data.UserVO;
import cn.iselab.mooctest.user.web.wrapper.BaseWrapper;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;

/**
 * @Description: 作用描述
 * @Author: xuexb
 * @CreateDate: 19-1-2$ 上午2:21$
 */
@Service
public class UserVOWrapper extends BaseWrapper<UserVO, User> {

    @Override
    public UserVO wrap(User user) {
        UserVO userVO = new UserVO();

        userVO.setAvailability(user.getAvailability());
        userVO.setCity(user.getCity());
        userVO.setCreateTime(user.getCreateTime().getTime());
        userVO.setEmail(user.getEmail());
        userVO.setId(user.getId());
        userVO.setManualCheckValid(user.getManualCheckValid());
        userVO.setMobile(user.getMobile());
        userVO.setName(user.getName());
        userVO.setPassword(user.getPassword());
        userVO.setPhotoUrl(user.getPhotoUrl());
        userVO.setProvince(user.getProvince());
        userVO.setSchool(user.getSchool());
        return userVO;
    }

    @Override
    public User unwrap(UserVO data) {
        User user = new User();

        user.setSchool(data.getSchool());
        user.setProvince(data.getProvince());
        user.setPhotoUrl(data.getPhotoUrl());
        user.setAvailability(data.getAvailability());
        user.setCity(data.getCity());
        user.setCreateTime(new Timestamp(data.getCreateTime()));
        user.setEmail(data.getEmail());
        user.setId(data.getId());
        user.setManualCheckValid(data.getManualCheckValid());
        user.setMobile(data.getMobile());
        user.setName(data.getName());
        user.setPassword(data.getPassword());

        return user;
    }
}
