|
@@ -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();
|
|
|
+ }
|
|
|
}
|