| package com.xzx.gc.user.service;  | 
|   | 
| import cn.hutool.core.convert.Convert;  | 
| import cn.hutool.core.util.NumberUtil;  | 
| import cn.hutool.core.util.StrUtil;  | 
| import com.xzx.gc.common.constant.Constants;  | 
| import com.xzx.gc.common.utils.BusinessUtil;  | 
| import com.xzx.gc.entity.VersionInfo;  | 
| import com.xzx.gc.user.mapper.VersionInfoMapper;  | 
| import lombok.extern.slf4j.Slf4j;  | 
| import org.springframework.beans.factory.annotation.Autowired;  | 
| import org.springframework.stereotype.Service;  | 
| import org.springframework.transaction.annotation.Transactional;  | 
|   | 
| import javax.servlet.http.HttpServletRequest;  | 
|   | 
| @Service  | 
| @Transactional  | 
| @Slf4j  | 
| public class VersionService {  | 
|   | 
|     @Autowired  | 
|     private VersionInfoMapper versionInfoMapper;  | 
|   | 
|     @Autowired  | 
|     private HttpServletRequest request;  | 
|       | 
|     @Autowired  | 
|     private BusinessUtil businessUtil;  | 
|   | 
|     public VersionInfo find(){  | 
|         String version = request.getHeader("anroidVersion");  | 
|         if(StrUtil.isNotBlank(version)){  | 
|             Double currentVersion = businessUtil.getVersion(version);  | 
|             VersionInfo versionInfo=new VersionInfo();  | 
|             versionInfo.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));  | 
|             VersionInfo versionInfo1 = versionInfoMapper.selectOne(versionInfo);  | 
|             Double newVersion = versionInfo1.getNewVersion();  | 
|             Double minVersion = versionInfo1.getMinVersion();  | 
|   | 
|             if(NumberUtil.compare(currentVersion,newVersion)<0){  | 
|                 versionInfo1.setUpdateFlag(Convert.toShort(Constants.RESULT_SUCCESS));  | 
|             }  | 
|             if(NumberUtil.compare(currentVersion,minVersion)<0) {  | 
|                 versionInfo1.setForceUpdateFlag(Convert.toShort(Constants.RESULT_SUCCESS));  | 
|             }  | 
|             return  versionInfo1;  | 
|         }else {  | 
|             return null;  | 
|         }  | 
|     }  | 
| }  | 
|   |