package com.xhkjedu.sstudy.service.subjectbook;

import com.xhkjedu.sstudy.mapper.subjectbook.VersionMapper;
import com.xhkjedu.sstudy.model.subjectbook.TVersion;
import com.xhkjedu.sstudy.utils.StudyUtil;
import com.xhkjedu.utils.N_Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ClassName SubjectService
 * Description TODO 教材版本
 * Author WN
 * Date 2020/6/1 11:44
 **/
@Service
public class VersionService {
    @Autowired
    private VersionMapper versionMapper;

   /**
    *功能描述 版本--列表
    * @author WN
    * @date 2020/6/2
    * @param version
    */
    public List<TVersion> listVersions(TVersion version){
        return versionMapper.listVersions(version);
    }

   /**
    *功能描述 版本--添加
    * @author WN
    * @date 2020/6/2
    * @param  * @param version
    * @return java.lang.Integer
    */
    public Integer addVersion(TVersion version){
        String id = StudyUtil.getId();
        version.setVersionid(id);
        version.setCreatetime(N_Utils.getSecondTimestamp());
        return versionMapper.insertSelective(version);
    }

    /**
     *功能描述 版本--修改
     * @author WN
     * @date 2020/6/2
     * @param  * @param version
     * @return java.lang.Integer
     */
    public Integer updateVersion(TVersion version){
        version.setCreatetime(N_Utils.getSecondTimestamp());
        return versionMapper.updateByPrimaryKeySelective(version);
    }

   /**
    *功能描述  版本--删除
    * @author WN
    * @date 2020/6/2
    * @param  * @param version
    * @return java.lang.Integer
    */
    public Integer delVersion(TVersion version){
        return versionMapper.deleteByPrimaryKey(version.getVersionid());
    }

    //查找使用版本的模块
    public String findUseModule(String versionid) {
        return versionMapper.findUseModule(versionid);
    }

}
