提交 51b9b022 编写于 作者: liyi_hz2008's avatar liyi_hz2008

Merge branch 'feature/BBS.addParameter_voteUserCount' into 'develop'

Merge of feature/BBS.addParameter_voteUserCount[企业社区]调整了部分服务逻辑

See merge request o2oa/o2oa!177
......@@ -123,6 +123,19 @@ public class BBSVoteRecordFactory extends AbstractFactory {
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 {
if( maxRecordCount == null ){
throw new Exception( "maxRecordCount is null." );
......
......@@ -162,7 +162,12 @@ public class ActionGetSubjectOperationPermissoin extends BaseAction {
if (check) {
if (effectivePerson.getDistinguishedName() != null
&& subjectInfo.getCreatorName().equalsIgnoreCase(effectivePerson.getDistinguishedName())) {
wrap.setEditAble(true);
//如果该贴子已经有回复内容了,就不允许删除了
if( replyInfoService.countWithSubjectForPage( subjectId, false ) == 0 ){
wrap.setEditAble(true);
}else{
wrap.setEditAble(false);
}
}
}
......
......@@ -5,11 +5,7 @@ import java.util.List;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
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;
......@@ -18,6 +14,7 @@ public class BaseAction extends StandardJaxrsAction{
protected UserPermissionService UserPermissionService = new UserPermissionService();
protected Ehcache cache = ApplicationCache.instance().getCache( BaseAction.class);
protected BBSSubjectInfoService subjectInfoService = new BBSSubjectInfoService();
protected BBSReplyInfoService replyInfoService = new BBSReplyInfoService();
protected BBSSectionInfoService sectionInfoService = new BBSSectionInfoService();
protected BBSPermissionInfoService permissionInfoService = new BBSPermissionInfoService();
protected UserManagerService userManagerService = new UserManagerService();
......
......@@ -114,7 +114,7 @@ public class ActionSubjectView extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
try {
//查询投票总
//查询投票总数
Long voteCount = subjectVoteService.countVoteRecordForSubject( id, null );
currentSubject.setVoteCount( voteCount );
}catch (Exception e) {
......@@ -123,15 +123,26 @@ public class ActionSubjectView extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
try {
voteOptionList = subjectVoteService.listVoteOption( id );
} catch (Exception e) {
//查询投票总人数
List<String> voteUsers = subjectVoteService.listVoteUserForSubject( id, null );
currentSubject.setVoteUserCount( voteUsers.size() );
}catch (Exception e) {
check = false;
Exception exception = new ExceptionVoteOptionListById( e, id );
result.error( exception );
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);
}
}
......@@ -342,10 +353,15 @@ public class ActionSubjectView extends BaseAction {
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
@FieldDescribe( "主贴内容" )
private String content = null;
@FieldDescribe( "投票总数" )
private Long voteCount = 0L;
@FieldDescribe( "投票人数" )
private Integer voteUserCount = 0;
private String pictureBase64 = null;
......@@ -369,7 +385,11 @@ public class ActionSubjectView extends BaseAction {
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
public Integer getVoteUserCount() { return voteUserCount; }
public void setVoteUserCount(Integer voteUserCount) { this.voteUserCount = voteUserCount; }
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
......
package com.x.bbs.assemble.control.service;
import java.util.ArrayList;
import java.util.Date;
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 {
if( subjectId == null || subjectId.isEmpty() ){
return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册