Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tea_resource_api
Project
Project
Details
Activity
Releases
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
高宇
tea_resource_api
Commits
bf5435fe
Commit
bf5435fe
authored
Mar 11, 2025
by
Zachary
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(测试IP):测试国别
parent
1c076006
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
249 additions
and
4 deletions
+249
-4
pom.xml
pom.xml
+6
-1
Alibaba-PuHuiTi-Bold.ttf
...n/java/org/rcisoft/business/test/Alibaba-PuHuiTi-Bold.ttf
+0
-0
CertificateGenerator.java
.../java/org/rcisoft/business/test/CertificateGenerator.java
+38
-0
TestController.java
.../org/rcisoft/business/test/controller/TestController.java
+86
-0
TestRepository.java
...in/java/org/rcisoft/business/test/dao/TestRepository.java
+15
-0
TestData.java
src/main/java/org/rcisoft/business/test/entity/TestData.java
+10
-0
GeoIpTest.java
src/main/java/org/rcisoft/business/test/geoip/GeoIpTest.java
+25
-0
TestService.java
...n/java/org/rcisoft/business/test/service/TestService.java
+15
-0
TestServiceImpl.java
...g/rcisoft/business/test/service/impl/TestServiceImpl.java
+43
-0
temp.jpg
src/main/java/org/rcisoft/business/test/temp.jpg
+0
-0
template.jpg
src/main/java/org/rcisoft/business/test/template.jpg
+0
-0
application-conf-dev.yml
src/main/resources/application-conf-dev.yml
+10
-3
GeoLite2-Country.mmdb
src/main/resources/geoip/GeoLite2-Country.mmdb
+0
-0
BLessonMapper.xml
...esources/mapper/business/blesson/mapper/BLessonMapper.xml
+1
-0
No files found.
pom.xml
View file @
bf5435fe
...
@@ -80,7 +80,11 @@
...
@@ -80,7 +80,11 @@
<artifactId>
protobuf-java
</artifactId>
<artifactId>
protobuf-java
</artifactId>
<version>
3.5.1
</version>
<version>
3.5.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.maxmind.geoip2
</groupId>
<artifactId>
geoip2
</artifactId>
<version>
4.2.1
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -124,6 +128,7 @@
...
@@ -124,6 +128,7 @@
</build>
</build>
<repositories>
<repositories>
<repository>
<repository>
<id>
nexus-91isoft-release
</id>
<id>
nexus-91isoft-release
</id>
<name>
local release nexus
</name>
<name>
local release nexus
</name>
...
...
src/main/java/org/rcisoft/business/test/Alibaba-PuHuiTi-Bold.ttf
0 → 100644
View file @
bf5435fe
File added
src/main/java/org/rcisoft/business/test/CertificateGenerator.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
public
class
CertificateGenerator
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 1. 加载模板
BufferedImage
template
=
ImageIO
.
read
(
new
File
(
"D:\\All_Server_Projects\\91soft\\tea\\tea_resource_api\\src\\main\\java\\org\\rcisoft\\business\\test\\temp.jpg"
));
BufferedImage
certificate
=
new
BufferedImage
(
template
.
getWidth
(),
template
.
getHeight
(),
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
g
=
certificate
.
createGraphics
();
g
.
drawImage
(
template
,
0
,
0
,
null
);
// 2. 设置字体(支持中文)
Font
font
=
Font
.
createFont
(
Font
.
TRUETYPE_FONT
,
new
File
(
"D:\\All_Server_Projects\\91soft\\tea\\tea_resource_api\\src\\main\\java\\org\\rcisoft\\business\\test\\Alibaba-PuHuiTi-Bold.ttf"
)).
deriveFont
(
100
f
);
g
.
setFont
(
font
);
g
.
setColor
(
new
Color
(
49
,
145
,
184
));
// 3. 动态绘制数据
String
name
=
"徐豪泽"
;
String
score
=
"100分"
;
FontMetrics
metrics
=
g
.
getFontMetrics
();
int
x
=
(
certificate
.
getWidth
()
-
metrics
.
stringWidth
(
name
))
/
2
;
// 水平居中
int
y
=
700
;
// 垂直位置(需根据模板调整)
g
.
drawString
(
name
,
x
,
y
);
g
.
drawString
(
score
,
500
,
600
);
// 4. 保存证书
g
.
dispose
();
ImageIO
.
write
(
certificate
,
"png"
,
new
File
(
"certificate_output.png"
));
}
}
src/main/java/org/rcisoft/business/test/controller/TestController.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
controller
;
import
com.maxmind.geoip2.DatabaseReader
;
import
com.maxmind.geoip2.model.CountryResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.business.test.entity.TestData
;
import
org.rcisoft.business.test.service.TestService
;
import
org.rcisoft.core.constant.CyMessCons
;
import
org.rcisoft.core.model.CyPersistModel
;
import
org.rcisoft.core.result.CyResult
;
import
org.rcisoft.core.util.CyResultGenUtil
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
@RestController
@RequestMapping
(
"/test"
)
@Api
(
tags
=
"测试类"
)
public
class
TestController
{
@Resource
private
TestService
testService
;
@ApiOperation
(
value
=
"测试查询"
)
@GetMapping
(
"/query"
)
public
CyResult
testQuery
(){
return
CyResultGenUtil
.
builder
(
new
CyPersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
testService
.
queryList
()
);
}
@ApiOperation
(
value
=
"测试添加"
)
@PostMapping
(
"/add"
)
public
CyResult
testAdd
(
@RequestBody
TestData
testData
,
BindingResult
bindingResult
){
CyPersistModel
data
=
testService
.
add
(
testData
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
testData
);
}
@ApiOperation
(
value
=
"测试删除"
)
@DeleteMapping
(
"/del/{id}"
)
public
CyResult
testDel
(
@PathVariable
Integer
id
){
CyPersistModel
data
=
testService
.
del
(
id
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
id
);
}
@ApiOperation
(
"测试修改"
)
@PutMapping
(
"/update/{id}"
)
public
CyResult
testUpdate
(
@PathVariable
Integer
id
,
@RequestBody
TestData
testData
){
testData
.
setId
(
id
);
CyPersistModel
data
=
testService
.
update
(
testData
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
testData
);
}
@GetMapping
(
"/geo"
)
public
CyResult
testDetectIp
(
HttpServletRequest
request
)
throws
Exception
{
File
geoIpDataBase
=
new
ClassPathResource
(
"geoip/GeoLite2-Country.mmdb"
).
getFile
();
DatabaseReader
reader
=
new
DatabaseReader
.
Builder
(
geoIpDataBase
).
build
();
String
ip
=
request
.
getRemoteAddr
();
InetAddress
ipAddress
=
InetAddress
.
getByName
(
ip
);
CountryResponse
country
=
reader
.
country
(
ipAddress
);
System
.
out
.
println
(
country
.
getCountry
().
getName
());
return
CyResultGenUtil
.
builder
(
new
CyPersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
country
.
getCountry
().
getName
()
);
}
}
src/main/java/org/rcisoft/business/test/dao/TestRepository.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
dao
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.rcisoft.business.test.entity.TestData
;
import
org.rcisoft.core.mapper.CyBaseMapper
;
import
java.util.List
;
@Mapper
public
interface
TestRepository
extends
CyBaseMapper
<
TestData
>
{
List
<
TestData
>
query
();
int
del
(
Integer
id
);
int
add
(
TestData
testData
);
int
update
(
TestData
testData
);
}
src/main/java/org/rcisoft/business/test/entity/TestData.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
entity
;
import
lombok.Data
;
import
org.rcisoft.core.entity.CyIdIncreEntity
;
@Data
public
class
TestData
extends
CyIdIncreEntity
<
TestData
>
{
private
Integer
id
;
private
String
data
;
}
src/main/java/org/rcisoft/business/test/geoip/GeoIpTest.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
geoip
;
import
com.maxmind.geoip2.DatabaseReader
;
import
com.maxmind.geoip2.model.CityResponse
;
import
com.maxmind.geoip2.model.CountryResponse
;
import
com.maxmind.geoip2.record.Country
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.InetAddress
;
public
class
GeoIpTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
geoIpDataBase
=
new
ClassPathResource
(
"geoip/GeoLite2-Country.mmdb"
).
getFile
();
DatabaseReader
reader
=
new
DatabaseReader
.
Builder
(
geoIpDataBase
).
build
();
InetAddress
ipAddress
=
InetAddress
.
getByName
(
"111.163.121.235"
);
CountryResponse
country
=
reader
.
country
(
ipAddress
);
System
.
out
.
println
(
country
.
getCountry
().
getName
());
}
}
src/main/java/org/rcisoft/business/test/service/TestService.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
service
;
import
org.rcisoft.business.test.entity.TestData
;
import
org.rcisoft.core.model.CyPersistModel
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
public
interface
TestService
{
CyPersistModel
add
(
TestData
testData
);
List
<
TestData
>
queryList
();
CyPersistModel
del
(
Integer
id
);
CyPersistModel
update
(
TestData
testData
);
}
src/main/java/org/rcisoft/business/test/service/impl/TestServiceImpl.java
0 → 100644
View file @
bf5435fe
package
org
.
rcisoft
.
business
.
test
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.test.dao.TestRepository
;
import
org.rcisoft.business.test.entity.TestData
;
import
org.rcisoft.business.test.service.TestService
;
import
org.rcisoft.core.model.CyPersistModel
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
@Slf4j
public
class
TestServiceImpl
extends
ServiceImpl
<
TestRepository
,
TestData
>
implements
TestService
{
@Resource
private
TestRepository
testRepository
;
@Override
public
CyPersistModel
add
(
TestData
testData
)
{
int
add
=
testRepository
.
add
(
testData
);
return
new
CyPersistModel
(
add
);
}
@Override
public
List
<
TestData
>
queryList
()
{
return
testRepository
.
query
();
}
@Override
public
CyPersistModel
del
(
Integer
id
)
{
int
del
=
testRepository
.
del
(
id
);
return
new
CyPersistModel
(
del
);
}
@Override
public
CyPersistModel
update
(
TestData
testData
)
{
int
update
=
testRepository
.
update
(
testData
);
return
new
CyPersistModel
(
update
);
}
}
src/main/java/org/rcisoft/business/test/temp.jpg
0 → 100644
View file @
bf5435fe
This diff is collapsed.
Click to expand it.
src/main/java/org/rcisoft/business/test/template.jpg
0 → 100644
View file @
bf5435fe
39.6 KB
src/main/resources/application-conf-dev.yml
View file @
bf5435fe
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
cy_redis
:
cy_redis
:
ip
:
127.0.0.1
ip
:
127.0.0.1
port
:
6379
port
:
6379
password
:
123456
password
:
database
:
10
database
:
10
# rabbitMq
# rabbitMq
...
@@ -31,14 +31,20 @@ cy_mq:
...
@@ -31,14 +31,20 @@ cy_mq:
# # password: root
# # password: root
# db: demo
# db: demo
#cy_db:
# # ip: 106.3.97.198
# ip: 127.0.0.1
# port: 3306
# username: root
# password: 123456
# db: tea
cy_db
:
cy_db
:
# ip: 106.3.97.198
# ip: 106.3.97.198
ip
:
127.0.0.1
ip
:
127.0.0.1
port
:
3306
port
:
3306
username
:
root
username
:
root
password
:
123456
password
:
root
db
:
tea
db
:
tea
# mongodb
# mongodb
cy_mongodb
:
cy_mongodb
:
ip
:
127.0.0.1
ip
:
127.0.0.1
...
@@ -141,6 +147,7 @@ cy:
...
@@ -141,6 +147,7 @@ cy:
-
"
/pc/sysuser/updatePassword"
-
"
/pc/sysuser/updatePassword"
-
"
/ossinfo/uploadVideoToOss"
-
"
/ossinfo/uploadVideoToOss"
-
"
/ossinfo/uploadZipToOss"
-
"
/ossinfo/uploadZipToOss"
-
"
/test/**"
# - "/**/**"
# - "/**/**"
permitStatic
:
[
"
/"
,
"
/*.html"
,
"
/favicon.ico"
,
"
/**/*.html"
,
"
/**/*.js"
,
"
/**/*.css"
]
permitStatic
:
[
"
/"
,
"
/*.html"
,
"
/favicon.ico"
,
"
/**/*.html"
,
"
/**/*.js"
,
"
/**/*.css"
]
...
...
src/main/resources/geoip/GeoLite2-Country.mmdb
0 → 100644
View file @
bf5435fe
File added
src/main/resources/mapper/business/blesson/mapper/BLessonMapper.xml
View file @
bf5435fe
...
@@ -204,6 +204,7 @@
...
@@ -204,6 +204,7 @@
and remainingDate = 0
and remainingDate = 0
</if>
</if>
ORDER BY tln.create_date DESC
ORDER BY tln.create_date DESC
</select>
</select>
<select
id=
"pagingBLessonObligatory"
resultType=
"org.rcisoft.business.blesson.entity.BLesson"
>
<select
id=
"pagingBLessonObligatory"
resultType=
"org.rcisoft.business.blesson.entity.BLesson"
>
SELECT
SELECT
...
...
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