Commit 44cd6848 authored by 赵啸非's avatar 赵啸非

修改文档与添加登录返回token和过期时间

parent 0e9c8312
...@@ -30,7 +30,7 @@ arrays|数组类型|[{"name":"zhang3"},{"name":"zhang2"}] ...@@ -30,7 +30,7 @@ arrays|数组类型|[{"name":"zhang3"},{"name":"zhang2"}]
参数名称|类型|备注|必填|其它 参数名称|类型|备注|必填|其它
---|---|---|---|--- ---|---|---|---|---
userName|String|用户名称|是|- loginName|String|用户名称|是|-
password|String|用户密码|是|- password|String|用户密码|是|-
securityCode|String|校验码|是|- securityCode|String|校验码|是|-
...@@ -38,7 +38,7 @@ securityCode|String|校验码|是|- ...@@ -38,7 +38,7 @@ securityCode|String|校验码|是|-
``` ```
{ {
"userName":"zhang3", "loginName":"zhang3",
"password":"123456", "password":"123456",
"securityCode":"5455" "securityCode":"5455"
} }
...@@ -50,6 +50,11 @@ securityCode|String|校验码|是|- ...@@ -50,6 +50,11 @@ securityCode|String|校验码|是|-
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|- code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|- msg|String|消息|-
data|object|数据对象|-
 currUserName|String|登录用户名|-
 id|Long|登录用户ID|-
 token|String|token|-
 expiresTime|Long|过期时间|-
**响应消息样例:** **响应消息样例:**
......
This diff is collapsed.
package com.mortals.xhx.base.framework.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author: zxfei
* @date: 2022/2/15 13:16
* @description:
**/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowCredentials(true)
.allowedOrigins("*")
.allowedMethods(new String[] { "GET", "POST","PUT","DELETE"})
.allowedHeaders("*")
.exposedHeaders("*");
}
}
...@@ -92,24 +92,27 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor ...@@ -92,24 +92,27 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor
recordSysLog(request, userEntity, "用户登录系统成功!"); recordSysLog(request, userEntity, "用户登录系统成功!");
// 返回拥有的菜单数据 // 返回拥有的菜单数据
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId()); //Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
List<MenuEntity> outlookBarList = menuService.findTreeMenu(userEntity, urls); // List<MenuEntity> outlookBarList = menuService.findTreeMenu(userEntity, urls);
String currUserName = userEntity.getRealName(); String currUserName = userEntity.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) { if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员"; currUserName = "管理员";
} }
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("currUserName", currUserName); data.put("currUserName", currUserName);
data.put("barList", outlookBarList); //data.put("barList", outlookBarList);
data.put("id", userEntity.getId()); data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType()); data.put("userType", userEntity.getUserType());
this.generateBlackCookie(request, response, loginName, urls); //设置token 和过期时间
CookieInfo loginCookie = CookieService.getLoginCookie(request);
data.put("token", loginCookie.getToken());
data.put("expiresTime",loginCookie.getExpiresTime().getTime());
// this.generateBlackCookie(request, response, loginName, urls);
ret.put(KEY_RESULT_DATA, data); ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!"); ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
ret.put("resources", urls); // ret.put("resources", urls);
return ret.toJSONString(); return ret.toJSONString();
} catch (Exception e) { } catch (Exception e) {
log.error("login error ", e); log.error("login error ", e);
......
...@@ -11,4 +11,5 @@ import lombok.Data; ...@@ -11,4 +11,5 @@ import lombok.Data;
@Data @Data
public class UserEntityExt extends BaseEntityLong { public class UserEntityExt extends BaseEntityLong {
private String siteName; private String siteName;
private String token;
} }
\ No newline at end of file
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>i5ting_ztree_toc:</title> <title>i5ting_ztree_toc:api-two</title>
<link href="toc/style/GitHub.css" media="all" rel="stylesheet" type="text/css"/> <link href="toc/style/github.css" media="all" rel="stylesheet" type="text/css"/>
<link href="toc/style/GitHub2.css" media="all" rel="stylesheet" type="text/css"/> <link href="toc/style/github2.css" media="all" rel="stylesheet" type="text/css"/>
<link href="toc/css/zTreeStyle/zTreeStyle.css" media="all" rel="stylesheet" type="text/css"/> <link href="toc/css/zTreeStyle/zTreeStyle.css" media="all" rel="stylesheet" type="text/css"/>
<style> <style>
pre { pre {
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>userName</td> <td>loginName</td>
<td>String</td> <td>String</td>
<td>用户名称</td> <td>用户名称</td>
<td></td> <td></td>
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
<p><strong>请求样例:</strong></p> <p><strong>请求样例:</strong></p>
<pre class="prettyprint linenums:0"><code> <pre class="prettyprint linenums:0"><code>
{ {
&quot;userName&quot;:&quot;zhang3&quot;, &quot;loginName&quot;:&quot;zhang3&quot;,
&quot;password&quot;:&quot;123456&quot;, &quot;password&quot;:&quot;123456&quot;,
&quot;securityCode&quot;:&quot;5455&quot; &quot;securityCode&quot;:&quot;5455&quot;
} }
...@@ -203,6 +203,36 @@ ...@@ -203,6 +203,36 @@
<td>消息</td> <td>消息</td>
<td>-</td> <td>-</td>
</tr> </tr>
<tr>
<td>data</td>
<td>object</td>
<td>数据对象</td>
<td>-</td>
</tr>
<tr>
<td>&emsp;currUserName</td>
<td>String</td>
<td>登录用户名</td>
<td>-</td>
</tr>
<tr>
<td>&emsp;id</td>
<td>Long</td>
<td>登录用户ID</td>
<td>-</td>
</tr>
<tr>
<td>&emsp;token</td>
<td>String</td>
<td>token</td>
<td>-</td>
</tr>
<tr>
<td>&emsp;expiresTime</td>
<td>Long</td>
<td>过期时间</td>
<td>-</td>
</tr>
</tbody> </tbody>
</table> </table>
<p><strong>响应消息样例:</strong></p> <p><strong>响应消息样例:</strong></p>
......
...@@ -4,7 +4,7 @@ POST {{baseUrl}}/login/login ...@@ -4,7 +4,7 @@ POST {{baseUrl}}/login/login
Content-Type: application/json Content-Type: application/json
{ {
"userName":"admin", "loginName":"admin",
"password":"admin", "password":"admin",
"securityCode":"8888" "securityCode":"8888"
} }
......
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