提交 8ee2eae9 编写于 作者: liyi_hz2008's avatar liyi_hz2008

修复在某些特殊情况下,日程管理会展示两条系统自建日历的问题

上级 cda067a6
......@@ -104,7 +104,10 @@ public class CalendarFactory extends AbstractFactory {
p = CriteriaBuilderTools.predicate_and( cb, p, cb.equal(root.get(Calendar_.source), source));
}
if( StringUtils.isNotEmpty( createor )) {
p = CriteriaBuilderTools.predicate_and( cb, p, cb.equal(root.get(Calendar_.createor), createor));
p = CriteriaBuilderTools.predicate_and( cb, p, cb.or(
cb.equal(root.get(Calendar_.createor), createor),
cb.equal(root.get(Calendar_.target), createor)
));
}
Predicate permission = null;
......@@ -140,7 +143,10 @@ public class CalendarFactory extends AbstractFactory {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Calendar> root = cq.from(Calendar.class);
Predicate permission = cb.equal( root.get(Calendar_.createor), personName );
Predicate permission = cb.or(
cb.equal(root.get(Calendar_.createor), personName),
cb.equal(root.get(Calendar_.target), personName)
);
cq.select(root.get(Calendar_.id));
return em.createQuery(cq.where(permission)).getResultList();
}
......
......@@ -11,6 +11,7 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.calendar.assemble.control.ThisApplication;
import com.x.calendar.core.entity.Calendar;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
......@@ -70,6 +71,7 @@ public class ActionListWhatICanView extends BaseAction {
if( ListTools.isNotEmpty( calendarList )) {
result.setCount( Long.parseLong( calendarList.size() + "" ));
WoCalendar woCalendar = null;
Boolean existsSystemDefaultCalendar = false;
for( Calendar calendar : calendarList ) {
woCalendar = WoCalendar.copier.copy( calendar ) ;
woCalendar.setManageable( ThisApplication.isCalendarManager( effectivePerson, calendar ) );
......@@ -79,8 +81,20 @@ public class ActionListWhatICanView extends BaseAction {
if( "UNIT".equalsIgnoreCase( calendar.getType() ) ) {
wo.addUnitCalendar( woCalendar );
}else {
if( calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() )) {
wo.addMyCalendar( woCalendar );
if( calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() )
|| StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
if( StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
if( !existsSystemDefaultCalendar ){
wo.addMyCalendar( woCalendar );
existsSystemDefaultCalendar = true;
}else{
//多了一个系统日历,删除当前这个日历
calendarServiceAdv.destory( calendar.getId() );
}
}else{
wo.addMyCalendar( woCalendar );
}
}else {
wo.addFollowCalendar( woCalendar );
}
......
......@@ -174,7 +174,7 @@ public class CalendarService {
//创建一个自己的默认日历
Calendar calendar = new Calendar();
calendar.setSource( "PERSON" );
calendar.setCreateor( personName );
calendar.setCreateor( "SYSTEM" );
calendar.setColor( "#1462be" );
calendar.setDescription( "我的默认日历" );
calendar.setId( Calendar.createId() );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册