package com.vote.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vote.system.domain.VoteOrganizers;
import com.vote.system.service.VoteOrganizersService;
import com.vote.system.mapper.VoteOrganizersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * @author MacBook
 * @description 针对表【vote_organizers(主办方)】的数据库操作Service实现
 * @createDate 2024-08-11 17:31:18
 */
@Service
public class VoteOrganizersServiceImpl extends ServiceImpl<VoteOrganizersMapper, VoteOrganizers>
        implements VoteOrganizersService {

    @Autowired
    private VoteOrganizersMapper voteOrganizersMapper;

    @Override
    public List<VoteOrganizers> getOrganizers() {
        //查所有
        List<VoteOrganizers> organizers = voteOrganizersMapper.selectList(null);
        if (organizers == null) {
            return Collections.emptyList();
        }
        return organizers;
    }

    /**
     * 添加主办方
     * @param voteOrganizers
     * @return
     */
    @Override
    @Transactional
    public int addOrganizers(VoteOrganizers voteOrganizers) {
        //添加
        return voteOrganizersMapper.insert(voteOrganizers);
    }
}




