新增区域在线人用户接口
This commit is contained in:
parent
982a9f1ebc
commit
010bbe596a
@ -6,12 +6,15 @@ import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: UserExpandController
|
||||
* @Description: 用户拓展
|
||||
@ -59,4 +62,14 @@ public class UserExpandAppController extends DefaultBaseController {
|
||||
return userExpandService.getWhole(userId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "在线用户列表", notes = "通过区域获取在线用户列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list-online-release/{areaCode}")
|
||||
public List<UserDTO> listOnlineReleaseByAreaCode(@PathVariable("areaCode") String areaCode) {
|
||||
return userExpandService.listUserOnlineReleaseByAreaCode(areaCode);
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
|
||||
import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO;
|
||||
import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO;
|
||||
import ink.wgink.interfaces.user.IUserExpandBaseService;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -66,4 +67,12 @@ public interface IUserExpandService extends IUserExpandBaseService<UserExpandDTO
|
||||
* @return
|
||||
*/
|
||||
UserExpandDTO getWhole(String userId);
|
||||
|
||||
/**
|
||||
* 在线用户列表
|
||||
*
|
||||
* @param areaCode
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> listUserOnlineReleaseByAreaCode(String areaCode);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.com.tenlion.usercenter.service.userexpand.impl;
|
||||
|
||||
import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts;
|
||||
import cn.com.tenlion.usercenter.dao.userexpand.IUserExpandDao;
|
||||
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
|
||||
import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO;
|
||||
@ -12,6 +13,7 @@ import ink.wgink.interfaces.department.IDepartmentUserBaseService;
|
||||
import ink.wgink.interfaces.role.IRoleUserBaseService;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
|
||||
import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager;
|
||||
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentDTO;
|
||||
@ -19,8 +21,10 @@ import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||
import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.session.WebSocketSession;
|
||||
import ink.wgink.util.ArrayListUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import ink.wgink.util.string.WStringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -217,6 +221,25 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
|
||||
return userExpandDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listUserOnlineReleaseByAreaCode(String areaCode) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("areaCodeLike", WStringUtil.cutContinuityRepeatCharDesc(areaCode, '0', 3));
|
||||
List<UserExpandDTO> userExpandDTOs = list(params);
|
||||
if (userExpandDTOs.isEmpty()) {
|
||||
LOG.debug("area code: {}, user count: 0");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> userIds = ArrayListUtil.listBeanStringIdValue(userExpandDTOs, "userId", UserExpandDTO.class);
|
||||
List<WebSocketSession> webSocketSessions = WebSocketChannelManager.getInstance().listOnlineUser(userIds, ISmartCityUserCenterConsts.APP_CLIENT_NAME);
|
||||
List<String> onlineUserIds = new ArrayList<>();
|
||||
webSocketSessions.forEach(webSocketSession -> {
|
||||
onlineUserIds.add(webSocketSession.getUserId());
|
||||
});
|
||||
LOG.debug("area code: {}, user count: {}, online user count", areaCode, userExpandDTOs.size(), webSocketSessions.size());
|
||||
return userBaseService.listByUserIds(onlineUserIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户
|
||||
*
|
||||
|
@ -27,7 +27,7 @@ spring:
|
||||
max-request-size: 1GB
|
||||
datasource:
|
||||
druid:
|
||||
url: jdbc:mysql://127.0.0.1:3306/db_smart_city_usercenter?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://192.168.0.103:3306/db_smart_city_usercenter?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true
|
||||
db-type: mysql
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
@ -57,7 +57,7 @@ spring:
|
||||
uri: mongodb://smartcity:smartcity@127.0.0.1:27017/smartcity
|
||||
redis:
|
||||
database: 6
|
||||
host: 127.0.0.1
|
||||
host: 192.168.0.103
|
||||
port: 6379
|
||||
password: 666
|
||||
timeout: 3000ms
|
||||
@ -68,7 +68,7 @@ spring:
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092
|
||||
bootstrap-servers: 192.168.0.103:9092
|
||||
producer:
|
||||
# 写入失败时,重试次数。当leader节点失效,一个repli节点会替代成为leader节点,此时可能出现写入失败,
|
||||
# 当retris为0时,produce不会重复。retirs重发,此时repli节点完全成为leader节点,不会产生消息丢失。
|
||||
@ -111,7 +111,7 @@ file:
|
||||
use-min-io: true
|
||||
# 与use-min-io配套使用
|
||||
min-io:
|
||||
endpoint: http://127.0.0.1:9900
|
||||
endpoint: http://192.168.0.103:9900
|
||||
access-key: smartcity
|
||||
secret-key: smartcity
|
||||
|
||||
|
@ -130,8 +130,8 @@ map:
|
||||
zoom: 8
|
||||
base-map-url: https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China
|
||||
baidu-map:
|
||||
center-lat: 40.98896497581636
|
||||
center-lng: 113.11412662267688
|
||||
center-lat: 41.000587
|
||||
center-lng: 113.138723
|
||||
zoom: 11
|
||||
boundary: 乌兰察布市
|
||||
|
||||
|
@ -247,6 +247,10 @@
|
||||
<if test="areaCode != null and areaCode != ''">
|
||||
t1.area_code = #{areaCode}
|
||||
</if>
|
||||
<if test="areaCodeLike != null and areaCodeLike != ''">
|
||||
AND
|
||||
t1.area_code LIKE CONCAT(#{areaCodeLike}, '%')
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
t1.user_id IN
|
||||
|
Loading…
Reference in New Issue
Block a user