Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bme-access-upload
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
李洪明
bme-access-upload
Commits
9ede9b41
Commit
9ede9b41
authored
Jul 08, 2025
by
李洪明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加登录
parent
30a927e6
Pipeline
#1272
canceled with stages
Changes
7
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
589 additions
and
4 deletions
+589
-4
ApplicationContextHelper.java
...om/bme/access/upload/common/ApplicationContextHelper.java
+31
-0
CommonResult.java
src/main/java/com/bme/access/upload/common/CommonResult.java
+109
-0
HttpUtils.java
src/main/java/com/bme/access/upload/common/HttpUtils.java
+361
-0
LoginConfig.java
src/main/java/com/bme/access/upload/config/LoginConfig.java
+46
-0
LoginService.java
...va/com/bme/access/upload/module/service/LoginService.java
+8
-0
AuthController.java
...java/com/bme/access/upload/module/web/AuthController.java
+34
-0
LoginController.java
...ava/com/bme/access/upload/module/web/LoginController.java
+0
-4
No files found.
src/main/java/com/bme/access/upload/common/ApplicationContextHelper.java
0 → 100644
View file @
9ede9b41
package
com
.
bme
.
access
.
upload
.
common
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ApplicationContextHelper
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
ApplicationContextHelper
.
applicationContext
=
applicationContext
;
if
(
ApplicationContextHelper
.
applicationContext
==
null
)
{
ApplicationContextHelper
.
applicationContext
=
applicationContext
;
}
}
public
static
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
clasz
)
{
return
applicationContext
!=
null
?
applicationContext
.
getBean
(
clasz
)
:
null
;
}
public
static
Object
getBean
(
String
name
){
return
getApplicationContext
().
getBean
(
name
);
}
}
\ No newline at end of file
src/main/java/com/bme/access/upload/common/CommonResult.java
0 → 100644
View file @
9ede9b41
package
com
.
bme
.
access
.
upload
.
common
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
CommonResult
{
public
CommonResult
()
{
}
public
CommonResult
(
boolean
success
,
String
msg
,
Object
data
)
{
super
();
this
.
success
=
success
;
this
.
msg
=
msg
;
this
.
data
=
data
;
}
public
static
CommonResult
success
()
{
return
CommonResult
.
success
(
null
,
null
);
}
public
static
CommonResult
success
(
String
msg
)
{
return
CommonResult
.
success
(
msg
,
null
);
}
public
static
CommonResult
success
(
String
msg
,
Object
data
)
{
CommonResult
result
=
new
CommonResult
(
true
,
msg
,
data
);
result
.
setType
(
0
);
return
result
;
}
public
static
CommonResult
fail
()
{
return
CommonResult
.
fail
(
null
,
null
);
}
public
static
CommonResult
fail
(
String
msg
)
{
return
CommonResult
.
fail
(
msg
,
null
);
}
public
static
CommonResult
fail
(
String
msg
,
Object
data
)
{
CommonResult
result
=
new
CommonResult
(
false
,
msg
,
data
);
result
.
setType
(
0
);
return
result
;
}
@SuppressWarnings
(
"unchecked"
)
public
CommonResult
data
(
Object
...
objects
)
{
if
(
objects
!=
null
)
{
if
(
objects
.
length
==
1
)
{
this
.
data
=
objects
[
0
];
}
else
{
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<
String
,
Object
>();
if
(
data
instanceof
Map
)
{
dataMap
=
(
Map
<
String
,
Object
>)
this
.
data
;
}
for
(
int
i
=
0
;
i
<
objects
.
length
/
2
;
i
++)
{
int
index
=
i
*
2
;
dataMap
.
put
(
String
.
valueOf
(
objects
[
index
]),
objects
[
index
+
1
]);
}
this
.
data
=
dataMap
;
}
}
return
this
;
}
private
boolean
success
;
private
Integer
type
;
private
String
msg
;
private
Object
data
;
public
boolean
isSuccess
()
{
return
success
;
}
public
void
setSuccess
(
boolean
success
)
{
this
.
success
=
success
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
Object
getData
()
{
return
data
;
}
public
void
setData
(
Object
data
)
{
this
.
data
=
data
;
}
public
static
CommonResult
result
(
boolean
checkResult
)
{
CommonResult
result
=
new
CommonResult
();
result
.
setSuccess
(
checkResult
);
return
result
;
}
}
\ No newline at end of file
src/main/java/com/bme/access/upload/common/HttpUtils.java
0 → 100644
View file @
9ede9b41
This diff is collapsed.
Click to expand it.
src/main/java/com/bme/access/upload/config/LoginConfig.java
0 → 100644
View file @
9ede9b41
package
com
.
bme
.
access
.
upload
.
config
;
import
com.alibaba.fastjson.JSONObject
;
import
com.bme.access.upload.common.*
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.Map
;
@Configuration
public
class
LoginConfig
{
//账号
public
final
static
String
USERNAME
=
"13905902008"
;
//密码
public
final
static
String
PASSWORD
=
"uR4}eP4!"
;
public
final
static
String
AUTH
=
"111"
;
public
final
static
String
LOGIN_URL
=
"https://dctapi.soszyzg.com/dct/login"
;
public
static
String
token
=
""
;
@PostConstruct
public
void
getLogin
()
throws
Exception
{
Map
<
String
,
Object
>
body
=
new
HashMap
<>();
body
.
put
(
"username"
,
USERNAME
);
body
.
put
(
"password"
,
PASSWORD
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"Content-Type"
,
"application/json"
);
headers
.
put
(
"X-Access-Token"
,
AUTH
);
HttpResponse
response
=
HttpUtils
.
sendRequest
(
LOGIN_URL
,
null
,
headers
,
null
,
body
);
String
str
=
EntityUtils
.
toString
(
response
.
getEntity
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
str
);
Integer
code
=
jsonObject
.
getInteger
(
"code"
);
if
(
code
.
equals
(
200
)){
String
result
=
jsonObject
.
getString
(
"result"
);
JSONObject
resultObject
=
JSONObject
.
parseObject
(
result
);
token
=
resultObject
.
getString
(
"token"
);
}
}
}
src/main/java/com/bme/access/upload/module/service/LoginService.java
0 → 100644
View file @
9ede9b41
package
com
.
bme
.
access
.
upload
.
module
.
service
;
import
org.springframework.stereotype.Service
;
@Service
public
class
LoginService
{
}
src/main/java/com/bme/access/upload/module/web/AuthController.java
0 → 100644
View file @
9ede9b41
package
com
.
bme
.
access
.
upload
.
module
.
web
;
import
com.bme.access.upload.common.CommonResult
;
import
com.bme.access.upload.common.HttpUtils
;
import
com.bme.access.upload.config.LoginConfig
;
import
com.bme.access.upload.module.service.LoginService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@Slf4j
@RequestMapping
(
"/auth"
)
public
class
AuthController
{
@Autowired
private
LoginService
loginService
;
@Autowired
private
LoginConfig
loginConfig
;
@GetMapping
(
""
)
public
CommonResult
getAuthToken
()
throws
Exception
{
loginConfig
.
getLogin
();
return
CommonResult
.
success
(
"成功"
);
}
}
src/main/java/com/bme/access/upload/module/web/LoginController.java
deleted
100644 → 0
View file @
30a927e6
package
com
.
bme
.
access
.
upload
.
module
.
web
;
public
class
LoginController
{
}
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