package com.engine.htxc.contract.service.impl;


import com.engine.core.impl.Service;
import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.contract.service.CounterpartyService;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;

@Slf4j
public class CounterpartyServiceImpl extends Service implements CounterpartyService {

    private DbTools dbTools=new DbTools();

    @Override
    public Map<String, Object> getRoleName(Map<String, Object> map) {
        Map<String,Object> apidatas = Maps.newHashMap();
        try {
            String userId = map.get("userId") ==null ? "":map.get("userId").toString();
            String sql = "select b.rolesmark,c.lastname,a.roleid,c.id from hrmrolemembers a,hrmroles b,hrmresource c where a.roleid=b.id and a.resourceid=c.id and c.id=?";
            List<Map<String,Object>> dataList = dbTools.getSqlToList(sql,userId);
            apidatas.put("code","200");
            apidatas.put("data",dataList);
            apidatas.put("userid",userId);
        }catch (Exception e){
            log.error("get rolename fail [{}]", e);
            apidatas.put("code","400");
            apidatas.put("message",e.getMessage());
        }
        return apidatas;
    }
}
