|
@@ -1,24 +1,45 @@
|
|
package cn.cslg.permission.service;
|
|
package cn.cslg.permission.service;
|
|
|
|
|
|
import cn.cslg.permission.common.model.Records;
|
|
import cn.cslg.permission.common.model.Records;
|
|
|
|
+import cn.cslg.permission.common.model.common.SystemFile;
|
|
import cn.cslg.permission.common.model.dto.*;
|
|
import cn.cslg.permission.common.model.dto.*;
|
|
|
|
+import cn.cslg.permission.common.model.qiaobi.version.AddFunctionDTO;
|
|
|
|
+import cn.cslg.permission.common.model.qiaobi.version.QiaoBiVersionVO;
|
|
|
|
+import cn.cslg.permission.common.model.qiaobi.version.VersionStatusDTO;
|
|
|
|
+import cn.cslg.permission.common.model.vo.FunctionVO;
|
|
import cn.cslg.permission.common.model.vo.VersionVO;
|
|
import cn.cslg.permission.common.model.vo.VersionVO;
|
|
|
|
+import cn.cslg.permission.common.utils.LoginUtils;
|
|
|
|
+import cn.cslg.permission.domain.Application;
|
|
|
|
+import cn.cslg.permission.domain.Function;
|
|
|
|
+import cn.cslg.permission.domain.Personnel;
|
|
import cn.cslg.permission.domain.Version;
|
|
import cn.cslg.permission.domain.Version;
|
|
import cn.cslg.permission.domain.associate.AssoFunctionModule;
|
|
import cn.cslg.permission.domain.associate.AssoFunctionModule;
|
|
|
|
+import cn.cslg.permission.exception.ExceptionEnum;
|
|
|
|
+import cn.cslg.permission.exception.XiaoShiException;
|
|
import cn.cslg.permission.mapper.VersionMapper;
|
|
import cn.cslg.permission.mapper.VersionMapper;
|
|
-import cn.cslg.permission.service.associate.AssoFunctionModuleService;
|
|
|
|
|
|
+import cn.cslg.permission.service.outSideApi.FileManagerService;
|
|
|
|
+import cn.cslg.permission.service.qiaobi.AssoFunctionModuleService;
|
|
|
|
+import cn.cslg.permission.service.qiaobi.AssoVersionFunctionService;
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author xiexiang
|
|
* @Author xiexiang
|
|
@@ -26,153 +47,279 @@ import java.util.List;
|
|
*/
|
|
*/
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
-@RequiredArgsConstructor
|
|
|
|
|
|
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
public class VersionService extends ServiceImpl<VersionMapper, Version> {
|
|
public class VersionService extends ServiceImpl<VersionMapper, Version> {
|
|
|
|
+
|
|
private final AssoFunctionModuleService assoFunctionModuleService;
|
|
private final AssoFunctionModuleService assoFunctionModuleService;
|
|
-// private final FileManagerService fileManagerService;
|
|
|
|
|
|
+ // private final FileManagerService fileManagerService;
|
|
|
|
+ private final FunctionService functionService;
|
|
|
|
+ private final AssoVersionFunctionService assoVersionFunctionService;
|
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
|
+ private final PersonnelService personnelService;
|
|
|
|
+ private final FileManagerService fileManagerService;
|
|
|
|
+ private final ApplicationService applicationService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增
|
|
* 新增
|
|
*/
|
|
*/
|
|
- public Records add(VersionDTO versionDTO) {
|
|
|
|
- Records records = new Records();
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Integer add(VersionDTO versionDTO) {
|
|
Version version = new Version();
|
|
Version version = new Version();
|
|
|
|
+ List<AssoFunctionCodeDTO> codeDTOS = versionDTO.getAssoFunctionCodeDTOS();
|
|
|
|
+ if (codeDTOS == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String versionNum = versionDTO.getVersionNum();
|
|
BeanUtils.copyProperties(versionDTO, version);
|
|
BeanUtils.copyProperties(versionDTO, version);
|
|
|
|
+ if (version.getStatus() != null && version.getStatus().equals(3)) {
|
|
|
|
+ version.setPublishTime(new Date());
|
|
|
|
+ }
|
|
|
|
+ version.setCreateId(loginUtils.getId());
|
|
version.insert();
|
|
version.insert();
|
|
Integer id = version.getId();
|
|
Integer id = version.getId();
|
|
- String versionNum = version.getVersionNum();
|
|
|
|
- List<AssoFunctionModuleDTO> assoFunctionModuleDTOS = new ArrayList<>();
|
|
|
|
- List<AssoFunctionCodeDTO> codeDTOS = versionDTO.getAssoFunctionCodeDTOS();
|
|
|
|
- if (codeDTOS != null && !codeDTOS.isEmpty()) {
|
|
|
|
- for (AssoFunctionCodeDTO codeDTO : codeDTOS) {
|
|
|
|
- AssoFunctionModuleDTO assoFunctionModuleDTO = new AssoFunctionModuleDTO();
|
|
|
|
- // 代码和功能赋值
|
|
|
|
- assoFunctionModuleDTO.setFunctionId(codeDTO.getFunctionId());
|
|
|
|
- assoFunctionModuleDTO.setCode(codeDTO.getCode());
|
|
|
|
- // 版本id
|
|
|
|
- assoFunctionModuleDTO.setVersionId(id);
|
|
|
|
- // 版本号
|
|
|
|
- assoFunctionModuleDTO.setVersion(versionNum);
|
|
|
|
- // 字段配置
|
|
|
|
- assoFunctionModuleDTO.setAuthType(codeDTO.getAuthType());
|
|
|
|
- assoFunctionModuleDTO.setCreateUser(versionDTO.getCreateUser());
|
|
|
|
- assoFunctionModuleDTO.setIsDelete(false);
|
|
|
|
- assoFunctionModuleDTOS.add(assoFunctionModuleDTO);
|
|
|
|
- }
|
|
|
|
- assoFunctionModuleService.add(assoFunctionModuleDTOS);
|
|
|
|
- }
|
|
|
|
- records.setRecords(version.getId());
|
|
|
|
- return records;
|
|
|
|
|
|
+ //保存版本和功能关联
|
|
|
|
+ List<Integer> functionIds = codeDTOS.stream().map(AssoFunctionCodeDTO::getFunctionId).collect(Collectors.toList());
|
|
|
|
+ assoVersionFunctionService.addAssoVersionFunctions(functionIds, version.getId());
|
|
|
|
+
|
|
|
|
+ assoFunctionModuleService.saveFunctionModuleBatch(codeDTOS, id, versionNum);
|
|
|
|
+ return id;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * 更新版本
|
|
*/
|
|
*/
|
|
- public Records update(VersionDTO versionDTO) {
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Integer update(VersionDTO versionDTO) {
|
|
|
|
+// Integer personId =loginUtils.getId();
|
|
|
|
+ Integer personId = 1;
|
|
Records records = new Records();
|
|
Records records = new Records();
|
|
Integer id = versionDTO.getId();
|
|
Integer id = versionDTO.getId();
|
|
|
|
+ this.checkVersionStatus(id);
|
|
|
|
+
|
|
Version version = this.getById(id);
|
|
Version version = this.getById(id);
|
|
BeanUtils.copyProperties(versionDTO, version);
|
|
BeanUtils.copyProperties(versionDTO, version);
|
|
|
|
+ if (versionDTO.getStatus() != null && versionDTO.getStatus().equals(3)) {
|
|
|
|
+ version.setPublishTime(new Date());
|
|
|
|
+ }
|
|
|
|
+ version.setCreateId(personId);
|
|
version.updateById();
|
|
version.updateById();
|
|
- records.setRecords(id);
|
|
|
|
- return records;
|
|
|
|
|
|
+ List<AssoFunctionCodeDTO> codeDTOS = versionDTO.getAssoFunctionCodeDTOS();
|
|
|
|
+ List<Integer> functionIds = new ArrayList<>();
|
|
|
|
+ if (codeDTOS != null && codeDTOS.size() > 0) {
|
|
|
|
+ functionIds = codeDTOS.stream().map(AssoFunctionCodeDTO::getFunctionId).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ assoVersionFunctionService.addAssoVersionFunctions(functionIds, version.getId());
|
|
|
|
+ String versionNum = version.getVersionNum();
|
|
|
|
+ assoFunctionModuleService.saveFunctionModuleBatch(codeDTOS, id, versionNum);
|
|
|
|
+ return id;
|
|
}
|
|
}
|
|
|
|
|
|
- public Records queryVersionList(QueryVersionListDTO queryVersionListDTO){
|
|
|
|
|
|
+ public Records queryVersionList(QueryVersionListDTO queryVersionListDTO) {
|
|
Records records = new Records();
|
|
Records records = new Records();
|
|
Long current = queryVersionListDTO.getCurrent();
|
|
Long current = queryVersionListDTO.getCurrent();
|
|
Long size = queryVersionListDTO.getSize();
|
|
Long size = queryVersionListDTO.getSize();
|
|
String versionName = queryVersionListDTO.getVersionName();
|
|
String versionName = queryVersionListDTO.getVersionName();
|
|
String versionNum = queryVersionListDTO.getVersionNum();
|
|
String versionNum = queryVersionListDTO.getVersionNum();
|
|
-
|
|
|
|
|
|
+ Integer status = queryVersionListDTO.getStatus();
|
|
|
|
+ List<Integer> ids = queryVersionListDTO.getIds();
|
|
LambdaQueryWrapper<Version> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Version> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ if (status != null) {
|
|
|
|
+ queryWrapper.eq(Version::getStatus, status);
|
|
|
|
+ }
|
|
if (versionName != null) {
|
|
if (versionName != null) {
|
|
queryWrapper.like(Version::getVersionName, versionName);
|
|
queryWrapper.like(Version::getVersionName, versionName);
|
|
}
|
|
}
|
|
if (versionNum != null) {
|
|
if (versionNum != null) {
|
|
queryWrapper.like(Version::getVersionNum, versionNum);
|
|
queryWrapper.like(Version::getVersionNum, versionNum);
|
|
}
|
|
}
|
|
- IPage<Version> versions = this.page(new Page<>(current, size), queryWrapper);
|
|
|
|
- List<Version> versionList = versions.getRecords();
|
|
|
|
|
|
+ if (ids != null && ids.size() > 0) {
|
|
|
|
+ queryWrapper.in(Version::getId, ids);
|
|
|
|
+ }
|
|
|
|
+ queryWrapper.orderByDesc(Version::getCreateTime);
|
|
|
|
+ List<Version> versionList = new ArrayList<>();
|
|
|
|
+ if (current != null && size != null) {
|
|
|
|
+ IPage<Version> versions = this.page(new Page<>(current, size), queryWrapper);
|
|
|
|
+ versionList = versions.getRecords();
|
|
|
|
+ records.setCurrent(current);
|
|
|
|
+ records.setSize(size);
|
|
|
|
+ records.setTotal(versions.getTotal());
|
|
|
|
+ } else {
|
|
|
|
+ versionList = this.list(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+ List<QiaoBiVersionVO> qiaoBiVersionVOS = this.loadQiaoBiVersionVO(versionList);
|
|
|
|
|
|
- records.setCurrent(current);
|
|
|
|
- records.setSize(current);
|
|
|
|
- records.setTotal(versions.getTotal());
|
|
|
|
- records.setRecords(versionList);
|
|
|
|
|
|
+ records.setRecords(qiaoBiVersionVOS);
|
|
return records;
|
|
return records;
|
|
}
|
|
}
|
|
|
|
|
|
- public Records queryVersionInfo(QueryVersionInfoDTO queryVersionInfoDTO){
|
|
|
|
- Records records = new Records();
|
|
|
|
- VersionVO versionVO = new VersionVO();
|
|
|
|
- Integer versionId = queryVersionInfoDTO.getId();
|
|
|
|
- Version version = this.getById(versionId);
|
|
|
|
- if (version != null) {
|
|
|
|
- versionVO.setVersionNum(version.getVersionNum());
|
|
|
|
- versionVO.setId(version.getId());
|
|
|
|
- versionVO.setVersionName(version.getVersionName());
|
|
|
|
- versionVO.setRemark(version.getRemark());
|
|
|
|
- versionVO.setFileGuid(version.getFileGuid());
|
|
|
|
- LambdaQueryWrapper<AssoFunctionModule> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.eq(AssoFunctionModule::getVersionId, versionId);
|
|
|
|
- AssoFunctionModule assoFunctionModule = assoFunctionModuleService.getOne(queryWrapper, false);
|
|
|
|
- if (assoFunctionModule != null) {
|
|
|
|
- versionVO.setAuthType(assoFunctionModule.getAuthType());
|
|
|
|
- versionVO.setFunctionId(assoFunctionModule.getFunctionId());
|
|
|
|
- versionVO.setCode(assoFunctionModule.getCode());
|
|
|
|
- versionVO.setCreateUser(assoFunctionModule.getCreateUser());
|
|
|
|
- versionVO.setCreateTime(assoFunctionModule.getCreateTime());
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void delete(List<Integer> ids) {
|
|
|
|
+ if (ids == null || ids.size() == 0) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "请选择版本");
|
|
}
|
|
}
|
|
- records.setRecords(versionVO);
|
|
|
|
- return records;
|
|
|
|
|
|
+ //删除版本
|
|
|
|
+ this.deleteByIds(ids);
|
|
|
|
+ //删除版本和功能关联
|
|
|
|
+ assoVersionFunctionService.deleteByVersionIds(ids);
|
|
|
|
+ //删除版本和模块代码关联
|
|
|
|
+ assoFunctionModuleService.deleteByVersionIds(ids);
|
|
}
|
|
}
|
|
|
|
|
|
- public Records queryById(Integer id) throws IOException {
|
|
|
|
- Records records = new Records();
|
|
|
|
- VersionVO versionVO = new VersionVO();
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据id删除版本
|
|
|
|
+ *
|
|
|
|
+ * @param ids
|
|
|
|
+ */
|
|
|
|
+ public void deleteByIds(List<Integer> ids) {
|
|
|
|
+ if (ids != null && ids.size() > 0) {
|
|
|
|
+ this.removeByIds(ids);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 窍笔应用添加功能
|
|
|
|
+ *
|
|
|
|
+ * @param addFunctionDTO
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public FunctionVO addFunction(AddFunctionDTO addFunctionDTO) {
|
|
|
|
+ String code = addFunctionDTO.getApplicationCode();
|
|
|
|
+ //根据功能名称以及上级id查询功能;
|
|
|
|
+ FunctionVO functionVO = new FunctionVO();
|
|
|
|
+ BeanUtils.copyProperties(addFunctionDTO, functionVO);
|
|
|
|
+ Application application = applicationService.getByCode(code);
|
|
|
|
+ if (application == null) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "应用不存在");
|
|
|
|
+ }
|
|
|
|
+ functionVO.setApply(application.getId());
|
|
|
|
+ Function function = functionService.getFunctionByName(functionVO);
|
|
|
|
+ if (function == null) {
|
|
|
|
+ functionVO.setFunctionType(1);
|
|
|
|
+ function = functionService.addFunctionByVo(functionVO);
|
|
|
|
+ }
|
|
|
|
+ FunctionVO functionVO1 = FunctionService.transformToVo(function);
|
|
|
|
+
|
|
|
|
+ return functionVO1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新校验版本状态信息
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ public void checkVersionStatus(Integer id) {
|
|
Version version = this.getById(id);
|
|
Version version = this.getById(id);
|
|
- if (version != null) {
|
|
|
|
- versionVO.setVersionNum(version.getVersionNum());
|
|
|
|
- versionVO.setId(version.getId());
|
|
|
|
- versionVO.setVersionName(version.getVersionName());
|
|
|
|
- versionVO.setRemark(version.getRemark());
|
|
|
|
- versionVO.setFileGuid(version.getFileGuid());
|
|
|
|
-// List<String> fileGuids = new ArrayList<>();
|
|
|
|
-// fileGuids.add(version.getFileGuid());
|
|
|
|
-// List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
|
-// if (fileGuids.size() != 0) {
|
|
|
|
-// String res = fileManagerService.getSystemFileFromFMS(fileGuids);
|
|
|
|
-// systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
|
-// }
|
|
|
|
-// if (!systemFiles.isEmpty()) {
|
|
|
|
-// versionVO.setSystemFileList(systemFiles);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- LambdaQueryWrapper<AssoFunctionModule> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.eq(AssoFunctionModule::getVersionId, id);
|
|
|
|
- AssoFunctionModule assoFunctionModule = assoFunctionModuleService.getOne(queryWrapper, false);
|
|
|
|
- if (assoFunctionModule != null) {
|
|
|
|
- versionVO.setAuthType(assoFunctionModule.getAuthType());
|
|
|
|
- versionVO.setFunctionId(assoFunctionModule.getFunctionId());
|
|
|
|
- versionVO.setCode(assoFunctionModule.getCode());
|
|
|
|
- versionVO.setCreateUser(assoFunctionModule.getCreateUser());
|
|
|
|
- versionVO.setCreateTime(assoFunctionModule.getCreateTime());
|
|
|
|
- }
|
|
|
|
|
|
+ if (version == null) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "版本不存在");
|
|
|
|
+ }
|
|
|
|
+ if (version.getStatus().equals(3)) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "版本已发布,不允许修改");
|
|
|
|
+
|
|
}
|
|
}
|
|
- records.setRecords(versionVO);
|
|
|
|
- return records;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void delete(List<Integer> ids){
|
|
|
|
- for (Integer id : ids) {
|
|
|
|
- Version version = this.getById(id);
|
|
|
|
- if (version != null) {
|
|
|
|
- LambdaQueryWrapper<AssoFunctionModule> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.eq(AssoFunctionModule::getVersionId, id);
|
|
|
|
- assoFunctionModuleService.remove(queryWrapper);
|
|
|
|
- this.removeById(id);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 装载窍笔vo类
|
|
|
|
+ *
|
|
|
|
+ * @param versions
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<QiaoBiVersionVO> loadQiaoBiVersionVO(List<Version> versions) {
|
|
|
|
+ List<QiaoBiVersionVO> qiaoBiVersionVOS = new ArrayList<>();
|
|
|
|
+ if (versions == null || versions.size() == 0) {
|
|
|
|
+ return qiaoBiVersionVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> createIds = versions.stream().map(Version::getCreateId).collect(Collectors.toList());
|
|
|
|
+ List<Personnel> personnelList = new ArrayList<>();
|
|
|
|
+ if (createIds != null && createIds.size() > 0) {
|
|
|
|
+ personnelList = personnelService.getPersonByIds(createIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
|
+ List<String> guids = versions.stream().filter(item -> item.getFileGuid() != null).map(Version::getFileGuid).collect(Collectors.toList());
|
|
|
|
+ if (guids.size() != 0) {
|
|
|
|
+ try {
|
|
|
|
+ if (guids != null && guids.size() != 0) {
|
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
|
+ systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
|
+ System.out.println("before" + systemFiles);
|
|
|
|
+ if (systemFiles == null) {
|
|
|
|
+ systemFiles = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace(
|
|
|
|
+ );
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "获取文件信息错误");
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //装载数据
|
|
|
|
+ for (Version item : versions) {
|
|
|
|
+ QiaoBiVersionVO qiaoBiVersionVO = new QiaoBiVersionVO();
|
|
|
|
+ BeanUtils.copyProperties(item, qiaoBiVersionVO);
|
|
|
|
+ Personnel personnel = personnelList.stream().filter(tem -> tem.getId().equals(item.getCreateId())).findFirst().orElse(null);
|
|
|
|
+ if (personnel != null) {
|
|
|
|
+ qiaoBiVersionVO.setCreateName(personnel.getPersonnelName());
|
|
|
|
+ }
|
|
|
|
+ SystemFile systemFile = systemFiles.stream().filter(tem -> tem.getGuid().equals(item.getFileGuid())).findFirst().orElse(null);
|
|
|
|
+ qiaoBiVersionVO.setSystemFile(systemFile);
|
|
|
|
+ qiaoBiVersionVOS.add(qiaoBiVersionVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return qiaoBiVersionVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Version getLastVersion() {
|
|
|
|
+ LambdaQueryWrapper<Version> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(Version::getStatus, 3).orderByDesc(Version::getPublishTime).orderByDesc(Version::getCreateTime);
|
|
|
|
+ Version version = this.getOne(queryWrapper, false);
|
|
|
|
+ return version;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Integer updateVersionStatus(VersionStatusDTO versionStatusDTO) {
|
|
|
|
+ Integer versionId = versionStatusDTO.getId();
|
|
|
|
+ Integer status = versionStatusDTO.getStatus();
|
|
|
|
+ if (versionId == null) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "请选择版本");
|
|
|
|
+ }
|
|
|
|
+ Version version = this.getById(versionId);
|
|
|
|
+ if (version == null) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "版本不存在");
|
|
|
|
+ }
|
|
|
|
+ if (version.getStatus() == 3) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "已发布版本不允许修改");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (status == null) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "非法传参");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (status.equals(3)) {
|
|
|
|
+ version.setPublishTime(new Date());
|
|
|
|
+ }
|
|
|
|
+ version.setStatus(status);
|
|
|
|
+ version.updateById();
|
|
|
|
+ return version.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public QiaoBiVersionVO queryVersionLast() {
|
|
|
|
+ QiaoBiVersionVO qiaoBiVersionVO = new QiaoBiVersionVO();
|
|
|
|
+ LambdaQueryWrapper<Version> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(Version::getStatus, 3);
|
|
|
|
+ queryWrapper.orderByDesc(Version::getPublishTime);
|
|
|
|
+ Version version = this.getOne(queryWrapper, false);
|
|
|
|
+ if (version == null) {
|
|
|
|
+ return qiaoBiVersionVO;
|
|
|
|
+ }
|
|
|
|
+ List<QiaoBiVersionVO> qiaoBiVersionVOS = this.loadQiaoBiVersionVO(Arrays.asList(version));
|
|
|
|
+ if (qiaoBiVersionVOS != null && qiaoBiVersionVOS.size() > 0) {
|
|
|
|
+ qiaoBiVersionVO = qiaoBiVersionVOS.get(0);
|
|
|
|
+ }
|
|
|
|
+ return qiaoBiVersionVO;
|
|
}
|
|
}
|
|
}
|
|
}
|