Selaa lähdekoodia

Merge branch 'fix/云文件oracle数据库查询顶层列表问题' into 'develop'

Merge of fix/[云文件]云文件oracle数据库查询顶层列表问题 to develop

See merge request o2oa/o2oa!611
o2null 5 vuotta sitten
vanhempi
commit
1d07b79f16

+ 2 - 0
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/Business.java

@@ -6,6 +6,8 @@ import com.x.organization.core.express.Organization;
 
 
 public class Business {
 public class Business {
 
 
+	public final static String TOP_FOLD = "$$TOP_FOLD";
+
 	private EntityManagerContainer emc;
 	private EntityManagerContainer emc;
 
 
 	public Business(EntityManagerContainer emc) throws Exception {
 	public Business(EntityManagerContainer emc) throws Exception {

+ 1 - 1
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/factory/Attachment2Factory.java

@@ -26,7 +26,7 @@ public class Attachment2Factory extends AbstractFactory {
 		Root<Attachment2> root = cq.from(Attachment2.class);
 		Root<Attachment2> root = cq.from(Attachment2.class);
 		Predicate p = cb.equal(root.get(Attachment2_.person), person);
 		Predicate p = cb.equal(root.get(Attachment2_.person), person);
 		p = cb.and(p, cb.equal(root.get(Attachment2_.status), "正常"));
 		p = cb.and(p, cb.equal(root.get(Attachment2_.status), "正常"));
-		p = cb.and(p, cb.or(cb.isNull(root.get(Attachment2_.folder)), cb.equal(root.get(Attachment2_.folder), "")));
+		p = cb.and(p, cb.equal(root.get(Attachment2_.folder), Business.TOP_FOLD));
 		cq.select(root.get(Attachment2_.id)).where(p);
 		cq.select(root.get(Attachment2_.id)).where(p);
 		return em.createQuery(cq).getResultList();
 		return em.createQuery(cq).getResultList();
 	}
 	}

+ 1 - 1
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/factory/Folder2Factory.java

@@ -28,7 +28,7 @@ public class Folder2Factory extends AbstractFactory {
 		Root<Folder2> root = cq.from(Folder2.class);
 		Root<Folder2> root = cq.from(Folder2.class);
 		Predicate p = cb.equal(root.get(Folder2_.person), person);
 		Predicate p = cb.equal(root.get(Folder2_.person), person);
 		p = cb.and(p, cb.equal(root.get(Folder2_.status), "正常"));
 		p = cb.and(p, cb.equal(root.get(Folder2_.status), "正常"));
-		p = cb.and(p, cb.or(cb.isNull(root.get(Folder2_.superior)), cb.equal(root.get(Folder2_.superior), "")));
+		p = cb.and(p, cb.equal(root.get(Folder2_.superior), Business.TOP_FOLD));
 		cq.select(root.get(Folder2_.id)).where(p);
 		cq.select(root.get(Folder2_.id)).where(p);
 		return em.createQuery(cq).getResultList();
 		return em.createQuery(cq).getResultList();
 	}
 	}

+ 3 - 2
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionUpload.java

@@ -35,7 +35,8 @@ class ActionUpload extends StandardJaxrsAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			Business business = new Business(emc);
 			Business business = new Business(emc);
 			ActionResult<Wo> result = new ActionResult<>();
 			ActionResult<Wo> result = new ActionResult<>();
-			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))) {
+			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))
+					&& !Business.TOP_FOLD.equals(folderId)) {
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				if (null == folder) {
 				if (null == folder) {
 					throw new ExceptionFolderNotExist(folderId);
 					throw new ExceptionFolderNotExist(folderId);
@@ -46,7 +47,7 @@ class ActionUpload extends StandardJaxrsAction {
 				}
 				}
 				folderId = folder.getId();
 				folderId = folder.getId();
 			} else {
 			} else {
-				folderId = null;
+				folderId = Business.TOP_FOLD;
 			}
 			}
 			StorageMapping mapping = ThisApplication.context().storageMappings().random(OriginFile.class);
 			StorageMapping mapping = ThisApplication.context().storageMappings().random(OriginFile.class);
 			if (null == mapping) {
 			if (null == mapping) {

+ 3 - 2
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/attachment2/ActionUploadCallback.java

@@ -36,7 +36,8 @@ class ActionUploadCallback extends StandardJaxrsAction {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			Business business = new Business(emc);
 			Business business = new Business(emc);
 			ActionResult<Wo<WoObject>> result = new ActionResult<>();
 			ActionResult<Wo<WoObject>> result = new ActionResult<>();
-			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))) {
+			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))
+					&& !Business.TOP_FOLD.equals(folderId)) {
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				if (null == folder) {
 				if (null == folder) {
 					throw new ExceptionFolderNotExistCallback(callback, folderId);
 					throw new ExceptionFolderNotExistCallback(callback, folderId);
@@ -47,7 +48,7 @@ class ActionUploadCallback extends StandardJaxrsAction {
 				}
 				}
 				folderId = folder.getId();
 				folderId = folder.getId();
 			} else {
 			} else {
-				folderId = null;
+				folderId = Business.TOP_FOLD;
 			}
 			}
 			StorageMapping mapping = ThisApplication.context().storageMappings().random(OriginFile.class);
 			StorageMapping mapping = ThisApplication.context().storageMappings().random(OriginFile.class);
 			if (null == mapping) {
 			if (null == mapping) {

+ 9 - 0
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/folder2/ActionCreate.java

@@ -27,10 +27,19 @@ public class ActionCreate extends BaseAction {
 			if (this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), null)) {
 			if (this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), null)) {
 				throw new ExceptionFolderNameExist(effectivePerson.getName(), wi.getName(), wi.getSuperior());
 				throw new ExceptionFolderNameExist(effectivePerson.getName(), wi.getName(), wi.getSuperior());
 			}
 			}
+			if(StringUtils.isEmpty(wi.getSuperior())){
+				wi.setSuperior(Business.TOP_FOLD);
+			}else{
+				Folder2 superior = emc.find(wi.getSuperior(), Folder2.class);
+				if(superior==null){
+					throw new ExceptionFolderNotExist(wi.getSuperior());
+				}
+			}
 			emc.beginTransaction(Folder2.class);
 			emc.beginTransaction(Folder2.class);
 			Folder2 folder = Wi.copier.copy(wi);
 			Folder2 folder = Wi.copier.copy(wi);
 			folder.setPerson(effectivePerson.getDistinguishedName());
 			folder.setPerson(effectivePerson.getDistinguishedName());
 			folder.setStatus("正常");
 			folder.setStatus("正常");
+
 			emc.persist(folder, CheckPersistType.all);
 			emc.persist(folder, CheckPersistType.all);
 			emc.commit();
 			emc.commit();
 			Wo wo = new Wo();
 			Wo wo = new Wo();

+ 3 - 1
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/folder2/ActionUpdate.java

@@ -35,7 +35,7 @@ class ActionUpdate extends BaseAction {
 				throw new ExceptionAccessDenied(effectivePerson.getName());
 				throw new ExceptionAccessDenied(effectivePerson.getName());
 			}
 			}
 			wi.setSuperior(StringUtils.trimToEmpty(wi.getSuperior()));
 			wi.setSuperior(StringUtils.trimToEmpty(wi.getSuperior()));
-			if(StringUtils.isNotBlank(wi.getSuperior())) {
+			if(StringUtils.isNotBlank(wi.getSuperior()) && !Business.TOP_FOLD.equals(wi.getSuperior())) {
 				Folder2 supFolder = emc.find(wi.getSuperior(), Folder2.class);
 				Folder2 supFolder = emc.find(wi.getSuperior(), Folder2.class);
 				if (null == supFolder) {
 				if (null == supFolder) {
 					throw new ExceptionFolderNotExist(wi.getSuperior());
 					throw new ExceptionFolderNotExist(wi.getSuperior());
@@ -49,6 +49,8 @@ class ActionUpdate extends BaseAction {
 				if(ids.contains(folder.getSuperior())){
 				if(ids.contains(folder.getSuperior())){
 					throw new Exception("superior can not be sub folder.");
 					throw new Exception("superior can not be sub folder.");
 				}
 				}
+			}else{
+				wi.setSuperior(Business.TOP_FOLD);
 			}
 			}
 
 
 			this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), folder.getId());
 			this.exist(business, effectivePerson, wi.getName(), wi.getSuperior(), folder.getId());

+ 3 - 2
o2server/x_file_assemble_control/src/main/java/com/x/file/assemble/control/jaxrs/share/ActionSaveToFolder.java

@@ -26,7 +26,8 @@ class ActionSaveToFolder extends BaseAction {
 			if (null == share) {
 			if (null == share) {
 				throw new ExceptionAttachmentNotExist(shareId);
 				throw new ExceptionAttachmentNotExist(shareId);
 			}
 			}
-			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))) {
+			if ((!StringUtils.isEmpty(folderId)) && (!StringUtils.equalsIgnoreCase(folderId, EMPTY_SYMBOL))
+					&& !Business.TOP_FOLD.equals(folderId)) {
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				Folder2 folder = emc.find(folderId, Folder2.class);
 				if (folder == null) {
 				if (folder == null) {
 					throw new ExceptionFolderNotExist(folderId);
 					throw new ExceptionFolderNotExist(folderId);
@@ -36,7 +37,7 @@ class ActionSaveToFolder extends BaseAction {
 					throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName(), folderId);
 					throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName(), folderId);
 				}
 				}
 			}else{
 			}else{
-				folderId = null;
+				folderId = Business.TOP_FOLD;
 			}
 			}
 			/* 判断文件的分享用户是否包含当前用户 */
 			/* 判断文件的分享用户是否包含当前用户 */
 			if(!"password".equals(share.getShareType())) {
 			if(!"password".equals(share.getShareType())) {

+ 1 - 1
o2server/x_file_core_entity/src/main/java/com/x/file/core/entity/personal/Attachment2.java

@@ -135,7 +135,7 @@ public class Attachment2 extends SliceJpaObject {
 	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + folder_FIELDNAME)
 	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + folder_FIELDNAME)
 	@Index(name = TABLE + IndexNameMiddle + folder_FIELDNAME)
 	@Index(name = TABLE + IndexNameMiddle + folder_FIELDNAME)
 	/* 上级目录必须存在 */
 	/* 上级目录必须存在 */
-	@CheckPersist(allowEmpty = true, citationExists = @CitationExist(type = Folder2.class, equals = @Equal(property = "person", field = "person")))
+	@CheckPersist(allowEmpty = false)
 	private String folder;
 	private String folder;
 
 
 	public static final String originFile_FIELDNAME = "originFile";
 	public static final String originFile_FIELDNAME = "originFile";

+ 2 - 4
o2server/x_file_core_entity/src/main/java/com/x/file/core/entity/personal/Folder2.java

@@ -87,12 +87,10 @@ public class Folder2 extends SliceJpaObject {
 	private String name;
 	private String name;
 
 
 	public static final String superior_FIELDNAME = "superior";
 	public static final String superior_FIELDNAME = "superior";
-	@FieldDescribe("上级分类ID,为空代表顶级分类。")
+	@FieldDescribe("上级目录ID。")
 	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + superior_FIELDNAME)
 	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + superior_FIELDNAME)
 	@Index(name = TABLE + IndexNameMiddle + superior_FIELDNAME)
 	@Index(name = TABLE + IndexNameMiddle + superior_FIELDNAME)
-	@CheckPersist(allowEmpty = true, citationExists =
-	/* 上级目录必须存在,且不能为自己 */
-	@CitationExist(type = Folder2.class, equals = @Equal(property = "person", field = "person")))
+	@CheckPersist(allowEmpty = false)
 	private String superior;
 	private String superior;
 
 
 	public static final String status_FIELDNAME = "status";
 	public static final String status_FIELDNAME = "status";