xiaoyong931011
2021-06-25 64a787288e4fc42bae9aa214dc5b470185e791ac
Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop
3 files added
2 files modified
84 ■■■■ changed files
gc-core/src/main/java/com/xzx/gc/common/request/MyResponseBodyAdvice.java 3 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/mapper/VersionInfoMapper.java 8 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/service/VersionService.java 63 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/mapper/shop/VersionInfoMapper.xml 4 ●●●● patch | view | raw | blame | history
pom.xml 6 ●●●●● patch | view | raw | blame | history
gc-core/src/main/java/com/xzx/gc/common/request/MyResponseBodyAdvice.java
@@ -25,7 +25,6 @@
 * @author
 * @desc 返回数据加密
 */
@Slf4j
@ControllerAdvice
public class MyResponseBodyAdvice implements ResponseBodyAdvice {
@@ -49,9 +48,7 @@
            String authKey = serverHttpRequest.getHeaders().get("authKey").get(0);
            String s = JSONUtil.toJsonStr(body);
            if (!url.contains("/admin")) {
                log.info("这是进入了body");
                Object versionService = SpringUtil.getBean("versionService");
                log.info("这是进入了body:{}", versionService);
                VersionInfo versionInfo = ReflectUtil.invoke(versionService, "find");
                JSONObject jsonObject = JSONUtil.parseObj(s);
                if (versionInfo != null) {
gc-shop/src/main/java/com/xzx/gc/shop/mapper/VersionInfoMapper.java
New file
@@ -0,0 +1,8 @@
package com.xzx.gc.shop.mapper;
import com.xzx.gc.entity.VersionInfo;
import com.xzx.gc.util.GcMapper;
public interface VersionInfoMapper extends GcMapper<VersionInfo> {
}
gc-shop/src/main/java/com/xzx/gc/shop/service/VersionService.java
New file
@@ -0,0 +1,63 @@
package com.xzx.gc.shop.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.shop.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;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@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;
        }
    }
    public VersionInfo findNew(){
        VersionInfo versionInfo=new VersionInfo();
        versionInfo.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));
        List<VersionInfo> versionInfos = versionInfoMapper.select(versionInfo);
        return versionInfos.stream().sorted(Comparator.comparingLong(VersionInfo::getId).reversed()).collect(Collectors.toList()).get(0);
    }
}
gc-shop/src/main/resources/mapper/shop/VersionInfoMapper.xml
New file
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xzx.gc.system.mapper.VersionInfoMapper">
</mapper>
pom.xml
@@ -120,12 +120,6 @@
            <version>1.3.7</version>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.7.2</version>
        </dependency>
    </dependencies>
    <build>