Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
d11c499e
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
11 个月 前同步成功
通知
76
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d11c499e
编写于
4月 05, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FileUpload&UserInfo&Accounts
上级
a14aeb1b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
324 addition
and
29 deletion
+324
-29
maxkey-core/src/main/java/org/maxkey/entity/Accounts.java
maxkey-core/src/main/java/org/maxkey/entity/Accounts.java
+11
-1
maxkey-core/src/main/java/org/maxkey/entity/FileUpload.java
maxkey-core/src/main/java/org/maxkey/entity/FileUpload.java
+122
-0
maxkey-core/src/main/java/org/maxkey/entity/UserInfo.java
maxkey-core/src/main/java/org/maxkey/entity/UserInfo.java
+12
-21
maxkey-persistence/src/main/java/org/maxkey/persistence/mapper/FileUploadMapper.java
.../java/org/maxkey/persistence/mapper/FileUploadMapper.java
+32
-0
maxkey-persistence/src/main/java/org/maxkey/persistence/service/FileUploadService.java
...ava/org/maxkey/persistence/service/FileUploadService.java
+39
-0
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java
.../java/org/maxkey/persistence/service/UserInfoService.java
+4
-1
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtMvcConfig.java
...-web-mgt/src/main/java/org/maxkey/MaxKeyMgtMvcConfig.java
+3
-0
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/AccountsController.java
...in/java/org/maxkey/web/contorller/AccountsController.java
+6
-2
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/FileUploadEndpoint.java
...in/java/org/maxkey/web/contorller/FileUploadEndpoint.java
+74
-0
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java
...in/java/org/maxkey/web/contorller/UserInfoController.java
+21
-4
未找到文件。
maxkey-core/src/main/java/org/maxkey/entity/Accounts.java
浏览文件 @
d11c499e
...
...
@@ -71,6 +71,8 @@ public class Accounts extends JpaBaseEntity implements Serializable {
@Column
private
String
strategyId
;
@Column
private
String
strategyName
;
@Column
private
int
status
;
@Column
...
...
@@ -214,7 +216,15 @@ public class Accounts extends JpaBaseEntity implements Serializable {
}
}
public
String
getInstId
()
{
public
String
getStrategyName
()
{
return
strategyName
;
}
public
void
setStrategyName
(
String
strategyName
)
{
this
.
strategyName
=
strategyName
;
}
public
String
getInstId
()
{
return
instId
;
}
...
...
maxkey-core/src/main/java/org/maxkey/entity/FileUpload.java
0 → 100644
浏览文件 @
d11c499e
package
org.maxkey.entity
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
org.apache.mybatis.jpa.persistence.JpaBaseEntity
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@Entity
@Table
(
name
=
"MXK_FILE_UPLOAD"
)
public
class
FileUpload
extends
JpaBaseEntity
{
private
static
final
long
serialVersionUID
=
-
4338400992411166457L
;
@Id
@Column
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
,
generator
=
"snowflakeid"
)
String
id
;
@Column
byte
[]
uploaded
;
@JsonIgnore
MultipartFile
uploadFile
;
@Column
String
fileName
;
@Column
String
contentType
;
@Column
long
contentSize
;
@Column
String
createdBy
;
String
createdDate
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
byte
[]
getUploaded
()
{
return
uploaded
;
}
public
void
setUploaded
(
byte
[]
uploaded
)
{
this
.
uploaded
=
uploaded
;
}
public
MultipartFile
getUploadFile
()
{
return
uploadFile
;
}
public
void
setUploadFile
(
MultipartFile
uploadFile
)
{
this
.
uploadFile
=
uploadFile
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getContentType
()
{
return
contentType
;
}
public
void
setContentType
(
String
contentType
)
{
this
.
contentType
=
contentType
;
}
public
long
getContentSize
()
{
return
contentSize
;
}
public
void
setContentSize
(
long
contentSize
)
{
this
.
contentSize
=
contentSize
;
}
public
String
getCreatedBy
()
{
return
createdBy
;
}
public
void
setCreatedBy
(
String
createdBy
)
{
this
.
createdBy
=
createdBy
;
}
public
String
getCreatedDate
()
{
return
createdDate
;
}
public
void
setCreatedDate
(
String
createdDate
)
{
this
.
createdDate
=
createdDate
;
}
@Override
public
String
toString
()
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"FileUpload [id="
);
builder
.
append
(
id
);
builder
.
append
(
", uploadFile="
);
builder
.
append
(
uploadFile
);
builder
.
append
(
", createdBy="
);
builder
.
append
(
this
.
createdBy
);
builder
.
append
(
"]"
);
return
builder
.
toString
();
}
}
maxkey-core/src/main/java/org/maxkey/entity/UserInfo.java
浏览文件 @
d11c499e
...
...
@@ -18,7 +18,6 @@
package
org.maxkey.entity
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.io.IOException
;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -31,7 +30,6 @@ import javax.persistence.Id;
import
javax.persistence.Table
;
import
org.apache.mybatis.jpa.persistence.JpaBaseEntity
;
import
org.maxkey.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* .
...
...
@@ -110,8 +108,7 @@ public class UserInfo extends JpaBaseEntity {
@Column
protected
byte
[]
picture
;
protected
String
pictureBase64
;
@JsonIgnore
protected
MultipartFile
pictureFile
;
protected
String
pictureId
;
@Column
protected
int
idType
;
@Column
...
...
@@ -413,16 +410,6 @@ public class UserInfo extends JpaBaseEntity {
this
.
password
=
password
;
}
public
byte
[]
getPicture
()
{
if
(
pictureFile
!=
null
&&
!
pictureFile
.
isEmpty
())
{
try
{
picture
=
pictureFile
.
getBytes
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
picture
;
}
public
String
getPictureBase64
()
{
return
pictureBase64
;
...
...
@@ -439,6 +426,10 @@ public class UserInfo extends JpaBaseEntity {
}
}
public
byte
[]
getPicture
()
{
return
picture
;
}
/**
* @return the protectedAppsMap
*/
...
...
@@ -628,15 +619,15 @@ public class UserInfo extends JpaBaseEntity {
this
.
birthDate
=
birthDate
;
}
public
MultipartFile
getPictureFile
()
{
return
pictureFile
;
}
public
String
getPictureId
()
{
return
pictureId
;
}
public
void
setPictureFile
(
MultipartFile
pictureFile
)
{
this
.
pictureFile
=
pictureFile
;
}
public
void
setPictureId
(
String
pictureId
)
{
this
.
pictureId
=
pictureId
;
}
public
int
getIdType
()
{
public
int
getIdType
()
{
return
idType
;
}
...
...
maxkey-persistence/src/main/java/org/maxkey/persistence/mapper/FileUploadMapper.java
0 → 100644
浏览文件 @
d11c499e
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package
org.maxkey.persistence.mapper
;
import
org.apache.mybatis.jpa.persistence.IJpaBaseMapper
;
import
org.maxkey.entity.FileUpload
;
/**
* @author Crystal.sea
*
*/
public
interface
FileUploadMapper
extends
IJpaBaseMapper
<
FileUpload
>
{
}
maxkey-persistence/src/main/java/org/maxkey/persistence/service/FileUploadService.java
0 → 100644
浏览文件 @
d11c499e
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.maxkey.persistence.service
;
import
org.apache.mybatis.jpa.persistence.JpaBaseService
;
import
org.maxkey.entity.FileUpload
;
import
org.maxkey.persistence.mapper.FileUploadMapper
;
import
org.springframework.stereotype.Repository
;
@Repository
public
class
FileUploadService
extends
JpaBaseService
<
FileUpload
>{
public
FileUploadService
()
{
super
(
FileUploadMapper
.
class
);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public
FileUploadMapper
getMapper
()
{
return
(
FileUploadMapper
)
super
.
getMapper
();
}
}
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java
浏览文件 @
d11c499e
...
...
@@ -212,7 +212,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
public
UserInfo
passwordEncoder
(
UserInfo
userInfo
)
{
//密码不为空,则需要进行加密处理
if
(
userInfo
.
getPassword
()!=
null
&&
!
userInfo
.
getPassword
().
equals
(
""
))
{
if
(
!
StringUtils
.
isBlank
(
userInfo
.
getPassword
()
))
{
String
password
=
passwordEncoder
.
encode
(
userInfo
.
getPassword
());
userInfo
.
setDecipherable
(
PasswordReciprocal
.
getInstance
().
encode
(
userInfo
.
getPassword
()));
_logger
.
debug
(
"decipherable : "
+
userInfo
.
getDecipherable
());
...
...
@@ -220,6 +220,9 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
userInfo
.
setPasswordLastSetTime
(
DateUtils
.
getCurrentDateTimeAsString
());
userInfo
.
setModifiedDate
(
DateUtils
.
getCurrentDateTimeAsString
());
}
else
{
userInfo
.
setPassword
(
null
);
userInfo
.
setDecipherable
(
null
);
}
return
userInfo
;
}
...
...
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/MaxKeyMgtMvcConfig.java
浏览文件 @
d11c499e
...
...
@@ -121,6 +121,7 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
.
addPathPatterns
(
"/apps/**"
)
.
addPathPatterns
(
"/accounts/**"
)
.
addPathPatterns
(
"/access/**"
)
.
addPathPatterns
(
"/access/**/**"
)
...
...
@@ -136,6 +137,8 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
.
addPathPatterns
(
"/institutions/**"
)
.
addPathPatterns
(
"/localization/**"
)
.
addPathPatterns
(
"/file/upload/"
)
;
_logger
.
debug
(
"add PermissionAdapter"
);
...
...
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/AccountsController.java
浏览文件 @
d11c499e
...
...
@@ -83,6 +83,7 @@ public class AccountsController {
@RequestMapping
(
value
=
{
"/get/{id}"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
get
(
@PathVariable
(
"id"
)
String
id
)
{
Accounts
account
=
accountsService
.
get
(
id
);
account
.
setRelatedPassword
(
PasswordReciprocal
.
getInstance
().
decoder
(
account
.
getRelatedPassword
()));
return
new
Message
<
Accounts
>(
account
).
buildResponse
();
}
...
...
@@ -127,10 +128,13 @@ public class AccountsController {
@ResponseBody
@RequestMapping
(
value
=
"/generate"
)
public
String
generate
(
@ModelAttribute
Accounts
account
)
{
public
ResponseEntity
<?>
generate
(
@ModelAttribute
Accounts
account
)
{
AccountsStrategy
accountsStrategy
=
accountsStrategyService
.
get
(
account
.
getStrategyId
());
UserInfo
userInfo
=
userInfoService
.
get
(
account
.
getUserId
());
return
accountsService
.
generateAccount
(
userInfo
,
accountsStrategy
);
return
new
Message
<
Object
>(
Message
.
SUCCESS
,
(
Object
)
accountsService
.
generateAccount
(
userInfo
,
accountsStrategy
)
).
buildResponse
();
}
}
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/FileUploadEndpoint.java
0 → 100644
浏览文件 @
d11c499e
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.maxkey.web.contorller
;
import
java.io.IOException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.maxkey.authn.annotation.CurrentUser
;
import
org.maxkey.entity.FileUpload
;
import
org.maxkey.entity.Message
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.persistence.service.FileUploadService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
@Controller
public
class
FileUploadEndpoint
{
private
static
Logger
_logger
=
LoggerFactory
.
getLogger
(
FileUploadEndpoint
.
class
);
@Autowired
FileUploadService
fileUploadService
;
@RequestMapping
(
value
={
"/file/upload/"
})
@ResponseBody
public
ResponseEntity
<?>
upload
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@ModelAttribute
FileUpload
fileUpload
,
@CurrentUser
UserInfo
currentUser
){
_logger
.
debug
(
"FileUpload"
);
fileUpload
.
setId
(
fileUpload
.
generateId
());
fileUpload
.
setContentType
(
fileUpload
.
getUploadFile
().
getContentType
());
fileUpload
.
setFileName
(
fileUpload
.
getUploadFile
().
getOriginalFilename
());
fileUpload
.
setContentSize
(
fileUpload
.
getUploadFile
().
getSize
());
fileUpload
.
setCreatedBy
(
currentUser
.
getUsername
());
/*
* upload UploadFile MultipartFile to Uploaded Bytes
*/
if
(
null
!=
fileUpload
.
getUploadFile
()&&!
fileUpload
.
getUploadFile
().
isEmpty
()){
try
{
fileUpload
.
setUploaded
(
fileUpload
.
getUploadFile
().
getBytes
());
fileUploadService
.
insert
(
fileUpload
);
_logger
.
trace
(
"FileUpload SUCCESS"
);
}
catch
(
IOException
e
)
{
_logger
.
error
(
"FileUpload IOException"
,
e
);
}
}
return
new
Message
<
Object
>(
Message
.
SUCCESS
,(
Object
)
fileUpload
.
getId
()).
buildResponse
();
}
}
maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java
浏览文件 @
d11c499e
...
...
@@ -38,6 +38,7 @@ import org.maxkey.constants.ConstsPasswordSetType;
import
org.maxkey.entity.ExcelImport
;
import
org.maxkey.entity.Message
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.persistence.service.FileUploadService
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.util.DateUtils
;
import
org.maxkey.util.ExcelUtils
;
...
...
@@ -73,6 +74,9 @@ public class UserInfoController {
@Autowired
private
UserInfoService
userInfoService
;
@Autowired
FileUploadService
fileUploadService
;
@RequestMapping
(
value
=
{
"/fetch"
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
...
...
@@ -101,6 +105,8 @@ public class UserInfoController {
if
(
userInfo
.
getPicture
()!=
null
){
userInfo
.
transPictureBase64
();
}
userInfo
.
setPassword
(
""
);
userInfo
.
setDecipherable
(
""
);
return
new
Message
<
UserInfo
>(
userInfo
).
buildResponse
();
}
...
...
@@ -110,6 +116,10 @@ public class UserInfoController {
_logger
.
debug
(
"-Add :"
+
userInfo
);
userInfo
.
setId
(
WebContext
.
genId
());
userInfo
.
setInstId
(
currentUser
.
getInstId
());
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getPictureId
()))
{
userInfo
.
setPicture
(
fileUploadService
.
get
(
userInfo
.
getPictureId
()).
getUploaded
());
fileUploadService
.
remove
(
userInfo
.
getPictureId
());
}
if
(
userInfoService
.
insert
(
userInfo
))
{
return
new
Message
<
UserInfo
>(
Message
.
SUCCESS
).
buildResponse
();
}
else
{
...
...
@@ -128,6 +138,10 @@ public class UserInfoController {
convertExtraAttribute
(
userInfo
)
;
_logger
.
info
(
userInfo
.
getExtraAttribute
());
userInfo
.
setInstId
(
currentUser
.
getInstId
());
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getPictureId
()))
{
userInfo
.
setPicture
(
fileUploadService
.
get
(
userInfo
.
getPictureId
()).
getUploaded
());
fileUploadService
.
remove
(
userInfo
.
getPictureId
());
}
if
(
userInfoService
.
update
(
userInfo
))
{
return
new
Message
<
UserInfo
>(
Message
.
SUCCESS
).
buildResponse
();
}
else
{
...
...
@@ -148,9 +162,12 @@ public class UserInfoController {
@ResponseBody
@RequestMapping
(
value
=
"/randomPassword"
)
public
String
randomPassword
()
{
return
userInfoService
.
randomPassword
();
@RequestMapping
(
value
=
"/randomPassword"
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
randomPassword
()
{
return
new
Message
<
Object
>(
Message
.
SUCCESS
,
(
Object
)
userInfoService
.
randomPassword
()
).
buildResponse
();
}
...
...
@@ -169,7 +186,7 @@ public class UserInfoController {
@ResponseBody
@RequestMapping
(
value
=
"/changePassword"
)
@RequestMapping
(
value
=
"/changePassword"
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
ResponseEntity
<?>
changePassword
(
@ModelAttribute
(
"userInfo"
)
UserInfo
userInfo
)
{
_logger
.
debug
(
userInfo
.
getId
());
userInfo
.
setPasswordSetType
(
ConstsPasswordSetType
.
PASSWORD_NORMAL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录