package com.docus.server.archive.converter;

import com.docus.server.archive.entity.PowerUser;
import com.docus.server.zqdyry.entity.ZqDyRyUserInfoView;

/**
 * @author YongBin Wen
 * @date 2024/5/24 14:17
 */
public class ZqDyRyUserInfoConverter {
    public static PowerUser convertUserInfo(ZqDyRyUserInfoView view) {
        if (view == null) {
            return null;
        }
        Long roleId = ("1".equals(view.getFL()) || "3".equals(view.getFL())) ? 1L : 2L;
        Integer enable = "1".equals(view.getFISAVAILABLE()) ? 1 : 0;
        PowerUser user = new PowerUser();
        user.setUserName(view.getFEMPCODE());
        user.setName(view.getFEMPNAME());
        user.setDeptId(view.getFIPDEPTID());
        user.setEffective(enable);
        user.setEnabled(enable);
        user.setRoleId(roleId);
        user.setPowerDept(user.getDeptId());
        // 医生默认管辖医生为自己
        if (roleId.equals(1L)) {
            user.setPowerAttending(user.getUserName());
        }
        return user;
    }
}
