Ver Fonte

1、查看投票主题信息服务新增了投票人数的信息
2、变更:用户发贴没有任何评论时允许删除,如果有评论了,就无法删除,需要联系版主或者管理员删除。

o2lee há 5 anos atrás
pai
commit
86abc67d47

+ 13 - 0
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/factory/BBSVoteRecordFactory.java

@@ -123,6 +123,19 @@ public class BBSVoteRecordFactory extends AbstractFactory {
 		return em.createQuery(cq.where(p)).getSingleResult();
 		return em.createQuery(cq.where(p)).getSingleResult();
 	}
 	}
 
 
+	public List<String> listVoteUserForSubject( String subjectId, String voteOptionId ) throws Exception {
+		EntityManager em = this.entityManagerContainer().get( BBSVoteRecord.class );
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<String> cq = cb.createQuery(String.class);
+		Root<BBSVoteRecord> root = cq.from( BBSVoteRecord.class);
+		Predicate p = cb.equal( root.get( BBSVoteRecord_.subjectId ), subjectId );
+		if( StringUtils.isNotEmpty( voteOptionId ) ){
+			p = cb.and( p, cb.equal( root.get( BBSVoteRecord_.optionId ), voteOptionId ));
+		}
+		cq.select( root.get( BBSVoteRecord_.votorName ) );
+		return em.createQuery(cq.where(p).distinct(true)).getResultList();
+	}
+
 	public List<BBSVoteRecord> listVoteRecordForPage(String subjectId, String voteOptionId, Integer maxRecordCount) throws Exception {
 	public List<BBSVoteRecord> listVoteRecordForPage(String subjectId, String voteOptionId, Integer maxRecordCount) throws Exception {
 		if( maxRecordCount == null ){
 		if( maxRecordCount == null ){
 			throw new Exception( "maxRecordCount is null." );
 			throw new Exception( "maxRecordCount is null." );

+ 6 - 1
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/jaxrs/permissioninfo/ActionGetSubjectOperationPermissoin.java

@@ -112,7 +112,12 @@ public class ActionGetSubjectOperationPermissoin extends BaseAction {
 			hasPermission = checkUserPermission(checkUserPermission, roleAndPermission.getPermissionInfoList());
 			hasPermission = checkUserPermission(checkUserPermission, roleAndPermission.getPermissionInfoList());
 			if (hasPermission) {
 			if (hasPermission) {
 				wrap.setManageAble(true);
 				wrap.setManageAble(true);
-				wrap.setEditAble(true);
+				//如果该贴子已经有回复内容了,就不允许删除了
+				if( replyInfoService.countWithSubjectForPage( subjectId, false ) == 0 ){
+					wrap.setEditAble(false);
+				}else{
+					wrap.setEditAble(true);
+				}
 			}
 			}
 		}
 		}
 		if (check) {
 		if (check) {

+ 2 - 5
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/jaxrs/permissioninfo/BaseAction.java

@@ -5,11 +5,7 @@ import java.util.List;
 import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.tools.ListTools;
 import com.x.base.core.project.tools.ListTools;
-import com.x.bbs.assemble.control.service.BBSPermissionInfoService;
-import com.x.bbs.assemble.control.service.BBSSectionInfoService;
-import com.x.bbs.assemble.control.service.BBSSubjectInfoService;
-import com.x.bbs.assemble.control.service.UserManagerService;
-import com.x.bbs.assemble.control.service.UserPermissionService;
+import com.x.bbs.assemble.control.service.*;
 
 
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Ehcache;
 
 
@@ -18,6 +14,7 @@ public class BaseAction extends StandardJaxrsAction{
 	protected UserPermissionService UserPermissionService = new UserPermissionService();
 	protected UserPermissionService UserPermissionService = new UserPermissionService();
 	protected Ehcache cache = ApplicationCache.instance().getCache( BaseAction.class);
 	protected Ehcache cache = ApplicationCache.instance().getCache( BaseAction.class);
 	protected BBSSubjectInfoService subjectInfoService = new BBSSubjectInfoService();
 	protected BBSSubjectInfoService subjectInfoService = new BBSSubjectInfoService();
+	protected BBSReplyInfoService replyInfoService = new BBSReplyInfoService();
 	protected BBSSectionInfoService sectionInfoService = new BBSSectionInfoService();
 	protected BBSSectionInfoService sectionInfoService = new BBSSectionInfoService();
 	protected BBSPermissionInfoService permissionInfoService = new BBSPermissionInfoService();
 	protected BBSPermissionInfoService permissionInfoService = new BBSPermissionInfoService();
 	protected UserManagerService userManagerService = new UserManagerService();
 	protected UserManagerService userManagerService = new UserManagerService();

+ 27 - 7
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/jaxrs/subjectinfo/ActionSubjectView.java

@@ -114,7 +114,7 @@ public class ActionSubjectView extends BaseAction {
 						logger.error( e, effectivePerson, request, null);
 						logger.error( e, effectivePerson, request, null);
 					}
 					}
 					try {
 					try {
-						//查询投票总
+						//查询投票总数
 						Long voteCount = subjectVoteService.countVoteRecordForSubject( id, null );
 						Long voteCount = subjectVoteService.countVoteRecordForSubject( id, null );
 						currentSubject.setVoteCount( voteCount );
 						currentSubject.setVoteCount( voteCount );
 					}catch (Exception e) {
 					}catch (Exception e) {
@@ -123,15 +123,26 @@ public class ActionSubjectView extends BaseAction {
 						result.error( exception );
 						result.error( exception );
 						logger.error( e, effectivePerson, request, null);
 						logger.error( e, effectivePerson, request, null);
 					}
 					}
-					
+
 					try {
 					try {
-						voteOptionList = subjectVoteService.listVoteOption( id );
-					} catch (Exception e) {
+						//查询投票总人数
+						List<String> voteUsers = subjectVoteService.listVoteUserForSubject( id, null );
+						currentSubject.setVoteUserCount( voteUsers.size() );
+					}catch (Exception e) {
 						check = false;
 						check = false;
 						Exception exception = new ExceptionVoteOptionListById( e, id );
 						Exception exception = new ExceptionVoteOptionListById( e, id );
 						result.error( exception );
 						result.error( exception );
 						logger.error( e, effectivePerson, request, null);
 						logger.error( e, effectivePerson, request, null);
 					}
 					}
+					
+//					try {
+//						voteOptionList = subjectVoteService.listVoteOption( id );
+//					} catch (Exception e) {
+//						check = false;
+//						Exception exception = new ExceptionVoteOptionListById( e, id );
+//						result.error( exception );
+//						logger.error( e, effectivePerson, request, null);
+//					}
 					result.getData().setCurrentSubject(currentSubject);
 					result.getData().setCurrentSubject(currentSubject);
 				}
 				}
 			}
 			}
@@ -342,10 +353,15 @@ public class ActionSubjectView extends BaseAction {
 		
 		
 		@FieldDescribe( "投票主题的所有投票选项列表." )
 		@FieldDescribe( "投票主题的所有投票选项列表." )
 		private List<WoBBSVoteOptionGroup> voteOptionGroupList;
 		private List<WoBBSVoteOptionGroup> voteOptionGroupList;
-		
+
+		@FieldDescribe( "主贴内容" )
 		private String content = null;
 		private String content = null;
-		
+
+		@FieldDescribe( "投票总数" )
 		private Long voteCount = 0L;
 		private Long voteCount = 0L;
+
+		@FieldDescribe( "投票人数" )
+		private Integer voteUserCount = 0;
 		
 		
 		private String pictureBase64 = null;
 		private String pictureBase64 = null;
 		
 		
@@ -369,7 +385,11 @@ public class ActionSubjectView extends BaseAction {
 		
 		
 		@FieldDescribe( "当前用户是否已经投票过." )
 		@FieldDescribe( "当前用户是否已经投票过." )
 		private Boolean voted = false;
 		private Boolean voted = false;
-		
+
+		public Integer getVoteUserCount() { return voteUserCount; }
+
+		public void setVoteUserCount(Integer voteUserCount) { this.voteUserCount = voteUserCount; }
+
 		public String getLatestReplyUserShort() {
 		public String getLatestReplyUserShort() {
 			return latestReplyUserShort;
 			return latestReplyUserShort;
 		}
 		}

+ 14 - 0
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSSubjectVoteService.java

@@ -1,5 +1,6 @@
 package com.x.bbs.assemble.control.service;
 package com.x.bbs.assemble.control.service;
 
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
@@ -315,6 +316,19 @@ public class BBSSubjectVoteService {
 		}
 		}
 	}
 	}
 
 
+	public List<String> listVoteUserForSubject( String subjectId, String voteOptionId ) throws Exception {
+		if( subjectId == null || subjectId.isEmpty() ){
+			return new ArrayList<>();
+		}
+		Business business = null;
+		try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
+			business = new Business(emc);
+			return business.voteRecordFactory().listVoteUserForSubject( subjectId, voteOptionId );
+		}catch( Exception e ){
+			throw e;
+		}
+	}
+
 	public List<BBSVoteRecord> listVoteRecordForPage(String subjectId, String voteOptionId, Integer maxRecordCount ) throws Exception {
 	public List<BBSVoteRecord> listVoteRecordForPage(String subjectId, String voteOptionId, Integer maxRecordCount ) throws Exception {
 		if( subjectId == null || subjectId.isEmpty() ){
 		if( subjectId == null || subjectId.isEmpty() ){
 			return null;
 			return null;