package com.docus.server.archive.converter;

import com.docus.server.archive.entity.PowerUser;
import com.docus.server.ydzyy.entity.YdZyyUserInfoView;


/**
 * 梅州三院用户信息转换器
 *
 * @author wyb
 */
public class YdZyyUserInfoConverter {
    public static PowerUser convertUserInfo(YdZyyUserInfoView view) {
        if (view == null) {
            return null;
        }
        Long roleId = 0L;
        // 角色：0医生，1护士
        String role = view.getRoleName();
        if ("0".equals(role)) {
            roleId = 1L;
        }
        if ("1".equals(role)) {
            roleId = 2L;
        }

        Integer enable = Integer.valueOf(view.getIsActive());
        ;
        PowerUser user = new PowerUser();
        user.setUserName(view.getCode());
        user.setName(view.getName());
        user.setDeptId("");
        user.setEffective(enable);
        user.setEnabled(enable);
        user.setRoleId(roleId);
        user.setPowerDept("");
        // 医生默认管辖医生为自己
        if (roleId.equals(1L)) {
            user.setPowerAttending(user.getUserName());
        }
        return user;
    }
}
