| | |
| | | |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.helper.FileHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | String filePath = getFilePath(temp, root, mf); |
| | | |
| | | // 元数据 |
| | | MetaEntity me = createMetaEntity(entity, mf); |
| | | if (metaService.insert(me) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | // 元数据文件 |
| | | MetaEntity mfe = createMetaFileEntity(me, mf, filePath); |
| | | if (metaService.insert(mfe) > 0) { |
| | | MetaEntity me = createMetaEntity(entity, mf, filePath); |
| | | if (metaService.insert(me) > 0) { |
| | | count++; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 创建元数据实体 |
| | | */ |
| | | private MetaEntity createMetaEntity(MetaEntity entity, MetaEntity mf) { |
| | | private MetaEntity createMetaEntity(MetaEntity entity, MetaEntity mf, String filePath) { |
| | | MetaEntity me = new MetaEntity(); |
| | | me.setDepid(entity.getDepid()); |
| | | me.setEventid(StringHelper.getGuid()); |
| | | me.setDirid(entity.getDirid()); |
| | | me.setDepid(entity.getDepid()); |
| | | me.setVerid(entity.getVerid()); |
| | | me.setType("file"); |
| | | me.setName(mf.getName()); |
| | | me.setType("file"); |
| | | me.setGuid(entity.getGuid()); |
| | | me.setPath(FileHelper.getRelativePath(filePath)); |
| | | me.setSizes(mf.getSizes()); |
| | | me.setCreateTime(entity.getCreateTime()); |
| | | me.setCreateUser(entity.getCreateUser()); |
| | | |
| | | return me; |
| | | } |
| | | |
| | | /** |
| | | * 创建元数据文件实体 |
| | | */ |
| | | private MetaEntity createMetaFileEntity(MetaEntity me, MetaEntity entity, String filePath) { |
| | | MetaEntity mfe = new MetaEntity(); |
| | | mfe.setName(entity.getName()); |
| | | mfe.setMetaid(me.getId()); |
| | | mfe.setGuid(entity.getGuid()); |
| | | mfe.setSizes(entity.getSizes()); |
| | | mfe.setPath(FileHelper.getRelativePath(filePath)); |
| | | mfe.setCreateUser(me.getCreateUser()); |
| | | mfe.setCreateTime(me.getCreateTime()); |
| | | |
| | | return mfe; |
| | | } |
| | | } |