参考文章: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