Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
f62f2c48
Commit
f62f2c48
authored
Aug 18, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片审核表修改
parent
ead3fd2d
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
190 additions
and
18 deletions
+190
-18
OSSCheckExtras.java
...ava/com/tanpu/community/api/beans/req/OSSCheckExtras.java
+17
-0
OSSCheckReq.java
...n/java/com/tanpu/community/api/beans/req/OSSCheckReq.java
+3
-2
OSSCheckResult.java
...ava/com/tanpu/community/api/beans/req/OSSCheckResult.java
+18
-0
OSSCheckScanResult.java
...com/tanpu/community/api/beans/req/OSSCheckScanResult.java
+22
-0
FileChechStatusEnum.java
...va/com/tanpu/community/api/enums/FileChechStatusEnum.java
+40
-0
CallBackController.java
...va/com/tanpu/community/controller/CallBackController.java
+26
-4
CodeAutoGenerator.java
.../main/java/com/tanpu/community/dao/CodeAutoGenerator.java
+1
-1
FileRecordEntity.java
...anpu/community/dao/entity/community/FileRecordEntity.java
+30
-7
FileRecordMapper.java
...anpu/community/dao/mapper/community/FileRecordMapper.java
+1
-1
FileManager.java
...rc/main/java/com/tanpu/community/manager/FileManager.java
+17
-1
OSSFileService.java
...main/java/com/tanpu/community/service/OSSFileService.java
+13
-2
FileRecordEntityMapper.xml
...ain/resources/mapper/community/FileRecordEntityMapper.xml
+2
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckExtras.java
0 → 100644
View file @
f62f2c48
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckExtras
{
private
String
sexRate
;
private
String
normRate
;
private
String
pornRate
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckReq.java
View file @
f62f2c48
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
com.google.gson.JsonObject
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -16,6 +17,6 @@ public class OSSCheckReq {
...
@@ -16,6 +17,6 @@ public class OSSCheckReq {
private
boolean
stock
;
private
boolean
stock
;
private
String
region
;
private
String
region
;
private
String
freezed
;
private
String
freezed
;
private
String
scanResult
;
private
JsonObject
scanResult
;
private
String
auditResult
;
private
JsonObject
auditResult
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckResult.java
0 → 100644
View file @
f62f2c48
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckResult
{
private
String
label
;
private
double
rate
;
private
String
scene
;
private
String
suggestion
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckScanResult.java
0 → 100644
View file @
f62f2c48
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckScanResult
{
private
String
code
;
private
String
dataId
;
private
OSSCheckExtras
extras
;
private
String
msg
;
private
List
<
OSSCheckResult
>
results
;
private
String
taskId
;
}
community-api/src/main/java/com/tanpu/community/api/enums/FileChechStatusEnum.java
0 → 100644
View file @
f62f2c48
package
com
.
tanpu
.
community
.
api
.
enums
;
import
org.apache.commons.collections4.SetUtils
;
import
java.util.HashSet
;
public
enum
FileChechStatusEnum
{
INIT
(
0
,
"初始化"
),
PASS
(
1
,
"审核通过"
),
NOT_PASS
(
2
,
"审核不通过"
);
public
static
final
HashSet
<
String
>
ossTypeSet
=
SetUtils
.
hashSet
(
"jpg"
,
"jpeg"
,
"png"
,
"txt"
);
private
Integer
code
;
private
String
type
;
FileChechStatusEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
community-service/src/main/java/com/tanpu/community/controller/CallBackController.java
View file @
f62f2c48
package
com
.
tanpu
.
community
.
controller
;
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.manager.FileManager
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -14,16 +18,34 @@ import java.util.Map;
...
@@ -14,16 +18,34 @@ import java.util.Map;
@RequestMapping
(
value
=
"/api"
)
@RequestMapping
(
value
=
"/api"
)
public
class
CallBackController
{
public
class
CallBackController
{
@Autowired
private
FileManager
fileManager
;
/**
* 阿里云图片审核回调接口
* 回调时间:6秒以内
* 文档地址:https://help.aliyun.com/document_detail/129946.html?spm=a2c4g.11186623.6.562.19a05f3aNkd2Oo#table-s9e-grd-408
* @param checksum
* @param content
* @return
*/
@ApiOperation
(
"oss图片审核回调"
)
@ApiOperation
(
"oss图片审核回调"
)
@PostMapping
(
value
=
"/picCheck/callback"
)
@PostMapping
(
value
=
"/picCheck/callback"
)
public
String
picCheck
(
String
checksum
,
String
content
)
{
public
String
picCheck
(
String
checksum
,
String
content
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
log
.
info
(
"params:{}"
,
checksum
);
log
.
info
(
"checksum:{}"
,
checksum
);
log
.
info
(
"content:{}"
,
content
);
Map
<
String
,
Object
>
response
=
JsonUtil
.
toMap
(
content
);
String
fileKey
=
(
String
)
response
.
get
(
"object"
);
boolean
freezed
=
(
boolean
)
response
.
get
(
"freezed"
);
HashMap
<
String
,
Object
>
scanResult
=
(
HashMap
<
String
,
Object
>)
response
.
get
(
"scanResult"
);
String
taskId
=
(
String
)
scanResult
.
get
(
"taskId"
);
fileManager
.
updateCheckResult
(
fileKey
,
freezed
,
taskId
);
return
"success"
;
return
"success"
;
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
new
Date
());
}
}
}
community-service/src/main/java/com/tanpu/community/dao/CodeAutoGenerator.java
View file @
f62f2c48
...
@@ -23,7 +23,7 @@ public class CodeAutoGenerator {
...
@@ -23,7 +23,7 @@ public class CodeAutoGenerator {
String
mysqlPassword
=
"@imeng123"
;
String
mysqlPassword
=
"@imeng123"
;
String
jdbcUrl
=
"jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community"
;
String
jdbcUrl
=
"jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community"
;
// String[] tables = new String[]{"theme"};
// String[] tables = new String[]{"theme"};
String
[]
tables
=
new
String
[]{
"
notification
"
};
String
[]
tables
=
new
String
[]{
"
file_record
"
};
String
basePackage
=
"com.tanpu.community"
;
String
basePackage
=
"com.tanpu.community"
;
String
mapperPackage
=
"dao.mapper.community"
;
String
mapperPackage
=
"dao.mapper.community"
;
String
entityPackage
=
"dao.entity.community"
;
String
entityPackage
=
"dao.entity.community"
;
...
...
community-service/src/main/java/com/tanpu/community/dao/entity/community/FileRecordEntity.java
View file @
f62f2c48
...
@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
...
@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
* </p>
* </p>
*
*
* @author xudong
* @author xudong
* @since 2021-0
7-12
* @since 2021-0
8-18
*/
*/
@TableName
(
"file_record"
)
@TableName
(
"file_record"
)
@Builder
@Builder
...
@@ -31,9 +31,9 @@ public class FileRecordEntity implements Serializable {
...
@@ -31,9 +31,9 @@ public class FileRecordEntity implements Serializable {
@ApiModelProperty
(
value
=
"id"
)
@ApiModelProperty
(
value
=
"id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"文件Id"
)
@ApiModelProperty
(
value
=
"文件
主键
Id"
)
private
String
fileId
;
private
String
fileId
;
@ApiModelProperty
(
value
=
"类型:1:图片"
)
@ApiModelProperty
(
value
=
"类型:1:图片"
)
...
@@ -45,7 +45,7 @@ public class FileRecordEntity implements Serializable {
...
@@ -45,7 +45,7 @@ public class FileRecordEntity implements Serializable {
@ApiModelProperty
(
value
=
"阿里云key"
)
@ApiModelProperty
(
value
=
"阿里云key"
)
private
String
fileOssKey
;
private
String
fileOssKey
;
@ApiModelProperty
(
value
=
"预览url"
)
@ApiModelProperty
(
value
=
"预
签名预
览url"
)
private
String
previewUrl
;
private
String
previewUrl
;
private
LocalDateTime
createTime
;
private
LocalDateTime
createTime
;
...
@@ -56,16 +56,21 @@ public class FileRecordEntity implements Serializable {
...
@@ -56,16 +56,21 @@ public class FileRecordEntity implements Serializable {
private
String
extInfo
;
private
String
extInfo
;
@ApiModelProperty
(
value
=
"审核状态 0:初试化 1:通过 2:不通过"
)
private
Integer
checkStatus
;
@ApiModelProperty
(
value
=
"阿里云校验任务id(用于同步查询结果)"
)
private
String
checkTaskId
;
public
String
getUrl
(){
public
String
getUrl
(){
return
getPreviewUrl
().
substring
(
0
,
getPreviewUrl
().
indexOf
(
"?"
));
return
getPreviewUrl
().
substring
(
0
,
getPreviewUrl
().
indexOf
(
"?"
));
}
}
public
Long
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Integer
id
)
{
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
@@ -141,6 +146,22 @@ public class FileRecordEntity implements Serializable {
...
@@ -141,6 +146,22 @@ public class FileRecordEntity implements Serializable {
this
.
extInfo
=
extInfo
;
this
.
extInfo
=
extInfo
;
}
}
public
Integer
getCheckStatus
()
{
return
checkStatus
;
}
public
void
setCheckStatus
(
Integer
checkStatus
)
{
this
.
checkStatus
=
checkStatus
;
}
public
String
getCheckTaskId
()
{
return
checkTaskId
;
}
public
void
setCheckTaskId
(
String
checkTaskId
)
{
this
.
checkTaskId
=
checkTaskId
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"FileRecordEntity{"
+
return
"FileRecordEntity{"
+
...
@@ -154,6 +175,8 @@ public class FileRecordEntity implements Serializable {
...
@@ -154,6 +175,8 @@ public class FileRecordEntity implements Serializable {
", updateTime="
+
updateTime
+
", updateTime="
+
updateTime
+
", deleteTag="
+
deleteTag
+
", deleteTag="
+
deleteTag
+
", extInfo="
+
extInfo
+
", extInfo="
+
extInfo
+
", checkStatus="
+
checkStatus
+
", checkTaskId="
+
checkTaskId
+
"}"
;
"}"
;
}
}
}
}
community-service/src/main/java/com/tanpu/community/dao/mapper/community/FileRecordMapper.java
View file @
f62f2c48
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
* </p>
*
*
* @author xudong
* @author xudong
* @since 2021-0
7-07
* @since 2021-0
8-18
*/
*/
public
interface
FileRecordMapper
extends
BaseMapper
<
FileRecordEntity
>
{
public
interface
FileRecordMapper
extends
BaseMapper
<
FileRecordEntity
>
{
...
...
community-service/src/main/java/com/tanpu/community/manager/FileManager.java
View file @
f62f2c48
...
@@ -10,7 +10,6 @@ import com.tanpu.community.util.ConvertUtil;
...
@@ -10,7 +10,6 @@ import com.tanpu.community.util.ConvertUtil;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -61,4 +60,21 @@ public class FileManager {
...
@@ -61,4 +60,21 @@ public class FileManager {
.
collect
(
Collectors
.
toMap
(
FileRecordEntity:
:
getFileId
,
FileRecordEntity:
:
getUrl
));
.
collect
(
Collectors
.
toMap
(
FileRecordEntity:
:
getFileId
,
FileRecordEntity:
:
getUrl
));
}
}
public
void
updateCheckResult
(
String
fileKey
,
boolean
check
,
String
taskId
)
{
FileRecordEntity
fileRecordEntity
=
ossFileService
.
queryByOssKey
(
fileKey
);
if
(
fileRecordEntity
==
null
){
throw
new
BizException
(
"图片未找到:"
+
fileKey
);
}
if
(
check
){
// 审核失败
fileRecordEntity
.
setCheckStatus
(
2
);
}
else
{
// 审核通过
fileRecordEntity
.
setCheckStatus
(
1
);
}
fileRecordEntity
.
setCheckTaskId
(
taskId
);
ossFileService
.
update
(
fileRecordEntity
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/OSSFileService.java
View file @
f62f2c48
...
@@ -134,8 +134,9 @@ public class OSSFileService {
...
@@ -134,8 +134,9 @@ public class OSSFileService {
.
in
(
FileRecordEntity:
:
getFileId
,
fileIds
));
.
in
(
FileRecordEntity:
:
getFileId
,
fileIds
));
}
}
// 同步查询,使用taskId,且1/24小时内才能查询
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shanghai"
,
"请填写您的accessKeyId"
,
"请填写您的accessKeySecret
"
);
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shanghai"
,
"LTAIAKEzVydP0Q9P"
,
"59V9ke9txaIFzWxHFKTb1eoOOpmKpJ
"
);
DefaultProfile
.
addEndpoint
(
"cn-shanghai"
,
"cn-shanghai"
,
"Green"
,
"green.cn-shanghai.aliyuncs.com"
);
DefaultProfile
.
addEndpoint
(
"cn-shanghai"
,
"cn-shanghai"
,
"Green"
,
"green.cn-shanghai.aliyuncs.com"
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
...
@@ -150,7 +151,7 @@ public class OSSFileService {
...
@@ -150,7 +151,7 @@ public class OSSFileService {
List
<
String
>
taskIds
=
new
ArrayList
<
String
>();
List
<
String
>
taskIds
=
new
ArrayList
<
String
>();
taskIds
.
add
(
"img
4hDosCHcrFk5jAMR80XWJN-1pZ@0p
"
);
taskIds
.
add
(
"img
5B0C6GGD4uq41U3aPy6qpD-1uRam9
"
);
imageAsyncScanResultsRequest
.
setHttpContent
(
JSON
.
toJSONString
(
taskIds
).
getBytes
(
"UTF-8"
),
"UTF-8"
,
FormatType
.
JSON
);
imageAsyncScanResultsRequest
.
setHttpContent
(
JSON
.
toJSONString
(
taskIds
).
getBytes
(
"UTF-8"
),
"UTF-8"
,
FormatType
.
JSON
);
/**
/**
...
@@ -194,4 +195,14 @@ public class OSSFileService {
...
@@ -194,4 +195,14 @@ public class OSSFileService {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
public
FileRecordEntity
queryByOssKey
(
String
fileKey
)
{
return
fileRecordMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FileRecordEntity
>().
eq
(
FileRecordEntity:
:
getFileOssKey
,
fileKey
));
}
public
void
update
(
FileRecordEntity
fileRecordEntity
)
{
fileRecordMapper
.
updateById
(
fileRecordEntity
);
}
}
}
community-service/src/main/resources/mapper/community/FileRecordEntityMapper.xml
View file @
f62f2c48
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
<result
column=
"ext_info"
property=
"extInfo"
/>
<result
column=
"ext_info"
property=
"extInfo"
/>
<result
column=
"check_status"
property=
"checkStatus"
/>
<result
column=
"check_task_id"
property=
"checkTaskId"
/>
</resultMap>
</resultMap>
</mapper>
</mapper>
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