Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-analysis
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.online.exam
pica-cloud-analysis
提交
11a83a6c
提交
11a83a6c
编写于
6月 28, 2020
作者:
minghao.wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 去除token的校验
上级
4d1d73d6
流水线
#30915
已通过 于阶段
in 4 minute 和 18 second
变更
7
流水线
2
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
54 行增加
和
169 行删除
+54
-169
pom.xml
server/pom.xml
+1
-1
IOnlineExamServiceClient.java
...exam/analysis/server/client/IOnlineExamServiceClient.java
+0
-25
OnlineExamServiceClient.java
.../analysis/server/client/impl/OnlineExamServiceClient.java
+0
-16
AntiSpamController.java
...e/exam/analysis/server/controller/AntiSpamController.java
+11
-6
RedisTestController.java
.../exam/analysis/server/controller/RedisTestController.java
+0
-92
TestController.java
...nline/exam/analysis/server/controller/TestController.java
+0
-29
LoginUtil.java
...ca/cloud/online/exam/analysis/server/utils/LoginUtil.java
+42
-0
未找到文件。
server/pom.xml
浏览文件 @
11a83a6c
...
...
@@ -109,7 +109,7 @@
<dependency>
<groupId>
com.pica.cloud.foundation
</groupId>
<artifactId>
pica-cloud-redis
</artifactId>
<version>
1.
3.2
</version>
<version>
1.
2.6-SNAPSHOT
</version>
</dependency>
<dependency>
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/client/IOnlineExamServiceClient.java
已删除
100644 → 0
浏览文件 @
4d1d73d6
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
client
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author wuminghao
* @date 2018/9/30 10:01
*/
@FeignClient
(
value
=
"10901-PICA-CLOUD-ONLINEEXAM"
)
public
interface
IOnlineExamServiceClient
{
/**
* 调用
* @param onlineExamId
* @param sysCode
* @param token
* @return
*/
@RequestMapping
(
value
=
"/onlineexam/getExamStatus"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
String
getExamStatus
(
@RequestParam
(
value
=
"onlineExamId"
)
Integer
onlineExamId
,
@RequestParam
(
value
=
"code"
)
Integer
code
,
@RequestHeader
(
value
=
"sysCode"
)
String
sysCode
,
@RequestHeader
(
value
=
"token"
)
String
token
);
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/client/impl/OnlineExamServiceClient.java
已删除
100644 → 0
浏览文件 @
4d1d73d6
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
client
.
impl
;
import
com.pica.cloud.online.exam.analysis.server.client.IOnlineExamServiceClient
;
import
org.springframework.stereotype.Component
;
/**
* @author wuminghao
* @date 2018/9/30 10:22
*/
@Component
public
class
OnlineExamServiceClient
implements
IOnlineExamServiceClient
{
@Override
public
String
getExamStatus
(
Integer
onlineExamId
,
Integer
code
,
String
sysCode
,
String
token
)
{
return
""
;
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AntiSpamController.java
浏览文件 @
11a83a6c
...
...
@@ -11,6 +11,7 @@ import com.pica.cloud.online.exam.analysis.common.util.ReturnUtil;
import
com.pica.cloud.online.exam.analysis.server.configuration.SpringContextAware
;
import
com.pica.cloud.online.exam.analysis.server.constants.RedisKey
;
import
com.pica.cloud.online.exam.analysis.server.service.AntiSpamService
;
import
com.pica.cloud.online.exam.analysis.server.utils.LoginUtil
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.tuple.Pair
;
...
...
@@ -31,7 +32,10 @@ public class AntiSpamController extends BaseController {
private
SpringContextAware
springContextAware
;
@Autowired
AntiSpamService
antiSpamService
;
private
AntiSpamService
antiSpamService
;
@Autowired
private
LoginUtil
loginUtil
;
@LoginPermission
@ApiOperation
(
value
=
"内容检测"
,
response
=
PicaResponse
.
class
)
...
...
@@ -47,14 +51,14 @@ public class AntiSpamController extends BaseController {
}
}
PicaUser
user
=
fetchPica
User
();
PicaUser
user
=
loginUtil
.
getCurrent
User
();
Pair
<
String
,
Integer
>
params
;
try
{
params
=
parseContentAndType
(
content
);
}
catch
(
Exception
e
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
return
antiSpamService
.
processString
(
user
.
getId
()
,
sysCode
,
params
.
getLeft
(),
params
.
getRight
()
!=
0
);
return
antiSpamService
.
processString
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
params
.
getLeft
(),
params
.
getRight
()
!=
0
);
}
@LoginPermission
...
...
@@ -82,7 +86,8 @@ public class AntiSpamController extends BaseController {
return
PicaResponse
.
toResponse
(
""
);
}
}
PicaUser
user
=
fetchPicaUser
();
PicaUser
user
=
loginUtil
.
getCurrentUser
();
Pair
<
String
,
Integer
>
params
;
try
{
params
=
parseContentAndType
(
content
);
...
...
@@ -109,7 +114,7 @@ public class AntiSpamController extends BaseController {
}
}
PicaUser
user
=
fetchPica
User
();
PicaUser
user
=
loginUtil
.
getCurrent
User
();
StringBuilder
sbContent
=
new
StringBuilder
();
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
...
...
@@ -118,7 +123,7 @@ public class AntiSpamController extends BaseController {
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
if
(!
antiSpamService
.
processImageContent
(
user
.
getId
()
,
sysCode
,
sbContent
.
toString
()))
{
if
(!
antiSpamService
.
processImageContent
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
sbContent
.
toString
()))
{
return
ReturnUtil
.
getPicaResponse
(
"400002"
,
"图片包含违禁内容,请修改后重新输入"
,
""
);
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/RedisTestController.java
已删除
100644 → 0
浏览文件 @
4d1d73d6
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.annotation.LoginPermission
;
import
com.pica.cloud.foundation.utils.controller.BaseController
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisSentinelPool
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
@RestController
public
class
RedisTestController
extends
BaseController
{
@Autowired
private
ICacheClient
cacheClient
;
@RequestMapping
(
value
=
"/redis"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@LoginPermission
public
PicaResponse
<
Map
<
String
,
String
>>
redis
()
{
// http://localhost:11501/hospital/hospitals/redis
// cluster
String
token
=
getToken
();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
"1111111"
);
map
.
put
(
"token"
,
getToken
());
map
.
put
(
"sysCode"
,
getSysCode
());
try
{
token
=
cacheClient
.
saveToken
(
map
,
3600
);
}
catch
(
Exception
ex
)
{
// nothing to do
}
System
.
out
.
println
(
token
);
Map
<
String
,
String
>
map1
=
cacheClient
.
getToken
(
token
);
System
.
out
.
println
(
JSON
.
toJSON
(
map1
));
PicaUser
user
=
fetchPicaUser
();
System
.
out
.
println
(
JSON
.
toJSON
(
user
));
// sentinel
Set
<
String
>
set1
=
new
HashSet
<>();
set1
.
add
(
"192.168.140.27:17000"
);
set1
.
add
(
"192.168.140.28:17000"
);
set1
.
add
(
"192.168.140.29:17000"
);
JedisSentinelPool
pool1
=
new
JedisSentinelPool
(
"master01"
,
set1
,
"Uu49Kz1olY85HQBu"
);
Jedis
jedis1
=
pool1
.
getResource
();
System
.
out
.
println
(
"sentinel dev - "
+
jedis1
.
get
(
"token-"
+
token
));
Set
<
String
>
set2
=
new
HashSet
<>();
set2
.
add
(
"192.168.110.68:17000"
);
set2
.
add
(
"192.168.110.69:17001"
);
set2
.
add
(
"192.168.110.70:17002"
);
JedisSentinelPool
pool2
=
new
JedisSentinelPool
(
"master01"
,
set2
,
"Uu49Kz1olY85HQBu"
);
Jedis
jedis2
=
pool2
.
getResource
();
System
.
out
.
println
(
"sentinel test - "
+
jedis2
.
get
(
"token-"
+
token
));
Set
<
String
>
set3
=
new
HashSet
<>();
set3
.
add
(
"192.168.110.177:17000"
);
set3
.
add
(
"192.168.110.178:17000"
);
set3
.
add
(
"192.168.110.179:17000"
);
JedisSentinelPool
pool3
=
new
JedisSentinelPool
(
"master01"
,
set3
,
"Uu49Kz1olY85HQBu"
);
Jedis
jedis3
=
pool3
.
getResource
();
System
.
out
.
println
(
"sentinel uat - "
+
jedis3
.
get
(
"token-"
+
token
));
cacheClient
.
deleteToken
(
token
);
try
{
PicaUser
user1
=
fetchPicaUser
();
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
"Exception -> the user has been deleted"
);
}
Map
<
String
,
String
>
map2
=
new
HashMap
<>();
map2
.
put
(
"id"
,
"1111111"
);
map2
.
put
(
"token"
,
getToken
());
map2
.
put
(
"sysCode"
,
getSysCode
());
try
{
token
=
cacheClient
.
saveToken
(
map2
,
3600
);
}
catch
(
Exception
ex
)
{
// nothing to do
}
return
PicaResponse
.
toResponse
(
token
);
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/TestController.java
已删除
100644 → 0
浏览文件 @
4d1d73d6
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
controller
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.online.exam.analysis.server.client.IOnlineExamServiceClient
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author wuminghao
* @date 2018/9/30 9:58
*/
@RestController
@RequestMapping
(
"/onlineexam"
)
@Api
(
value
=
"服务调用"
,
description
=
"测试"
)
public
class
TestController
{
@Autowired
private
IOnlineExamServiceClient
onlineExamServiceClient
;
@ApiOperation
(
value
=
"获取考试状态"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/getExamStatus"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
String
getExamStatus
(
@RequestHeader
String
token
)
{
return
onlineExamServiceClient
.
getExamStatus
(
1
,
1
,
"27"
,
token
);
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/utils/LoginUtil.java
0 → 100644
浏览文件 @
11a83a6c
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
utils
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
/**
* @author wuminghao
* @date 2020/6/28 15:35
*/
@Component
public
class
LoginUtil
{
public
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginUtil
.
class
);
@Autowired
private
ICacheClient
cacheClient
;
public
PicaUser
getCurrentUser
()
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
();
String
token
=
servletRequestAttributes
.
getRequest
().
getHeader
(
"token"
);
if
(
StringUtils
.
isEmpty
(
token
))
{
return
null
;
}
else
{
return
cacheClient
.
getToken
(
token
,
PicaUser
.
class
);
}
}
public
PicaUser
getCurrentUserByToken
(
String
token
)
{
if
(
StringUtils
.
isEmpty
(
token
))
{
return
null
;
}
else
{
return
cacheClient
.
getToken
(
token
,
PicaUser
.
class
);
}
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录