package com.cm.common.plugin.service.authority.impl;

import com.cm.common.base.AbstractService;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.plugin.dao.authority.IAuthorityDao;
import com.cm.common.plugin.pojo.vos.authority.AuthorityUserVO;
import com.cm.common.plugin.service.authority.IAuthorityService;
import com.cm.common.utils.HashMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: AuthorityServiceImpl
 * @Description: 权限
 * @Author: WangGeng
 * @Date: 2019/12/14 11:01 上午
 * @Version: 1.0
 **/
@Service
public class AuthorityServiceImpl extends AbstractService implements IAuthorityService {

    @Autowired
    private IAuthorityDao authorityDao;

    @Override
    public void saveAuthorityUser(AuthorityUserVO authorityUserVO) throws Exception {
        Map<String, Object> params = HashMapUtil.beanToMap(authorityUserVO);
        authorityDao.saveAuthorityUser(params);
    }

    @Override
    public void deleteAuthorityUserByUserId(String userId) throws RemoveException {
        Map<String, Object> params = getHashMap(1);
        params.put("userId", userId);
        authorityDao.deleteAuthorityUser(params);
    }
}
