package com.engine.htsc.mail.service;

import com.engine.core.impl.Service;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;

import java.util.HashMap;
import java.util.Map;

public class MailService extends Service {

    /**
     * 根据选择获取联系人信息
     * @param userid
     * @param lxr
     * @param sfyjcysjr 0-是 1-否
     * @param sfzdcf 0-否 1-是
     * @return
     */
    public Map<String,Object> getUserInfo(String userid, String lxr, String ssjg, String sfyjcysjr, String sfzdcf){
        BaseBean bs = new BaseBean();
        RecordSet rs = new RecordSet();
        Map<String,Object> resultMap = new HashMap<>();

        try{
            String mobile = "";
            if("1".equals(sfyjcysjr)){
                String sql = "select mobile from hrmresource where id = '"+lxr+"'";
                bs.writeLog(sql);
                rs.executeQuery(sql);
                if(rs.next()){
                    mobile = Util.null2String(rs.getString("mobile"));
                }
            }else{
                if("0".equals(sfzdcf)){
                    String sql = "select lxdh from uf_cysjr where sjrxm = '"+lxr+"' and modedatacreater = '"+userid+"'";
                    bs.writeLog(sql);
                    rs.executeQuery(sql);
                    if(rs.next()){
                        mobile = Util.null2String(rs.getString("lxdh"));
                    }
                }else {
                    String sql = "select lxdh from uf_fzjgcysjr where sjrxm = '"+lxr+"' and ssjg = '"+ssjg+"'";
                    bs.writeLog(sql);
                    rs.executeQuery(sql);
                    if(rs.next()){
                        mobile = Util.null2String(rs.getString("lxdh"));
                    }
                }
            }
            resultMap.put("mobile",mobile);
        }catch (Exception e){
            e.printStackTrace();
        }

        return resultMap;
    }
}
