Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
gs1-office-web-sit
Commits
f3cef519
Commit
f3cef519
authored
Dec 28, 2021
by
吴迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增】新增与名配置代码
parent
e099bd1e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
210 additions
and
9 deletions
+210
-9
DomainListController.java
...ffice/modules/manage/controller/DomainListController.java
+42
-0
GLNController.java
...va/io/office/modules/manage/controller/GLNController.java
+17
-3
DomainListProperties.java
...io/office/modules/manage/entity/DomainListProperties.java
+19
-0
DateUtils.java
src/main/java/io/office/modules/manage/utils/DateUtils.java
+15
-0
SearchLimitUtil.java
.../java/io/office/modules/manage/utils/SearchLimitUtil.java
+77
-0
application-dev.yml
src/main/resources/application-dev.yml
+18
-2
application-prod.yml
src/main/resources/application-prod.yml
+10
-2
application-test.yml
src/main/resources/application-test.yml
+12
-2
No files found.
src/main/java/io/office/modules/manage/controller/DomainListController.java
0 → 100644
View file @
f3cef519
package
io
.
office
.
modules
.
manage
.
controller
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.DomainListProperties
;
import
io.office.modules.manage.service.DocService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
/**
* @description:
*
* @author wudi
* @date 10:33 2021/12/28
*/
@Slf4j
@EnableConfigurationProperties
(
DomainListProperties
.
class
)
@RestController
@RequestMapping
(
"/domain"
)
public
class
DomainListController
{
@Autowired
private
DomainListProperties
domainListProperties
;
@RequestMapping
(
"/api/list"
)
// @RequiresPermissions("manage:doc:list")
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
return
R
.
ok
().
put
(
"page"
,
domainListProperties
.
getList
());
}
}
src/main/java/io/office/modules/manage/controller/GLNController.java
View file @
f3cef519
package
io
.
office
.
modules
.
manage
.
controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
io.office.common.utils.IPUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.app.annotation.Login
;
import
io.office.modules.manage.entity.SearchgtinlogEntity
;
import
io.office.modules.manage.service.FirmService
;
import
io.office.modules.manage.service.SearchgtinlogService
;
import
io.office.modules.manage.utils.ESSearchUtils
;
import
io.office.modules.manage.utils.GLNSearchUtils
;
import
io.office.modules.manage.utils.UploadUtils
;
import
io.office.modules.manage.utils.*
;
import
io.office.modules.manage.vo.request.DomesticCodeDetailRequest
;
import
io.office.modules.manage.vo.request.DomesticCodeVo
;
import
io.office.modules.manage.vo.request.GLNRequestBo
;
import
io.office.modules.sys.service.SysCaptchaService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -40,9 +41,14 @@ public class GLNController {
@Autowired
private
FirmService
firmService
;
@Autowired
private
SearchLimitUtil
searchLimitUtil
;
@Login
@PostMapping
(
"/api/gln"
)
public
R
uploadFile
(
@RequestBody
GLNRequestBo
glnRequestBo
,
HttpServletRequest
request
)
{
String
typeKey
=
""
;
boolean
captcha
=
sysCaptchaService
.
validate
(
glnRequestBo
.
getUuid
(),
glnRequestBo
.
getCaptcha
());
if
(!
captcha
){
return
R
.
error
(
"验证码不正确"
);
...
...
@@ -57,6 +63,7 @@ public class GLNController {
// glnRequestBo.setCode("0"+glnRequestBo.getCode());
searchgtinlogEntity
.
setKeyword
(
glnRequestBo
.
getCode
());
searchgtinlogEntity
.
setClassStr
(
"GLN查询"
);
typeKey
=
"GLN查询"
;
}
else
if
(
glnRequestBo
.
getType
().
equals
(
"GTIN"
)){
if
(
glnRequestBo
.
getCode
().
length
()<
12
)
{
return
R
.
error
(
"GTIN不能少于12位!"
);
...
...
@@ -68,6 +75,13 @@ public class GLNController {
glnRequestBo
.
setCode
(
"0"
+
glnRequestBo
.
getCode
());
}
searchgtinlogEntity
.
setClassStr
(
"境外条码查询:厂商信息查询"
);
typeKey
=
"境外条码查询:厂商信息查询"
;
}
//校验是否开启
String
searchLimitStr
=
searchLimitUtil
.
checkSearchLimit
(
request
,
typeKey
);
if
(
StringUtils
.
isNotBlank
(
searchLimitStr
))
{
return
R
.
error
(
searchLimitStr
);
}
searchgtinlogEntity
.
setKeyword
(
glnRequestBo
.
getCode
());
searchgtinlogEntity
.
setSearchsource
(
0
);
...
...
src/main/java/io/office/modules/manage/entity/DomainListProperties.java
0 → 100644
View file @
f3cef519
package
io
.
office
.
modules
.
manage
.
entity
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
java.util.List
;
/**
*
* @description:
*
* @author wudi
* @date 10:40 2021/12/28
*/
@Data
@ConfigurationProperties
(
prefix
=
"gs1.domain"
)
//指定ly.upload开头的变量
public
class
DomainListProperties
{
private
List
<
String
>
list
;
}
src/main/java/io/office/modules/manage/utils/DateUtils.java
View file @
f3cef519
...
...
@@ -255,6 +255,21 @@ public class DateUtils {
/**
* 得到n秒之后之后的日期
*/
public
static
String
getAfterSecondCycleByHour
(
Date
date
,
String
second
)
{
int
daysInt
=
Integer
.
parseInt
(
second
);
Calendar
canlendar
=
Calendar
.
getInstance
();
canlendar
.
setTime
(
date
);
canlendar
.
add
(
Calendar
.
SECOND
,
daysInt
);
SimpleDateFormat
sdfd
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateStr
=
sdfd
.
format
(
canlendar
.
getTime
());
return
dateStr
;
}
/**
* 得到n小时之后的日期
*/
public
static
String
getAfterMinCycleByHour
(
Date
date
,
String
mins
)
{
...
...
src/main/java/io/office/modules/manage/utils/SearchLimitUtil.java
0 → 100644
View file @
f3cef519
package
io
.
office
.
modules
.
manage
.
utils
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
io.office.common.utils.IPUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.SearchgtinlogEntity
;
import
io.office.modules.manage.service.SearchgtinlogService
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
/**
* @description:
*
* @author wudi
* @date 14:45 2021/12/27
* <p>
* #是否开启查询限制 1 打开 0关闭
* searchLimitSwitch: 1
* #是否开启每次查询次数限制 1 打开 0关闭
* searchDayLimitSwitch: 1
* #查询次数限制上限
* searchDayCountLimitSwitch: 10
*/
@Component
public
class
SearchLimitUtil
{
@Value
(
"${searchLimitSwitch}"
)
private
String
searchLimitSwitch
;
@Value
(
"${searchDayLimitSwitch}"
)
private
String
searchDayLimitSwitch
;
@Value
(
"${searchDayCountLimitSwitch}"
)
private
String
searchDayCountLimitSwitch
;
@Resource
private
SearchgtinlogService
searchgtinlogService
;
public
String
checkSearchLimit
(
HttpServletRequest
request
,
String
typeKeyWord
)
{
if
(
StringUtils
.
isNotBlank
(
searchLimitSwitch
)
&&
searchLimitSwitch
.
equalsIgnoreCase
(
"1"
))
{
Date
date
=
new
Date
();
String
ip
=
IPUtils
.
getIpAddr
(
request
);
//查询最后查询的时间
QueryWrapper
<
SearchgtinlogEntity
>
searchgtinlogEntityQueryWrapper
=
new
QueryWrapper
<>();
searchgtinlogEntityQueryWrapper
.
eq
(
"ip"
,
ip
);
searchgtinlogEntityQueryWrapper
.
eq
(
"keyword"
,
typeKeyWord
);
searchgtinlogEntityQueryWrapper
.
between
(
"createdate"
,
DateUtils
.
getAfterSecondCycleByHour
(
date
,
"-5"
),
DateUtils
.
formatDateToString
(
date
,
DateUtils
.
FORMAT1
));
int
count
=
searchgtinlogService
.
count
(
searchgtinlogEntityQueryWrapper
);
if
(
count
>=
1
)
{
return
"搜索频率过于频繁,请5s后重试!"
;
}
//是否开启当日查询次数限制
if
(
StringUtils
.
isNotBlank
(
searchDayLimitSwitch
)
&&
searchDayLimitSwitch
.
equalsIgnoreCase
(
"1"
))
{
if
(
StringUtils
.
isNotBlank
(
searchDayCountLimitSwitch
))
{
QueryWrapper
<
SearchgtinlogEntity
>
searchgtinlogEntityIpQueryWrapper
=
new
QueryWrapper
<>();
searchgtinlogEntityIpQueryWrapper
.
eq
(
"ip"
,
ip
);
searchgtinlogEntityQueryWrapper
.
eq
(
"keyword"
,
typeKeyWord
);
searchgtinlogEntityIpQueryWrapper
.
between
(
"createdate"
,
DateUtils
.
getDayStartTime
(
date
),
DateUtils
.
getDayEndTime
(
date
));
int
countIp
=
searchgtinlogService
.
count
(
searchgtinlogEntityIpQueryWrapper
);
if
(
countIp
>=
Integer
.
parseInt
(
searchDayCountLimitSwitch
))
{
return
"今日搜索次数已达到上限,请明天再查询!"
;
}
}
}
}
return
null
;
}
}
src/main/resources/application-dev.yml
View file @
f3cef519
...
...
@@ -74,4 +74,21 @@ file:
prefix
:
http://81.68.189.225:9091/office/uploadFileResource/
ueditorSavePath
:
/uploadFileResource/
prefix_host
:
http://81.68.189.225:9091/office/
\ No newline at end of file
prefix_host
:
http://81.68.189.225:9091/office/
#是否开启查询限制 1 打开 0关闭
searchLimitSwitch
:
1
#是否开启每次查询次数限制 1 打开 0关闭
searchDayLimitSwitch
:
1
#查询次数限制上限
searchDayCountLimitSwitch
:
10
#域名
gs1
:
domain
:
list
:
-
http://81.68.189.225
-
http://81.68.189.225
src/main/resources/application-prod.yml
View file @
f3cef519
...
...
@@ -46,4 +46,12 @@ spring:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/renren_security
# username: renren
# password: 123456
\ No newline at end of file
# password: 123456
#域名
gs1
:
domain
:
list
:
-
http://www.gs1cn.orgc
-
http://www.ancc.org.cn
\ No newline at end of file
src/main/resources/application-test.yml
View file @
f3cef519
...
...
@@ -74,4 +74,14 @@ file:
prefix
:
http://192.168.0.77:9091/office/uploadFileResource/
ueditorSavePath
:
D:/uploadFileResource/
prefix_host
:
http://192.168.0.77:9091/office/
\ No newline at end of file
prefix_host
:
http://192.168.0.77:9091/office/
#是否开启查询限制 1 打开 0关闭
searchLimitSwitch
:
1
#域名
gs1
:
domain
:
list
:
-
http://192.168.0.77
-
http://192.168.0.77
\ No newline at end of file
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