1
This commit is contained in:
@@ -6,8 +6,10 @@ import java.util.List;
|
||||
public interface ClientDeviceMapper {
|
||||
ClientDevice selectByDeviceId(String deviceId);
|
||||
List<ClientDevice> selectByUsername(String username);
|
||||
List<ClientDevice> selectOnlineDevices();
|
||||
int insert(ClientDevice device);
|
||||
int updateByDeviceId(ClientDevice device);
|
||||
int updateExpiredDevicesOffline();
|
||||
int deleteByDeviceId(String deviceId);
|
||||
int countByUsername(String username);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,15 @@
|
||||
<select id="countByUsername" resultType="int">
|
||||
select count(1) from client_device where username = #{username}
|
||||
</select>
|
||||
|
||||
<select id="selectOnlineDevices" resultMap="ClientDeviceMap">
|
||||
select * from client_device where status = 'online' order by last_active_at desc
|
||||
</select>
|
||||
|
||||
<update id="updateExpiredDevicesOffline">
|
||||
update client_device set status = 'offline'
|
||||
where status = 'online' and (last_active_at is null or last_active_at < date_sub(now(), interval 2 minute))
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user