package com.ruoyi.predict.service.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.predict.domain.WtgType;
import com.ruoyi.predict.mapper.WtgTypeMapper;
import com.ruoyi.predict.service.IWtgTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * WtgTypeService业务层处理
 *
 * @author hlf
 * @date 2022-01-10
 */
@Service
public class WtgTypeServiceImpl implements IWtgTypeService {
    @Autowired(required = false)
    private WtgTypeMapper wtgTypeMapper;

    /**
     * 查询WtgType
     *
     * @param typeNo WtgTypeID
     * @return WtgType
     */
    @Override
    public WtgType selectWtgTypeById(Long typeNo) {
        return wtgTypeMapper.selectWtgTypeById(typeNo);
    }

    /**
     * 查询WtgType列表
     *
     * @param wtgType WtgType
     * @return WtgType
     */
    @Override
    public List<WtgType> selectWtgTypeList(WtgType wtgType) {
        return wtgTypeMapper.selectWtgTypeList(wtgType);
    }

    /**
     * 新增WtgType
     *
     * @param wtgType WtgType
     * @return 结果
     */
    @Override
    public int insertWtgType(WtgType wtgType) {
        return wtgTypeMapper.insertWtgType(wtgType);
    }

    /**
     * 修改WtgType
     *
     * @param wtgType WtgType
     * @return 结果
     */
    @Override
    public int updateWtgType(WtgType wtgType) {
        return wtgTypeMapper.updateWtgType(wtgType);
    }

    /**
     * 删除WtgType信息
     *
     * @param typeNo WtgTypeID
     * @return 结果
     */
    @Override
    public int deleteWtgTypeById(Long typeNo) {
        return wtgTypeMapper.deleteWtgTypeById(typeNo);
    }

    /**
     * 删除WtgType对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWtgTypeByIds(String ids) {
        return wtgTypeMapper.deleteWtgTypeByIds(Convert.toStrArray(ids));
    }

    @Override
    public Long selectNewData() {
        return wtgTypeMapper.selectNewData();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertWtgTypeList(List<WtgType> wtgTypeList) {
        return wtgTypeMapper.insertWtgTypeList(wtgTypeList);
    }

    @Override
    public String checkTypeNoUnique(Long typeNo) {
        int count = wtgTypeMapper.checkTypeNoUnique(typeNo);
        if (count > 0)
        {
            return UserConstants.USER_NAME_NOT_UNIQUE;
        }
        return UserConstants.USER_NAME_UNIQUE;
    }

    @Override
    public WtgType selectWtgTypeByTypeName(String fanType) {
        return wtgTypeMapper.selectWtgTypeByTypeName(fanType);
    }
}
