浏览代码

APP端VCI固件更新

bmmx 1 年之前
父节点
当前提交
2933720d12

+ 29 - 0
src/main/java/com/om/controller/user/APPVciController.java

@@ -0,0 +1,29 @@
+package com.om.controller.user;
+
+import com.om.entity.dto.AppBaseDTO;
+import com.om.entity.vo.AppSDKVO;
+import com.om.service.IVciInfoService;
+import com.om.utils.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@Api(tags = "APP端VCI固件模块")
+@RequestMapping("app/vci")
+public class APPVciController {
+
+    @Resource
+    private IVciInfoService vciInfoService;
+    @ApiOperation("VCI固件更新")
+    @PostMapping("/update")
+    public Result<AppSDKVO> VciUpdate(@RequestBody AppBaseDTO dto){
+        return vciInfoService.VciUpdate(dto);
+    }
+
+}

+ 14 - 0
src/main/java/com/om/entity/vo/AppSDKVO.java

@@ -0,0 +1,14 @@
+package com.om.entity.vo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+public class AppSDKVO {
+
+    private List<SDKData> sdkData;
+    private List<appData> appData;
+}

+ 24 - 0
src/main/java/com/om/entity/vo/SDKData.java

@@ -0,0 +1,24 @@
+package com.om.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class SDKData {
+    @ApiModelProperty(value = "文件大小")
+    private String fileSize;
+
+    @ApiModelProperty(value = "SDK版本")
+    private String version;
+
+    @ApiModelProperty(value = "版本描述")
+    private String description;
+
+    @ApiModelProperty(value = "pcb版本")
+    private String pcbVersion;
+
+    @ApiModelProperty(value = "下载地址")
+    private String url;
+}

+ 24 - 0
src/main/java/com/om/entity/vo/appData.java

@@ -0,0 +1,24 @@
+package com.om.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class appData {
+    @ApiModelProperty(value = "文件大小")
+    private String fileSize;
+
+    @ApiModelProperty(value = "app版本")
+    private String version;
+
+    @ApiModelProperty(value = "版本描述")
+    private String description;
+
+    @ApiModelProperty(value = "最小的sdk版本")
+    private String minSdkVersion;
+
+    @ApiModelProperty(value = "下载地址")
+    private String url;
+}

+ 4 - 0
src/main/java/com/om/service/IVciInfoService.java

@@ -1,8 +1,10 @@
 package com.om.service;
 
+import com.om.entity.dto.AppBaseDTO;
 import com.om.entity.dto.VciQueryPageDTO;
 import com.om.entity.po.VciInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.om.entity.vo.AppSDKVO;
 import com.om.entity.vo.UserVciVO;
 import com.om.entity.vo.VciQueryPageVO;
 import com.om.utils.Result;
@@ -32,4 +34,6 @@ public interface IVciInfoService extends IService<VciInfo> {
     Result<List<UserVciVO>> getListByUserId(Integer userId);
 
     Result<VciQueryPageVO> getPageList(VciQueryPageDTO dto);
+
+    Result<AppSDKVO> VciUpdate(AppBaseDTO dto);
 }

+ 122 - 10
src/main/java/com/om/service/impl/VciInfoServiceImpl.java

@@ -3,22 +3,19 @@ package com.om.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.om.entity.dto.AppBaseDTO;
+import com.om.entity.dto.GuidDTO;
 import com.om.entity.dto.VciQueryPageDTO;
-import com.om.entity.po.DiagnosticLog;
-import com.om.entity.po.User;
-import com.om.entity.po.UserVci;
-import com.om.entity.po.VciInfo;
-import com.om.entity.vo.DiaLogQueryPageVO;
-import com.om.entity.vo.UserVciVO;
-import com.om.entity.vo.VciQueryPageVO;
+import com.om.entity.po.*;
+import com.om.entity.vo.*;
 import com.om.exception.BadReqException;
 import com.om.mapper.UserMapper;
 import com.om.mapper.VciInfoMapper;
-import com.om.service.IUserService;
-import com.om.service.IUserVciService;
-import com.om.service.IVciInfoService;
+import com.om.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.om.utils.JwtUtils;
 import com.om.utils.Result;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -26,6 +23,7 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -44,6 +42,31 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
     @Resource
     private IUserVciService userVciService;
 
+    @Resource
+    private JwtUtils jwtUtils;
+
+    @Resource
+    private ISdkClientsService sdkClientsService;
+
+    @Resource
+    private ISdkVersionInfoService sdkVersionInfoService;
+
+    @Resource
+    private ISdkVersionDescribeService sdkVersionDescribeService;
+
+    @Resource
+    private IPcbVersionInfoService pcbVersionInfoService;
+
+    @Resource
+    private IAppService appService;
+
+    @Resource
+    private IAppVersionDescribeService appVersionDescribeService;
+
+    @Resource
+    private IAppsClientsService appsClientsService;
+
+
     @Override
     public Result addVci(VciInfo vciInfo) {
         if (BeanUtil.isEmpty(vciInfo)){
@@ -159,5 +182,94 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
         return Result.ok(vo);
     }
 
+    @Override
+    public Result<AppSDKVO> VciUpdate(AppBaseDTO dto) {
+        if (BeanUtil.isEmpty(dto)){
+            throw new BadReqException("数据为空");
+        }
+
+        String guid = dto.getGuid();
+        GuidDTO guidDTO = jwtUtils.getGuidDTOFromToken(guid);
+        String clientNum = guidDTO.getClientNum();
+        String language = dto.getLanguage();
+        Integer userId = guidDTO.getUserId();
+
+        AppSDKVO appSDKVO = new AppSDKVO();
+        List<SDKData> sdkData = new ArrayList<>();
+        List<appData> appData = new ArrayList<>();
+
+        //根据客户端clientNum查询sdk
+        List<Integer> sdkIds = sdkClientsService.lambdaQuery()
+                .eq(SdkClients::getClientNum, clientNum)
+                .list().stream().map(c -> c.getSdkId()).collect(Collectors.toList());
+
+        List<SdkVersionInfo> sdkVersionInfos = sdkVersionInfoService.listByIds(sdkIds);
+        for (SdkVersionInfo sdkVersionInfo : sdkVersionInfos) {
+            SDKData sdk = BeanUtil.copyProperties(sdkVersionInfo, SDKData.class);
+            sdk.setVersion(sdkVersionInfo.getVersionNum());
+            sdk.setUrl(sdkVersionInfo.getSavePath());
+
+            //根据pcbId查询pcb
+            PcbVersionInfo pcbVersionInfo = pcbVersionInfoService.getById(sdkVersionInfo.getId());
+            if(BeanUtil.isEmpty(pcbVersionInfo)){
+                throw new BadReqException("该PCB版本不存在!!!");
+            }
+
+            SdkVersionDescribe sdkVersionDescribe = sdkVersionDescribeService.lambdaQuery()
+                    .eq(SdkVersionDescribe::getSdkId, sdkVersionInfo.getId())
+                    .eq(SdkVersionDescribe::getLanguage, language)
+                    .one();
+
+            if (BeanUtil.isEmpty(sdkVersionDescribe)){
+                throw new BadReqException("SDK版本描述不存在");
+            }
+
+            sdk.setDescription(sdkVersionDescribe.getDescription());
+            sdk.setPcbVersion(pcbVersionInfo.getVersionNum());
+            sdkData.add(sdk);
+        }
+
+        List<Integer> appIds = appsClientsService.lambdaQuery()
+                .eq(AppsClients::getClientNum, clientNum)
+                .list().stream().map(c -> c.getAppId()).collect(Collectors.toList());
+        List<App> apps = appService.listByIds(appIds);
+        if (apps.isEmpty()){
+            return Result.ok();
+        }
+        for (App app : apps) {
+            appData appData1 = BeanUtil.copyProperties(app, appData.class);
+            appData1.setVersion(app.getVersionNum());
+            appData1.setUrl(app.getSavePath());
+
+            AppVersionDescribe appVersionDescribe = appVersionDescribeService.lambdaQuery()
+                    .eq(AppVersionDescribe::getAppId, app.getId())
+                    .eq(AppVersionDescribe::getLanguage, language)
+                    .one();
+            if (BeanUtil.isEmpty(appVersionDescribe)){
+                throw new BadReqException("app版本描述不存在");
+            }
+
+
+            appData1.setDescription(appVersionDescribe.getDescription());
+            Integer sdkId = app.getSdkId();
+            //根据sdkid查询sdk版本
+            SdkVersionInfo sdkVersionInfo = sdkVersionInfoService.getById(sdkId);
+            if (BeanUtil.isEmpty(sdkVersionInfo)){
+                throw new BadReqException("该sdk版本不存在");
+            }
+
+            appData1.setMinSdkVersion(sdkVersionInfo.getVersionNum());
+
+            appData.add(appData1);
+        }
+
+
+        appSDKVO.setAppData(appData);
+        appSDKVO.setSdkData(sdkData);
+        return Result.ok(appSDKVO);
+    }
+
+   
+
 
 }