package com.zcloud.basic.info.facade;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.basic.info.api.CorpInfoServiceI;
import com.zcloud.basic.info.api.UserServiceI;
import com.zcloud.basic.info.command.convertor.CorpInfoCoConvertor;
import com.zcloud.basic.info.command.convertor.UserCoConvertor;
import com.zcloud.basic.info.dto.clientobject.UserCO;
import com.zcloud.gbscommon.zclouduser.facade.ZcloudUserFacade;
import com.zcloud.gbscommon.zclouduser.response.ZcloudUserCo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author lin
 */
@DubboService
public class ZcloudUserFacadeImpl implements ZcloudUserFacade {
    @Resource
    private UserServiceI userServiceI;
    @Resource
    private UserCoConvertor userCoConvertor;

    @Override
    public MultiResponse<ZcloudUserCo> listByUserIdAndDeptId() {
        System.out.println("listByUserIdAndDeptId");
        ZcloudUserCo zcloudUserCo = new ZcloudUserCo();
        zcloudUserCo.setName("hello word");
        ArrayList<ZcloudUserCo> objects = new ArrayList<>();
        objects.add(zcloudUserCo);
        return MultiResponse.of(objects);
    }

    @Override
    public SingleResponse<ZcloudUserCo> getInfoByUserId(Long aLong) {
        UserCO user = userServiceI.getInfoByUserId(aLong);
        ZcloudUserCo zcloudUserCo = userCoConvertor.converCOToDubboCO(user);
        return SingleResponse.of(zcloudUserCo);
    }

    @Override
    public MultiResponse<ZcloudUserCo> listByUserIds(Collection<Long> collection) {
        List<UserCO> users = userServiceI.listByUserIds(collection);
        List<ZcloudUserCo> zcloudUserCo = userCoConvertor.converCOsToDubboCOs(users);
        return MultiResponse.of(zcloudUserCo);
    }

    @Override
    public MultiResponse<ZcloudUserCo> getUserList() {
        List<UserCO> users = userServiceI.getUserList();
        List<ZcloudUserCo> zcloudUserCo = userCoConvertor.converCOsToDubboCOs(users);
        return MultiResponse.of(zcloudUserCo);
    }

    @Override
    public MultiResponse<ZcloudUserCo> listUserByUserName(Collection<String> collection) {
        List<UserCO> users = userServiceI.listUserByUserName(collection);
        List<ZcloudUserCo> zcloudUserCo = userCoConvertor.converCOsToDubboCOs(users);
        return MultiResponse.of(zcloudUserCo);
    }

    @Override
    public MultiResponse<ZcloudUserCo> listUserByUserNameV1(Collection<String> collection) {
        List<UserCO> users = userServiceI.listUserByUserNameV1(collection);
        List<ZcloudUserCo> zcloudUserCo = userCoConvertor.converCOsToDubboCOs(users);
        return MultiResponse.of(zcloudUserCo);
    }
}
