package com.ruoyi.project.plant.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.plant.mapper.TTargetlistMapper;
import com.ruoyi.project.plant.domain.TTargetlist;
import com.ruoyi.project.plant.service.ITTargetlistService;

import javax.annotation.Resource;

/**
 * 目标录入Service业务层处理
 *
 * @author ruoyi
 * @date 2020-11-24
 */
@Service
public class TTargetlistServiceImpl implements ITTargetlistService
{
    @Resource
    private TTargetlistMapper tTargetlistMapper;

    /**
     * 查询目标录入
     *
     * @param id 目标录入ID
     * @return 目标录入
     */
    @Override
    public TTargetlist selectTTargetlistById(Long id)
    {
        return tTargetlistMapper.selectTTargetlistById(id);
    }

    /**
     * 查询目标录入列表
     *
     * @param tTargetlist 目标录入
     * @return 目标录入
     */
    @Override
    public List<TTargetlist> selectTTargetlistList(TTargetlist tTargetlist)
    {
        return tTargetlistMapper.selectTTargetlistList(tTargetlist);
    }

    /**
     * 查询目标录入列表(目标措施)
     *
     * @param tTargetlist 目标录入
     * @return 目标录入集合
     */
    @Override
    public List<TTargetlist> selectListMeasures(TTargetlist tTargetlist) {
        return tTargetlistMapper.selectListMeasures(tTargetlist);
    }

    @Override
    public List<TTargetlist> selectAllContent(TTargetlist tTargetlist) {
        return tTargetlistMapper.selectAllContent(tTargetlist);
    }
    @Override
    public List<TTargetlist> selectAllMeasures(TTargetlist tTargetlist) {
        return tTargetlistMapper.selectAllMeasures(tTargetlist);
    }

    /**
     * 新增目标录入
     *
     * @param tTargetlist 目标录入
     * @return 结果
     */
    @Override
    public int insertTTargetlist(TTargetlist tTargetlist)
    {
        //序号排列
        String[] items = tTargetlist.getItem().split("\\.");
        tTargetlist.setItemTop(Long.parseLong(items[0]));
        if (items.length == 1) {
            tTargetlist.setItemLast(Long.parseLong("0"));
        }else {
            tTargetlist.setItemLast(Long.parseLong(items[1]));
        }
        return tTargetlistMapper.insertTTargetlist(tTargetlist);
    }

    /**
     * 修改目标录入
     *
     * @param tTargetlist 目标录入
     * @return 结果
     */
    @Override
    public int updateTTargetlist(TTargetlist tTargetlist)
    {
        //序号排列
        String[] items = tTargetlist.getItem().split("\\.");
        tTargetlist.setItemTop(Long.parseLong(items[0]));
        if (items.length == 1) {
            tTargetlist.setItemLast(Long.parseLong("0"));
        }else {
            tTargetlist.setItemLast(Long.parseLong(items[1]));
        }
        return tTargetlistMapper.updateTTargetlist(tTargetlist);
    }

    /**
     * 批量删除目标录入
     *
     * @param ids 需要删除的目标录入ID
     * @return 结果
     */
    @Override
    public int deleteTTargetlistByIds(Long[] ids)
    {
        return tTargetlistMapper.deleteTTargetlistByIds(ids);
    }

    /**
     * 删除目标录入信息
     *
     * @param id 目标录入ID
     * @return 结果
     */
    @Override
    public int deleteTTargetlistById(Long id)
    {
        return tTargetlistMapper.deleteTTargetlistById(id);
    }
}
