Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
d3cf8d62
提交
d3cf8d62
authored
3月 18, 2025
作者:
zgz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
专题添加数据权限
上级
697f1fbb
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
512 行增加
和
25 行删除
+512
-25
pom.xml
pom.xml
+5
-0
EventAnalysisApplication.java
src/main/java/com/zzsn/event/EventAnalysisApplication.java
+2
-0
SubjectManageController.java
...va/com/zzsn/event/controller/SubjectManageController.java
+37
-4
EsService.java
src/main/java/com/zzsn/event/es/EsService.java
+5
-0
DataPermitClient.java
src/main/java/com/zzsn/event/feign/api/DataPermitClient.java
+24
-0
DataPermitClientProd.java
...n/java/com/zzsn/event/feign/api/DataPermitClientProd.java
+22
-0
SubjectMapper.java
src/main/java/com/zzsn/event/mapper/SubjectMapper.java
+2
-2
SubjectMapper.xml
src/main/java/com/zzsn/event/mapper/xml/SubjectMapper.xml
+3
-2
Constant.java
src/main/java/com/zzsn/event/permit/Constant.java
+22
-0
EnumDBType.java
src/main/java/com/zzsn/event/permit/EnumDBType.java
+5
-0
ParamAop.java
src/main/java/com/zzsn/event/permit/ParamAop.java
+53
-0
SqlConditionUtil.java
src/main/java/com/zzsn/event/permit/SqlConditionUtil.java
+156
-0
UQueryEntity.java
src/main/java/com/zzsn/event/permit/UQueryEntity.java
+17
-0
SubjectService.java
src/main/java/com/zzsn/event/service/SubjectService.java
+3
-2
InformationServiceImpl.java
...a/com/zzsn/event/service/impl/InformationServiceImpl.java
+6
-1
SubjectServiceImpl.java
.../java/com/zzsn/event/service/impl/SubjectServiceImpl.java
+43
-9
TokenUtil.java
src/main/java/com/zzsn/event/util/TokenUtil.java
+88
-0
application-dev.yml
src/main/resources/application-dev.yml
+6
-1
application-pro.yml
src/main/resources/application-pro.yml
+7
-3
application-test.yml
src/main/resources/application-test.yml
+6
-1
没有找到文件。
pom.xml
浏览文件 @
d3cf8d62
...
@@ -180,6 +180,11 @@
...
@@ -180,6 +180,11 @@
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.fusesource.hawtbuf/hawtbuf -->
<!-- https://mvnrepository.com/artifact/org.fusesource.hawtbuf/hawtbuf -->
<dependency>
<dependency>
<groupId>
com.auth0
</groupId>
<artifactId>
java-jwt
</artifactId>
<version>
3.18.1
</version>
</dependency>
<dependency>
<groupId>
org.fusesource.hawtbuf
</groupId>
<groupId>
org.fusesource.hawtbuf
</groupId>
<artifactId>
hawtbuf
</artifactId>
<artifactId>
hawtbuf
</artifactId>
<version>
1.11
</version>
<version>
1.11
</version>
...
...
src/main/java/com/zzsn/event/EventAnalysisApplication.java
浏览文件 @
d3cf8d62
...
@@ -2,7 +2,9 @@ package com.zzsn.event;
...
@@ -2,7 +2,9 @@ package com.zzsn.event;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableFeignClients
@SpringBootApplication
@SpringBootApplication
public
class
EventAnalysisApplication
{
public
class
EventAnalysisApplication
{
...
...
src/main/java/com/zzsn/event/controller/SubjectManageController.java
浏览文件 @
d3cf8d62
...
@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -142,8 +143,10 @@ public class SubjectManageController {
...
@@ -142,8 +143,10 @@ public class SubjectManageController {
@GetMapping
((
"/pageList"
))
@GetMapping
((
"/pageList"
))
public
Result
<?>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
public
Result
<?>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
Page
<
SubjectPage
>
pageList
=
subjectService
.
researchCenterPageList
(
subjectCondition
,
pageNo
,
pageSize
);
@RequestParam
(
required
=
false
)
String
flagCode
,
HttpServletRequest
request
)
{
UserVo
loginUser
=
UserUtil
.
getLoginUser
();
Page
<
SubjectPage
>
pageList
=
subjectService
.
researchCenterPageList
(
subjectCondition
,
pageNo
,
pageSize
,
flagCode
,
request
,
loginUser
.
getUsername
());
return
Result
.
OK
(
pageList
);
return
Result
.
OK
(
pageList
);
}
}
...
@@ -152,6 +155,8 @@ public class SubjectManageController {
...
@@ -152,6 +155,8 @@ public class SubjectManageController {
*
*
* @param type 分类(1-个人;2-公开;3-个人+公开)
* @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称
* @param subjectName 专题名称
* @param environment 环境 1-测试 2-正式
* @param flagCode 数据权限code
* @param pageNo 当前页
* @param pageNo 当前页
* @param pageSize 每页返回条数
* @param pageSize 每页返回条数
* @author lkg
* @author lkg
...
@@ -161,10 +166,38 @@ public class SubjectManageController {
...
@@ -161,10 +166,38 @@ public class SubjectManageController {
public
Result
<?>
visiblePageList
(
@RequestParam
Integer
type
,
public
Result
<?>
visiblePageList
(
@RequestParam
Integer
type
,
@RequestParam
(
required
=
false
)
String
subjectName
,
@RequestParam
(
required
=
false
)
String
subjectName
,
@RequestParam
(
required
=
false
)
String
environment
,
@RequestParam
(
required
=
false
)
String
environment
,
@RequestParam
(
required
=
false
)
String
flagCode
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
request
)
{
UserVo
loginUser
=
UserUtil
.
getLoginUser
();
Page
<
Node
>
pageList
=
subjectService
.
visiblePageList
(
loginUser
.
getUsername
(),
type
,
subjectName
,
pageNo
,
pageSize
,
environment
,
request
,
flagCode
);
return
Result
.
OK
(
pageList
);
}
/**
* 当前用户可见的专题列表-研究中心-不验证
*
* @param type 分类(1-个人;2-公开;3-个人+公开)
* @param subjectName 专题名称
* @param environment 环境 1-测试 2-正式
* @param flagCode 数据权限code
* @param pageNo 当前页
* @param pageSize 每页返回条数
* @author lkg
* @date 2025/2/8
*/
@GetMapping
(
"/visiblePageListNoSign"
)
public
Result
<?>
visiblePageListNoSign
(
@RequestParam
Integer
type
,
@RequestParam
(
required
=
false
)
String
subjectName
,
@RequestParam
(
required
=
false
)
String
environment
,
@RequestParam
(
required
=
false
)
String
flagCode
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
request
)
{
UserVo
loginUser
=
UserUtil
.
getLoginUser
();
UserVo
loginUser
=
UserUtil
.
getLoginUser
();
Page
<
Node
>
pageList
=
subjectService
.
visiblePageList
(
loginUser
.
getUsername
(),
type
,
subjectName
,
pageNo
,
pageSize
,
environment
);
Page
<
Node
>
pageList
=
subjectService
.
visiblePageList
(
loginUser
.
getUsername
(),
type
,
subjectName
,
pageNo
,
pageSize
,
environment
,
request
,
flagCode
);
return
Result
.
OK
(
pageList
);
return
Result
.
OK
(
pageList
);
}
}
...
...
src/main/java/com/zzsn/event/es/EsService.java
浏览文件 @
d3cf8d62
...
@@ -777,6 +777,11 @@ public class EsService {
...
@@ -777,6 +777,11 @@ public class EsService {
searchSourceBuilder
.
sort
(
"score"
,
SortOrder
.
ASC
);
searchSourceBuilder
.
sort
(
"score"
,
SortOrder
.
ASC
);
}
}
break
;
break
;
case
"yqgzzk"
:
searchSourceBuilder
.
sort
(
"dataFrom"
,
SortOrder
.
DESC
);
searchSourceBuilder
.
sort
(
"topNum"
,
SortOrder
.
DESC
);
searchSourceBuilder
.
sort
(
"score"
,
SortOrder
.
DESC
);
break
;
default
:
default
:
searchSourceBuilder
.
sort
(
"publishDate"
,
SortOrder
.
DESC
);
searchSourceBuilder
.
sort
(
"publishDate"
,
SortOrder
.
DESC
);
break
;
break
;
...
...
src/main/java/com/zzsn/event/feign/api/DataPermitClient.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
feign
.
api
;
import
com.alibaba.fastjson2.JSONObject
;
import
feign.RequestLine
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @author zgz
* @date 2025/2/18
*/
@FeignClient
(
name
=
"data-permit"
,
url
=
"http://1.95.77.159:10089/permission/"
)
public
interface
DataPermitClient
{
/**
* 获取数据权限
* @return
*/
@PostMapping
(
value
=
"/data/permit/aop/getQueryEntity"
)
JSONObject
getQueryEntity
(
@RequestParam
(
"queryEntity"
)
JSONObject
params
,
@RequestHeader
(
"Accesstoken"
)
String
accesstoken
);
}
src/main/java/com/zzsn/event/feign/api/DataPermitClientProd.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
feign
.
api
;
import
com.alibaba.fastjson2.JSONObject
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @author zgz
* @date 2025/2/18
*/
@FeignClient
(
name
=
"data-permit"
,
url
=
"http://1.95.77.159:10089/permission/"
)
public
interface
DataPermitClientProd
{
/**
* 获取数据权限
* @return
*/
@PostMapping
(
value
=
"/data/permit/aop/getQueryEntity"
)
JSONObject
getQueryEntity
(
@RequestParam
(
"queryEntity"
)
JSONObject
params
,
@RequestHeader
(
"Accesstoken"
)
String
accesstoken
);
}
src/main/java/com/zzsn/event/mapper/SubjectMapper.java
浏览文件 @
d3cf8d62
...
@@ -49,7 +49,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
...
@@ -49,7 +49,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @author lkg
* @author lkg
* @date 2025/1/14
* @date 2025/1/14
*/
*/
Page
<
SubjectPage
>
researchCenterFacePageList
(
@Param
(
"subjectCondition"
)
SubjectCondition
subjectCondition
,
Page
<
SubjectPage
>
page
);
Page
<
SubjectPage
>
researchCenterFacePageList
(
@Param
(
"subjectCondition"
)
SubjectCondition
subjectCondition
,
Page
<
SubjectPage
>
page
,
@Param
(
"sql"
)
String
sql
,
@Param
(
"username"
)
String
username
);
/**
/**
* 当前用户可见的专题分页列表(公开和个人非公开)-研究中心
* 当前用户可见的专题分页列表(公开和个人非公开)-研究中心
...
@@ -61,7 +61,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
...
@@ -61,7 +61,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @author lkg
* @author lkg
* @date 2025/2/8
* @date 2025/2/8
*/
*/
Page
<
Node
>
visibleList
(
@Param
(
"username"
)
String
username
,
@Param
(
"type"
)
Integer
type
,
@Param
(
"subjectName"
)
String
subjectName
,
Page
<
String
>
page
,
@Param
(
"environment"
)
String
environment
);
Page
<
Node
>
visibleList
(
@Param
(
"username"
)
String
username
,
@Param
(
"type"
)
Integer
type
,
@Param
(
"subjectName"
)
String
subjectName
,
Page
<
String
>
page
,
@Param
(
"environment"
)
String
environment
,
@Param
(
"sql"
)
String
sql
);
/**
/**
* 获取专题详情(包含样例文章信息)
* 获取专题详情(包含样例文章信息)
...
...
src/main/java/com/zzsn/event/mapper/xml/SubjectMapper.xml
浏览文件 @
d3cf8d62
...
@@ -135,7 +135,8 @@
...
@@ -135,7 +135,8 @@
from subject d
from subject d
LEFT JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN subject_type c ON b.type_id = c.id
LEFT JOIN subject_type c ON b.type_id = c.id
where d.face_public = 1
where
((d.face_public = 1 and d.create_by = #{username}) or (d.face_public = 1 and #{sql}))
<if
test=
"subjectCondition.environment !=null and subjectCondition.environment !=''"
>
<if
test=
"subjectCondition.environment !=null and subjectCondition.environment !=''"
>
and d.environment =#{subjectCondition.environment}
and d.environment =#{subjectCondition.environment}
</if>
</if>
...
@@ -215,7 +216,7 @@
...
@@ -215,7 +216,7 @@
and face_public = 1
and face_public = 1
</when>
</when>
<otherwise>
<otherwise>
and (
create_by = #{username} or face_public = 1
)
and (
(create_by = #{username}) or (face_public = 1 and #{sql})
)
</otherwise>
</otherwise>
</choose>
</choose>
</select>
</select>
...
...
src/main/java/com/zzsn/event/permit/Constant.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
permit
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Constant
{
public
static
Map
<
String
,
String
>
symbolMap
=
new
HashMap
<>();
static
{
symbolMap
.
put
(
"="
,
"="
);
symbolMap
.
put
(
">"
,
">"
);
symbolMap
.
put
(
">="
,
">="
);
symbolMap
.
put
(
"<"
,
"<"
);
symbolMap
.
put
(
"<="
,
"<="
);
symbolMap
.
put
(
"!="
,
"!="
);
symbolMap
.
put
(
"in"
,
"in"
);
symbolMap
.
put
(
"isNull"
,
"isNull"
);
symbolMap
.
put
(
"between"
,
"between"
);
symbolMap
.
put
(
"like"
,
"like"
);
symbolMap
.
put
(
"likeLeft"
,
"likeLeft"
);
symbolMap
.
put
(
"likeRight"
,
"likeRight"
);
}
}
src/main/java/com/zzsn/event/permit/EnumDBType.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
permit
;
public
enum
EnumDBType
{
MYSQL
,
ES
;
}
src/main/java/com/zzsn/event/permit/ParamAop.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
permit
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.zzsn.event.feign.api.DataPermitClient
;
import
com.zzsn.event.feign.api.DataPermitClientProd
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Aspect
@Component
@Slf4j
public
class
ParamAop
{
@Autowired
private
DataPermitClient
dataPermitClient
;
@Autowired
private
DataPermitClientProd
dataPermitClientProd
;
public
UQueryEntity
startArs
(
UQueryEntity
queryEntity
,
String
accesstoken
,
String
environment
){
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"userId"
,
queryEntity
.
getUserId
());
params
.
put
(
"flagCode"
,
queryEntity
.
getFlagCode
());
params
.
put
(
"dbType"
,
EnumDBType
.
MYSQL
);
params
.
put
(
"dataType"
,
EnumDataType
.
NEWS
);
try
{
JSONObject
jo
=
new
JSONObject
();
if
(
StringUtils
.
isNotBlank
(
environment
)
&&
environment
.
equals
(
"2"
)){
jo
=
dataPermitClientProd
.
getQueryEntity
(
params
,
accesstoken
);
}
else
{
jo
=
dataPermitClient
.
getQueryEntity
(
params
,
accesstoken
);
}
if
(
jo
!=
null
)
{
if
(
jo
.
containsKey
(
"condition"
))
{
String
jSONString
=
JSONObject
.
toJSONString
(
jo
.
get
(
"condition"
));
queryEntity
.
setSql
(
SqlConditionUtil
.
get
(
JSONObject
.
parseObject
(
jSONString
)));
}
if
(
jo
.
containsKey
(
"fields"
))
{
queryEntity
.
setFields
(
jo
.
getString
(
"fields"
));
}
if
(
jo
.
containsKey
(
"shareIds"
))
{
queryEntity
.
setShardIds
(
jo
.
getJSONArray
(
"shareIds"
).
toJavaList
(
String
.
class
));
}
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"{}"
,
ex
);
}
return
queryEntity
;
}
}
src/main/java/com/zzsn/event/permit/SqlConditionUtil.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
permit
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
public
class
SqlConditionUtil
{
private
static
String
FLAG_AND
=
"and"
;
private
static
String
FLAG_OR
=
"or"
;
public
static
List
<
String
>
FLAG_LIST
;
final
static
String
[]
MUST_CONDTION_FIELDS
=
new
String
[]{
"name"
,
"value"
,
"condition"
};
static
{
FLAG_LIST
=
new
ArrayList
<>();
FLAG_LIST
.
add
(
"and"
);
FLAG_LIST
.
add
(
"or"
);
}
public
static
String
getSql
(
JSONObject
jo
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
setChd
(
jo
,
stringBuilder
);
return
stringBuilder
.
toString
();
}
private
static
void
setChd
(
JSONObject
jo
,
StringBuilder
stringBuilder
)
{
stringBuilder
.
append
(
"("
);
for
(
int
i
=
0
;
i
<
jo
.
getJSONArray
(
"query"
).
size
();
i
++)
{
JSONObject
chdJo
=
(
JSONObject
)
jo
.
getJSONArray
(
"query"
).
get
(
i
);
if
(
chdJo
.
containsKey
(
"flag"
)
&&
FLAG_LIST
.
contains
(
jo
.
getString
(
"flag"
).
toLowerCase
()))
{
setChd
(
chdJo
,
stringBuilder
);
}
else
{
setCondition
(
stringBuilder
,
chdJo
);
}
if
(
i
<
jo
.
getJSONArray
(
"query"
).
size
()
-
1
)
{
setFlag
(
stringBuilder
,
jo
.
getString
(
"flag"
).
toLowerCase
());
}
}
stringBuilder
.
append
(
")"
);
}
private
static
void
setFlag
(
StringBuilder
stringBuilder
,
String
flag
)
{
stringBuilder
.
append
(
" "
);
stringBuilder
.
append
(
flag
);
stringBuilder
.
append
(
" "
);
}
/***
* 装配查询条件
* @param stringBuilder
* @param jsonObject
*/
private
static
void
setCondition
(
StringBuilder
stringBuilder
,
JSONObject
jsonObject
)
{
if
(
jsonObject
.
containsKey
(
"condition"
)
&&
"isNull"
.
equals
(
jsonObject
.
getString
(
"condition"
)))
{
stringBuilder
.
append
(
jsonObject
.
getString
(
"name"
));
stringBuilder
.
append
(
" is null "
);
return
;
}
for
(
String
field
:
MUST_CONDTION_FIELDS
)
{
if
(!
jsonObject
.
containsKey
(
field
)
||
StringUtils
.
isBlank
(
jsonObject
.
getString
(
field
)))
{
return
;
}
}
try
{
String
condtion
=
jsonObject
.
getString
(
"condition"
);
if
(!
Constant
.
symbolMap
.
containsKey
(
condtion
))
{
return
;
}
String
name
=
jsonObject
.
getString
(
"name"
);
Object
value
=
jsonObject
.
get
(
"value"
);
boolean
isNumber
=
false
;
if
(
jsonObject
.
containsKey
(
"dataType"
)
&&
"number"
.
equals
(
jsonObject
.
getString
(
"dataType"
)))
{
isNumber
=
true
;
}
switch
(
condtion
)
{
case
"like"
:
{
value
=
"'%"
+
jsonObject
.
get
(
"value"
).
toString
()
+
"%'"
;
break
;
}
case
"likeLeft"
:
{
value
=
"'%"
+
jsonObject
.
get
(
"value"
).
toString
();
break
;
}
case
"likeRight"
:
{
value
=
jsonObject
.
get
(
"value"
).
toString
()
+
"%'"
;
break
;
}
case
"in"
:
{
//数字类型
if
(
isNumber
)
{
value
=
jsonObject
.
getJSONArray
(
"value"
).
toJSONString
().
replaceAll
(
"\",\""
,
","
).
replace
(
"[\""
,
"("
).
replace
(
"\"]"
,
")"
).
replace
(
"["
,
"("
).
replace
(
"]"
,
")"
);
}
else
{
value
=
jsonObject
.
getJSONArray
(
"value"
).
toJSONString
().
replaceAll
(
"\",\""
,
"','"
).
replace
(
"[\""
,
"('"
).
replace
(
"\"]"
,
"')"
);
}
break
;
}
default
:
value
=
isNumber
==
true
?
value
:
"'"
+
value
+
"'"
;
break
;
}
stringBuilder
.
append
(
name
);
stringBuilder
.
append
(
" "
);
stringBuilder
.
append
(
Constant
.
symbolMap
.
get
(
condtion
));
stringBuilder
.
append
(
" "
);
stringBuilder
.
append
(
value
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"{}"
,
ex
);
}
}
public
static
String
get
(
JSONObject
jo
)
{
String
sql
=
getSql
(
jo
);
if
(
"()"
.
equals
(
sql
))
{
return
null
;
}
else
{
return
sql
;
}
}
public
static
void
main
(
String
[]
ag
)
{
log
.
info
(
JSON
.
toJSONString
(
getSql
(
getData
())));
}
public
static
JSONObject
getData
()
{
try
{
//data-数据授权-人物类.json
InputStream
inputStream
=
new
ClassPathResource
(
"1.json"
).
getInputStream
();
String
text
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
)).
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
inputStream
.
close
();
return
JSON
.
parseObject
(
text
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/main/java/com/zzsn/event/permit/UQueryEntity.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
permit
;
import
lombok.Data
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
java.util.List
;
@Data
public
class
UQueryEntity
{
private
String
userId
;
private
String
flagCode
;
private
String
sql
;
private
String
fields
;
private
List
<
String
>
shardIds
;
private
BoolQueryBuilder
queryBuilder
;
}
src/main/java/com/zzsn/event/service/SubjectService.java
浏览文件 @
d3cf8d62
...
@@ -7,6 +7,7 @@ import com.zzsn.event.entity.Subject;
...
@@ -7,6 +7,7 @@ import com.zzsn.event.entity.Subject;
import
com.zzsn.event.util.tree.Node
;
import
com.zzsn.event.util.tree.Node
;
import
com.zzsn.event.vo.*
;
import
com.zzsn.event.vo.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -37,7 +38,7 @@ public interface SubjectService extends IService<Subject> {
...
@@ -37,7 +38,7 @@ public interface SubjectService extends IService<Subject> {
* @author lkg
* @author lkg
* @date 2024/12/18
* @date 2024/12/18
*/
*/
Page
<
SubjectPage
>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
Integer
pageNo
,
Integer
pageSize
);
Page
<
SubjectPage
>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
Integer
pageNo
,
Integer
pageSize
,
String
flagCode
,
HttpServletRequest
request
,
String
username
);
/**
/**
* 当前用户可见的专题分页列表-研究中心
* 当前用户可见的专题分页列表-研究中心
...
@@ -50,7 +51,7 @@ public interface SubjectService extends IService<Subject> {
...
@@ -50,7 +51,7 @@ public interface SubjectService extends IService<Subject> {
* @author lkg
* @author lkg
* @date 2025/2/8
* @date 2025/2/8
*/
*/
Page
<
Node
>
visiblePageList
(
String
username
,
Integer
type
,
String
subjectName
,
Integer
pageNo
,
Integer
pageSize
,
String
environment
);
Page
<
Node
>
visiblePageList
(
String
username
,
Integer
type
,
String
subjectName
,
Integer
pageNo
,
Integer
pageSize
,
String
environment
,
HttpServletRequest
request
,
String
flagCode
);
/**
/**
* 获取专题详情(包含样例文章信息)
* 获取专题详情(包含样例文章信息)
...
...
src/main/java/com/zzsn/event/service/impl/InformationServiceImpl.java
浏览文件 @
d3cf8d62
...
@@ -209,7 +209,7 @@ public class InformationServiceImpl implements InformationService {
...
@@ -209,7 +209,7 @@ public class InformationServiceImpl implements InformationService {
BeanUtils
.
copyProperties
(
obj
,
copy
);
BeanUtils
.
copyProperties
(
obj
,
copy
);
num
++;
num
++;
copy
.
setIndex
(
num
+
"."
);
copy
.
setIndex
(
num
+
"."
);
copy
.
setTitle
(
StringUtils
.
isNotEmpty
(
copy
.
getTitle
())?
copy
.
getTitle
()
+
"。"
:
""
);
//
copy.setTitle(StringUtils.isNotEmpty(copy.getTitle())?copy.getTitle() + "。":"");
listN
.
add
(
copy
);
listN
.
add
(
copy
);
}
}
HashMap
map
=
new
HashMap
();
HashMap
map
=
new
HashMap
();
...
@@ -220,6 +220,10 @@ public class InformationServiceImpl implements InformationService {
...
@@ -220,6 +220,10 @@ public class InformationServiceImpl implements InformationService {
}
else
{
}
else
{
//不加标签获取列表数据
//不加标签获取列表数据
searchCondition
.
setLabelMark
(
null
);
searchCondition
.
setLabelMark
(
null
);
//中外智库专栏-数据需排序
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getSubjectId
())
&&
searchCondition
.
getSubjectId
().
equals
(
subjectId
)){
searchCondition
.
setColumn
(
"yqgzzk"
);
}
specialInformationIPage
=
esService
.
pageListByCondition
(
searchCondition
,
subjectIdList
);
specialInformationIPage
=
esService
.
pageListByCondition
(
searchCondition
,
subjectIdList
);
long
totalT
=
specialInformationIPage
.
getTotal
();
long
totalT
=
specialInformationIPage
.
getTotal
();
if
(
totalT
>
0
)
{
if
(
totalT
>
0
)
{
...
@@ -237,6 +241,7 @@ public class InformationServiceImpl implements InformationService {
...
@@ -237,6 +241,7 @@ public class InformationServiceImpl implements InformationService {
List
<
LabelModelVo
>
modelVoList
=
modelMap
.
get
(
info
.
getSubjectId
());
List
<
LabelModelVo
>
modelVoList
=
modelMap
.
get
(
info
.
getSubjectId
());
formatLabel
(
modelVoList
,
info
);
formatLabel
(
modelVoList
,
info
);
info
.
setIndex
(
num
+
"."
);
info
.
setIndex
(
num
+
"."
);
// info.setTitle(StringUtils.isNotEmpty(info.getTitle())?info.getTitle() + "。":"");
dataList
.
add
(
info
);
dataList
.
add
(
info
);
}
}
//中外智库专栏-数据需过滤
//中外智库专栏-数据需过滤
...
...
src/main/java/com/zzsn/event/service/impl/SubjectServiceImpl.java
浏览文件 @
d3cf8d62
...
@@ -21,11 +21,10 @@ import com.zzsn.event.enums.BindTypeEnum;
...
@@ -21,11 +21,10 @@ import com.zzsn.event.enums.BindTypeEnum;
import
com.zzsn.event.enums.CodePrefixEnum
;
import
com.zzsn.event.enums.CodePrefixEnum
;
import
com.zzsn.event.enums.SourceTypeEnum
;
import
com.zzsn.event.enums.SourceTypeEnum
;
import
com.zzsn.event.mapper.SubjectMapper
;
import
com.zzsn.event.mapper.SubjectMapper
;
import
com.zzsn.event.permit.ParamAop
;
import
com.zzsn.event.permit.UQueryEntity
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.util.CodeGenerateUtil
;
import
com.zzsn.event.util.*
;
import
com.zzsn.event.util.CronUtil
;
import
com.zzsn.event.util.HttpUtil
;
import
com.zzsn.event.util.RedisUtil
;
import
com.zzsn.event.util.tree.Node
;
import
com.zzsn.event.util.tree.Node
;
import
com.zzsn.event.util.user.UserUtil
;
import
com.zzsn.event.util.user.UserUtil
;
import
com.zzsn.event.util.user.UserVo
;
import
com.zzsn.event.util.user.UserVo
;
...
@@ -41,6 +40,7 @@ import org.springframework.stereotype.Service;
...
@@ -41,6 +40,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
...
@@ -104,7 +104,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
...
@@ -104,7 +104,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
private
InfoSourceGroupService
infoSourceGroupService
;
private
InfoSourceGroupService
infoSourceGroupService
;
@Autowired
@Autowired
private
ISubjectInfoSourceMapService
iSubjectInfoSourceMapService
;
private
ISubjectInfoSourceMapService
iSubjectInfoSourceMapService
;
@Autowired
private
ParamAop
paramAop
;
@Value
(
"${python.subjectProcessorUrl}"
)
@Value
(
"${python.subjectProcessorUrl}"
)
private
String
subjectProcessorUrl
;
private
String
subjectProcessorUrl
;
@Value
(
"${clb.subject.default.processing.advanceMonth}"
)
@Value
(
"${clb.subject.default.processing.advanceMonth}"
)
...
@@ -159,11 +160,28 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
...
@@ -159,11 +160,28 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}
@Override
@Override
public
Page
<
SubjectPage
>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
Integer
pageNo
,
Integer
pageSize
)
{
public
Page
<
SubjectPage
>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
Integer
pageNo
,
Integer
pageSize
,
String
flagCode
,
HttpServletRequest
request
,
String
username
)
{
Integer
facePublic
=
subjectCondition
.
getFacePublic
();
Integer
facePublic
=
subjectCondition
.
getFacePublic
();
Page
<
SubjectPage
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
Page
<
SubjectPage
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
if
(
facePublic
!=
null
&&
facePublic
==
1
)
{
if
(
facePublic
!=
null
&&
facePublic
==
1
)
{
page
=
baseMapper
.
researchCenterFacePageList
(
subjectCondition
,
page
);
//公开的添加数据权限-查询拥有权限的公开专题以及个人创建的公开专题
String
sql
=
""
;
if
(
StringUtils
.
isNotBlank
(
flagCode
)){
String
accesstoken
=
request
.
getHeader
(
"Accesstoken"
);
String
userId
=
TokenUtil
.
verifyToken
(
accesstoken
);
UQueryEntity
queryEntity
=
new
UQueryEntity
();
queryEntity
.
setUserId
(
userId
);
queryEntity
.
setFlagCode
(
flagCode
);
queryEntity
=
paramAop
.
startArs
(
queryEntity
,
accesstoken
,
subjectCondition
.
getEnvironment
());
String
sqlStr
=
queryEntity
.
getSql
();
if
(
sqlStr
.
contains
(
"()"
)){
sqlStr
=
sqlStr
.
replace
(
"()"
,
"(1=2)"
);
}
sql
=
sqlStr
;
log
.
info
(
"researchCenterPageList sql:{}"
,
sql
);
}
log
.
info
(
"researchCenterPageList username:{},environment:{},sql:{}"
,
username
,
subjectCondition
.
getEnvironment
(),
sql
);
page
=
baseMapper
.
researchCenterFacePageList
(
subjectCondition
,
page
,
sql
,
username
);
}
else
{
}
else
{
//查询类别id的所有明细id
//查询类别id的所有明细id
List
<
String
>
typeIds
=
new
ArrayList
<>();
List
<
String
>
typeIds
=
new
ArrayList
<>();
...
@@ -180,9 +198,25 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
...
@@ -180,9 +198,25 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}
@Override
@Override
public
Page
<
Node
>
visiblePageList
(
String
username
,
Integer
type
,
String
subjectName
,
Integer
pageNo
,
Integer
pageSize
,
String
environment
)
{
public
Page
<
Node
>
visiblePageList
(
String
username
,
Integer
type
,
String
subjectName
,
Integer
pageNo
,
Integer
pageSize
,
String
environment
,
HttpServletRequest
request
,
String
flagCode
)
{
Page
<
String
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
Page
<
String
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
return
baseMapper
.
visibleList
(
username
,
type
,
subjectName
,
page
,
environment
);
String
sql
=
""
;
if
(
StringUtils
.
isNotBlank
(
flagCode
)){
String
accesstoken
=
request
.
getHeader
(
"Accesstoken"
);
String
userId
=
TokenUtil
.
verifyToken
(
accesstoken
);
UQueryEntity
queryEntity
=
new
UQueryEntity
();
queryEntity
.
setUserId
(
userId
);
queryEntity
.
setFlagCode
(
flagCode
);
queryEntity
=
paramAop
.
startArs
(
queryEntity
,
accesstoken
,
environment
);
String
sqlStr
=
queryEntity
.
getSql
();
if
(
sqlStr
.
contains
(
"()"
)){
sqlStr
=
sqlStr
.
replace
(
"()"
,
"(1=2)"
);
}
sql
=
sqlStr
;
log
.
info
(
"visiblePageList sql:{}"
,
sql
);
}
log
.
info
(
"visiblePageList username:{},type:{},subjectName:{},environment:{},sql:{}"
,
username
,
type
,
subjectName
,
environment
,
sql
);
return
baseMapper
.
visibleList
(
username
,
type
,
subjectName
,
page
,
environment
,
sql
);
}
}
@Override
@Override
...
...
src/main/java/com/zzsn/event/util/TokenUtil.java
0 → 100644
浏览文件 @
d3cf8d62
package
com
.
zzsn
.
event
.
util
;
import
com.auth0.jwt.JWT
;
import
com.auth0.jwt.JWTVerifier
;
import
com.auth0.jwt.algorithms.Algorithm
;
import
com.auth0.jwt.interfaces.Claim
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* token util
*
* @author yanrj 2018-7-17 13:17:11
*
*/
public
class
TokenUtil
{
/**
* createToken
*
* @param userId
* @return
* @throws Exception
*/
public
static
String
createToken
(
String
userId
,
String
timeStr
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"alg"
,
"HS256"
);
map
.
put
(
"typ"
,
"JWT"
);
map
.
put
(
"timeStr"
,
timeStr
);
String
token
=
JWT
.
create
().
withHeader
(
map
)
// header
.
withClaim
(
"userId"
,
userId
)
// payload
.
withClaim
(
"timeStr"
,
timeStr
)
// payload
.
sign
(
Algorithm
.
HMAC256
(
"secret"
));
return
token
;
}
/**
* verifyToken
*
* @param token
* @return
* @throws Exception
*/
public
static
String
verifyToken
(
String
token
){
JWTVerifier
verifier
=
JWT
.
require
(
Algorithm
.
HMAC256
(
"secret"
)).
build
();
DecodedJWT
jwt
=
verifier
.
verify
(
token
);
Map
<
String
,
Claim
>
claims
=
jwt
.
getClaims
();
return
claims
.
get
(
"userId"
).
asString
();
}
/**
* get token time String
*
* @param token
* @return
* @throws Exception
*/
public
static
String
getTimeStrToken
(
String
token
)
throws
Exception
{
JWTVerifier
verifier
=
JWT
.
require
(
Algorithm
.
HMAC256
(
"secret"
)).
build
();
DecodedJWT
jwt
=
verifier
.
verify
(
token
);
Map
<
String
,
Claim
>
claims
=
jwt
.
getClaims
();
return
claims
.
get
(
"timeStr"
).
asString
();
}
/**
* main
*
* @param args
* @throws Exception
*/
// public static void main(String[] args) throws Exception {
//// Long startTime = System.currentTimeMillis();
// String token = createToken("190","1578276314015");
// System.out.println(token);
//// Long midTime = System.currentTimeMillis();
//// System.out.println(midTime - startTime + "ms");
//// String userId = verifyToken(token);
//// System.out.println(userId);
//// Long endTime = System.currentTimeMillis();
//// System.out.println(endTime - midTime + "ms");
// System.out.println( verifyToken(token) );
// System.out.println( getTimeStrToken(token) );
// }
}
src/main/resources/application-dev.yml
浏览文件 @
d3cf8d62
...
@@ -159,7 +159,7 @@ python:
...
@@ -159,7 +159,7 @@ python:
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
jeecg
:
jeecg
:
shiro
:
shiro
:
excludeUrls
:
/info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign
excludeUrls
:
/info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign
,/subject/manage/visiblePageListNoSign
kafka
:
kafka
:
topic
:
topic
:
...
@@ -183,3 +183,8 @@ caiji:
...
@@ -183,3 +183,8 @@ caiji:
url
:
http://1.95.133.166:8823/baseSourceInfo/api/subject/keywordSave
url
:
http://1.95.133.166:8823/baseSourceInfo/api/subject/keywordSave
projectCode
:
zzsn_prod
projectCode
:
zzsn_prod
projectName
:
克虏宝正式
projectName
:
克虏宝正式
data-permit
:
dataPermitGetQueryEntityTest
:
http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd
:
http://1.95.14.24:8060/
src/main/resources/application-pro.yml
浏览文件 @
d3cf8d62
...
@@ -151,7 +151,7 @@ python:
...
@@ -151,7 +151,7 @@ python:
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
jeecg
:
jeecg
:
shiro
:
shiro
:
excludeUrls
:
excludeUrls
:
/info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign,/subject/manage/visiblePageListNoSign
kafka
:
kafka
:
topic
:
topic
:
subject
:
subject
:
...
@@ -165,4 +165,8 @@ clb:
...
@@ -165,4 +165,8 @@ clb:
subject
:
subject
:
default
:
default
:
processing
:
processing
:
advanceMonth
:
6
advanceMonth
:
6
\ No newline at end of file
data-permit
:
dataPermitGetQueryEntityTest
:
http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd
:
http://1.95.14.24:8060/
\ No newline at end of file
src/main/resources/application-test.yml
浏览文件 @
d3cf8d62
...
@@ -161,7 +161,7 @@ python:
...
@@ -161,7 +161,7 @@ python:
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
clearDuplicateHistoryUrl
:
http://1.95.13.40:8080/subject/delete_history_data
jeecg
:
jeecg
:
shiro
:
shiro
:
excludeUrls
:
info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign
excludeUrls
:
info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign
,/subject/manage/visiblePageListNoSign
kafka
:
kafka
:
topic
:
topic
:
subject
:
subject
:
...
@@ -173,3 +173,7 @@ clb:
...
@@ -173,3 +173,7 @@ clb:
default
:
default
:
processing
:
processing
:
advanceMonth
:
6
advanceMonth
:
6
data-permit
:
dataPermitGetQueryEntityTest
:
http://1.95.77.159:10089/permission/
dataPermitGetQueryEntityProd
:
http://1.95.14.24:8060/
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论