package com.yd.dal.service.user.impl;

import com.yd.dal.entity.user.AclUser;
import com.yd.dal.mapper.user.UserMapper;
import com.yd.dal.service.user.AclUserDALService;
import com.yd.util.deshandler.DESTypeHandler;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

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

@Service("aclUserDALService")
public class AclUserDALServiceImpl implements AclUserDALService {
    @Resource
    private UserMapper aclUserMapper;

    @Override
    public List<AclUser> findByIds(List<Long> userIdList) {
        return aclUserMapper.findByIds(userIdList);
    }

    @Override
    public String selectNamesByMobileNos(String appointedApprovePractitioners) {
        DESTypeHandler desTypeHandler = new DESTypeHandler();
        List<String> origineList = Arrays.asList(appointedApprovePractitioners.split(","));
        List<String> mobileNoList = new ArrayList<>();
        for (String mobileNo : origineList) {
            mobileNoList.add(desTypeHandler.encode(mobileNo));
        }
        return aclUserMapper.selectNamesByMobileNos(mobileNoList);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return aclUserMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(AclUser record) {
        return aclUserMapper.insert(record);
    }

    @Override
    public int insertSelective(AclUser record) {
        return aclUserMapper.insertSelective(record);
    }

    @Override
    public AclUser selectByPrimaryKey(Long id) {
        return aclUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(AclUser record) {
        return aclUserMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AclUser record) {
        return aclUserMapper.updateByPrimaryKey(record);
    }
}
