提交 a3321c8b 编写于 作者: O o2sword

论坛允许使用昵称发布

上级 78004424
......@@ -14,6 +14,8 @@ public class Person extends GsonPropertyObject {
private String id;
@FieldDescribe("个人名称")
private String name;
@FieldDescribe("昵称")
private String nickName;
@FieldDescribe("性别,m:男,f:女,d:未知")
private GenderType genderType;
@FieldDescribe("签名")
......@@ -238,4 +240,12 @@ public class Person extends GsonPropertyObject {
public void setId(String id) {
this.id = id;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
}
package com.x.bbs.assemble.control;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.bbs.assemble.control.factory.BBSConfigSettingFactory;
import com.x.bbs.assemble.control.factory.BBSForumInfoFactory;
import com.x.bbs.assemble.control.factory.BBSOperationRecordFactory;
......@@ -18,11 +20,14 @@ import com.x.bbs.assemble.control.factory.BBSVoteOptionFactory;
import com.x.bbs.assemble.control.factory.BBSVoteRecordFactory;
import com.x.organization.core.express.Organization;
/**
* @author sword
*/
public class Business {
private EntityManagerContainer emc;
public Business(EntityManagerContainer emc) throws Exception {
public Business(EntityManagerContainer emc) {
this.emc = emc;
}
......@@ -56,6 +61,15 @@ public class Business {
return organization;
}
public boolean controlAble(EffectivePerson effectivePerson) throws Exception {
boolean result = false;
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.BBSManager))) {
result = true;
}
return result;
}
public BBSVoteRecordFactory voteRecordFactory() throws Exception {
if (null == this.voteRecordFactory) {
this.voteRecordFactory = new BBSVoteRecordFactory(this);
......
......@@ -2,6 +2,7 @@ package com.x.bbs.assemble.control;
import java.util.List;
import com.x.bbs.assemble.control.queue.NickNameConsumeQueue;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.Context;
......@@ -12,7 +13,6 @@ import com.x.base.core.project.message.MessageConnector;
import com.x.base.core.project.tools.ListTools;
import com.x.bbs.assemble.control.queue.QueueNewReplyNotify;
import com.x.bbs.assemble.control.queue.QueueNewSubjectNotify;
import com.x.bbs.assemble.control.schedule.MarketSubjectTypeTask;
import com.x.bbs.assemble.control.schedule.SubjectReplyTotalStatisticTask;
import com.x.bbs.assemble.control.schedule.SubjectTotalStatisticTask;
import com.x.bbs.assemble.control.schedule.UserCountTodaySetZeroTask;
......@@ -36,6 +36,7 @@ public class ThisApplication {
public static final String BBSMANAGER = "BBSManager";
public static final QueueNewReplyNotify queueNewReplyNotify = new QueueNewReplyNotify();
public static final QueueNewSubjectNotify queueNewSubjectNotify = new QueueNewSubjectNotify();
public static final NickNameConsumeQueue nickNameConsumeQueue = new NickNameConsumeQueue();
public static String CONFIG_BBS_ANONYMOUS_PERMISSION = "YES";
public static Context context() {
......@@ -51,8 +52,9 @@ public class ThisApplication {
MessageConnector.start(context());
context().startQueue(queueNewReplyNotify);
context().startQueue(queueNewSubjectNotify);
context.schedule(SubjectTotalStatisticTask.class, "0 0 1 * * ?"); // 每天凌晨一点执行
context.schedule(UserCountTodaySetZeroTask.class, "0 1 0 * * ?"); // 每天凌晨执行
context().startQueue(nickNameConsumeQueue);
context.schedule(SubjectTotalStatisticTask.class, "0 0 1 * * ?");
context.schedule(UserCountTodaySetZeroTask.class, "0 1 0 * * ?");
context.schedule(SubjectReplyTotalStatisticTask.class, "0 40 * * * ?");
context.schedule(UserSubjectReplyPermissionStatisticTask.class, "0 0/30 * * * ?");
} catch (Exception e) {
......@@ -120,7 +122,7 @@ public class ThisApplication {
/**
* 判断用户是否有BBS系统管理权限 1、系统管理员Manager或者xadmin 2、拥有BBSManager角色的人员
*
*
* @param effectivePerson
* @return
*/
......@@ -139,7 +141,7 @@ public class ThisApplication {
/**
* 判断用户是否有权限对指定的论坛进行管理 1、系统管理员、BBS管理员 2、指定论坛设置的管理员
*
*
* @param effectivePerson
* @param forumInfo
* @return
......
......@@ -2,7 +2,7 @@ package com.x.bbs.assemble.control.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.ManagerUserJaxrsFilter;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
/**
* web服务过滤器,将指定的URL定义为需要用户认证的服务,如果用户未登录,则无法访问该服务
......@@ -11,4 +11,4 @@ import com.x.base.core.project.jaxrs.ManagerUserJaxrsFilter;
"/jaxrs/user/*",
"/servlet/*"
} , asyncSupported = true)
public class BBSJaxrsManagerUserFilter extends ManagerUserJaxrsFilter {}
\ No newline at end of file
public class BBSJaxrsManagerUserFilter extends CipherManagerUserJaxrsFilter {}
package com.x.bbs.assemble.control.jaxrs.permissioninfo;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.bbs.assemble.control.Business;
import com.x.bbs.assemble.control.jaxrs.permissioninfo.exception.ExceptionPermissionInfoProcess;
import com.x.bbs.assemble.control.jaxrs.permissioninfo.exception.ExceptionSectionIdEmpty;
import com.x.bbs.assemble.control.jaxrs.permissioninfo.exception.ExceptionSectionNotExists;
import com.x.bbs.assemble.control.service.bean.RoleAndPermission;
import com.x.bbs.entity.BBSForumInfo;
import com.x.bbs.entity.BBSSectionInfo;
import com.x.bbs.entity.enums.BbsRoleEnum;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* 查询用户的权限
* @author sword
*/
public class ActionGetUserPermission extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionGetUserPermission.class);
protected ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
result.setData(wo);
if(effectivePerson.isAnonymous()){
return result;
}
Business business = new Business(null);
if(business.controlAble(effectivePerson)) {
wo.setBbsAdmin(true);
wo.setBbsForumAdmin(true);
wo.setBbsSectionAdmin(true);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<BBSForumInfo> forumInfoList = emc.fetchAll(BBSForumInfo.class, ListTools.toList(JpaObject.id_FIELDNAME));
wo.setForumList(ListTools.extractField(forumInfoList, JpaObject.id_FIELDNAME, String.class, true, true));
List<BBSSectionInfo> sectionInfoList = emc.fetchAll(BBSSectionInfo.class, ListTools.toList(JpaObject.id_FIELDNAME));
wo.setSectionList(ListTools.extractField(sectionInfoList, JpaObject.id_FIELDNAME, String.class, true, true));
}
}else{
RoleAndPermission roleAndPermission = this.UserPermissionService.getUserRoleAndPermission(effectivePerson.getDistinguishedName());
if(ListTools.isNotEmpty(roleAndPermission.getRoleInfoList())){
roleAndPermission.getRoleInfoList().forEach(r -> {
if(r.startsWith(BbsRoleEnum.FORUM_SUPER_MANAGER.getValue())){
wo.getForumList().add(StringUtils.substringAfter(r, BbsRoleEnum.FORUM_SUPER_MANAGER.getValue()+"_"));
}
if(r.startsWith(BbsRoleEnum.SECTION_MANAGER.getValue())){
wo.getSectionList().add(StringUtils.substringAfter(r, BbsRoleEnum.SECTION_MANAGER.getValue()+"_"));
}
});
if(!wo.getForumList().isEmpty()){
wo.setBbsForumAdmin(true);
}
if(!wo.getSectionList().isEmpty()){
wo.setBbsSectionAdmin(true);
}
}
}
result.setData(wo);
return result;
}
public static class Wo{
@FieldDescribe( "是否是BBS管理员." )
private Boolean bbsAdmin = false;
@FieldDescribe( "是否是分区管理员." )
private Boolean bbsForumAdmin = false;
@FieldDescribe( "是否是板块管理员." )
private Boolean bbsSectionAdmin = false;
@FieldDescribe( "可管理的分区." )
private List<String> forumList = new ArrayList();
@FieldDescribe( "可管理的板块." )
private List<String> sectionList = new ArrayList();
public Boolean getBbsAdmin() {
return bbsAdmin;
}
public void setBbsAdmin(Boolean bbsAdmin) {
this.bbsAdmin = bbsAdmin;
}
public Boolean getBbsForumAdmin() {
return bbsForumAdmin;
}
public void setBbsForumAdmin(Boolean bbsForumAdmin) {
this.bbsForumAdmin = bbsForumAdmin;
}
public Boolean getBbsSectionAdmin() {
return bbsSectionAdmin;
}
public void setBbsSectionAdmin(Boolean bbsSectionAdmin) {
this.bbsSectionAdmin = bbsSectionAdmin;
}
public List<String> getForumList() {
return forumList;
}
public void setForumList(List<String> forumList) {
this.forumList = forumList;
}
public List<String> getSectionList() {
return sectionList;
}
public void setSectionList(List<String> sectionList) {
this.sectionList = sectionList;
}
}
}
......@@ -26,12 +26,32 @@ import com.x.bbs.assemble.control.jaxrs.configsetting.exception.ExceptionConfigS
import com.x.bbs.assemble.control.jaxrs.permissioninfo.exception.ExceptionSectionIdEmpty;
import com.x.bbs.assemble.control.jaxrs.permissioninfo.exception.ExceptionSubjectIdEmpty;
/**
* @author sword
*/
@Path("permission")
@JaxrsDescribe("权限查询服务")
public class PermissionInfoAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(PermissionInfoAction.class);
@JaxrsMethodDescribe(value = "查询当前用户的操作权限.", action = ActionGetUserPermission.class)
@GET
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void getUserPermission(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request) {
ActionResult<ActionGetUserPermission.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGetUserPermission().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "查询用户在指定板块中的所有操作权限.", action = ActionGetSectionOperationPermissoin.class)
@GET
@Path("section/{sectionId}")
......@@ -154,4 +174,4 @@ public class PermissionInfoAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
}
......@@ -21,16 +21,16 @@ import com.x.bbs.assemble.control.jaxrs.replyinfo.exception.ExceptionReplyNotExi
import com.x.bbs.entity.BBSReplyInfo;
public class ActionGet extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionGet.class );
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id ) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wo wrap = null;
BBSReplyInfo replyInfo = null;
Boolean check = true;
if( check ){
if( id == null || id.isEmpty() ){
check = false;
......@@ -58,6 +58,9 @@ public class ActionGet extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if(StringUtils.isBlank(wrap.getNickName())){
wrap.setNickName(wrap.getCreatorName());
}
if( wrap != null && StringUtils.isNotEmpty( wrap.getCreatorName() ) ) {
wrap.setCreatorNameShort( wrap.getCreatorName().split( "@" )[0]);
}
......@@ -74,16 +77,16 @@ public class ActionGet extends BaseAction {
}
public static class Wo extends BBSReplyInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSReplyInfo, Wo > copier = WrapCopierFactory.wo( BBSReplyInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
......@@ -103,4 +106,4 @@ public class ActionGet extends BaseAction {
this.auditorNameShort = auditorNameShort;
}
}
}
\ No newline at end of file
}
......@@ -102,6 +102,9 @@ public class ActionListMyReplyForPages extends BaseAction {
if (check) {
if (ListTools.isNotEmpty(wraps)) {
for (Wo wo : wraps) {
if(StringUtils.isBlank(wo.getNickName())){
wo.setNickName(wo.getCreatorName());
}
if (StringUtils.isNotEmpty(wo.getCreatorName())) {
wo.setCreatorNameShort(wo.getCreatorName().split("@")[0]);
}
......@@ -163,4 +166,4 @@ public class ActionListMyReplyForPages extends BaseAction {
this.subjectId = subjectId;
}
}
}
\ No newline at end of file
}
......@@ -98,6 +98,9 @@ public class ActionListWithReply extends BaseAction {
if (check) {
if (ListTools.isNotEmpty(wraps)) {
for (Wo wo : wraps) {
if(StringUtils.isBlank(wo.getNickName())){
wo.setNickName(wo.getCreatorName());
}
if (StringUtils.isNotEmpty(wo.getCreatorName())) {
wo.setCreatorNameShort(wo.getCreatorName().split("@")[0]);
}
......@@ -105,7 +108,6 @@ public class ActionListWithReply extends BaseAction {
wo.setAuditorNameShort(wo.getAuditorName().split("@")[0]);
}
}
// SortTools.desc(wraps, "createTime" );
result.setCount( Long.parseLong(wraps.size()+"") );
}
}
......@@ -141,4 +143,4 @@ public class ActionListWithReply extends BaseAction {
this.auditorNameShort = auditorNameShort;
}
}
}
\ No newline at end of file
}
......@@ -146,6 +146,9 @@ public class ActionListWithSubjectForPage extends BaseAction {
if (ListTools.isNotEmpty(wraps)) {
List<BBSReplyInfo> subReplies = null;
for (Wo wo : wraps) {
if(StringUtils.isBlank(wo.getNickName())){
wo.setNickName(wo.getCreatorName());
}
if (StringUtils.isNotEmpty(wo.getCreatorName())) {
wo.setCreatorNameShort(wo.getCreatorName().split("@")[0]);
}
......@@ -247,4 +250,4 @@ public class ActionListWithSubjectForPage extends BaseAction {
this.auditorNameShort = auditorNameShort;
}
}
}
\ No newline at end of file
}
......@@ -5,8 +5,12 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.organization.Person;
import com.x.bbs.assemble.control.Business;
import com.x.bbs.assemble.control.ThisApplication;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -228,6 +232,8 @@ public class ActionSave extends BaseAction {
wrapIn.setSectionId(subjectInfo.getSectionId());
wrapIn.setSectionName(subjectInfo.getSectionName());
wrapIn.setCreatorName(effectivePerson.getDistinguishedName());
Business business = new Business(null);
wrapIn.setNickName(business.organization().person().getNickName(effectivePerson.getDistinguishedName()));
}
if (check) {
......@@ -266,7 +272,7 @@ public class ActionSave extends BaseAction {
CacheManager.notify( BBSForumInfo.class );
CacheManager.notify( BBSSectionInfo.class );
CacheManager.notify( BBSSubjectInfo.class );
operationRecordService.replyOperation(effectivePerson.getDistinguishedName(), replyInfo, "CREATE", hostIp, hostName);
} catch (Exception e) {
check = false;
......@@ -332,4 +338,4 @@ public class ActionSave extends BaseAction {
public static class Wo extends WoId {
}
}
\ No newline at end of file
}
......@@ -79,7 +79,7 @@ public class ActionSubjectGet extends BaseAction {
BBSSubjectInfo subjectInfo = null;
String subjectContent = null;
Boolean check = true;
// 查询版块信息是否存在
if (check) {
try {
......@@ -167,7 +167,6 @@ public class ActionSubjectGet extends BaseAction {
}
if (check) {
// 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
if (wrap != null) {
cutPersonNames(wrap);
}
......@@ -178,15 +177,18 @@ public class ActionSubjectGet extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = ""; bBSIndexSetterNameShort = "";
* screamSetterNameShort = ""; originalSetterNameShort = ""; creatorNameShort =
* ""; auditorNameShort = "";
*
*
* @param subject
*/
private void cutPersonNames(Wo subject) {
if (subject != null) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if ( StringUtils.isNotEmpty( subject.getLatestReplyUser() )) {
subject.setLatestReplyUserShort(subject.getLatestReplyUser().split("@")[0]);
}
......@@ -390,4 +392,4 @@ public class ActionSubjectGet extends BaseAction {
}
}
}
\ No newline at end of file
}
......@@ -26,9 +26,9 @@ import com.x.bbs.entity.BBSVoteOption;
import com.x.bbs.entity.BBSVoteOptionGroup;
public class ActionSubjectListCreamedForPages extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectListCreamedForPages.class );
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps = new ArrayList<>();
......@@ -46,7 +46,7 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if( check ){
if( page == null ){
page = 1;
......@@ -96,7 +96,7 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
if( ListTools.isNotEmpty( subjectInfoList_out ) ){
try {
wraps = Wo.copier.copy( subjectInfoList_out );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionSubjectWrapOut( e );
......@@ -105,7 +105,7 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
}
}
}
if (check) {
//将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
if( ListTools.isNotEmpty( wraps ) ){
......@@ -114,7 +114,7 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
}
}
}
result.setData( wraps );
result.setCount( total );
return result;
......@@ -122,18 +122,21 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = "";
bBSIndexSetterNameShort = "";
screamSetterNameShort = "";
originalSetterNameShort = "";
creatorNameShort = "";
auditorNameShort = "";
* @param subject
*/
private void cutPersonNames( Wo subject ) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
......@@ -154,33 +157,33 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
}
}
}
public static class Wi{
private Boolean getBBSTopSubject = true;
private Boolean getForumTopSubject = true;
private Boolean getSectionTopSubject = true;
private String subjectId = null;
private String voteOptionId = null;
private String forumId = null;
private String mainSectionId = null;
private String sectionId = null;
private String searchContent = null;
private String creatorName = null;
private Boolean needPicture = false;
private Boolean withTopSubject = null; // 是否包含置顶贴
public static List<String> Excludes = new ArrayList<String>( JpaObject.FieldsUnmodify );
public Boolean getGetBBSTopSubject() {
......@@ -255,49 +258,49 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
public void setVoteOptionId(String voteOptionId) {
this.voteOptionId = voteOptionId;
}
}
public static class Wo extends BBSSubjectInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
private List<WoSubjectAttachment> subjectAttachmentList;
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
private String content = null;
private Long voteCount = 0L;
private String pictureBase64 = null;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "首页推荐人姓名" )
private String bBSIndexSetterNameShort = "";
@FieldDescribe( "精华设置人姓名" )
private String screamSetterNameShort = "";
@FieldDescribe( "原创设置人姓名" )
private String originalSetterNameShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
private Boolean voted = false;
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
......@@ -394,24 +397,24 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
this.voteCount = voteCount;
}
}
public static class WoSubjectAttachment extends BBSSubjectAttachment{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectAttachment, WoSubjectAttachment > wo = WrapCopierFactory.wo( BBSSubjectAttachment.class, WoSubjectAttachment.class, null, JpaObject.FieldsInvisible);
}
public static class WoBBSVoteOptionGroup extends BBSVoteOptionGroup{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOptionGroup, WoBBSVoteOptionGroup > copier = WrapCopierFactory.wo( BBSVoteOptionGroup.class, WoBBSVoteOptionGroup.class, null, JpaObject.FieldsInvisible);
private List<WoBBSVoteOption> voteOptions = null;
public List<WoBBSVoteOption> getVoteOptions() {
......@@ -424,13 +427,13 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
}
public static class WoBBSVoteOption extends BBSVoteOption{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOption, WoBBSVoteOption > copier = WrapCopierFactory.wo( BBSVoteOption.class, WoBBSVoteOption.class, null, JpaObject.FieldsInvisible);
private Boolean voted = false;
public Boolean getVoted() {
......@@ -441,4 +444,4 @@ public class ActionSubjectListCreamedForPages extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -40,7 +40,7 @@ import net.sf.ehcache.Element;
*
*/
public class ActionSubjectListForBBSIndex extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectListForBBSIndex.class );
@SuppressWarnings("unchecked")
......@@ -58,11 +58,11 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if ( check ) {
isBBSManager = ThisApplication.isBBSManager(effectivePerson);
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)), isBBSManager, count, page);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
......@@ -78,7 +78,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
return result;
}
public ActionResult<List<Wo>> getSubjectQueryResult( Wi wrapIn, HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count ) {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps_out = null;
......@@ -91,7 +91,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
Boolean check = true;
if( check && StringUtils.isNotEmpty( wrapIn.getSectionId() ) ){
if (check) {
try {
sectionInfo = sectionInfoServiceAdv.get( wrapIn.getSectionId() );
......@@ -102,7 +102,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if (check) {
if ( sectionInfo == null ) {
check = false;
......@@ -111,7 +111,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
}
}
if( check ){
try{
viewSectionIds = getViewableSectionIds( request, effectivePerson );
......@@ -121,13 +121,13 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if( check ){
if( page == null ){
page = 1;
}
}
if( check ){
if( count == null ){
count = 20;
......@@ -148,7 +148,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
}
}
if( check ){
if( selectTotal > 0 && total > 0 ){
if( page <= 0 ){ page = 1; }
......@@ -189,14 +189,17 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
return result;
}
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* @param subject
*/
private void cutPersonNames( Wo subject ) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
......@@ -205,38 +208,38 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
}
}
}
public static class Wi{
@FieldDescribe( "贴子ID." )
private String subjectId = null;
@FieldDescribe( "投标选项ID." )
private String voteOptionId = null;
@FieldDescribe( "贴子所属论坛ID." )
private String forumId = null;
@FieldDescribe( "贴子所属主版块ID." )
private String mainSectionId = null;
@FieldDescribe( "贴子所属版块ID." )
private String sectionId = null;
@FieldDescribe( "标题模糊搜索关键词" )
private String searchContent = null;
@FieldDescribe( "创建者名称." )
private String creatorName = null;
@FieldDescribe( "是否只查询有大图的贴子." )
private Boolean needPicture = false;
@FieldDescribe( "是否包含置顶贴." )
private Boolean withTopSubject = false; // 是否包含置顶贴
public static List<String> Excludes = new ArrayList<String>( JpaObject.FieldsUnmodify );
public String getForumId() {
return forumId;
}
......@@ -294,7 +297,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
public void setVoteOptionId(String voteOptionId) {
this.voteOptionId = voteOptionId;
}
public String getCacheKey( EffectivePerson effectivePerson, Boolean isBBSManager ) {
StringBuffer sb = new StringBuffer();
if( StringUtils.isNotEmpty( effectivePerson.getDistinguishedName() )) {
......@@ -340,26 +343,26 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
return sb.toString();
}
}
public static class Wo{
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
@FieldDescribe("ID")
private String id = "";
@FieldDescribe("论坛ID")
private String forumId = "";
@FieldDescribe("版块ID")
private String sectionId = "";
@FieldDescribe("主版块ID")
private String mainSectionId = "";
@FieldDescribe("首页图片ID")
private String picId = "";
@FieldDescribe("主题名称:标题")
private String title = "";
......@@ -374,10 +377,13 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
@FieldDescribe("最新回复时间")
private Date latestReplyTime = null;
@FieldDescribe("发贴用户")
private String creatorName = null;
@FieldDescribe("发贴用户昵称")
private String nickName = null;
@FieldDescribe("最新回复用户")
private String latestReplyUser = null;
......@@ -391,7 +397,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
private Long viewTotal = 0L;
@FieldDescribe("主题热度")
private Long hot = 0L;
private Long hot = 0L;
@FieldDescribe("是否为置顶主题")
private Boolean isTopSubject = false;
......@@ -404,16 +410,16 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
@FieldDescribe("版主推荐主题")
private Boolean isRecommendSubject = false;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
public String getCreatorName() {
return creatorName;
}
......@@ -425,7 +431,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
public String getCreatorNameShort() {
return creatorNameShort;
}
......@@ -441,7 +447,7 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
public void setLatestReplyUserShort(String latestReplyUserShort) {
this.latestReplyUserShort = latestReplyUserShort;
}
public void setCreatorNameShort(String creatorNameShort) {
this.creatorNameShort = creatorNameShort;
}
......@@ -597,5 +603,13 @@ public class ActionSubjectListForBBSIndex extends BaseAction {
public void setIsRecommendSubject(Boolean isRecommendSubject) {
this.isRecommendSubject = isRecommendSubject;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
}
}
\ No newline at end of file
}
......@@ -39,7 +39,7 @@ import com.x.bbs.entity.BBSVoteOptionGroup;
import net.sf.ehcache.Element;
public class ActionSubjectListForPage extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectListForPage.class );
@SuppressWarnings("unchecked")
......@@ -57,11 +57,11 @@ public class ActionSubjectListForPage extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if ( check ) {
isBBSManager = ThisApplication.isBBSManager(effectivePerson);
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)), isBBSManager, page, count);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
......@@ -77,7 +77,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
return result;
}
public ActionResult<List<Wo>> getSubjectQueryResult( Wi wrapIn, HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count ) {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps_nonTop = new ArrayList<>();
......@@ -111,7 +111,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
}
}
if( check ){
try{
viewSectionIds = getViewableSectionIds( request, effectivePerson );
......@@ -121,13 +121,13 @@ public class ActionSubjectListForPage extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if( check ){
if( page == null ){
page = 1;
}
}
if( check ){
if( count == null ){
count = 20;
......@@ -137,7 +137,7 @@ public class ActionSubjectListForPage extends BaseAction {
//查询的最大条目数
selectTotal = page * count;
Boolean selectTopInSection = null;//默认是将版块内所有的置顶和非置顶贴全部查出
//查询出所有的置顶贴
if ( check && wrapIn != null && wrapIn.getWithTopSubject() != null && wrapIn.getWithTopSubject() ) {
try {
......@@ -160,7 +160,7 @@ public class ActionSubjectListForPage extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if( check ){
//置顶贴会占用分页的每页条目数
if( wraps_top != null ){
......@@ -171,7 +171,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
}
}
if( check ){
selectTopInSection = false; //置顶贴的处理已经在前面处理过了,置顶贴已经放到一个List里,不需要再次查询出来了,后续的查询过滤置顶贴
if( selectTotal > 0 ){
......@@ -186,7 +186,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
}
}
if( check ){
if( selectTotal > 0 && total > 0 ){
try{
......@@ -209,7 +209,7 @@ public class ActionSubjectListForPage extends BaseAction {
}
}
}
if( check ){
if( page <= 0 ){
page = 1;
......@@ -251,18 +251,21 @@ public class ActionSubjectListForPage extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = "";
bBSIndexSetterNameShort = "";
screamSetterNameShort = "";
originalSetterNameShort = "";
creatorNameShort = "";
auditorNameShort = "";
* @param subject
*/
private void cutPersonNames( Wo subject ) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
......@@ -283,45 +286,45 @@ public class ActionSubjectListForPage extends BaseAction {
}
}
}
public static class Wi{
@FieldDescribe( "贴子ID." )
private String subjectId = null;
@FieldDescribe( "投标选项ID." )
private String voteOptionId = null;
@FieldDescribe( "贴子所属论坛ID." )
private String forumId = null;
@FieldDescribe( "贴子所属主版块ID." )
private String mainSectionId = null;
@FieldDescribe( "贴子所属版块ID." )
private String sectionId = null;
@FieldDescribe( "标题模糊搜索关键词" )
private String searchContent = null;
@FieldDescribe( "创建者名称." )
private String creatorName = null;
@FieldDescribe( "是否只查询有大图的贴子." )
private Boolean needPicture = false;
@FieldDescribe( "是否包含置顶贴." )
private Boolean withTopSubject = false; // 是否包含置顶贴
@FieldDescribe( "创建日期开始." )
private Date startTime = null;
private Date startTime = null;
@FieldDescribe( "创建日期结束." )
private Date endTime = null;
private Date endTime = null;
public static List<String> Excludes = new ArrayList<String>( JpaObject.FieldsUnmodify );
public String getForumId() {
return forumId;
}
......@@ -379,7 +382,7 @@ public class ActionSubjectListForPage extends BaseAction {
public void setVoteOptionId(String voteOptionId) {
this.voteOptionId = voteOptionId;
}
public String getCacheKey(EffectivePerson effectivePerson, Boolean isBBSManager) {
StringBuffer sb = new StringBuffer();
String pattern = "yyyy-MM-dd HH:mm:ss";
......@@ -419,7 +422,7 @@ public class ActionSubjectListForPage extends BaseAction {
sb.append( "#" );
sb.append( creatorName );
}
if( startTime != null ) {
sb.append( "#" );
sb.append( formatter.format(startTime));
......@@ -428,14 +431,14 @@ public class ActionSubjectListForPage extends BaseAction {
sb.append( "#" );
sb.append( formatter.format(endTime));
}
sb.append( "#" );
sb.append( needPicture );
sb.append( "#" );
sb.append( withTopSubject );
return sb.toString();
}
public Date getStartTime() {
return startTime;
}
......@@ -448,51 +451,51 @@ public class ActionSubjectListForPage extends BaseAction {
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
public static class Wo extends BBSSubjectInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
private List<WoSubjectAttachment> subjectAttachmentList;
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
private String content = null;
private Long voteCount = 0L;
private String pictureBase64 = null;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "首页推荐人姓名" )
private String bBSIndexSetterNameShort = "";
@FieldDescribe( "精华设置人姓名" )
private String screamSetterNameShort = "";
@FieldDescribe( "原创设置人姓名" )
private String originalSetterNameShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
......@@ -589,21 +592,21 @@ public class ActionSubjectListForPage extends BaseAction {
this.voteCount = voteCount;
}
}
public static class WoSubjectAttachment extends BBSSubjectAttachment{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSSubjectAttachment, WoSubjectAttachment > copier = WrapCopierFactory.wo( BBSSubjectAttachment.class, WoSubjectAttachment.class, null, JpaObject.FieldsInvisible);
}
public static class WoBBSVoteOptionGroup extends BBSVoteOptionGroup{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSVoteOptionGroup, WoBBSVoteOptionGroup > copier = WrapCopierFactory.wo( BBSVoteOptionGroup.class, WoBBSVoteOptionGroup.class, null, JpaObject.FieldsInvisible);
private List<WoBBSVoteOption> voteOptions = null;
public List<WoBBSVoteOption> getVoteOptions() {
......@@ -616,11 +619,11 @@ public class ActionSubjectListForPage extends BaseAction {
}
public static class WoBBSVoteOption extends BBSVoteOption{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSVoteOption, WoBBSVoteOption > copier = WrapCopierFactory.wo( BBSVoteOption.class, WoBBSVoteOption.class, null, JpaObject.FieldsInvisible);
private Boolean voted = false;
public Boolean getVoted() {
......@@ -631,4 +634,4 @@ public class ActionSubjectListForPage extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -124,15 +124,18 @@ public class ActionSubjectListMyForPage extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = ""; bBSIndexSetterNameShort = "";
* screamSetterNameShort = ""; originalSetterNameShort = "";
* creatorNameShort = ""; auditorNameShort = "";
*
*
* @param subject
*/
private void cutPersonNames(Wo subject) {
if (subject != null) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if ( StringUtils.isNotEmpty( subject.getLatestReplyUser() )) {
subject.setLatestReplyUserShort(subject.getLatestReplyUser().split("@")[0]);
}
......@@ -428,4 +431,4 @@ public class ActionSubjectListMyForPage extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -88,15 +88,18 @@ public class ActionSubjectListRecommendedForBBSIndex extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = ""; bBSIndexSetterNameShort = "";
* screamSetterNameShort = ""; originalSetterNameShort = "";
* creatorNameShort = ""; auditorNameShort = "";
*
*
* @param subject
*/
private void cutPersonNames(Wo subject) {
if (subject != null) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if ( StringUtils.isNotEmpty( subject.getLatestReplyUser() )) {
subject.setLatestReplyUserShort(subject.getLatestReplyUser().split("@")[0]);
}
......@@ -304,4 +307,4 @@ public class ActionSubjectListRecommendedForBBSIndex extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -27,9 +27,9 @@ import com.x.bbs.entity.BBSVoteOption;
import com.x.bbs.entity.BBSVoteOptionGroup;
public class ActionSubjectListRecommendedForPages extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectListRecommendedForPages.class );
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps = new ArrayList<>();
......@@ -41,7 +41,7 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
String searchMainSectionId = null;
Wi wrapIn = null;
Boolean check = true;
try {
wrapIn = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e ) {
......@@ -50,7 +50,7 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if( check ){
if( page == null ){
page = 1;
......@@ -100,7 +100,7 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
}
if( ListTools.isNotEmpty( subjectInfoList_out ) ){
try {
wraps = Wo.copier.copy( subjectInfoList_out );
wraps = Wo.copier.copy( subjectInfoList_out );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionSubjectWrapOut( e );
......@@ -124,18 +124,21 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = "";
bBSIndexSetterNameShort = "";
screamSetterNameShort = "";
originalSetterNameShort = "";
creatorNameShort = "";
auditorNameShort = "";
* @param subject
*/
private void cutPersonNames( Wo subject ) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
......@@ -156,47 +159,47 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
}
}
}
public static class Wo extends BBSSubjectInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
private List<WoSubjectAttachment> subjectAttachmentList;
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
private String content = null;
private Long voteCount = 0L;
private String pictureBase64 = null;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "首页推荐人姓名" )
private String bBSIndexSetterNameShort = "";
@FieldDescribe( "精华设置人姓名" )
private String screamSetterNameShort = "";
@FieldDescribe( "原创设置人姓名" )
private String originalSetterNameShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
private Boolean voted = false;
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
......@@ -293,24 +296,24 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
this.voteCount = voteCount;
}
}
public static class WoSubjectAttachment extends BBSSubjectAttachment{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectAttachment, WoSubjectAttachment > copier = WrapCopierFactory.wo( BBSSubjectAttachment.class, WoSubjectAttachment.class, null, JpaObject.FieldsInvisible);
}
public static class WoBBSVoteOptionGroup extends BBSVoteOptionGroup{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOptionGroup, WoBBSVoteOptionGroup > copier = WrapCopierFactory.wo( BBSVoteOptionGroup.class, WoBBSVoteOptionGroup.class, null, JpaObject.FieldsInvisible);
private List<WoBBSVoteOption> voteOptions = null;
public List<WoBBSVoteOption> getVoteOptions() {
......@@ -323,13 +326,13 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
}
public static class WoBBSVoteOption extends BBSVoteOption{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOption, WoBBSVoteOption > copier = WrapCopierFactory.wo( BBSVoteOption.class, WoBBSVoteOption.class, null, JpaObject.FieldsInvisible);
private Boolean voted = false;
public Boolean getVoted() {
......@@ -340,4 +343,4 @@ public class ActionSubjectListRecommendedForPages extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -112,15 +112,18 @@ public class ActionSubjectListTop extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = ""; bBSIndexSetterNameShort = "";
* screamSetterNameShort = ""; originalSetterNameShort = "";
* creatorNameShort = ""; auditorNameShort = "";
*
*
* @param subject
*/
private void cutPersonNames(Wo subject) {
if (subject != null) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if ( StringUtils.isNotEmpty( subject.getLatestReplyUser() )) {
subject.setLatestReplyUserShort(subject.getLatestReplyUser().split("@")[0]);
}
......@@ -329,4 +332,4 @@ public class ActionSubjectListTop extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -32,7 +32,7 @@ import java.util.List;
import java.util.Optional;
public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectListWithSubjectTypeForPage.class );
@SuppressWarnings("unchecked")
......@@ -64,7 +64,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
result.error(exception);
}
}
if( check ) {
Cache.CacheKey cacheKey = new Cache.CacheKey( this.getClass(), effectivePerson.getDistinguishedName(), MD5Tool.getMD5Str(gson.toJson(wrapIn)) ,isBBSManager,page,count);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey );
......@@ -80,7 +80,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
return result;
}
public ActionResult<List<Wo>> getSubjectQueryResult( Wi wrapIn, HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps_nonTop = new ArrayList<>();
......@@ -114,7 +114,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
}
}
if( check ){
try{
viewSectionIds = getViewableSectionIds( request, effectivePerson );
......@@ -124,13 +124,13 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if( check ){
if( page == null ){
page = 1;
}
}
if( check ){
if( count == null ){
count = 20;
......@@ -140,7 +140,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
//查询的最大条目数
selectTotal = page * count;
Boolean selectTopInSection = null;//默认是将版块内所有的置顶和非置顶贴全部查出
//查询出所有的置顶贴
if ( check && wrapIn != null && wrapIn.getWithTopSubject() != null && wrapIn.getWithTopSubject() ) {
try {
......@@ -164,7 +164,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
logger.error( e, effectivePerson, request, null);
}
}
if( check ){
//置顶贴会占用分页的每页条目数
if( wraps_top != null ){
......@@ -175,7 +175,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
}
}
if( check ){
selectTopInSection = false; //置顶贴的处理已经在前面处理过了,置顶贴已经放到一个List里,不需要再次查询出来了,后续的查询过滤置顶贴
if( selectTotal > 0 ){
......@@ -190,7 +190,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
}
}
if( check ){
if( selectTotal > 0 && total > 0 ){
try{
......@@ -213,7 +213,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
}
}
if( check ){
if( page <= 0 ){
page = 1;
......@@ -259,18 +259,21 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
/**
* 将带@形式的人员标识修改为人员的姓名并且赋值到xxShort属性里
*
*
* latestReplyUserShort = "";
bBSIndexSetterNameShort = "";
screamSetterNameShort = "";
originalSetterNameShort = "";
creatorNameShort = "";
auditorNameShort = "";
* @param subject
*/
private void cutPersonNames( Wo subject ) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
......@@ -320,21 +323,21 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
subjectInfo.setWoBBSReplyInfo(bbsReplyInfoList);
}
}
public static class Wi{
@FieldDescribe( "贴子ID." )
private String subjectId = null;
@FieldDescribe( "投标选项ID." )
private String voteOptionId = null;
@FieldDescribe( "贴子所属论坛ID." )
private String forumId = null;
@FieldDescribe( "贴子所属主版块ID." )
private String mainSectionId = null;
@FieldDescribe( "贴子所属版块ID." )
private String sectionId = null;
......@@ -346,25 +349,25 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
@FieldDescribe( "标题模糊搜索关键词" )
private String searchContent = null;
@FieldDescribe( "创建者名称." )
private String creatorName = null;
@FieldDescribe( "是否只查询有大图的贴子." )
private Boolean needPicture = false;
@FieldDescribe( "是否包含置顶贴." )
private Boolean withTopSubject = false; // 是否包含置顶贴
@FieldDescribe( "创建日期开始." )
private Date startTime = null;
private Date startTime = null;
@FieldDescribe( "创建日期结束." )
private Date endTime = null;
private Date endTime = null;
public static List<String> Excludes = new ArrayList<String>( JpaObject.FieldsUnmodify );
public String getForumId() {
return forumId;
}
......@@ -434,7 +437,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
public void setVoteOptionId(String voteOptionId) {
this.voteOptionId = voteOptionId;
}
public String getCacheKey(EffectivePerson effectivePerson, Boolean isBBSManager) {
StringBuffer sb = new StringBuffer();
String pattern = "yyyy-MM-dd HH:mm:ss";
......@@ -478,7 +481,7 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
sb.append( "#" );
sb.append( creatorName );
}
if( startTime != null ) {
sb.append( "#" );
sb.append( formatter.format(startTime));
......@@ -487,14 +490,14 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
sb.append( "#" );
sb.append( formatter.format(endTime));
}
sb.append( "#" );
sb.append( needPicture );
sb.append( "#" );
sb.append( withTopSubject );
return sb.toString();
}
public Date getStartTime() {
return startTime;
}
......@@ -507,50 +510,50 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
public static class Wo extends BBSSubjectInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
private List<WoBBSReplyInfo> bbsReplyInfo = null;
private List<WoSubjectAttachment> subjectAttachmentList;
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
private String content = null;
private Long voteCount = 0L;
private String pictureBase64 = null;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "首页推荐人姓名" )
private String bBSIndexSetterNameShort = "";
@FieldDescribe( "精华设置人姓名" )
private String screamSetterNameShort = "";
@FieldDescribe( "原创设置人姓名" )
private String originalSetterNameShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
......@@ -658,21 +661,21 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
this.voteCount = voteCount;
}
}
public static class WoSubjectAttachment extends BBSSubjectAttachment{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSSubjectAttachment, WoSubjectAttachment > copier = WrapCopierFactory.wo( BBSSubjectAttachment.class, WoSubjectAttachment.class, null, JpaObject.FieldsInvisible);
}
public static class WoBBSVoteOptionGroup extends BBSVoteOptionGroup{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSVoteOptionGroup, WoBBSVoteOptionGroup > copier = WrapCopierFactory.wo( BBSVoteOptionGroup.class, WoBBSVoteOptionGroup.class, null, JpaObject.FieldsInvisible);
private List<WoBBSVoteOption> voteOptions = null;
public List<WoBBSVoteOption> getVoteOptions() {
......@@ -685,11 +688,11 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
}
public static class WoBBSVoteOption extends BBSVoteOption{
private static final long serialVersionUID = -5076990764713538973L;
public static WrapCopier< BBSVoteOption, WoBBSVoteOption > copier = WrapCopierFactory.wo( BBSVoteOption.class, WoBBSVoteOption.class, null, JpaObject.FieldsInvisible);
private Boolean voted = false;
public Boolean getVoted() {
......@@ -750,4 +753,4 @@ public class ActionSubjectListWithSubjectTypeForPage extends BaseAction {
this.auditorNameShort = auditorNameShort;
}
}
}
\ No newline at end of file
}
......@@ -6,6 +6,9 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.organization.Person;
import com.x.bbs.assemble.control.Business;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
......@@ -137,6 +140,9 @@ public class ActionSubjectSave extends BaseAction {
subjectInfo.setVotePersonVisible(wrapIn.getVotePersonVisible());
subjectInfo.setVoteResultVisible(wrapIn.getVoteResultVisible());
subjectInfo.setGrade(wrapIn.getGrade());
Business business = new Business(null);
subjectInfo.setNickName(business.organization().person().getNickName(effectivePerson.getDistinguishedName()));
}
if (check) {
......@@ -149,7 +155,7 @@ public class ActionSubjectSave extends BaseAction {
CacheManager.notify( BBSSubjectInfo.class );
CacheManager.notify( BBSSectionInfo.class );
CacheManager.notify( BBSForumInfo.class );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionSubjectSave(e);
......@@ -237,4 +243,4 @@ public class ActionSubjectSave extends BaseAction {
public static class Wo extends WoId {
}
}
\ No newline at end of file
}
......@@ -22,11 +22,12 @@ import com.x.bbs.entity.BBSSubjectAttachment;
import com.x.bbs.entity.BBSSubjectInfo;
import com.x.bbs.entity.BBSVoteOption;
import com.x.bbs.entity.BBSVoteOptionGroup;
import org.apache.commons.lang3.StringUtils;
public class ActionSubjectSearchForPage extends BaseAction {
private static Logger logger = LoggerFactory.getLogger( ActionSubjectSearchForPage.class );
protected ActionResult<List<Wo>> execute( HttpServletRequest request, EffectivePerson effectivePerson, Integer page, Integer count, JsonElement jsonElement ) throws Exception {
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> wraps = new ArrayList<>();
......@@ -36,7 +37,7 @@ public class ActionSubjectSearchForPage extends BaseAction {
Long total = 0L;
Wi wrapIn = null;
Boolean check = true;
try {
wrapIn = this.convertToWrapIn( jsonElement, Wi.class );
} catch (Exception e ) {
......@@ -45,7 +46,7 @@ public class ActionSubjectSearchForPage extends BaseAction {
result.error( exception );
logger.error( e, effectivePerson, request, null);
}
if( check ){
if( page == null ){
page = 1;
......@@ -104,6 +105,9 @@ public class ActionSubjectSearchForPage extends BaseAction {
if( ListTools.isNotEmpty( subjectInfoList_out ) ){
try {
wraps = Wo.copier.copy( subjectInfoList_out );
for( Wo wo : wraps ) {
cutPersonNames( wo );
}
result.setData( wraps );
result.setCount( total );
} catch (Exception e) {
......@@ -117,32 +121,58 @@ public class ActionSubjectSearchForPage extends BaseAction {
return result;
}
private void cutPersonNames(Wo subject) {
if( subject != null ) {
if(StringUtils.isBlank(subject.getNickName())){
subject.setNickName(subject.getCreatorName());
}
if( StringUtils.isNotEmpty( subject.getLatestReplyUser() ) ) {
subject.setLatestReplyUserShort( subject.getLatestReplyUser().split( "@" )[0]);
}
if( StringUtils.isNotEmpty( subject.getbBSIndexSetterName() ) ) {
subject.setbBSIndexSetterNameShort( subject.getbBSIndexSetterName().split( "@" )[0]);
}
if( StringUtils.isNotEmpty( subject.getScreamSetterName() ) ) {
subject.setScreamSetterNameShort( subject.getScreamSetterName().split( "@" )[0]);
}
if( StringUtils.isNotEmpty( subject.getOriginalSetterName() ) ) {
subject.setOriginalSetterNameShort( subject.getOriginalSetterName().split( "@" )[0]);
}
if( StringUtils.isNotEmpty( subject.getCreatorName() ) ) {
subject.setCreatorNameShort( subject.getCreatorName().split( "@" )[0]);
}
if( StringUtils.isNotEmpty( subject.getAuditorName() ) ) {
subject.setAuditorNameShort( subject.getAuditorName().split( "@" )[0]);
}
}
}
public static class Wi{
private Boolean getBBSTopSubject = true;
private Boolean getForumTopSubject = true;
private Boolean getSectionTopSubject = true;
private String subjectId = null;
private String voteOptionId = null;
private String forumId = null;
private String mainSectionId = null;
private String sectionId = null;
private String searchContent = null;
private String creatorName = null;
private Boolean needPicture = false;
private Boolean withTopSubject = null; // 是否包含置顶贴
public static List<String> Excludes = new ArrayList<String>( JpaObject.FieldsUnmodify );
public Boolean getGetBBSTopSubject() {
......@@ -217,28 +247,46 @@ public class ActionSubjectSearchForPage extends BaseAction {
public void setVoteOptionId(String voteOptionId) {
this.voteOptionId = voteOptionId;
}
}
public static class Wo extends BBSSubjectInfo{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectInfo, Wo > copier = WrapCopierFactory.wo( BBSSubjectInfo.class, Wo.class, null, JpaObject.FieldsInvisible);
private List<WoSubjectAttachment> subjectAttachmentList;
@FieldDescribe( "投票主题的所有投票选项列表." )
private List<WoBBSVoteOptionGroup> voteOptionGroupList;
private String content = null;
private Long voteCount = 0L;
private String pictureBase64 = null;
@FieldDescribe( "最新回复用户" )
private String latestReplyUserShort = "";
@FieldDescribe( "首页推荐人姓名" )
private String bBSIndexSetterNameShort = "";
@FieldDescribe( "精华设置人姓名" )
private String screamSetterNameShort = "";
@FieldDescribe( "原创设置人姓名" )
private String originalSetterNameShort = "";
@FieldDescribe( "创建人姓名" )
private String creatorNameShort = "";
@FieldDescribe( "审核人姓名" )
private String auditorNameShort = "";
@FieldDescribe( "当前用户是否已经投票过." )
private Boolean voted = false;
......@@ -289,25 +337,73 @@ public class ActionSubjectSearchForPage extends BaseAction {
public void setVoteCount(Long voteCount) {
this.voteCount = voteCount;
}
public String getLatestReplyUserShort() {
return latestReplyUserShort;
}
public void setLatestReplyUserShort(String latestReplyUserShort) {
this.latestReplyUserShort = latestReplyUserShort;
}
public String getbBSIndexSetterNameShort() {
return bBSIndexSetterNameShort;
}
public void setbBSIndexSetterNameShort(String bBSIndexSetterNameShort) {
this.bBSIndexSetterNameShort = bBSIndexSetterNameShort;
}
public String getScreamSetterNameShort() {
return screamSetterNameShort;
}
public void setScreamSetterNameShort(String screamSetterNameShort) {
this.screamSetterNameShort = screamSetterNameShort;
}
public String getOriginalSetterNameShort() {
return originalSetterNameShort;
}
public void setOriginalSetterNameShort(String originalSetterNameShort) {
this.originalSetterNameShort = originalSetterNameShort;
}
public String getCreatorNameShort() {
return creatorNameShort;
}
public void setCreatorNameShort(String creatorNameShort) {
this.creatorNameShort = creatorNameShort;
}
public String getAuditorNameShort() {
return auditorNameShort;
}
public void setAuditorNameShort(String auditorNameShort) {
this.auditorNameShort = auditorNameShort;
}
}
public static class WoSubjectAttachment extends BBSSubjectAttachment{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSSubjectAttachment, WoSubjectAttachment > copier = WrapCopierFactory.wo( BBSSubjectAttachment.class, WoSubjectAttachment.class, null, JpaObject.FieldsInvisible);
}
public static class WoBBSVoteOptionGroup extends BBSVoteOptionGroup{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOptionGroup, WoBBSVoteOptionGroup > copier = WrapCopierFactory.wo( BBSVoteOptionGroup.class, WoBBSVoteOptionGroup.class, null, JpaObject.FieldsInvisible);
private List<WoBBSVoteOption> voteOptions = null;
public List<WoBBSVoteOption> getVoteOptions() {
......@@ -320,13 +416,13 @@ public class ActionSubjectSearchForPage extends BaseAction {
}
public static class WoBBSVoteOption extends BBSVoteOption{
private static final long serialVersionUID = -5076990764713538973L;
public static List<String> Excludes = new ArrayList<String>();
public static WrapCopier< BBSVoteOption, WoBBSVoteOption > copier = WrapCopierFactory.wo( BBSVoteOption.class, WoBBSVoteOption.class, null, JpaObject.FieldsInvisible);
private Boolean voted = false;
public Boolean getVoted() {
......@@ -337,4 +433,4 @@ public class ActionSubjectSearchForPage extends BaseAction {
this.voted = voted;
}
}
}
\ No newline at end of file
}
......@@ -18,6 +18,7 @@ import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectFi
import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectWrapOut;
import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionWrapInConvert;
import com.x.bbs.entity.BBSVoteRecord;
import org.apache.commons.lang3.StringUtils;
public class ActionVoteRecordListMyForPage extends BaseAction {
......@@ -86,6 +87,10 @@ public class ActionVoteRecordListMyForPage extends BaseAction {
int endIndex = page * count;
for (int i = 0; recordInfoList != null && i < recordInfoList.size(); i++) {
if (i < recordInfoList.size() && i >= startIndex && i < endIndex) {
BBSVoteRecord record = recordInfoList.get(i);
if(StringUtils.isBlank(record.getVotorNickName())){
record.setVotorNickName(record.getVotorName());
}
recordInfoList_out.add(recordInfoList.get(i));
}
}
......@@ -239,4 +244,4 @@ public class ActionVoteRecordListMyForPage extends BaseAction {
JpaObject.FieldsInvisible);
}
}
\ No newline at end of file
}
......@@ -12,14 +12,7 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionPublicSectionFilter;
import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectInfoProcess;
import com.x.bbs.assemble.control.service.BBSForumInfoServiceAdv;
import com.x.bbs.assemble.control.service.BBSOperationRecordService;
import com.x.bbs.assemble.control.service.BBSReplyInfoService;
import com.x.bbs.assemble.control.service.BBSSectionInfoServiceAdv;
import com.x.bbs.assemble.control.service.BBSSubjectInfoServiceAdv;
import com.x.bbs.assemble.control.service.BBSSubjectVoteService;
import com.x.bbs.assemble.control.service.UserManagerService;
import com.x.bbs.assemble.control.service.UserPermissionService;
import com.x.bbs.assemble.control.service.*;
import com.x.bbs.entity.*;
import net.sf.ehcache.Ehcache;
......@@ -28,7 +21,7 @@ public class BaseAction extends StandardJaxrsAction{
private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
protected Cache.CacheCategory cacheCategory = new Cache.CacheCategory(BBSSubjectInfo.class);
protected UserPermissionService UserPermissionService = new UserPermissionService();
protected BBSReplyInfoService replyInfoService = new BBSReplyInfoService();
protected BBSSectionInfoServiceAdv sectionInfoServiceAdv = new BBSSectionInfoServiceAdv();
......@@ -37,6 +30,7 @@ public class BaseAction extends StandardJaxrsAction{
protected BBSForumInfoServiceAdv forumInfoServiceAdv = new BBSForumInfoServiceAdv();
protected UserManagerService userManagerService = new UserManagerService();
protected BBSOperationRecordService operationRecordService = new BBSOperationRecordService();
protected BBSConfigSettingService configSettingService = new BBSConfigSettingService();
protected boolean isImage(BBSSubjectAttachment fileInfo) {
if (fileInfo == null || fileInfo.getExtension() == null || fileInfo.getExtension().isEmpty()) {
......@@ -60,11 +54,11 @@ public class BaseAction extends StandardJaxrsAction{
/**
* 获取用户可访问的所有版块ID列表
*
*
* @param request
* @param currentPerson
* @return
* @throws Exception
* @throws Exception
*/
protected List<String> getViewableSectionIds(HttpServletRequest request, EffectivePerson currentPerson) throws Exception {
List<BBSSectionInfo> sectionInfoList = null;
......
package com.x.bbs.assemble.control.queue;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.queue.AbstractQueue;
/**
* @author sword
*/
public class NickNameConsumeQueue extends AbstractQueue<String> {
private static Logger logger = LoggerFactory.getLogger(NickNameConsumeQueue.class);
@Override
protected void execute(String person) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
logger.debug("change nick name:{}.", person);
}
}
}
......@@ -21,9 +21,9 @@ import com.x.bbs.entity.BBSConfigSetting;
* 日 期:2016-05-20 17:17:26
**/
public class BBSConfigSettingService{
private static Logger logger = LoggerFactory.getLogger( BBSConfigSettingService.class );
/**
* 根据传入的ID从数据库查询BBSConfigSetting对象
* @param id
......@@ -40,10 +40,10 @@ public class BBSConfigSettingService{
throw e;
}
}
/**
* 向数据库保存BBSConfigSetting对象
* @param wrapIn
* @param bbsConfigSetting
*/
public BBSConfigSetting save( BBSConfigSetting bbsConfigSetting ) throws Exception {
BBSConfigSetting _bbsConfigSetting = null;
......@@ -52,11 +52,11 @@ public class BBSConfigSettingService{
if( _bbsConfigSetting != null ){
emc.beginTransaction( BBSConfigSetting.class );
bbsConfigSetting.copyTo( _bbsConfigSetting, JpaObject.FieldsUnmodify );
emc.check( _bbsConfigSetting, CheckPersistType.all );
emc.check( _bbsConfigSetting, CheckPersistType.all );
emc.commit();
}else{
emc.beginTransaction( BBSConfigSetting.class );
emc.persist( bbsConfigSetting, CheckPersistType.all);
emc.persist( bbsConfigSetting, CheckPersistType.all);
emc.commit();
}
}catch( Exception e ){
......@@ -65,10 +65,10 @@ public class BBSConfigSettingService{
}
return bbsConfigSetting;
}
/**
* 向数据库保存BBSConfigSetting对象
* @param wrapIn
* @param bbsConfigSetting
*/
public BBSConfigSetting update( BBSConfigSetting bbsConfigSetting ) throws Exception {
BBSConfigSetting _bbsConfigSetting = null;
......@@ -79,7 +79,7 @@ public class BBSConfigSettingService{
if( _bbsConfigSetting != null ){
emc.beginTransaction( BBSConfigSetting.class );
bbsConfigSetting.copyTo( _bbsConfigSetting, JpaObject.FieldsUnmodify );
emc.check( _bbsConfigSetting, CheckPersistType.all );
emc.check( _bbsConfigSetting, CheckPersistType.all );
emc.commit();
}else{
throw new Exception("config setting '"+ bbsConfigSetting.getConfigCode() +"' not exists");
......@@ -90,7 +90,7 @@ public class BBSConfigSettingService{
}
return bbsConfigSetting;
}
/**
* 根据ID从数据库中删除BBSConfigSetting对象
* @param id
......@@ -115,7 +115,7 @@ public class BBSConfigSettingService{
throw e;
}
}
/**
* 根据传入的ID从数据库查询BBSConfigSetting对象
* @param configCode
......@@ -134,10 +134,24 @@ public class BBSConfigSettingService{
throw e;
}
}
/**
* 论坛是否启用昵称,默认不启用
*/
public boolean useNickName() throws Exception {
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
Business business = new Business(emc);
String configValue = business.configSettingFactory().getValueWithConfigCode(BBSConfigSetting.BBS_CONFIG_USE_NICKNAME);
if(BBSConfigSetting.BBS_CONFIG_USE_NICKNAME_YES.equalsIgnoreCase(configValue)){
return true;
}
}
return false;
}
/**
* 根据传入的ID从数据库查询BBSConfigSetting对象
* @param id
* @param configCode
* @return
* @throws Exception
*/
......@@ -245,7 +259,7 @@ public class BBSConfigSettingService{
String value = null, description = null, type = null, selectContent = null;
Boolean isMultiple = false;
Integer ordernumber = 0;
value = "企业论坛";
type = "text";
selectContent = null;
......@@ -269,7 +283,7 @@ public class BBSConfigSettingService{
logger.warn( "system init system config 'BBS_TITLE_TAIL' got an exception." );
logger.error(e);
}
value = "信息|问题|投票";
type = "select";
selectContent = "信息|问题|投票";
......@@ -329,5 +343,17 @@ public class BBSConfigSettingService{
logger.warn( "system init system config 'BBS_ANONYMOUS_PERMISSION' got an exception." );
logger.error(e);
}
value = "YES";
type = "select";
selectContent = "YES|NO";
isMultiple = false;
description = "是否启用昵称:可选值:YES|NO(允许|不允许),单选。";
try {
checkAndInitSystemConfig("BBS_USE_NICKNAME", "是否启用昵称", value, description, type, selectContent, isMultiple, ++ordernumber );
} catch (Exception e) {
logger.warn( "system init system config 'BBS_USE_NICKNAME' got an exception." );
logger.error(e);
}
}
}
......@@ -27,9 +27,9 @@ import org.apache.commons.lang3.StringUtils;
*
*/
public class BBSReplyInfoService {
private static Logger logger = LoggerFactory.getLogger( BBSReplyInfoService.class );
/**
* 根据传入的ID从数据库查询BBSReplyInfo对象
* @param id
......@@ -46,7 +46,7 @@ public class BBSReplyInfoService {
throw e;
}
}
/**
* 向数据库保存BBSReplyInfo对象
* @param _bBSReplyInfo
......@@ -58,7 +58,7 @@ public class BBSReplyInfoService {
BBSSectionInfo _mainSectoinInfo = null;
BBSForumInfo _forumInfo = null;
BBSUserInfo _BBSUserInfo = null;
if( _bBSReplyInfo.getId() == null ){
_bBSReplyInfo.setId( BBSReplyInfo.createId() );
}
......@@ -71,13 +71,13 @@ public class BBSReplyInfoService {
}catch(Exception e){
maxOrderNumber = 0;
}
_forumInfo = emc.find( _bBSReplyInfo.getForumId(), BBSForumInfo.class );
_mainSectoinInfo = emc.find( _bBSReplyInfo.getMainSectionId(), BBSSectionInfo.class );
_sectionInfo = emc.find( _bBSReplyInfo.getSectionId(), BBSSectionInfo.class );
_subjectInfo = emc.find( _bBSReplyInfo.getSubjectId(), BBSSubjectInfo.class );
_bBSReplyInfo_tmp = emc.find( _bBSReplyInfo.getId(), BBSReplyInfo.class );
emc.beginTransaction( BBSReplyInfo.class );
emc.beginTransaction( BBSSubjectInfo.class );
emc.beginTransaction( BBSSectionInfo.class );
......@@ -90,12 +90,16 @@ public class BBSReplyInfoService {
//更新一条记录
_bBSReplyInfo.setCreateTime( _bBSReplyInfo_tmp.getCreateTime() );
_bBSReplyInfo.copyTo( _bBSReplyInfo_tmp, JpaObject.FieldsUnmodify );
emc.check( _bBSReplyInfo_tmp, CheckPersistType.all );
emc.check( _bBSReplyInfo_tmp, CheckPersistType.all );
}
if( _subjectInfo != null ){
_subjectInfo.setLatestReplyTime( new Date() );
_subjectInfo.setLatestReplyId( _bBSReplyInfo.getId() );
_subjectInfo.setLatestReplyUser( _bBSReplyInfo.getCreatorName() );
if(StringUtils.isNoneBlank(_bBSReplyInfo.getNickName())){
_subjectInfo.setLatestReplyUser(_bBSReplyInfo.getNickName());
}else {
_subjectInfo.setLatestReplyUser(_bBSReplyInfo.getCreatorName());
}
_subjectInfo.setReplyTotal( _subjectInfo.getReplyTotal() + 1 );
emc.check( _subjectInfo, CheckPersistType.all );
}
......@@ -115,23 +119,23 @@ public class BBSReplyInfoService {
_forumInfo.setReplyTotal( _forumInfo.getReplyTotal() + 1 );
emc.check( _forumInfo, CheckPersistType.all );
}
emc.commit();
//个人回复数增加1
BBSUserInfoService userInfoService = new BBSUserInfoService();
BBSUserInfo userInfo = userInfoService.getByUserName( _bBSReplyInfo.getCreatorName());
userInfo.setReplyCount(userInfo.getReplyCount() + 1);
userInfo.setReplyCountToday(userInfo.getReplyCountToday() + 1);
userInfoService.save(userInfo);
}catch( Exception e ){
logger.warn( "system find BBSReplyInfo{'id':'"+_bBSReplyInfo.getId()+"'} got an exception!" );
throw e;
}
return _bBSReplyInfo;
}
/**
* 根据ID从数据库中删除BBSReplyInfo对象
* @param id
......@@ -146,7 +150,7 @@ public class BBSReplyInfoService {
if( id == null || id.isEmpty() ){
return;
}
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
//先判断需要操作的应用信息是否存在,根据ID进行一次查询,如果不存在不允许继续操作
replyInfo = emc.find( id, BBSReplyInfo.class );
if ( null == replyInfo ) {
......@@ -156,7 +160,7 @@ public class BBSReplyInfoService {
emc.beginTransaction( BBSSubjectInfo.class );
emc.beginTransaction( BBSSectionInfo.class );
emc.beginTransaction( BBSForumInfo.class );
_forumInfo = emc.find( replyInfo.getForumId(), BBSForumInfo.class );
_mainSectoinInfo = emc.find( replyInfo.getMainSectionId(), BBSSectionInfo.class );
_sectionInfo = emc.find( replyInfo.getSectionId(), BBSSectionInfo.class );
......@@ -212,7 +216,7 @@ public class BBSReplyInfoService {
throw e;
}
}
public Long countWithSubjectForPage(String subjectId, Boolean showSubReply) throws Exception {
if( subjectId == null ){
throw new Exception( "subjectId can not null." );
......@@ -305,4 +309,4 @@ public class BBSReplyInfoService {
}
return allIds;
}
}
\ No newline at end of file
}
......@@ -34,7 +34,7 @@ public class BBSSubjectVoteService {
List<BBSVoteOptionGroup> voteOptionGroupList = null;
List<BBSVoteOption> voteOptionList = null;
Business busines = null;
try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create() ) {
busines = new Business(emc);
voteOptionList = busines.voteOptionFactory().listVoteOptionBySubject( subjectInfo.getId() );
......@@ -51,7 +51,7 @@ public class BBSSubjectVoteService {
emc.remove( group, CheckRemoveType.all );
}
}
int groupIndex = 0;
int optionIndex = 0;
for( WiVoteOptionGroup group : optionGroups ){
......@@ -94,17 +94,17 @@ public class BBSSubjectVoteService {
throw e;
}
}
/**
* 提交投票结果
*
*
* 1、记录投票日志
* 2、计算投票结果到投票选项组信息中
*
*
* @param effectivePerson
* @param subjectInfo
* @param optionGroups
* @throws Exception
* @throws Exception
*/
public void submitVoteResult( EffectivePerson effectivePerson, BBSSubjectInfo subjectInfo, List<WiVoteOptionGroup> optionGroups ) throws Exception {
//BBSVoteOptionGroup voteOptionGroup = null;
......@@ -117,7 +117,7 @@ public class BBSSubjectVoteService {
//emc.beginTransaction( BBSVoteOptionGroup.class );
emc.beginTransaction( BBSVoteOption.class );
emc.beginTransaction( BBSVoteRecord.class );
Business buiness = new Business(emc);
Business business = new Business(emc);
for( WiVoteOptionGroup group : optionGroups ){
voteOptionGroup = emc.find( group.getId(), BBSVoteOptionGroup.class );
if( ListTools.isNotEmpty( group.getSelectedVoteOptionIds() ) ){
......@@ -125,7 +125,7 @@ public class BBSSubjectVoteService {
voteOption = emc.find( selectedOptionId, BBSVoteOption.class );
if( voteOption != null ){
//查询一下是否已经投过票了
List<BBSVoteRecord> recordList = buiness.voteRecordFactory().listVoteCountByUserAndGroup( effectivePerson.getDistinguishedName(), group.getId() );
List<BBSVoteRecord> recordList = business.voteRecordFactory().listVoteCountByUserAndGroup( effectivePerson.getDistinguishedName(), group.getId() );
if( (ListTools.isEmpty( recordList) || recordList.size() < voteOptionGroup.getVoteChooseCount())
&& !doseNotChoosen( recordList, selectedOptionId )){
voteRecord = new BBSVoteRecord();
......@@ -139,6 +139,7 @@ public class BBSSubjectVoteService {
voteRecord.setOptionValue( voteOption.getId() );
voteRecord.setCreateTime( new Date() );
voteRecord.setVotorName( effectivePerson.getDistinguishedName() );
voteRecord.setVotorNickName(business.organization().person().getNickName(effectivePerson.getDistinguishedName()));
emc.persist( voteRecord, CheckPersistType.all );
voteOption.setChooseCount( voteOption.getChooseCount() + 1 );
......@@ -224,7 +225,7 @@ public class BBSSubjectVoteService {
throw e;
}
}
public List<BBSVoteOptionGroup> listVoteOptionGroup( String subjectId ) throws Exception {
if( subjectId == null || subjectId.isEmpty() ){
throw new Exception( "subjectId is null, return null!" );
......@@ -344,4 +345,4 @@ public class BBSSubjectVoteService {
throw e;
}
}
}
\ No newline at end of file
}
......@@ -18,7 +18,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
/**
* 系统配置信息管理实体类
*
*
* @author LIYI
*/
@ContainerEntity(dumpSize = 200, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
......@@ -30,13 +30,19 @@ import com.x.base.core.project.annotation.FieldDescribe;
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class BBSConfigSetting extends SliceJpaObject {
public static final String BBS_CONFIG_USE_NICKNAME = "BBS_USE_NICKNAME";
public static final String BBS_CONFIG_USE_NICKNAME_YES = "YES";
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.BBSConfigSetting.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
......@@ -46,6 +52,7 @@ public class BBSConfigSetting extends SliceJpaObject {
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
@Override
public void onPersist() throws Exception {
//nothing
}
......@@ -115,7 +122,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 获取配置名称
*
*
* @return
*/
public String getConfigName() {
......@@ -124,7 +131,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 设置配置名称
*
*
* @param configName
*/
public void setConfigName(String configName) {
......@@ -133,7 +140,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 获取配置编码
*
*
* @return
*/
public String getConfigCode() {
......@@ -142,7 +149,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 设置配置编码
*
*
* @param configCode
*/
public void setConfigCode(String configCode) {
......@@ -151,7 +158,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 获取配置值
*
*
* @return
*/
public String getConfigValue() {
......@@ -160,7 +167,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 设置配置值
*
*
* @param configValue
*/
public void setConfigValue(String configValue) {
......@@ -169,7 +176,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 获取排序号
*
*
* @return
*/
public Integer getOrderNumber() {
......@@ -178,7 +185,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 设置排序号
*
*
* @param orderNumber
*/
public void setOrderNumber(Integer orderNumber) {
......@@ -187,7 +194,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 获取备注说明信息
*
*
* @return
*/
public String getDescription() {
......@@ -196,7 +203,7 @@ public class BBSConfigSetting extends SliceJpaObject {
/**
* 设置备注说明信息
*
*
* @param description
*/
public void setDescription(String description) {
......@@ -227,4 +234,4 @@ public class BBSConfigSetting extends SliceJpaObject {
this.isMultiple = isMultiple;
}
}
\ No newline at end of file
}
......@@ -21,7 +21,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
/**
* 主题信息表
*
*
* @author LIYI
*/
@ContainerEntity(dumpSize = 200, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
......@@ -36,10 +36,12 @@ public class BBSReplyInfo extends SliceJpaObject {
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.BBSReplyInfo.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
......@@ -49,6 +51,7 @@ public class BBSReplyInfo extends SliceJpaObject {
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
@Override
public void onPersist() throws Exception {
}
/*
......@@ -146,6 +149,12 @@ public class BBSReplyInfo extends SliceJpaObject {
@CheckPersist(allowEmpty = false)
private String creatorName = "";
public static final String nickName_FIELDNAME = "nickName";
@FieldDescribe("创建人昵称")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + nickName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String nickName = "";
public static final String replyAuditStatus_FIELDNAME = "replyAuditStatus";
@FieldDescribe("回复审核状态:无审核|待审核|审核通过")
@Column(length = JpaObject.length_16B, name = ColumnNamePrefix + replyAuditStatus_FIELDNAME)
......@@ -331,4 +340,11 @@ public class BBSReplyInfo extends SliceJpaObject {
this.picId = picId;
}
}
\ No newline at end of file
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
}
......@@ -30,7 +30,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
/**
* 主题信息表
*
*
* @author LIYI
*/
@ContainerEntity(dumpSize = 200, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
......@@ -45,10 +45,12 @@ public class BBSSubjectInfo extends SliceJpaObject {
private static final long serialVersionUID = 3856138316794473794L;
private static final String TABLE = PersistenceProperties.BBSSubjectInfo.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
......@@ -58,6 +60,7 @@ public class BBSSubjectInfo extends SliceJpaObject {
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
@Override
public void onPersist() throws Exception {
}
/*
......@@ -330,6 +333,12 @@ public class BBSSubjectInfo extends SliceJpaObject {
@CheckPersist(allowEmpty = true)
private String creatorName = "";
public static final String nickName_FIELDNAME = "nickName";
@FieldDescribe("创建人昵称")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + nickName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String nickName = "";
public static final String subjectAuditStatus_FIELDNAME = "subjectAuditStatus";
@FieldDescribe("主题审核状态:无审核|待审核|审核通过")
@Column(length = JpaObject.length_16B, name = ColumnNamePrefix + subjectAuditStatus_FIELDNAME)
......@@ -831,4 +840,12 @@ public class BBSSubjectInfo extends SliceJpaObject {
public void setGrade(Integer grade) {
this.grade = grade;
}
}
\ No newline at end of file
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
}
......@@ -18,7 +18,7 @@ import com.x.base.core.project.annotation.FieldDescribe;
/**
* 用户投票记录
*
*
* @author LIYI
*/
@ContainerEntity(dumpSize = 200, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
......@@ -110,9 +110,16 @@ public class BBSVoteRecord extends SliceJpaObject {
public static final String votorName_FIELDNAME = "votorName";
@FieldDescribe("投票人")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + votorName_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + votorName_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String votorName = "";
public static final String votorNickName_FIELDNAME = "votorNickName";
@FieldDescribe("投票人昵称")
@Column(length = JpaObject.length_255B, name = ColumnNamePrefix + votorNickName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String votorNickName = "";
public String getForumId() {
return forumId;
}
......@@ -176,4 +183,12 @@ public class BBSVoteRecord extends SliceJpaObject {
public void setOptionGroupId(final String optionGroupId) {
this.optionGroupId = optionGroupId;
}
}
\ No newline at end of file
public String getVotorNickName() {
return votorNickName;
}
public void setVotorNickName(String votorNickName) {
this.votorNickName = votorNickName;
}
}
package com.x.bbs.entity.enums;
/**
* 论坛角色枚举类
* @author sword
*/
public enum BbsRoleEnum {
FORUM_SUPER_MANAGER("FORUM_SUPER_MANAGER", "论坛管理员", "拥有该论坛管理的最大权限"),
FORUM_VIEW("FORUM_VIEW", "论坛可见", "用户可以BBS系统中访问该论坛"),
FORUM_INFO_MANAGEMENT("FORUM_INFO_MANAGEMENT", "论坛信息管理", "用户拥有对论坛的版块增加,删除,修改权限"),
FORUM_SUBJECT_PUBLISH("FORUM_SUBJECT_PUBLISH", "论坛发布主题", "用户可以在论坛中所有版块发布主题"),
FORUM_REPLY_PUBLISH("FORUM_REPLY_PUBLISH", "论坛发表回复", "用户可以回复论坛中所有主题"),
SECTION_MANAGER("SECTION_MANAGER", "版块主", "拥有版块及版块内容管理的最大权限");
private String value;
private String name;
private String desc;
private BbsRoleEnum(String value, String name, String desc) {
this.value = value;
this.name = name;
this.desc = desc;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value == null ? null : value.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
}
package com.x.organization.assemble.express.jaxrs.person;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapString;
import com.x.organization.assemble.express.Business;
import com.x.organization.core.entity.Person;
import org.apache.commons.lang3.StringUtils;
import java.util.Optional;
class ActionGetNickName extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
CacheKey cacheKey = new CacheKey(this.getClass(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) {
result.setData((Wo) optional.get());
} else {
Wo wo = new Wo();
Person person = emc.find(flag, Person.class);
if(person==null){
person = business.person().pick(flag);
}
if(person==null) {
wo.setValue(flag);
}else{
if(StringUtils.isNoneBlank(person.getNickName())){
wo.setValue(person.getNickName());
}else{
wo.setValue(person.getName());
}
}
CacheManager.put(cacheCategory, cacheKey, wo);
result.setData(wo);
}
return result;
}
}
public static class Wo extends WrapString {
}
}
......@@ -75,6 +75,7 @@ class BaseAction extends StandardJaxrsAction {
t.setDingdingId(person.getDingdingId());
t.setZhengwuDingdingId(person.getZhengwuDingdingId());
t.setWeLinkId(person.getWeLinkId());
t.setNickName(person.getNickName());
return t;
}
......
......@@ -21,6 +21,9 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
/**
* @author sword
*/
@Path("person")
@JaxrsDescribe("个人接口")
public class PersonAction extends StandardJaxrsAction {
......@@ -45,6 +48,24 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "获取个人昵称.", action = ActionGetNickName.class)
@GET
@Path("nick/name/{flag}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void getNickName(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("人员标识") @PathParam("flag") String flag) {
ActionResult<ActionGetNickName.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGetNickName().execute(effectivePerson, flag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "判断个人是否拥有指定角色中的一个或者多个", action = ActionHasRole.class)
@POST
@Path("has/role")
......@@ -656,4 +677,4 @@ public class PersonAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
}
\ No newline at end of file
}
......@@ -59,10 +59,12 @@ public class Person extends SliceJpaObject {
private static final String TABLE = PersistenceProperties.Person.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
......@@ -87,6 +89,7 @@ public class Person extends SliceJpaObject {
/* 以上为 JpaObject 默认字段 */
@Override
public void onPersist() throws Exception {
this.pinyin = StringUtils.lowerCase(PinyinHelper.convertToPinyinString(name, "", PinyinFormat.WITHOUT_TONE));
this.pinyinInitial = StringUtils.lowerCase(PinyinHelper.getShortPinyin(name));
......@@ -176,6 +179,12 @@ public class Person extends SliceJpaObject {
@CheckPersist(allowEmpty = false, simplyString = false)
private String name;
public static final String nickName_FIELDNAME = "nickName";
@FieldDescribe("昵称.")
@Column(length = length_255B, name = ColumnNamePrefix + nickName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String nickName;
public static final String employee_FIELDNAME = "employee";
@Flag
@FieldDescribe("工号,不可重复.")
......@@ -865,4 +874,12 @@ public class Person extends SliceJpaObject {
public void setLanguage(String language) {
this.language = language;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
}
package com.x.organization.core.express.person;
import com.x.base.core.project.AbstractContext;
import com.x.base.core.project.Applications;
import com.x.base.core.project.jaxrs.WrapString;
import org.apache.commons.lang3.StringUtils;
class ActionGetNickName extends BaseAction {
public static String execute(AbstractContext context, String flag) throws Exception {
if(StringUtils.isBlank(flag)){
return flag;
}
Wo wo = context.applications().getQuery(applicationClass, Applications.joinQueryUri("person", "nick", "name", flag)).getData(Wo.class);
return wo.getValue();
}
public static class Wo extends WrapString {
}
}
......@@ -48,6 +48,11 @@ public class PersonFactory {
}
}
/** 获取个人的昵称 */
public String getNickName(String value) throws Exception {
return ActionGetNickName.execute(context, value);
}
/** 批量获取个人的distinguishedName */
public List<String> list(Collection<String> values) throws Exception {
return ActionList.execute(context, values);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册