package com.xhkjedu.sapi.service.appversion;

import com.xhkjedu.sapi.mapper.appversion.WebVersionMapper;
import com.xhkjedu.sapi.model.appversion.TWebVersion;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ywx
 * @classname WebVersionService
 * @description
 * @date 2022/6/27 14:55
 **/
@Service
public class WebVersionService {
    @Resource
    private WebVersionMapper webVersionMapper;

    //添加
    public void save(TWebVersion model) {
        Integer code = webVersionMapper.getCode(model.getVersiontype());//获取构建版
        model.setVersioncode(code);
        model.setCreatetime(N_Utils.getSecondTimestamp());
        webVersionMapper.insertSelective(model);
    }

    //删除
    public Integer deleteById(Integer versionid) {
        return webVersionMapper.deleteByPrimaryKey(versionid);
    }

    //修改
    public Integer update(TWebVersion model) {
        model.setVersioncode(null);
        model.setCreatetime(N_Utils.getSecondTimestamp());
        return webVersionMapper.updateByPrimaryKeySelective(model);
    }

    //获取列表
    public List<Map> listAll(TWebVersion app) {
        return webVersionMapper.listAll(app);
    }

    /**
     * 获取最新版本
     *
     * @return java.util.Map
     * @Param [versiontype]
     * @Author ywx
     * @Date 2022/6/27 15:18
     **/
    public Map getNew(Integer versiontype) {
        return webVersionMapper.getNew(versiontype);
    }
}
