package com.sckw.system.dubbo;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sckw.core.exception.SystemException;
import com.sckw.core.model.base.BaseModel;
import com.sckw.core.model.constant.Global;
import com.sckw.core.utils.IdWorker;
import com.sckw.core.model.page.PageHelperUtil;
import com.sckw.core.model.page.PageResult;
import com.sckw.core.utils.BeanUtils;
import com.sckw.core.utils.CollectionUtils;
import com.sckw.core.web.constant.HttpStatus;
import com.sckw.system.api.RemoteUserService;
import com.sckw.system.api.model.dto.req.*;
import com.sckw.system.api.model.dto.res.*;
import com.sckw.system.dao.*;
import com.sckw.system.model.*;
import com.sckw.system.model.pojo.FindEntUserPojo;
import com.sckw.system.model.pojo.FindMenuTreePojo;
import com.sckw.system.model.vo.req.FindListReqVo;
import com.sckw.system.model.vo.req.ForgetPasswordReqVo;
import com.sckw.system.model.vo.res.EntBaseInfo;
import com.sckw.system.model.vo.res.KwsMenuResVo;
import com.sckw.system.model.vo.res.KwsUserResVo;
import com.sckw.system.model.vo.res.KwsUserSystemTypeVo;
import com.sckw.system.service.*;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author czh
 * @desc 远程接口
 * @date 2023/6/12
 */

@DubboService(group = "design", version = "1.0.0")
public class RemoteUserServiceImpl implements RemoteUserService {

    private static final String DRIVER_ROLE_NAME = "司机";

    @Resource
    private RemoteBaseService remoteBaseService;

    @Resource
    private KwsUserService kwsUserService;

    @Resource
    private KwsRoleService kwsRoleService;

    @Resource
    private KwsMenuService kwsMenuService;

    @Resource
    private KwsUserLoginDao kwsUserLoginDao;

    @Resource
    private KwsEnterpriseService kwsEnterpriseService;

    @Resource
    private KwsEnterpriseDao kwsEnterpriseDao;

    @Resource
    private SysDictDao sysDictDao;

    @Resource
    private SysAreaDao sysAreaDao;

    @Resource
    private KwsUserRoleDao userRoleDao;

    @Resource
    private KwsUserDao userDao;

    @Resource
    private KwsRoleDao kwsRoleDao;

    @Resource
    private CommonService commonService;


    @Override
    public KwsEnterpriseResDto queryEnterpriseById(Long id) {
        return remoteBaseService.queryEnterpriseById(id);
    }

    @Override
    public List<KwsRoleResDto> queryRoleInfoByUserId(Long userId) {
        return remoteBaseService.queryRoleInfoByUserId(userId);
    }
    @Override
    public List<UserAccessMenuInfoResDto> queryUserAccessMenu(long id) {
        FindMenuTreePojo findMenuTreePojo = new FindMenuTreePojo();
        List<KwsUserRole> kwsUserRoles = kwsRoleService.findAllByUserId(id);
        if (CollectionUtils.isEmpty(kwsUserRoles)) {
            return Collections.emptyList();
        }
        findMenuTreePojo.setRoleIds(kwsUserRoles.stream().map(KwsUserRole::getRoleId).toList());

        List<KwsMenuResVo> kwsMenuResVos = kwsMenuService.findList(findMenuTreePojo);
        if (CollectionUtils.isEmpty(kwsMenuResVos)) {
            return Collections.emptyList();
        }

        return BeanUtils.copyToList(kwsMenuResVos, UserAccessMenuInfoResDto.class);
    }

    @Override
    public List<UserAccessMenuInfoResDto> queryRoleMenu(Long roleId) {
        FindMenuTreePojo findMenuTreePojo = new FindMenuTreePojo();
        findMenuTreePojo.setRoleIds(Collections.singletonList(roleId));

        List<KwsMenuResVo> kwsMenuResVos = kwsMenuService.findList(findMenuTreePojo);
        if (CollectionUtils.isEmpty(kwsMenuResVos)) {
            return Collections.emptyList();
        }

        return BeanUtils.copyToList(kwsMenuResVos, UserAccessMenuInfoResDto.class);
    }

    @Override
    public void forgetPassword(ForgetPasswordReqDto reqDto) throws SystemException {
        com.sckw.system.model.vo.req.ForgetPasswordReqVo forgetPasswordReqVo = new ForgetPasswordReqVo();
        BeanUtils.copyProperties(reqDto, forgetPasswordReqVo);
        kwsUserService.forgetPassword(forgetPasswordReqVo);
    }

    @Override
    public void saveUserLogin(UserLoginReqDto userLoginReqDto) {
        KwsUserLogin kwsUserLogin = new KwsUserLogin();
        BeanUtils.copyProperties(userLoginReqDto, kwsUserLogin);
        kwsUserLoginDao.insert(kwsUserLogin);
    }

    @Override
    public UserLoginReqDto currentDayLogin(long userId) {
        KwsUserLogin kwsUserLogin = kwsUserLoginDao.currentDayLogin(userId);
        if (Objects.isNull(kwsUserLogin)) {
            return null;
        }
        UserLoginReqDto userLoginReqDto = new UserLoginReqDto();
        BeanUtils.copyProperties(kwsUserLogin, userLoginReqDto);
        return userLoginReqDto;
    }

    @Override
    public List<EntCertificateResDto> queryCertificateByEntId(Long entId) {
        return remoteBaseService.queryCertificateByEntId(entId);
    }

    @Override
    public List<EntCheckTrackResDto> checkTrackByEntId(Long entId) {
        return remoteBaseService.checkTrackByEntId(entId);
    }


    @Override
    public void updatePassword(UpdatePasswordReqDto updatePassword) {
        kwsUserService.updatePassword(updatePassword);
    }

    @Override
    public void resetPassword(Long id) {
        kwsUserService.resetPassword(id);
    }

    @Override
    public void bindManager(Long entId, Long userId) {
        KwsEnterprise kwsEnterprise = kwsEnterpriseService.queryKwsEnterpriseById(entId);
        if (Objects.isNull(kwsEnterprise)) {
            return;
        }
        kwsEnterprise.setManager(userId);
        if (kwsEnterpriseDao.updateById(kwsEnterprise) <= 0) {
            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
        }
    }

    @Override
    public Map<Long, SysDictResDto> querySysDictByIds(List<Long> ids) {
        List<SysDict> sysDictList = sysDictDao.selectByKeys(ids);
        if (CollectionUtils.isEmpty(sysDictList)) {
            return Collections.emptyMap();
        }
        List<SysDictResDto> sysDictResDtos = BeanUtils.copyToList(sysDictList, SysDictResDto.class);
        return sysDictResDtos.stream().collect(Collectors.toMap(SysDictResDto::getId, item -> item, (oldValue, newValue) -> newValue));
    }

    @Override
    public void checkRegisterParam(String entName, String phone, Integer systemType) {
        commonService.checkEntRepeat(entName, phone);
        kwsUserService.checkAccountValid(phone, systemType);
    }

    @Override
    public List<EntTypeResDto> queryEntTypeById(Long entId) {
        return remoteBaseService.queryEntTypeById(entId);
    }


    /**
     * @param reqDto{cityCode 区域code  entTypeList 企业类型  entIdList 企业id page 页数 pageSize页大小}
     * @return PageResult
     * @desc: 根据区域code和企业类型分页查询企业信息
     * @author: czh
     * @date: 2023/9/1
     */
    @Override
    public PageResult queryEntInfoByCityCodeAndEntTypesWithPage(QueryEntInfoByCityCodeAndEntTypesWithPageReqDto reqDto) {
        PageHelper.startPage(reqDto.getPage(), reqDto.getPageSize());
        List<KwsEnterprise> list = remoteBaseService.queryEntInfoByCityCodeAndEntTypesWithPage(reqDto.getCityCode(), reqDto.getEntTypeList(), reqDto.getEntIdList(), reqDto.getEntName());
        return PageHelperUtil.getPageResult(new PageInfo<>(list));
    }


    /**
     * @param id 用户id
     * @return List
     * @desc: 根据用户id查数据权限
     * @author: czh
     * @date: 2023/9/4
     */
    @Override
    public List<Long> queryAuthUserList(Long id) {
        if (Objects.isNull(id)) {
            return Collections.emptyList();
        }

        List<Long> list = new ArrayList<>();
        list.add(id);
        List<KwsRoleResDto> kwsRoleResDtos = remoteBaseService.queryRoleInfoByUserId(id);
        if (CollectionUtils.isEmpty(kwsRoleResDtos)) {
            return list;
        }

        List<KwsAuthority> kwsAuthorities = remoteBaseService.queryAuthorityByRoles(kwsRoleResDtos.stream().map(KwsRoleResDto::getId).toList());
        if (CollectionUtils.isEmpty(kwsAuthorities)) {
            return list;
        }

        List<Long> deptIds = kwsAuthorities.stream().map(KwsAuthority::getDeptId).toList();
        List<KwsUser> kwsUsers = remoteBaseService.queryUserByDeptIds(deptIds);
        if (CollectionUtils.isEmpty(kwsUsers)) {
            return list;
        }

        list.addAll(kwsUsers.stream().filter(item -> item.getIsMain().equals(Global.NO) && !item.getId().equals(id)).map(KwsUser::getId).distinct().toList());
        return list;
    }

    @Override
    public List<FindEntUserResDto> findEntUser(Long entId) {
        FindListReqVo findListReqVo = new FindListReqVo();
        findListReqVo.setId(entId);
        List<FindEntUserPojo> entUser = kwsEnterpriseService.findEntUser(findListReqVo);
        if (CollectionUtils.isEmpty(entUser)) {
            return Collections.emptyList();
        }
        return BeanUtils.copyToList(entUser, FindEntUserResDto.class);
    }


    /**
     * @param code 区域code
     * @desc: 查某区域下的所有区域
     * @author: czh
     * @date: 2023/10/8
     */
    @Override
    public List<AreaTreeFrontResDto> findAllArea(Integer code) {
        List<SysArea> list = sysAreaDao.findAllArea(code);
        if (CollectionUtils.isEmpty(list)) {
            return Collections.emptyList();
        }
        return BeanUtils.copyToList(list, AreaTreeFrontResDto.class);
    }

    /**
     * @param firmName 企业名称
     * @param entTypes 企业类型
     * @desc 根据企业名称搜索企业ID（适用于关键字搜索）
     * @author zk
     * @date 2023/10/11
     **/
    @Override
    public List<Long> findEntIds(List<Integer> entTypes, String firmName) {
        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
            put("entTypes", entTypes);
            put("firmName", firmName);
        }};
        List<KwsEnterprise> ents = remoteBaseService.findEnts(params);
        List<Long> endIds = new ArrayList<>();
        ents.forEach(ent -> endIds.add(ent.getId()));
        return endIds;
    }

    /**
     * @param entIds   企业ID
     * @param userName 用户名称
     * @desc 根据企业ID或用户名称搜索用户ID（适用于关键字搜索）
     * @author zk
     * @date 2023/10/11
     **/
    @Override
    public List<Long> findUserIds(List<Long> entIds, String userName) {
        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
            put("entIds", entIds);
            put("userName", userName);
        }};
        //查询企业信息
        List<KwsUserResVo> users = kwsUserService.findList(params);
        List<Long> userIds = new ArrayList<>();
        users.forEach(user -> userIds.add(user.getId()));
        return userIds;
    }


    /**
     * 通过用户id查询所有的企业信息(传递的是客户经理用户的id)
     *
     * @param userId 客户经理id
     * @return list 企业id数组
     */
    @Override
    public List<Long> findEnterpriseIdsByUserIdIsMain(Long userId) {
        List<Long> enterpriseIds = new ArrayList<>();
        KwsUser kwsUser = userDao.selectByKey(userId);
        if (Global.YES == kwsUser.getIsMain()) {
            List<Long> enterpriseIdList = findAllEnterprise();
            enterpriseIds.addAll(enterpriseIdList);
        } else {
            List<KwsUserRole> userRoles = userRoleDao.findAllByUserId(userId);
            if (!org.springframework.util.CollectionUtils.isEmpty(userRoles) && userRoles.size() > 0) {
                List<Long> roleIds = userRoles.stream().map(KwsUserRole::getRoleId).distinct().collect(Collectors.toList());
//            enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleId(userId);
                List<Long> idsByUserRoleIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleIds(userId, roleIds);
                if (idsByUserRoleIds.size() > 0) {
                    enterpriseIds.addAll(idsByUserRoleIds);
                }
            }
            List<Long> entIds = kwsEnterpriseDao.findEnterpriseIdsByUserIds(Collections.singletonList(userId));
            if (entIds.size() > 0) {
                enterpriseIds.addAll(entIds);
            }
        }
        if (CollectionUtils.isNotEmpty(enterpriseIds) && enterpriseIds.size() > 0) {
            enterpriseIds = enterpriseIds.stream().distinct().collect(Collectors.toList());
        }
        return enterpriseIds;
    }


    /**
     * 通过用户id查询所有的企业信息(传递的是客户经理用户的id)
     *
     * @param userId 客户经理id
     * @return list 企业id数组
     */
    @Override
    public List<Long> findEnterpriseIds(Long userId) {
        List<Long> enterpriseIds = null;
        List<KwsUserRole> userRoles = userRoleDao.findAllByUserId(userId);
        if (!org.springframework.util.CollectionUtils.isEmpty(userRoles) && userRoles.size() > 0) {
            List<Long> roleIds = userRoles.stream().map(KwsUserRole::getRoleId).distinct().collect(Collectors.toList());
//            enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleId(userId);
            enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleIds(userId, roleIds);
        }
        List<Long> entIds = kwsEnterpriseDao.findEnterpriseIdsByUserIds(Collections.singletonList(userId));
        if (entIds.size() > 0) {
            enterpriseIds.addAll(entIds);
        }
        enterpriseIds = enterpriseIds.stream().distinct().collect(Collectors.toList());
        return enterpriseIds;
    }

    /**
     * 通过用户id查询所有的企业信息(传递的是客户经理用户的id)
     *
     * @param userIds 客户经理id
     * @return list 企业id数组
     */
    @Override
    public List<Long> findEnterpriseListByIds(List<Long> userIds) {
        List<Long> enterpriseIds = null;
        List<KwsUserRole> userRoles = userRoleDao.findRoleAllByUserIds(userIds);
        if (!org.springframework.util.CollectionUtils.isEmpty(userRoles) && userRoles.size() > 0) {
            List<Long> roleIds = userRoles.stream().map(KwsUserRole::getRoleId).distinct().collect(Collectors.toList());
            enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserIdAndUserRoleIds(userIds, roleIds);
        }
        return enterpriseIds;
    }

    /**
     * 通过用户id查询所有的企业信息(传递的是客户经理用户的id)
     *
     * @param userIds 客户经理id
     * @return list 企业id数组
     */
    @Override
    public List<Long> findEnterpriseListByUserIds(List<Long> userIds) {
        List<Long> enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserIds(userIds);
        return enterpriseIds;
    }

    /**
     * 查询出所有运营端账号
     *
     * @param systemType
     * @return
     */
    @Override
    public List<Long> selectUserBySystemType(Integer systemType) {
        List<Long> userIds = null;
        //List<KwsUserSystemTypeVo> userBySystemType = userDao.selectUserBySystemType(1);
        List<KwsUserSystemTypeVo> userBySystemType = userDao.selectUserBySystemTypeAndMain(1, 0);
        if (!org.springframework.util.CollectionUtils.isEmpty(userBySystemType) && userBySystemType.size() > 0) {
            userIds = userBySystemType.stream().map(KwsUserSystemTypeVo::getId).distinct().collect(Collectors.toList());
        }
        return userIds;
    }

    /**
     * 获取所有企业信息
     *
     * @return
     */
    @Override
    public List<Long> findAllEnterprise() {
        List<Long> entIds = null;
        List<KwsEnterprise> enterprises = kwsEnterpriseDao.findAllEnterprise();
        if (CollectionUtils.isNotEmpty(enterprises)) {
            entIds = enterprises.stream().map(KwsEnterprise::getId).collect(Collectors.toList());
        }
        return entIds;
    }

    @Override
    public List<Long> findChildEntList(Long entId) {
        List<EntBaseInfo> entBaseInfos = kwsEnterpriseDao.queryCte(entId);
        if (CollUtil.isNotEmpty(entBaseInfos)) {
            return entBaseInfos.stream().map(EntBaseInfo::getId).toList();
        }
        return new ArrayList<>();
    }

    @Override
    public List<Long> findEntListByUserId(Long userId) {
        List<Long> enterpriseIds = new ArrayList<>();
        KwsUser kwsUser = userDao.selectByKey(userId);
        if (Global.YES == kwsUser.getIsMain()) {
            List<Long> enterpriseIdList = findAllEnterprise();
            enterpriseIds.addAll(enterpriseIdList);
        } else {
            List<KwsUserRole> userRoles = userRoleDao.findAllByUserId(userId);
            if (!org.springframework.util.CollectionUtils.isEmpty(userRoles) && userRoles.size() > 0) {
                List<Long> roleIds = userRoles.stream().map(KwsUserRole::getRoleId).distinct().collect(Collectors.toList());
//            enterpriseIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleId(userId);
                List<Long> idsByUserRoleIds = kwsEnterpriseDao.findEnterpriseIdsByUserRoleIds(userId, roleIds);
                if (idsByUserRoleIds.size() > 0) {
                    enterpriseIds.addAll(idsByUserRoleIds);
                }
            }
            List<Long> entIds = kwsEnterpriseDao.findEnterpriseIdsByUserIds(Collections.singletonList(userId));
            if (entIds.size() > 0) {
                enterpriseIds.addAll(entIds);
            }
        }
        if (CollectionUtils.isNotEmpty(enterpriseIds) && enterpriseIds.size() > 0) {
            enterpriseIds = enterpriseIds.stream().distinct().collect(Collectors.toList());
        }
        return enterpriseIds;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveUser(KwsUserReqDto kwsUserReqDto) {
        KwsUser kwsUser = new KwsUser();
        BeanUtils.copyProperties(kwsUserReqDto, kwsUser);
        KwsUser kwsUser1 = userDao.selectOne(Wrappers.<KwsUser>lambdaQuery()
                .eq(KwsUser::getPhone, kwsUser.getPhone())
                .eq(BaseModel::getDelFlag, 0)
                .last("limit 1"));
        if (Objects.isNull(kwsUser1)){
            userDao.insert(kwsUser);
        }else {
            kwsUser.setId(kwsUser1.getId());
            kwsUser.setCreateTime(null);
            userDao.updateById(kwsUser);
        }
        bindDriverUserRole(kwsUser, kwsUserReqDto);
    }

    /**
     * 司机用户在 {@link KwsUser} 保存后关联企业下「司机」角色；若该企业尚不存在该角色则先初始化。
     */
    private void bindDriverUserRole(KwsUser kwsUser, KwsUserReqDto kwsUserReqDto) {
        if (kwsUser.getId() == null || kwsUserReqDto.getEntId() == null) {
            return;
        }
        KwsRole driverRole = kwsRoleDao.selectOne(Wrappers.<KwsRole>lambdaQuery()
                .eq(KwsRole::getEntId, kwsUserReqDto.getEntId())
                .eq(KwsRole::getName, DRIVER_ROLE_NAME)
                .eq(KwsRole::getDelFlag, Global.NO)
                .last("limit 1"));
        if (driverRole == null) {
            driverRole = initDriverRole(kwsUserReqDto);
        }
        List<KwsUserRole> userRoles = userRoleDao.findAllByUserId(kwsUser.getId());
        if (!CollectionUtils.isEmpty(userRoles)) {
            KwsRole finalDriverRole = driverRole;
            boolean alreadyBound = userRoles.stream()
                    .anyMatch(ur -> Objects.equals(ur.getRoleId(), finalDriverRole.getId()));
            if (alreadyBound) {
                return;
            }
        }
        Date now = new Date();
        KwsUserRole userRole = new KwsUserRole();
        userRole.setId(new IdWorker(1L).nextId());
        userRole.setUserId(kwsUser.getId());
        userRole.setRoleId(driverRole.getId());
        userRole.setRemark(kwsUserReqDto.getRemark());
        userRole.setStatus(Global.NO);
        userRole.setDelFlag(Global.NO);
        userRole.setCreateBy(kwsUserReqDto.getCreateBy() != null ? kwsUserReqDto.getCreateBy() : -1L);
        userRole.setCreateTime(kwsUserReqDto.getCreateTime() != null ? kwsUserReqDto.getCreateTime() : now);
        userRole.setUpdateBy(kwsUserReqDto.getUpdateBy() != null ? kwsUserReqDto.getUpdateBy() : userRole.getCreateBy());
        userRole.setUpdateTime(kwsUserReqDto.getUpdateTime() != null ? kwsUserReqDto.getUpdateTime() : now);
        userRoleDao.insert(userRole);
    }

    /**
     * 在当前企业下创建「司机」角色（admin_flag=2 非管理员），不绑定菜单； 相比为司机同步场景的最小初始化。
     */
    private KwsRole initDriverRole(KwsUserReqDto kwsUserReqDto) {
        Date now = new Date();
        KwsRole role = new KwsRole();
        long roleId = new IdWorker(1L).nextId();
        role.setId(roleId);
        role.setEntId(kwsUserReqDto.getEntId());
        role.setName(DRIVER_ROLE_NAME);
        role.setAdminFlag(2);
        role.setRemark("司机用户默认角色");
        role.setStatus(Global.NO);
        role.setDelFlag(Global.NO);
        Long operator = kwsUserReqDto.getCreateBy() != null ? kwsUserReqDto.getCreateBy() : -1L;
        role.setCreateBy(operator);
        role.setCreateTime(kwsUserReqDto.getCreateTime() != null ? kwsUserReqDto.getCreateTime() : now);
        role.setUpdateBy(kwsUserReqDto.getUpdateBy() != null ? kwsUserReqDto.getUpdateBy() : operator);
        role.setUpdateTime(kwsUserReqDto.getUpdateTime() != null ? kwsUserReqDto.getUpdateTime() : now);
        if (kwsRoleDao.insert(role) <= 0) {
            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
        }
        return role;
    }

    /**
     * 根据用户名查用户信息
     *
     * @param username 用户账号
     * @return
     */
    @Override
    public KwsUserResDto getUserByAccount(String username) {
        return remoteBaseService.getUserByAccount(username);
    }


    /**
     * 根据用户姓名模糊查用户信息
     *
     * @param name 用户姓名
     * @return list
     */
    @Override
    public List<KwsUserResDto> getUserByName(String name) {
        return remoteBaseService.getUserByName(name);
    }

    @Override
    public List<KwsUserDeptResDto> queryUserDeptByUserId(Long userId) {
        return remoteBaseService.queryUserDeptByUserId(userId);
    }

    @Override
    public List<KwsDeptResDto> queryDeptByIds(List<Long> ids) {
        return remoteBaseService.queryDeptByIds(ids);
    }

    @Override
    public void register(RegisterReqDto reqDto) throws SystemException {
        kwsUserService.register(reqDto);
    }

    @Override
    public void checkPassword(String account, String password, String currentPwd, String salt) throws SystemException {
        kwsUserService.checkPassword(account, password, currentPwd, salt);
    }

    @Override
    public List<KwsUserResDto> checkUserBase(String account, int systemType) throws SystemException {
        KwsUser kwsUser = kwsUserService.checkUserBase(account, systemType);
        KwsUserResDto kwsUserService = new KwsUserResDto();
        BeanUtils.copyProperties(kwsUser, kwsUserService);
        return Collections.singletonList(kwsUserService);
    }

}
