package cn.edu.whu.boot.apkversion.service;

import cn.edu.whu.boot.apkversion.mapper.ApkVersionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApkVersionService {

    @Autowired
    public ApkVersionMapper apkVersionMapper;

    public String getLatestVersion() {
        String lastversion=apkVersionMapper.getLatestVersion();
        if(lastversion!=null && !lastversion.equals("")){
            return lastversion;
        }
        return "0.1";
    }

    public String getDescriptionByVersion(String version) {
        String lastversion="无说明信息！";
        String res=apkVersionMapper.getDescriptionByVersion(version);
        if(res!=null&&!res.equals("")){
            lastversion=res;
        }
        return lastversion;
    }

    public String getApkPath(String version) {
        String apkPath=apkVersionMapper.getApkPathByVersion(version);
        if (apkPath!=null&& !apkPath.equals("")){
            return apkPath;
        }else {
            return "该版本不存在";
        }
    }
}
