package com.zd.exam.service.impl;

import java.util.List;

import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.datascope.annotation.DataScope;
import com.zd.common.security.utils.SaveUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.exam.mapper.ElExamClassifyMapper;
import com.zd.exam.domain.ElExamClassify;
import com.zd.exam.service.IElExamClassifyService;

/**
 * 题目类型Service业务层处理
 *
 * @author liubo
 * @date 2021-12-09
 */
@Service
public class ElExamClassifyServiceImpl implements IElExamClassifyService {
    @Autowired
    private ElExamClassifyMapper elExamClassifyMapper;

    /**
     * 查询题目类型
     *
     * @param id 题目类型主键
     * @return 题目类型
     */
    @Override
    public ElExamClassify selectElExamClassifyById(Long id) {
        return elExamClassifyMapper.selectElExamClassifyById(id);
    }

    /**
     * 查询题目类型列表
     *
     * @param elExamClassify 题目类型
     * @return 题目类型
     */
    @Override
    @DataScope(deptAlias = "t" , userAlias = "t" , permi = PerPrefix.EXAM_EL_CLASSIFY)
    public List<ElExamClassify> selectElExamClassifyList(ElExamClassify elExamClassify) {
        return elExamClassifyMapper.selectElExamClassifyList(elExamClassify);
    }

    /**
     * 新增题目类型
     *
     * @param elExamClassify 题目类型
     * @return 结果
     */
    @Override
    public int insertElExamClassify(ElExamClassify elExamClassify) {
        //设置其他公共字段
        SaveUtil.setCommonAttr(elExamClassify);
        return elExamClassifyMapper.insertElExamClassify(elExamClassify);
    }

    /**
     * 修改题目类型
     *
     * @param elExamClassify 题目类型
     * @return 结果
     */
    @Override
    public int updateElExamClassify(ElExamClassify elExamClassify) {
        elExamClassify.setUpdateTime(DateUtils.getNowDate());
        elExamClassify.setUpdateBy(SecurityUtils.getUsername());
        return elExamClassifyMapper.updateElExamClassify(elExamClassify);
    }

    /**
     * 批量删除题目类型
     *
     * @param ids 需要删除的题目类型主键
     * @return 结果
     */
    @Override
    public int deleteElExamClassifyByIds(Long[] ids) {
        return elExamClassifyMapper.deleteElExamClassifyByIds(ids);
    }

    /**
     * 删除题目类型信息
     *
     * @param id 题目类型主键
     * @return 结果
     */
    @Override
    public int deleteElExamClassifyById(Long id) {
        return elExamClassifyMapper.deleteElExamClassifyById(id);
    }
}
