Commit eb5108f7 by 袁伟铭

完善api接口

parent b26c0be0
......@@ -38,4 +38,7 @@ public interface SysFeign {
@GetMapping(value = "/single/getUserInfo/{appId}")
ResultVo getSingleUserInfo(@PathVariable String appId);
@GetMapping(value = "/single/logout")
ResultVo singleLogout();
}
......@@ -221,8 +221,17 @@ public interface IApiLogic extends IApiCommon {
*/
ApiResp getSingleUserInfo(ApiForm form);
/**
* 单点登出
*
* @param form
* @return
*/
ApiResp singleLogout(ApiForm form);
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓开放接口↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* 婚姻搜索接口
*
......
......@@ -156,6 +156,11 @@ public class ApiV100Logic extends BaseApiLogic implements IApiLogic {
}
@Override
public ApiResp singleLogout(ApiForm form) {
return ApiUtils.toApiResp(form, sysFeign.singleLogout());
}
@Override
public ApiResp marriageSearch(ApiForm form) {
Map<String, Object> paramsMap = form.getParamsMap();
ApiTokenVo apiTokenVo = form.getApiTokenVo();
......
......@@ -240,7 +240,7 @@ public class ApiUtils {
String method = "getSingleUserInfo";
String timestamp = System.currentTimeMillis() + "";
String version = "1.0.0";
String bizContent = "{}";
String bizContent = "{}";//JSON字符串
bizContent = StrUtil.isBlank(bizContent) ? "" : URLUtil.encode(Base64.encode(bizContent), StandardCharsets.UTF_8);
Map<String, String> params = new HashMap<>();
params.put("appId", appId);
......
......@@ -38,6 +38,12 @@ public class SingleController {
singleService.login(vo, request, response);
}
@ApiOperation("单点登出")
@AnonymousGetMapping(value = "/logout")
public void logout(HttpServletRequest request) {
singleService.logout(request);
}
@ApiOperation("获取用户信息")
@GetMapping(value = "/getUserInfo/{appId}")
public ResultVo getUserInfo(@PathVariable String appId) {
......
......@@ -63,6 +63,7 @@ public class SingleService {
private final OnlineUserService onlineUserService;
private final RedisUtils redisUtils;
private final AuthenticationManagerBuilder authenticationManagerBuilder;
private final TokenProvider tokenProvider;
public void register(User resources) {
String passwd = null;
......@@ -106,7 +107,7 @@ public class SingleService {
OnlineUserDto adminContext = ContextUtils.getAdminContext();
List<BindUserInfo> bindUserInfos = blindUserInfoDao.selectList(Wrappers.lambdaQuery(BindUserInfo.builder().userId(adminContext.getUserId())
.sysId(vo.getSystemId()).build()));
AssertUtils.isTrue(bindUserInfos.size()==0,"用户已绑定该系统");
AssertUtils.isTrue(bindUserInfos.size() == 0, "用户已绑定该系统");
SysInfo sysInfo = sysInfoDao.selectById(vo.getSystemId());
AssertUtils.notNull(sysInfo, "系统不存在");
......@@ -183,4 +184,10 @@ public class SingleService {
data.put("username", bindUserInfo.getSystemUserName());
return data;
}
public void logout(HttpServletRequest request) {
String token = tokenProvider.getToken(request);
onlineUserService.logout(token);
redisUtils.deleteStr(token);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment