package cn.pluss.platform.suggest.impl;

import java.util.List;
import java.util.Map;

import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.util.RegexUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.pluss.platform.entity.Suggest;
import cn.pluss.platform.suggest.SuggestService;
import cn.pluss.platform.mapper.SuggestMapper;

@Transactional
@Service("suggestService")
public class SuggestServiceImpl extends ServiceImpl<SuggestMapper, Suggest> implements SuggestService {

    private static final Logger logger = LoggerFactory.getLogger(SuggestServiceImpl.class);


    @Autowired
    private SuggestMapper suggestMapper;

    @Override
    public Suggest querySuggest(Suggest suggest) {
        return suggestMapper.querySuggest(suggest);
    }

    @Override
    public List<Suggest> querySuggestList(Suggest suggest) {
        return suggestMapper.querySuggestList(suggest);
    }

    @Override
    public void saveSuggest(Suggest suggest) {
        if (suggest.getPhone() != null && !RegexUtils.checkPhone(suggest.getPhone())) {
            throw new MsgException("手机号有误，请重新填写");
        }

        suggestMapper.saveSuggest(suggest);
    }

    @Override
    public void updateSuggest(Suggest suggest) {
        suggestMapper.updateSuggest(suggest);
    }

    @Override
    public void deleteSuggest(Suggest suggest) {
        suggestMapper.deleteSuggest(suggest);
    }

    @Override
    public List<Suggest> querySuggestPage(Map map) {
        return suggestMapper.querySuggestPage(map);
    }

    @Override
    public Integer querySuggestPageCount(Map map) {
        return suggestMapper.querySuggestPageCount(map);
    }

    @Override
    public void saveSuggestBatch(List<Suggest> suggestList) {
        suggestMapper.saveSuggestBatch(suggestList);
    }
}

