Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elleai
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
E
ellehuis-group
backend
elleai
Commits
283c6b10
Commit
283c6b10
authored
Oct 23, 2024
by
陈立彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后管授权接口
parent
bc999965
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
397 additions
and
0 deletions
+397
-0
PageRequest.java
...cn/breeze/elleai/application/dto/request/PageRequest.java
+26
-0
UserLoginRequest.java
...eeze/elleai/application/dto/request/UserLoginRequest.java
+26
-0
PagePermissionResult.java
...elleai/application/dto/response/PagePermissionResult.java
+23
-0
UserLoginResult.java
...eeze/elleai/application/dto/response/UserLoginResult.java
+36
-0
AuthController.java
...ava/cn/breeze/elleai/controller/admin/AuthController.java
+265
-0
JwtUtil.java
src/main/java/cn/breeze/elleai/util/JwtUtil.java
+19
-0
UserPrincipal.java
src/main/java/cn/breeze/elleai/util/UserPrincipal.java
+2
-0
No files found.
src/main/java/cn/breeze/elleai/application/dto/request/PageRequest.java
0 → 100644
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
application
.
dto
.
request
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
/**
* 描述:
*
* @Author: fangjh
* @CreateTime: 2023/04/25 14:44:53
*/
@Data
@Schema
(
description
=
"页面请求"
)
public
class
PageRequest
{
@Schema
(
description
=
"entId"
)
private
Integer
entId
;
@Schema
(
description
=
"用户id"
)
private
Long
userId
;
private
Long
id
;
@Schema
(
description
=
"状态"
)
private
Integer
status
;
}
src/main/java/cn/breeze/elleai/application/dto/request/UserLoginRequest.java
0 → 100644
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
application
.
dto
.
request
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author Administrator
*/
@Schema
(
description
=
"登录请求"
)
@Data
public
class
UserLoginRequest
implements
Serializable
{
/**
* 用户名
*/
@Schema
(
description
=
"用户名"
)
private
String
userName
;
@Schema
(
description
=
"登录密码"
)
private
String
password
;
@Schema
(
description
=
"验证码"
)
private
String
verifyCode
;
}
src/main/java/cn/breeze/elleai/application/dto/response/PagePermissionResult.java
0 → 100644
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
application
.
dto
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
/**
* 描述:
*
* @Author: fangjh
* @CreateTime: 2023/04/26 14:04:18
*/
@Data
public
class
PagePermissionResult
implements
Serializable
{
private
Integer
type
;
private
List
<
String
>
channels
;
private
Map
<
String
,
List
<
String
>>
permission
;
}
src/main/java/cn/breeze/elleai/application/dto/response/UserLoginResult.java
0 → 100644
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
application
.
dto
.
response
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @author Administrator
*/
@Data
@Schema
(
description
=
"登录结果"
)
public
class
UserLoginResult
implements
Serializable
{
@Schema
(
description
=
"授权token"
)
private
String
token
;
@Schema
(
description
=
"用户id"
)
private
String
userId
;
@Schema
(
description
=
"用户名"
)
private
String
userName
;
@Schema
(
description
=
"昵称"
)
private
String
nickName
;
@Schema
(
description
=
"头像"
)
private
String
avatar
;
@Schema
(
description
=
"是否超级用户"
)
private
Boolean
isSuperUser
;
@Schema
(
description
=
"最后更新时间"
)
private
Date
updateAt
;
}
src/main/java/cn/breeze/elleai/controller/admin/AuthController.java
0 → 100644
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
controller
.
admin
;
import
cn.breeze.elleai.application.dto.ApiResponse
;
import
cn.breeze.elleai.application.dto.request.PageRequest
;
import
cn.breeze.elleai.application.dto.request.UserLoginRequest
;
import
cn.breeze.elleai.application.dto.response.PagePermissionResult
;
import
cn.breeze.elleai.application.dto.response.UserLoginResult
;
import
cn.breeze.elleai.util.JwtUtil
;
import
cn.breeze.elleai.util.UserPrincipal
;
import
com.alibaba.fastjson2.JSONObject
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
/**
*
* 系统登录
* @author Administrator
*/
@RestController
@Tag
(
name
=
"登录认证"
)
@Slf4j
@RequestMapping
(
value
=
"/admin"
)
@RequiredArgsConstructor
public
class
AuthController
{
@Operation
(
summary
=
"用户登录"
)
@PostMapping
(
value
=
"/oauth/login"
)
public
ApiResponse
<
UserLoginResult
>
login
(
@RequestBody
UserLoginRequest
request
)
{
UserLoginResult
result
=
new
UserLoginResult
();
String
token
=
JwtUtil
.
generateToken
(
request
.
getUserName
(),
request
.
getPassword
());
result
.
setToken
(
token
);
result
.
setUserName
(
request
.
getUserName
());
return
ApiResponse
.
ok
(
result
);
}
@Operation
(
summary
=
"用户登出"
)
@PostMapping
(
value
=
"/oauth/logout"
)
public
ApiResponse
<
String
>
logout
(
UserPrincipal
userPrincipal
)
{
return
ApiResponse
.
ok
(
"success"
);
}
@Operation
(
summary
=
"登录用户信息"
)
@GetMapping
(
value
=
"/user/login_user_info"
)
public
ApiResponse
<
UserLoginResult
>
loginUserInfo
(
UserPrincipal
userPrincipal
)
{
UserLoginResult
result
=
new
UserLoginResult
();
result
.
setToken
(
userPrincipal
.
getToken
());
result
.
setUserName
(
userPrincipal
.
getUserName
());
result
.
setNickName
(
userPrincipal
.
getUserName
());
result
.
setUserId
(
userPrincipal
.
getUserId
());
return
ApiResponse
.
ok
(
result
);
}
@Operation
(
summary
=
"获取用户-页面"
)
@PostMapping
(
value
=
"/page/get_user_page"
)
public
ApiResponse
<
PagePermissionResult
>
getUserPage
(
UserPrincipal
principal
,
@RequestBody
PageRequest
request
)
{
String
json
=
"{\n"
+
" \"type\": 709394,\n"
+
" \"channels\": [\n"
+
" \"/test\",\n"
+
" \"/user\",\n"
+
" \"/admin/permission\",\n"
+
" \"/admin/roles\",\n"
+
" \"/admin/roles/modify/:id\",\n"
+
" \"/admin/pages\",\n"
+
" \"/collect/edit/:type/:id\",\n"
+
" \"/collect\",\n"
+
" \"/collect/report\",\n"
+
" \"/collect/detail/:id\",\n"
+
" \"/login\",\n"
+
" \"/sys/department\",\n"
+
" \"/sys/position\",\n"
+
" \"/profile/list\",\n"
+
" \"/profile/role\",\n"
+
" \"/market\",\n"
+
" \"/market/report/:id\",\n"
+
" \"/market/detail/:id/:status\",\n"
+
" \"/market/invite/:id\",\n"
+
" \"/profile/list/detail/:id/:status\",\n"
+
" \"/profile/labelset\",\n"
+
" \"/page/get_user_page\",\n"
+
" \"/logout\",\n"
+
" \"/user/list\",\n"
+
" \"/profile/schedule\",\n"
+
" \"/profile/examine\",\n"
+
" \"/profile/examine/detail/:id/:status/:xrefId\",\n"
+
" \"/report/imaging\",\n"
+
" \"/sys/permission\",\n"
+
" \"/profile/transfer\",\n"
+
" \"/client/verbal-trick\",\n"
+
" \"/client/tag-list\",\n"
+
" \"/client/jargon-type\",\n"
+
" \"/client/user-portrait\",\n"
+
" \"/client\",\n"
+
" \"/doctor\",\n"
+
" \"/test\",\n"
+
" \"/user\",\n"
+
" \"/admin/permission\",\n"
+
" \"/admin/roles\",\n"
+
" \"/admin/roles/modify/:id\",\n"
+
" \"/admin/pages\",\n"
+
" \"/login\",\n"
+
" \"/sys/department\",\n"
+
" \"/sys/position\",\n"
+
" \"/page/get_user_page\",\n"
+
" \"/logout\",\n"
+
" \"/report/imaging/detail\",\n"
+
" \"/report/invite\",\n"
+
" \"/report/invite/detail\",\n"
+
" \"/scene_category\"\n"
+
" ],\n"
+
" \"permission\": {\n"
+
" \"/user/list\": [\n"
+
" \"add\",\n"
+
" \"edit\",\n"
+
" \"add_tag\"\n"
+
" ],\n"
+
" \"/sys/permission\": [\n"
+
" \"add\",\n"
+
" \"delete\",\n"
+
" \"switch\",\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/client/verbal-trick\": [\n"
+
" \"jargon-add\",\n"
+
" \"jargon-edit\",\n"
+
" \"jargon-delete\",\n"
+
" \"keyword-add\",\n"
+
" \"keyword-edit\",\n"
+
" \"keyword-delete\",\n"
+
" \"keyword-switch\"\n"
+
" ],\n"
+
" \"/profile/examine\": [\n"
+
" \"pass\",\n"
+
" \"reject\"\n"
+
" ],\n"
+
" \"/test\": [\n"
+
" \"test\",\n"
+
" \"/\",\n"
+
" \"children\"\n"
+
" ],\n"
+
" \"/collect/detail/:id\": [\n"
+
" \"export\"\n"
+
" ],\n"
+
" \"/sys/position\": [\n"
+
" \"add\",\n"
+
" \"switch\",\n"
+
" \"delete\",\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/profile/role\": [\n"
+
" \"add\"\n"
+
" ],\n"
+
" \"/admin/pages\": [\n"
+
" \"add\",\n"
+
" \"switch\",\n"
+
" \"delete\",\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/market/report/:id\": [\n"
+
" \"export\"\n"
+
" ],\n"
+
" \"/client/user-portrait\": [\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/admin/roles\": [\n"
+
" \"add\",\n"
+
" \"switch\",\n"
+
" \"delete\",\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/profile/list/detail/:id/:status\": [\n"
+
" \"user-modify\",\n"
+
" \"require-modify\"\n"
+
" ],\n"
+
" \"/profile/list\": [\n"
+
" \"export\",\n"
+
" \"upload\",\n"
+
" \"modify-contact\",\n"
+
" \"batch-modify\",\n"
+
" \"user-modify\",\n"
+
" \"require-modify\",\n"
+
" \"create\"\n"
+
" ],\n"
+
" \"/profile/labelset\": [\n"
+
" \"modify\",\n"
+
" \"delete\",\n"
+
" \"add\",\n"
+
" \"edit\"\n"
+
" ],\n"
+
" \"/admin/permission\": [\n"
+
" \"ban\",\n"
+
" \"unban\",\n"
+
" \"delete\",\n"
+
" \"edit\",\n"
+
" \"disposition\",\n"
+
" \"add\",\n"
+
" \"editpwd\"\n"
+
" ],\n"
+
" \"/profile/schedule\": [\n"
+
" \"add\",\n"
+
" \"edit\",\n"
+
" \"delete\"\n"
+
" ],\n"
+
" \"/sys/department\": [\n"
+
" \"add\",\n"
+
" \"switch\",\n"
+
" \"delete\",\n"
+
" \"edit\",\n"
+
" \"person-list\",\n"
+
" \"person-add\",\n"
+
" \"person-delete\",\n"
+
" \"person-edit\",\n"
+
" \"batch-edit\",\n"
+
" \"batch-delete\"\n"
+
" ],\n"
+
" \"/collect\": [\n"
+
" \"add\",\n"
+
" \"edit\",\n"
+
" \"delete\",\n"
+
" \"switch\",\n"
+
" \"detail\"\n"
+
" ],\n"
+
" \"/admin/roles/modify/:id\": [\n"
+
" \"addPage\"\n"
+
" ],\n"
+
" \"/market\": [\n"
+
" \"add\",\n"
+
" \"edit\",\n"
+
" \"delete\",\n"
+
" \"switch\",\n"
+
" \"detail\",\n"
+
" \"copy\"\n"
+
" ],\n"
+
" \"/profile/examine/detail/:id/:status/:xrefId\": [\n"
+
" \"pass\",\n"
+
" \"reject\"\n"
+
" ],\n"
+
" \"/client/jargon-type\": [\n"
+
" \"add\",\n"
+
" \"edit\",\n"
+
" \"delete\"\n"
+
" ],\n"
+
" \"/market/invite/:id\": [\n"
+
" \"export\"\n"
+
" ],\n"
+
" \"/client/tag-list\": [\n"
+
" \"tag-add\",\n"
+
" \"tag-edit\",\n"
+
" \"tag-delete\",\n"
+
" \"tag-select\",\n"
+
" \"tag-contact\",\n"
+
" \"keyword-add\",\n"
+
" \"keyword-edit\",\n"
+
" \"keyword-delete\",\n"
+
" \"keyword-switch\"\n"
+
" ]\n"
+
" }"
;
return
ApiResponse
.
ok
(
JSONObject
.
parseObject
(
json
,
PagePermissionResult
.
class
));
}
}
src/main/java/cn/breeze/elleai/util/JwtUtil.java
View file @
283c6b10
package
cn
.
breeze
.
elleai
.
util
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.auth0.jwt.JWT
;
...
...
@@ -46,6 +47,7 @@ public class JwtUtil {
principal
.
setShopId
(
shopId
);
principal
.
setShopName
(
shopName
);
principal
.
setJobTitle
(
jobTitle
);
principal
.
setToken
(
token
);
return
principal
;
}
...
...
@@ -77,4 +79,21 @@ public class JwtUtil {
}
}));
}
public
static
String
generateToken
(
String
userName
,
String
password
)
{
String
token
=
null
;
Long
expireTime
=
1000
*
24
*
60
*
60
*
1000L
;
Date
expiresAt
=
new
Date
(
System
.
currentTimeMillis
()+
expireTime
);
token
=
JWT
.
create
()
.
withIssuer
(
"oss"
)
.
withClaim
(
"userId"
,
UUID
.
randomUUID
().
toString
(
true
))
.
withClaim
(
"userName"
,
userName
)
.
withClaim
(
"position"
,
""
)
.
withClaim
(
"jobTitle"
,
""
)
.
withClaim
(
"shopId"
,
""
)
.
withClaim
(
"shopName"
,
""
)
.
withExpiresAt
(
expiresAt
)
.
sign
(
Algorithm
.
HMAC256
(
"mezeron-ai"
));
return
token
;
}
}
src/main/java/cn/breeze/elleai/util/UserPrincipal.java
View file @
283c6b10
...
...
@@ -23,4 +23,6 @@ public class UserPrincipal implements Serializable {
private
String
shopName
;
private
PrincipalEnum
type
;
private
String
token
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment