Liferay chat-portlet 让所有用户均显示在线

参考文章:http://www.voidcn.com/article/p-sfigrudb-wg.html

这篇文章写的很好,但是还是有一些缺漏。

跟他的思路一样,但是做法不同。

先说一下思路:就是把所有的用户都查出来,但是不对用户做任何的限制,也就是取消onlin=true的限制,这样就可以显示都在线了。

第一步:找到default.xml,

<sql id="com.liferay.chat.service.persistence.StatusFinder.findByModifiedDate">
		<![CDATA[
			SELECT
				GOSHARE_Chat_Status.awake AS awake, User_.firstName AS firstName, Group_.groupId as groupId, User_.lastName AS lastName, User_.middleName AS middleName, User_.portraitId AS portraitId, User_.screenName AS screenName, User_.userId AS userId, User_.uuid_ AS userUuid,
				
			FROM
				GOSHARE_Chat_Status
			INNER JOIN
				User_ ON
					(User_.userId = GOSHARE_Chat_Status.userId)
			INNER JOIN
				Group_ ON
					(
						(Group_.classPK = User_.userId) AND
						(Group_.companyId = User_.companyId)
					)
			WHERE
				(Group_.classNameId = ?) AND
				(User_.companyId = ?) AND
				(User_.userId != ?) AND
				(GOSHARE_Chat_Status.modifiedDate > ?) AND
				(GOSHARE_Chat_Status.online_ = [$TRUE$])
			ORDER BY
				GOSHARE_Chat_Status.awake ASC,
				User_.firstName ASC,
				User_.middleName ASC,
				User_.lastName ASC
		]]>
	</sql>

把这段增加GOSHARE_Chat_Status.online_ AS online和删除AND
                (GOSHARE_Chat_Status.modifiedDate > ?) AND
                (GOSHARE_Chat_Status.online_ = [$TRUE$])

改变之后的代码:

	<sql id="com.liferay.chat.service.persistence.StatusFinder.findByModifiedDate">
		<![CDATA[
			SELECT
				GOSHARE_Chat_Status.awake AS awake, User_.firstName AS firstName, Group_.groupId as groupId, User_.lastName AS lastName, User_.middleName AS middleName, User_.portraitId AS portraitId, User_.screenName AS screenName, User_.userId AS userId, User_.uuid_ AS userUuid,
				GOSHARE_Chat_Status.online_ AS online 
			FROM
				GOSHARE_Chat_Status
			INNER JOIN
				User_ ON
					(User_.userId = GOSHARE_Chat_Status.userId)
			INNER JOIN
				Group_ ON
					(
						(Group_.classPK = User_.userId) AND
						(Group_.companyId = User_.companyId)
					)
			WHERE
				(Group_.classNameId = ?) AND
				(User_.companyId = ?) AND
				(User_.userId != ?) 
			ORDER BY
				GOSHARE_Chat_Status.awake ASC,
				User_.firstName ASC,
				User_.middleName ASC,
				User_.lastName ASC
		]]>
	</sql>

第二步:找到这个类StatusFinderImpl.java,在findByModifiedDate这个方法里注释掉qPos.add(modifiedDate);

	qPos.add(ClassNameLocalServiceUtil.getClassNameId(User.class));
			qPos.add(companyId);
			qPos.add(userId);
			//qPos.add(modifiedDate);

第三步:还是在那个类里,找到addScalars方法

增加sqlQuery.addScalar("online", Type.BOOLEAN);

sqlQuery.addScalar("awake", Type.BOOLEAN);
		sqlQuery.addScalar("firstName", Type.STRING);
		sqlQuery.addScalar("groupId", Type.LONG);
		sqlQuery.addScalar("lastName", Type.STRING);
		//sqlQuery.addScalar("male", Type.BOOLEAN);
		sqlQuery.addScalar("middleName", Type.STRING);
		sqlQuery.addScalar("portraitId", Type.LONG);
		sqlQuery.addScalar("screenName", Type.STRING);
		sqlQuery.addScalar("userId", Type.LONG);
		sqlQuery.addScalar("userUuid", Type.STRING);
		sqlQuery.addScalar("online", Type.BOOLEAN);

重启tomcat,ok

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值