Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
ae70b294
Commit
ae70b294
authored
Nov 17, 2023
by
“yiyousong”
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.scsmile.cn/zxf/device-new-platform
parents
e4c4047b
c5341d3f
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
203 additions
and
90 deletions
+203
-90
common-lib/pom.xml
common-lib/pom.xml
+0
-5
device-manager/src/main/java/com/mortals/xhx/base/system/resource/service/ResourceService.java
...als/xhx/base/system/resource/service/ResourceService.java
+6
-0
device-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+73
-4
device-manager/src/main/java/com/mortals/xhx/base/system/resource/web/ResourceController.java
...tals/xhx/base/system/resource/web/ResourceController.java
+65
-33
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+1
-3
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
...va/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
+12
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
...java/com/mortals/xhx/busiz/web/TestSendMsgController.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
...r/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
+2
-2
device-manager/src/main/java/com/mortals/xhx/common/utils/ControllerScanUtil.java
...java/com/mortals/xhx/common/utils/ControllerScanUtil.java
+36
-30
device-manager/src/test/java/ScanTest.java
device-manager/src/test/java/ScanTest.java
+1
-10
device-manager/src/test/java/com/mortals/httpclient/device/DeviceLogController.http
...va/com/mortals/httpclient/device/DeviceLogController.http
+2
-1
device-manager/src/test/java/com/mortals/httpclient/system.http
...-manager/src/test/java/com/mortals/httpclient/system.http
+4
-0
No files found.
common-lib/pom.xml
View file @
ae70b294
...
@@ -85,11 +85,6 @@
...
@@ -85,11 +85,6 @@
<artifactId>
javase
</artifactId>
<artifactId>
javase
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
io.swagger.core.v3
</groupId>
<artifactId>
swagger-annotations
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/resource/service/ResourceService.java
View file @
ae70b294
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
package
com.mortals.xhx.base.system.resource.service
;
package
com.mortals.xhx.base.system.resource.service
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
...
@@ -63,4 +65,8 @@ public interface ResourceService extends ICRUDService<ResourceEntity,Long> {
...
@@ -63,4 +65,8 @@ public interface ResourceService extends ICRUDService<ResourceEntity,Long> {
* @param userType
* @param userType
*/
*/
List
<
ResourceEntity
>
findAll
(
int
userType
);
List
<
ResourceEntity
>
findAll
(
int
userType
);
Rest
<
String
>
refreshResourceUrl
(
String
packageName
,
Context
context
);
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
ae70b294
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
package
com.mortals.xhx.base.system.resource.service.impl
;
package
com.mortals.xhx.base.system.resource.service.impl
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
...
@@ -23,14 +24,13 @@ import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
...
@@ -23,14 +24,13 @@ import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import
com.mortals.xhx.base.system.role.model.RoleAuthQuery
;
import
com.mortals.xhx.base.system.role.model.RoleAuthQuery
;
import
com.mortals.xhx.base.system.role.service.RoleAuthService
;
import
com.mortals.xhx.base.system.role.service.RoleAuthService
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.utils.ControllerScanUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.HashSet
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
java.util.Set
;
import
static
com
.
mortals
.
xhx
.
common
.
utils
.
MenuEncodeUtil
.
generateMenuUrlCode
;
import
static
com
.
mortals
.
xhx
.
common
.
utils
.
MenuEncodeUtil
.
generateMenuUrlCode
;
...
@@ -39,6 +39,7 @@ import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
...
@@ -39,6 +39,7 @@ import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
* <p>Description: ResourceServiceImpl service接口 </p>
* <p>Description: ResourceServiceImpl service接口 </p>
* <p>Copyright: Copyright ® </p>
* <p>Copyright: Copyright ® </p>
* <p>Company: </p>
* <p>Company: </p>
*
* @author
* @author
* @version 1.0.0
* @version 1.0.0
*/
*/
...
@@ -88,6 +89,74 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
...
@@ -88,6 +89,74 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
return
dao
.
getAll
(
userType
);
return
dao
.
getAll
(
userType
);
}
}
@Override
public
Rest
<
String
>
refreshResourceUrl
(
String
packageName
,
Context
context
)
{
List
<
Class
<?>>
classList
=
ControllerScanUtil
.
getAllClassByPackageName
(
packageName
);
//System.out.println(classList); //获取到了所有的类
List
<
ResourceEntity
>
newResourcelist
=
ControllerScanUtil
.
getAnnotationInfo
(
classList
).
stream
().
filter
(
f
->!
ObjectUtils
.
isEmpty
(
f
.
getUrl
())).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
ResourceEntity
>>
localResourceMap
=
this
.
find
(
new
ResourceQuery
()).
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
Map
<
String
,
List
<
ResourceEntity
>>
newResourceMap
=
newResourcelist
.
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
//更新 与新增 新加的;
newResourceMap
.
entrySet
().
forEach
(
item
->
{
List
<
ResourceEntity
>
resourceEntities
=
item
.
getValue
();
if
(
ObjectUtils
.
isEmpty
(
resourceEntities
))
return
;
if
(
resourceEntities
.
size
()
==
1
)
{
ResourceEntity
resourceEntity
=
resourceEntities
.
get
(
0
);
saveUpdateResourceEntity
(
context
,
localResourceMap
,
resourceEntity
);
}
else
if
(
resourceEntities
.
size
()
>
1
)
{
//原始扫描 有多个资源列表针对一个名称的
for
(
ResourceEntity
resourceEntity
:
resourceEntities
)
{
saveUpdateResourceEntity
(
context
,
localResourceMap
,
resourceEntity
);
}
}
});
return
Rest
.
ok
();
}
private
void
saveUpdateResourceEntity
(
Context
context
,
Map
<
String
,
List
<
ResourceEntity
>>
localResourceMap
,
ResourceEntity
resourceEntity
)
{
//查找 本地是否已经存在了
List
<
ResourceEntity
>
tempResourceList
=
localResourceMap
.
getOrDefault
(
resourceEntity
.
getName
(),
new
ArrayList
<>());
if
(
tempResourceList
.
size
()
==
0
)
{
//新增 resource;
resourceEntity
.
setCreateUserId
(
this
.
getContextUserId
(
context
));
resourceEntity
.
setCreateTime
(
new
Date
());
this
.
save
(
resourceEntity
,
context
);
}
else
if
(
tempResourceList
.
size
()
==
1
)
{
//更新
ResourceEntity
tempResource
=
tempResourceList
.
get
(
0
);
Set
<
String
>
setUrl
=
Arrays
.
stream
(
resourceEntity
.
getUrl
().
split
(
","
)).
collect
(
Collectors
.
toSet
());
Arrays
.
stream
(
tempResource
.
getUrl
().
split
(
","
)).
forEach
(
i
->
{
setUrl
.
add
(
i
);
});
tempResource
.
setUrl
(
setUrl
.
stream
().
collect
(
Collectors
.
joining
(
","
)));
this
.
update
(
tempResource
,
context
);
}
else
if
(
tempResourceList
.
size
()
>
1
)
{
//找到多个同名的 资源配置
for
(
ResourceEntity
tempResource
:
tempResourceList
)
{
//模糊匹配到路径有一个存在的
Set
<
String
>
setUrl
=
Arrays
.
stream
(
resourceEntity
.
getUrl
().
split
(
","
)).
collect
(
Collectors
.
toSet
());
String
[]
splitUrl
=
tempResource
.
getUrl
().
split
(
","
);
Boolean
bool
=
false
;
for
(
int
i
=
0
;
i
<
splitUrl
.
length
;
i
++)
{
if
(
setUrl
.
contains
(
splitUrl
[
i
]))
{
bool
=
true
;
break
;
}
}
if
(
bool
)
{
//匹配到了,更新当前这个资源
Arrays
.
stream
(
tempResource
.
getUrl
().
split
(
","
)).
forEach
(
i
->
{
setUrl
.
add
(
i
);
});
tempResource
.
setUrl
(
setUrl
.
stream
().
collect
(
Collectors
.
joining
(
","
)));
this
.
update
(
tempResource
,
context
);
}
}
}
}
@Override
@Override
protected
void
updateAfter
(
ResourceEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
updateAfter
(
ResourceEntity
entity
,
Context
context
)
throws
AppException
{
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/resource/web/ResourceController.java
View file @
ae70b294
...
@@ -2,9 +2,13 @@ package com.mortals.xhx.base.system.resource.web;
...
@@ -2,9 +2,13 @@ package com.mortals.xhx.base.system.resource.web;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.IBaseEnum
;
import
com.mortals.framework.common.IBaseEnum
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.code.UserType
;
import
com.mortals.framework.common.code.UserType
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
...
@@ -13,8 +17,10 @@ import com.mortals.xhx.common.code.SourceType;
...
@@ -13,8 +17,10 @@ import com.mortals.xhx.common.code.SourceType;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -27,9 +33,9 @@ import java.util.Map;
...
@@ -27,9 +33,9 @@ import java.util.Map;
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"resource"
)
@RequestMapping
(
"resource"
)
public
class
ResourceController
extends
BaseCRUDJsonBodyMappingController
<
ResourceService
,
ResourceEntity
,
Long
>
{
public
class
ResourceController
extends
BaseCRUDJsonBodyMappingController
<
ResourceService
,
ResourceEntity
,
Long
>
{
public
ResourceController
()
{
public
ResourceController
()
{
super
.
setModuleDesc
(
"资源信息"
);
super
.
setModuleDesc
(
"资源信息"
);
}
}
...
@@ -60,4 +66,30 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
...
@@ -60,4 +66,30 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
}
@Override
protected
void
doListBefore
(
ResourceEntity
query
,
Map
<
String
,
Object
>
model
,
Context
context
)
throws
AppException
{
query
.
setOrderColList
(
Arrays
.
asList
(
new
OrderCol
(
"sourceType"
)));
super
.
doListBefore
(
query
,
model
,
context
);
}
/**
* 资源路径刷新
*/
@PostMapping
(
value
=
"refreshUrl"
)
@UnAuth
public
Rest
<
String
>
refreshUrl
(
@RequestParam
(
name
=
"packageName"
,
defaultValue
=
"com.mortals.xhx"
)
String
packageName
)
{
log
.
info
(
"刷新资源路径,packageName"
,
packageName
);
String
busiDesc
=
this
.
getModuleDesc
()
+
"资源路径刷新"
;
Rest
<
String
>
rest
=
Rest
.
ok
(
busiDesc
+
" 【成功】"
);
try
{
this
.
service
.
refreshResourceUrl
(
packageName
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
log
.
error
(
busiDesc
,
e
);
rest
=
Rest
.
fail
(
super
.
convertException
(
e
));
}
return
rest
;
}
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
ae70b294
...
@@ -61,7 +61,6 @@ import com.mortals.xhx.module.site.service.SiteService;
...
@@ -61,7 +61,6 @@ import com.mortals.xhx.module.site.service.SiteService;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -89,8 +88,7 @@ import static com.mortals.xhx.common.key.RedisKey.KEY_TOKEN_API_CACHE;
...
@@ -89,8 +88,7 @@ import static com.mortals.xhx.common.key.RedisKey.KEY_TOKEN_API_CACHE;
*/
*/
@RestController
@RestController
@Slf4j
@Slf4j
@RequestMapping
(
"/api"
)
@RequestMapping
(
"api"
)
@Tag
(
name
=
"设备api"
)
public
class
DeviceApiController
{
public
class
DeviceApiController
{
@Autowired
@Autowired
private
DeviceService
deviceService
;
private
DeviceService
deviceService
;
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
View file @
ae70b294
...
@@ -3,6 +3,7 @@ package com.mortals.xhx.busiz.web;
...
@@ -3,6 +3,7 @@ package com.mortals.xhx.busiz.web;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
...
@@ -40,7 +41,7 @@ import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_REFRESH;
...
@@ -40,7 +41,7 @@ import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_REFRESH;
@RestController
@RestController
@Slf4j
@Slf4j
@RequestMapping
(
"
/
notify"
)
@RequestMapping
(
"notify"
)
public
class
DeviceSendMsgController
{
public
class
DeviceSendMsgController
{
@Autowired
@Autowired
private
DeviceService
deviceService
;
private
DeviceService
deviceService
;
...
@@ -167,5 +168,15 @@ public class DeviceSendMsgController {
...
@@ -167,5 +168,15 @@ public class DeviceSendMsgController {
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
public
static
void
main
(
String
[]
args
)
{
String
input
=
"/example/path/to/file"
;
// 去掉开头和结尾的 \
String
result
=
StrUtil
.
removeSuffix
(
StrUtil
.
removePrefix
(
input
,
"/"
),
"/"
);
System
.
out
.
println
(
"处理前: "
+
input
);
System
.
out
.
println
(
"处理后: "
+
result
);
}
}
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
View file @
ae70b294
...
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
...
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
*/
*/
@RestController
@RestController
@Slf4j
@Slf4j
@RequestMapping
(
"
/
test"
)
@RequestMapping
(
"test"
)
public
class
TestSendMsgController
{
public
class
TestSendMsgController
{
@Autowired
@Autowired
protected
ILogService
logService
=
FileLogServiceImpl
.
getInstance
();
protected
ILogService
logService
=
FileLogServiceImpl
.
getInstance
();
...
...
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
View file @
ae70b294
...
@@ -120,6 +120,6 @@ public interface ErrorCode {
...
@@ -120,6 +120,6 @@ public interface ErrorCode {
public
static
final
int
ERROR_TOKEN_UNAUTHORIZED
=
9002
;
public
static
final
int
ERROR_TOKEN_UNAUTHORIZED
=
9002
;
public
static
final
String
ERROR_TOKEN_UNAUTHORIZED_CONTENT
=
"token不正确或已过期"
;
public
static
final
String
ERROR_TOKEN_UNAUTHORIZED_CONTENT
=
"token不正确或已过期"
;
public
static
final
int
ERROR_USER_OPERATION
=
9009
;
public
static
final
int
ERROR_USER_OPERATION
=
405
;
public
static
final
String
ERROR_USER_OPERATION_CONTENT
=
"用户无该操作权限!"
;
public
static
final
String
ERROR_USER_OPERATION_CONTENT
=
"
当前
用户无该操作权限!"
;
}
}
device-manager/src/main/java/com/mortals/xhx/common/utils/ControllerScanUtil.java
View file @
ae70b294
package
com.mortals.xhx.common.utils
;
package
com.mortals.xhx.common.utils
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -31,6 +29,8 @@ public class ControllerScanUtil {
...
@@ -31,6 +29,8 @@ public class ControllerScanUtil {
public
static
final
String
[]
ULR_VIEW
=
{
"view"
,
"info"
,
"list"
,
"get"
,
"find"
,
"export"
,
"download"
,
public
static
final
String
[]
ULR_VIEW
=
{
"view"
,
"info"
,
"list"
,
"get"
,
"find"
,
"export"
,
"download"
,
"index"
,
"bill"
};
"index"
,
"bill"
};
public
static
final
String
[]
WHITE_URL
=
{
"login"
,
"test"
,
"file"
,
"securitycode"
};
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
List
<
Class
<?>>
classList
=
getAllClassByPackageName
(
"com.mortals.xhx"
);
List
<
Class
<?>>
classList
=
getAllClassByPackageName
(
"com.mortals.xhx"
);
...
@@ -49,40 +49,56 @@ public class ControllerScanUtil {
...
@@ -49,40 +49,56 @@ public class ControllerScanUtil {
if
(!
exits
)
{
if
(!
exits
)
{
continue
;
continue
;
}
}
//白名单地址的 也不需要
ResourceEntity
resourceViewEntity
=
new
ResourceEntity
();
ResourceEntity
resourceViewEntity
=
new
ResourceEntity
();
resourceViewEntity
.
initAttrValue
();
resourceViewEntity
.
initAttrValue
();
ResourceEntity
resourceEditEntity
=
new
ResourceEntity
();
ResourceEntity
resourceEditEntity
=
new
ResourceEntity
();
resourceEditEntity
.
initAttrValue
();
resourceEditEntity
.
initAttrValue
();
resourceEditEntity
.
setSourceType
(
1
);
Method
substringMethod
=
null
;
Method
substringMethod
=
null
;
String
result
=
""
;
String
result
=
""
;
try
{
try
{
String
packName
=
cls
.
getPackage
().
getName
();
if
(
StrUtil
.
contains
(
packName
,
"system"
))
{
//系统管理-xx管理-
substringMethod
=
cls
.
getMethod
(
"getModuleDesc"
);
result
=
(
String
)
substringMethod
.
invoke
(
cls
.
newInstance
());
resourceViewEntity
.
setName
(
"系统管理-"
+
result
+
"管理-查看"
);
resourceEditEntity
.
setName
(
"系统管理-"
+
result
+
"管理-维护"
);
}
else
{
substringMethod
=
cls
.
getMethod
(
"getModuleDesc"
);
substringMethod
=
cls
.
getMethod
(
"getModuleDesc"
);
result
=
(
String
)
substringMethod
.
invoke
(
cls
.
newInstance
());
result
=
(
String
)
substringMethod
.
invoke
(
cls
.
newInstance
());
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
if
(
ObjectUtils
.
isEmpty
(
result
))
{
boolean
tagExits
=
cls
.
isAnnotationPresent
(
Tag
.
class
);
if
(
tagExits
)
{
Tag
annotation
=
cls
.
getAnnotation
(
Tag
.
class
);
result
=
annotation
.
name
();
}
else
{
//自定义的controller 没有名称
result
=
"自定义api模块"
+
RandomUtil
.
randomInt
(
100
);
}
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
}
System
.
out
.
println
(
result
);
RequestMapping
requestMappingCls
=
cls
.
getAnnotation
(
RequestMapping
.
class
);
RequestMapping
requestMappingCls
=
cls
.
getAnnotation
(
RequestMapping
.
class
);
String
prefix
=
""
;
String
prefix
=
""
;
if
(
requestMappingCls
!=
null
)
{
if
(
requestMappingCls
!=
null
)
{
prefix
=
"/"
+
requestMappingCls
.
value
()[
0
];
prefix
=
"/"
+
requestMappingCls
.
value
()[
0
];
boolean
b
=
false
;
for
(
String
s
:
WHITE_URL
)
{
if
(
StrUtil
.
contains
(
requestMappingCls
.
value
()[
0
].
toLowerCase
(),
s
))
{
b
=
true
;
break
;
}
}
if
(
b
)
{
continue
;
}
}
if
(
ObjectUtils
.
isEmpty
(
result
))
{
if
(
requestMappingCls
!=
null
)
{
result
=
StrUtil
.
removeSuffix
(
StrUtil
.
removePrefix
(
requestMappingCls
.
value
()[
0
].
toUpperCase
(),
"/"
),
"/"
)
+
"接口模块"
;
}
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
}
}
Set
<
String
>
urlSet
=
new
HashSet
<>();
Set
<
String
>
urlSet
=
new
HashSet
<>();
//获取类中的所有的方法
//获取类中的所有的方法
...
@@ -100,7 +116,6 @@ public class ControllerScanUtil {
...
@@ -100,7 +116,6 @@ public class ControllerScanUtil {
String
url
=
prefix
+
"/"
+
requestMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
requestMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
// System.out.println("/" + prefix + "/" + requestMapping.value()[0]);
}
}
boolean
mExits1
=
method
.
isAnnotationPresent
(
GetMapping
.
class
);
boolean
mExits1
=
method
.
isAnnotationPresent
(
GetMapping
.
class
);
...
@@ -109,7 +124,6 @@ public class ControllerScanUtil {
...
@@ -109,7 +124,6 @@ public class ControllerScanUtil {
String
url
=
prefix
+
"/"
+
getMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
getMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
// System.out.println("/" + prefix + "/" + getMapping.value()[0]);
}
}
boolean
mExits2
=
method
.
isAnnotationPresent
(
PostMapping
.
class
);
boolean
mExits2
=
method
.
isAnnotationPresent
(
PostMapping
.
class
);
...
@@ -118,7 +132,6 @@ public class ControllerScanUtil {
...
@@ -118,7 +132,6 @@ public class ControllerScanUtil {
String
url
=
prefix
+
"/"
+
postMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
postMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
// System.out.println("/" + prefix + "/" + postMapping.value()[0]);
}
}
}
}
}
}
...
@@ -127,19 +140,16 @@ public class ControllerScanUtil {
...
@@ -127,19 +140,16 @@ public class ControllerScanUtil {
Method
[]
superMethods
=
cls
.
getSuperclass
().
getDeclaredMethods
();
Method
[]
superMethods
=
cls
.
getSuperclass
().
getDeclaredMethods
();
if
(
superMethods
!=
null
&&
superMethods
.
length
>
0
)
{
if
(
superMethods
!=
null
&&
superMethods
.
length
>
0
)
{
for
(
Method
method
:
superMethods
)
{
for
(
Method
method
:
superMethods
)
{
boolean
unAuth
=
method
.
isAnnotationPresent
(
UnAuth
.
class
);
boolean
unAuth
=
method
.
isAnnotationPresent
(
UnAuth
.
class
);
if
(
unAuth
)
{
if
(
unAuth
)
{
continue
;
continue
;
}
}
boolean
mExits
=
method
.
isAnnotationPresent
(
RequestMapping
.
class
);
boolean
mExits
=
method
.
isAnnotationPresent
(
RequestMapping
.
class
);
if
(
mExits
)
{
if
(
mExits
)
{
RequestMapping
requestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
RequestMapping
requestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
String
url
=
prefix
+
"/"
+
requestMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
requestMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
// System.out.println("super /" + prefix + "/" + requestMapping.value()[0]);
}
}
boolean
mExits1
=
method
.
isAnnotationPresent
(
GetMapping
.
class
);
boolean
mExits1
=
method
.
isAnnotationPresent
(
GetMapping
.
class
);
...
@@ -148,7 +158,6 @@ public class ControllerScanUtil {
...
@@ -148,7 +158,6 @@ public class ControllerScanUtil {
String
url
=
prefix
+
"/"
+
getMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
getMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
//System.out.println("super /" + prefix + "/" + getMapping.value()[0]);
}
}
boolean
mExits2
=
method
.
isAnnotationPresent
(
PostMapping
.
class
);
boolean
mExits2
=
method
.
isAnnotationPresent
(
PostMapping
.
class
);
...
@@ -157,7 +166,6 @@ public class ControllerScanUtil {
...
@@ -157,7 +166,6 @@ public class ControllerScanUtil {
String
url
=
prefix
+
"/"
+
postMapping
.
value
()[
0
];
String
url
=
prefix
+
"/"
+
postMapping
.
value
()[
0
];
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
url
=
url
.
replaceAll
(
"/+"
,
"/"
);
urlSet
.
add
(
url
);
urlSet
.
add
(
url
);
// System.out.println("super /" + prefix + "/" + postMapping.value()[0]);
}
}
}
}
}
}
...
@@ -196,8 +204,6 @@ public class ControllerScanUtil {
...
@@ -196,8 +204,6 @@ public class ControllerScanUtil {
}
}
public
static
List
<
Class
<?>>
getAllClassByPackageName
(
String
packageName
)
{
public
static
List
<
Class
<?>>
getAllClassByPackageName
(
String
packageName
)
{
// String packageName = pkg.getName();
// 获取当前包下以及子包下所以的类
// 获取当前包下以及子包下所以的类
List
<
Class
<?>>
returnClassList
=
getClasses
(
packageName
);
List
<
Class
<?>>
returnClassList
=
getClasses
(
packageName
);
return
returnClassList
;
return
returnClassList
;
...
...
device-manager/src/test/java/ScanTest.java
View file @
ae70b294
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.module.site.web.SiteController
;
import
com.mortals.xhx.module.site.web.SiteController
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -63,14 +61,7 @@ public class ScanTest {
...
@@ -63,14 +61,7 @@ public class ScanTest {
}
}
if
(
ObjectUtils
.
isEmpty
(
result
))
{
if
(
ObjectUtils
.
isEmpty
(
result
))
{
boolean
tagExits
=
cls
.
isAnnotationPresent
(
Tag
.
class
);
if
(
tagExits
)
{
Tag
annotation
=
cls
.
getAnnotation
(
Tag
.
class
);
result
=
annotation
.
name
();
}
else
{
//自定义的controller 没有名称
result
=
"自定义api模块"
+
RandomUtil
.
randomInt
(
100
);
}
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceViewEntity
.
setName
(
result
+
"-查看"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
resourceEditEntity
.
setName
(
result
+
"-维护"
);
}
}
...
...
device-manager/src/test/java/com/mortals/httpclient/device/DeviceLogController.http
View file @
ae70b294
###设备日志列表
###设备日志列表
POST {{baseUrl}}/device/
log
/list
POST {{baseUrl}}/device/
alarm/info
/list
Content-Type: application/json
Content-Type: application/json
{
{
"siteId": 87,
"page":1,
"page":1,
"size":10
"size":10
}
}
...
...
device-manager/src/test/java/com/mortals/httpclient/system.http
View file @
ae70b294
...
@@ -54,6 +54,10 @@ Accept: application/json
...
@@ -54,6 +54,10 @@ Accept: application/json
GET {{baseUrl}}/test/one/49
GET {{baseUrl}}/test/one/49
Accept: application/json
Accept: application/json
###controoler 测试
POST {{baseUrl}}/resource/refreshUrl
Accept: application/json
###站点树 测试
###站点树 测试
GET {{baseUrl}}/sitestat/siteTree
GET {{baseUrl}}/sitestat/siteTree
...
...
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