Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop
This commit is contained in:
commit
26168a0821
|
|
@ -11,13 +11,22 @@ public class EdMetaObjectHandler implements MetaObjectHandler {
|
|||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
if (metaObject.hasSetter("gmtCreate")) {
|
||||
this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
|
||||
this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
|
||||
}
|
||||
if (metaObject.hasGetter("createdAt")) {
|
||||
this.strictInsertFill(metaObject, "createdAt", Date.class, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
if (metaObject.hasSetter("gmtModified")) {
|
||||
this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date());
|
||||
}
|
||||
if (metaObject.hasGetter("updatedAt")) {
|
||||
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,19 @@ public class EdFileRelationController {
|
|||
|
||||
/**
|
||||
* 取消文件关系
|
||||
* @param id
|
||||
* @param relationId 关系主键id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping (value = "/cancel/{id}", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> cancelRelation (@PathVariable("id") String id) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.cancelRelation(id));
|
||||
@RequestMapping (value = "/cancel/{relationId}", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> cancelRelation (@PathVariable("relationId") String relationId) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.cancelRelation(relationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示文件关系
|
||||
*/
|
||||
@RequestMapping (value = "listRelations/{id}", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> listRelations (@PathVariable("id") String id) {
|
||||
return ElectromagneticResultUtil.success(edFileRelationService.listRelations(id));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ public class EdFileRelation {
|
|||
/**
|
||||
* 文件1 主键id
|
||||
*/
|
||||
@TableField(value = "fileId1")
|
||||
private String fileId1;
|
||||
@TableField(value = "file_id_1")
|
||||
private String id1;
|
||||
|
||||
/**
|
||||
* 文件2 主键id
|
||||
*/
|
||||
@TableField(value = "fileId2")
|
||||
private String fileId2;
|
||||
@TableField(value = "file_id_2")
|
||||
private String id2;
|
||||
|
||||
/**
|
||||
* 关系描述
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class Role {
|
|||
/**
|
||||
* 编辑时间
|
||||
*/
|
||||
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
|
||||
@TableField(value = "gmt_modified", fill = FieldFill.UPDATE)
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FIleRelationVO {
|
||||
|
||||
/**
|
||||
* 关系主键id
|
||||
*/
|
||||
private String relationId;
|
||||
|
||||
/**
|
||||
* 关系描述
|
||||
*/
|
||||
private String relationship;
|
||||
|
||||
/**
|
||||
* 关联文件
|
||||
*/
|
||||
private FileSimpleInfoVO relatedFile;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FileRelationViewVO {
|
||||
|
||||
/**
|
||||
* 主文件
|
||||
*/
|
||||
private FileSimpleInfoVO file;
|
||||
|
||||
/**
|
||||
* 关联文件关系列表
|
||||
*/
|
||||
List<FIleRelationVO> relationList;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileSimpleInfoVO {
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件编号
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 文件版本
|
||||
*/
|
||||
private String fileVersion;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
|
||||
|
||||
public interface EdFileRelationService {
|
||||
|
||||
|
|
@ -17,4 +18,11 @@ public interface EdFileRelationService {
|
|||
* @return
|
||||
*/
|
||||
Boolean cancelRelation (String id);
|
||||
|
||||
/**
|
||||
* 获取关系展示数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
FileRelationViewVO listRelations (String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,54 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.EdFileRelationMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FIleRelationVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileSimpleInfoVO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileRelationService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EdFileRelationServiceImpl implements EdFileRelationService {
|
||||
public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper, EdFileRelation> implements EdFileRelationService {
|
||||
|
||||
@Resource
|
||||
EdFileRelationMapper edFileRelationMapper;
|
||||
EdFileInfoMapper edFileInfoMapper;
|
||||
|
||||
/**
|
||||
* 创建文件关系
|
||||
* @param edFileRelation
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean createRelation (EdFileRelation edFileRelation) {
|
||||
// 无法建立已建立的关系
|
||||
String queryId1 = edFileRelation.getId1();
|
||||
String queryId2 = edFileRelation.getId2();
|
||||
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EdFileRelation::getId1, queryId1).eq(EdFileRelation::getId2, queryId2)
|
||||
.or()
|
||||
.eq(EdFileRelation::getId1, queryId2).eq(EdFileRelation::getId2, queryId1);
|
||||
List<EdFileRelation> list = this.list(queryWrapper);
|
||||
if (!list.isEmpty()) {
|
||||
throw new BizException (HttpStatus.BAD_REQUEST.value(), "请勿重复建立关系");
|
||||
}
|
||||
|
||||
edFileRelation.setId(IdWorker.getSnowFlakeIdString());
|
||||
edFileRelation.setCreatedBy(UserThreadLocal.getUserId());
|
||||
return edFileRelationMapper.insert(edFileRelation)>0;
|
||||
return this.save(edFileRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -31,8 +56,47 @@ public class EdFileRelationServiceImpl implements EdFileRelationService {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean cancelRelation (String id) {
|
||||
return edFileRelationMapper.deleteById(id)>0;
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关系数据
|
||||
*/
|
||||
@Override
|
||||
public FileRelationViewVO listRelations (String id) {
|
||||
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EdFileRelation::getId1, id)
|
||||
.or()
|
||||
.eq(EdFileRelation::getId2,id);
|
||||
List<EdFileRelation> list = this.list(queryWrapper);
|
||||
List<FIleRelationVO> relationList = new ArrayList<>();
|
||||
for (EdFileRelation edFileRelation : list) {
|
||||
FIleRelationVO fIleRelationVO = new FIleRelationVO();
|
||||
fIleRelationVO.setRelationId(edFileRelation.getId());
|
||||
fIleRelationVO.setRelationship(edFileRelation.getRelationship());
|
||||
String queryId = "";
|
||||
if (edFileRelation.getId1().equals(id)) {
|
||||
queryId = edFileRelation.getId2();
|
||||
} else {
|
||||
queryId = edFileRelation.getId1();
|
||||
}
|
||||
EdFileInfo info = edFileInfoMapper.selectById(queryId);
|
||||
FileSimpleInfoVO fileSimpleInfoVO = new FileSimpleInfoVO();
|
||||
BeanUtils.copyProperties(info, fileSimpleInfoVO);
|
||||
fIleRelationVO.setRelatedFile(fileSimpleInfoVO);
|
||||
relationList.add(fIleRelationVO);
|
||||
}
|
||||
|
||||
FileRelationViewVO fileRelationViewVO = new FileRelationViewVO();
|
||||
fileRelationViewVO.setRelationList(relationList);
|
||||
|
||||
EdFileInfo info = edFileInfoMapper.selectById(id);
|
||||
FileSimpleInfoVO fileSimpleInfoVO = new FileSimpleInfoVO();
|
||||
BeanUtils.copyProperties(info, fileSimpleInfoVO);
|
||||
fileRelationViewVO.setFile(fileSimpleInfoVO);
|
||||
|
||||
return fileRelationViewVO;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue