package com.pcloud.book.rightsSetting.dao.impl;

import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class RightsSettingDAOImpl   extends BaseDaoImpl<RightsSetting> implements RightsSettingDAO{
    @Override
    public int deleteByPrimaryKey(Long id) {
        return super.getSqlSession().delete(getStatement("deleteByPrimaryKey"),id);
    }

    @Override
    public RightsSetting selectByPrimaryKey(Long id) {
        return super.getSqlSession().selectOne(getStatement("selectByPrimaryKey"),id);
    }

    @Override
    public int updateByPrimaryKeySelective(RightsSetting record) {
        return super.getSqlSession().update(getStatement("updateByPrimaryKeySelective"),record);
    }

    @Override
    public int updateByPrimaryKey(RightsSetting record) {
        return  super.getSqlSession().update(getStatement("updateByPrimaryKeySelective"),record);
    }

    @Override
    public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId) {
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("firstClassify",firstClassify);
        paramMap.put("secondClassify",secondClassify);
        paramMap.put("gradeLabelId",gradeLabelId);
        paramMap.put("subjectLabelId",subjectLabelId);
        return getSessionTemplate().selectOne(getStatement("getByLabel"),paramMap);
    }
}
