Преглед на файлове

App端诊断日志上传

itcast преди 1 година
родител
ревизия
e7cb7b3695

+ 44 - 2
src/main/java/com/om/controller/admin/SdkVersionInfoController.java

@@ -1,9 +1,14 @@
 package com.om.controller.admin;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.om.entity.vo.PcbInfoVO;
+import com.om.service.ISdkVersionInfoService;
+import com.om.utils.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
 
 /**
  * <p>
@@ -15,6 +20,43 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/sdk-version-info")
+@Api(tags = "SDK模块")
 public class SdkVersionInfoController {
 
+    @Resource
+    ISdkVersionInfoService infoService;
+    @ApiOperation("增加按钮")
+    @PostMapping("/add")
+    public Result add(@RequestBody PcbInfoVO pcbInfoVO){
+
+        return infoService.add(pcbInfoVO);
+    }
+    @ApiOperation("删除sdk")
+    @DeleteMapping("/delete/{id}")
+    public Result delete(@PathVariable(name = "id") Integer id){
+
+        return infoService.delete(id);
+    }
+    @ApiOperation("下载文件")
+    @GetMapping("/downloadFile")
+    public Result downloadFile(@RequestParam Integer id){
+
+        return infoService.downloadFile(id);
+    }
+    @ApiOperation("修改sdk")
+    @PostMapping("/edit")
+    public Result edit(@RequestBody PcbInfoVO pcbInfoVO){
+
+        return infoService.edit(pcbInfoVO);
+    }
+
+    @ApiOperation("分页查询sdk数据集合")
+    @GetMapping("/getPageList")
+    public Result getPageList(@RequestParam Integer pageIndex,
+                              @RequestParam Integer pageSize,
+                              @RequestParam String username){
+
+        return infoService.getPageList(pageIndex,pageSize,username);
+    }
+
 }

+ 64 - 0
src/main/java/com/om/entity/vo/SDKInfoVO.java

@@ -0,0 +1,64 @@
+package com.om.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class SDKInfoVO {
+    @ApiModelProperty(value = "SdkVersionInfoId")
+    private Integer id;
+
+    @ApiModelProperty(value = "文件名")
+    private String fileName;
+
+    @ApiModelProperty(value = "文件大小")
+    private Long fileSize;
+
+    @ApiModelProperty(value = "上传人名称")
+    private String adminName;
+
+    @ApiModelProperty(value = "语言描述")
+    private String[] description;
+
+    @ApiModelProperty(value = "语言")
+    private String[] language;
+
+    @ApiModelProperty(value = "pcbId")
+    private Integer pcbId;
+
+    @ApiModelProperty(value = "客户端编号")
+    private String[] clientNum;
+
+    @ApiModelProperty(value = "发布时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private LocalDateTime releaseTime;
+
+    @ApiModelProperty(value = "保存路径")
+    private String savePath;
+
+    @ApiModelProperty(value = "pcb版本信息")
+    private String pcbVersion;
+
+    @ApiModelProperty(value = "状态")
+    private Integer status;
+
+    @ApiModelProperty(value = "版本编号")
+    private String versionNum;
+
+    @ApiModelProperty(value = "更新时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private LocalDateTime createTime;
+}

+ 12 - 0
src/main/java/com/om/service/ISdkVersionInfoService.java

@@ -2,6 +2,9 @@ package com.om.service;
 
 import com.om.entity.po.SdkVersionInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.om.entity.vo.PcbInfoVO;
+import com.om.entity.vo.SDKInfoVO;
+import com.om.utils.Result;
 
 /**
  * <p>
@@ -13,4 +16,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ISdkVersionInfoService extends IService<SdkVersionInfo> {
 
+    Result getPageList(Integer pageIndex, Integer pageSize, String username);
+
+    Result edit(SDKInfoVO infoVO);
+
+    Result downloadFile(Integer id);
+
+    Result delete(Integer id);
+
+    Result add(SDKInfoVO infoVO);
 }

+ 147 - 1
src/main/java/com/om/service/impl/SdkVersionInfoServiceImpl.java

@@ -1,11 +1,25 @@
 package com.om.service.impl;
 
-import com.om.entity.po.SdkVersionInfo;
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.om.entity.po.*;
+import com.om.entity.vo.PcbInfoVO;
+import com.om.entity.vo.SDKInfoVO;
 import com.om.mapper.SdkVersionInfoMapper;
+import com.om.service.ISdkClientsService;
+import com.om.service.IclientsService;
+import com.om.service.ISdkVersionDescribeService;
 import com.om.service.ISdkVersionInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.om.utils.Result;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -16,5 +30,137 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class SdkVersionInfoServiceImpl extends ServiceImpl<SdkVersionInfoMapper, SdkVersionInfo> implements ISdkVersionInfoService {
+    
+    @Resource
+    private ISdkClientsService clientsService;
+    
+    @Resource
+    private ISdkVersionDescribeService describeService;
+
+
+
+    @Override
+    public Result getPageList(Integer pageIndex, Integer pageSize, String username) {
+        Page<PcbVersionInfo> page = this.lambdaQuery()
+                .like(StringUtils.isNotBlank(username), PcbVersionInfo::getAdminName, username)
+                .page(new Page<>(pageIndex, pageSize));
+        List<PcbVersionInfo> infoList = page.getRecords();
+
+        //返回的List集合
+        List<PcbInfoVO> pcbInfoVOS = new ArrayList<>();
+        for (int i = 0; i < infoList.size(); i++) {
+            //传输的类型
+            PcbInfoVO pcbInfoVO = new PcbInfoVO();
+
+            PcbVersionInfo pcbVersionInfo = infoList.get(i);
+            //先copy基本数据
+            BeanUtil.copyProperties(pcbVersionInfo,pcbInfoVO);
+
+            Integer id = pcbVersionInfo.getId();
+            //先取语言和描述信息
+            LambdaQueryWrapper<PcbVersionDescribe> describeQueryWrapper = new LambdaQueryWrapper<>();
+            describeQueryWrapper.eq(PcbVersionDescribe::getPcbId,id);
+            List<PcbVersionDescribe> describeList = describeService.list(describeQueryWrapper);
+            //把取出来的数据存入俩个字符串中
+            String [] l = new String[describeList.size()];
+            String [] d = new String[describeList.size()];
+
+            for (int i1 = 0; i1 < describeList.size(); i1++) {
+                l[i1] = describeList.get(i1).getLanguage();
+                d[i1] = describeList.get(i1).getDescription();
+            }
+            pcbInfoVO.setDescription(d);
+            pcbInfoVO.setLanguage(l);
+
+            //在取出来客户端编号
+            LambdaQueryWrapper<SdkClients> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(SdkClients::getPcbId,id);
+            List<SdkClients> list = clientsService.list(queryWrapper);
+            String [] n = new String[list.size()];
+            for (int j = 0; j < n.length; j++) {
+                n[j] = list.get(j).getClientNum();
+            }
+            pcbInfoVO.setClientNum(n);
+            pcbInfoVOS.add(pcbInfoVO);
+        }
+
+        Page<PcbInfoVO> pcbVOPage = new Page<>();
+        BeanUtil.copyProperties(page,pcbVOPage);
+        pcbVOPage.setRecords(pcbInfoVOS);
+
+        return Result.ok(pcbVOPage);
+    }
+
+    @Override
+    public Result edit(SDKInfoVO infoVO) {
+        SdkVersionInfo info = getById(infoVO.getId());
+        LambdaQueryWrapper<SdkVersionInfo> infoQueryWapper = new LambdaQueryWrapper<>();
+        infoQueryWapper.eq(SdkVersionInfo::getId,info.getId());
+        BeanUtil.copyProperties(infoVO,info);
+        this.update(info,infoQueryWapper);
+
+        //修改客户端id
+        String[] clientNum = infoVO.getClientNum();
+        LambdaQueryWrapper<SdkClients> clientQueryWrapper = new LambdaQueryWrapper<>();
+        clientQueryWrapper.eq(SdkClients::getSdkId,infoVO.getId());
+        clientsService.remove(clientQueryWrapper);
+        for (int i = 0; i < clientNum.length; i++) {
+            SdkClients SdkClients = new SdkClients();
+            SdkClients.setSdkId(infoVO.getId());
+            SdkClients.setClientNum(clientNum[i]);
+            clientsService.save(SdkClients);
+        }
+
+        //没有进行描述和语言进行修改
+
+        return Result.ok();
+
+    }
+
+    @Override
+    public Result downloadFile(Integer id) {
+        return null;
+    }
+
+    @Override
+    public Result delete(Integer id) {
+        boolean pcb = removeById(id);
+        LambdaQueryWrapper<SdkVersionDescribe> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SdkVersionDescribe::getSdkId,id);
+        boolean info = describeService.remove(queryWrapper);
+        //还有关联表删除
+        LambdaQueryWrapper<SdkClients> clientsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        clientsLambdaQueryWrapper.eq(SdkClients::getSdkId,id);
+        clientsService.remove(clientsLambdaQueryWrapper);
+        return Result.ok();
+    }
+
+    @Override
+    public Result add(SDKInfoVO sdkInfoVO) {
+        SdkVersionInfo sdkVersionInfo = new SdkVersionInfo();
+        BeanUtil.copyProperties(sdkInfoVO,sdkVersionInfo);
+        this.save(sdkVersionInfo);
+        Integer sdkInfoId = sdkVersionInfo.getId();
+
+        //SdkClient表关联
+        for (int i = 0; i < sdkInfoVO.getClientNum().length; i++) {
+
+            SdkClients sdkClients = new SdkClients();
+            sdkClients.setSdkId(sdkInfoId);
+            sdkClients.setClientNum(sdkInfoVO.getClientNum()[i]);
+            clientsService.save(sdkClients);
+        }
+
+
+        for (int i = 0; i < sdkInfoVO.getLanguage().length; i++) {
+
+            SdkVersionDescribe describe = new SdkVersionDescribe();
+            describe.setSdkId(sdkInfoId);
+            describe.setLanguage(sdkInfoVO.getLanguage()[i]);
+            describe.setDescription(sdkInfoVO.getDescription()[i]);
+            describeService.save(describe);
+        }
 
+        return  Result.ok();
+    }
 }