package com.ruoyi.web.controller.manager;

import cn.hutool.core.convert.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.repo.ElRepo;
import com.ruoyi.system.domain.repo.vo.RepoVO;
import com.ruoyi.system.service.ElRepoService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * packageName com.ruoyi.web.controller.manager
 *
 * @author wangxy
 * @version JDK 8
 * @className ElRepoManager
 * @date 2024/6/27
 * @description 题库
 */
@Component
public class RepoManager {


    @Resource
    private ElRepoService elRepoService;


    /**
     * 查询
     *
     * @param repo
     * @return java.util.List<com.hyp.system.domain.SysNotice>
     */
    public List<RepoVO> selectRepoList(ElRepo repo) {
        return elRepoService.selectRepoList(repo);
    }


    /**
     * 修改
     *
     * @param repo
     * @return boolean
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(ElRepo repo) {
        if (StringUtils.isNotEmpty(repo.getId())) {
            repo.setUpdateTime(new Date());
        } else {
            repo.setCreateTime(new Date());
        }
        return elRepoService.saveOrUpdate(repo);
    }


    public ElRepo getById(String id) {
        return elRepoService.getById(id);
    }


    public List<ElRepo> getList() {
        return elRepoService.lambdaQuery().list();
    }

    public boolean deleteRepoByIds(String ids) {
        return elRepoService.removeByIds(Arrays.asList(Convert.toStrArray(ids)));
    }
}
