Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
lic
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
lic
Commits
5750044f
提交
5750044f
authored
11月 22, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
4e4d5225
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
232 行增加
和
4 行删除
+232
-4
StarBosResult.java
...ava/com/system/framework/core/response/StarBosResult.java
+17
-0
SysUserAccountController.java
...tem/oauth/system/controller/SysUserAccountController.java
+41
-4
JacksonUtil.java
...tem/src/main/java/com/system/oauth/utils/JacksonUtil.java
+174
-0
没有找到文件。
lic-framework/lic-framework-core/src/main/java/com/system/framework/core/response/StarBosResult.java
浏览文件 @
5750044f
...
@@ -165,6 +165,23 @@ public class StarBosResult<T> implements Serializable {
...
@@ -165,6 +165,23 @@ public class StarBosResult<T> implements Serializable {
log
.
error
(
starBosResult
.
toString
());
log
.
error
(
starBosResult
.
toString
());
return
starBosResult
;
return
starBosResult
;
}
}
public
static
Object
badArgument
()
{
return
fail
(
401
,
"参数不对"
);
}
public
static
Object
badArgumentValue
()
{
return
fail
(
402
,
"参数值不对"
);
}
public
static
Object
updatedDateExpired
()
{
return
fail
(
504
,
"更新数据已经失效"
);
}
public
static
Object
updatedDataFailed
()
{
return
fail
(
505
,
"更新数据失败"
);
}
public
int
getCode
()
{
public
int
getCode
()
{
return
code
;
return
code
;
}
}
...
...
lic-system/src/main/java/com/system/oauth/system/controller/SysUserAccountController.java
浏览文件 @
5750044f
...
@@ -4,15 +4,15 @@ import com.system.framework.core.response.StarBosResult;
...
@@ -4,15 +4,15 @@ import com.system.framework.core.response.StarBosResult;
import
com.system.oauth.system.entity.SysUserAccount
;
import
com.system.oauth.system.entity.SysUserAccount
;
import
com.system.oauth.system.service.ISysRoleService
;
import
com.system.oauth.system.service.ISysRoleService
;
import
com.system.oauth.system.service.ISysUserService
;
import
com.system.oauth.system.service.ISysUserService
;
import
com.system.oauth.utils.JacksonUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.List
;
@Api
(
tags
=
"用户账号管理"
)
@Api
(
tags
=
"用户账号管理"
)
...
@@ -25,6 +25,8 @@ public class SysUserAccountController {
...
@@ -25,6 +25,8 @@ public class SysUserAccountController {
private
ISysRoleService
roleService
;
private
ISysRoleService
roleService
;
@Autowired
@Autowired
private
ISysUserService
userService
;
private
ISysUserService
userService
;
@Autowired
private
PasswordEncoder
passwordEncoder
;
@GetMapping
(
"findRoleByUser"
)
@GetMapping
(
"findRoleByUser"
)
@ApiOperation
(
value
=
"userAccount-查询账号角色"
,
notes
=
"userAccount-查询账号角色"
)
@ApiOperation
(
value
=
"userAccount-查询账号角色"
,
notes
=
"userAccount-查询账号角色"
)
...
@@ -40,4 +42,39 @@ public class SysUserAccountController {
...
@@ -40,4 +42,39 @@ public class SysUserAccountController {
}
}
return
result
;
return
result
;
}
}
@PostMapping
(
"reset_password"
)
public
Object
resetByMobile
(
@RequestBody
String
body
,
HttpServletRequest
request
)
{
String
password
=
JacksonUtil
.
parseString
(
body
,
"password"
);
String
account
=
JacksonUtil
.
parseString
(
body
,
"account"
);
if
(
account
==
null
||
password
==
null
)
{
return
StarBosResult
.
badArgument
();
}
//判断验证码是否正确
// String cacheCode = CaptchaCodeManager.getCachedCaptcha(mobile);
// if (cacheCode == null || cacheCode.isEmpty() || !cacheCode.equals(code)) {
// return ResponseUtil.fail(AUTH_CAPTCHA_UNMATCH, "验证码错误");
// }
SysUserAccount
accountUser
=
userService
.
findByUsername
(
account
);
SysUserAccount
user
=
null
;
if
(
accountUser
==
null
)
{
return
StarBosResult
.
fail
(
500
,
"账号不存在"
);
}
else
{
user
=
accountUser
;
}
String
encodedPassword
=
passwordEncoder
.
encode
(
password
);
SysUserAccount
sysUserAccount
=
new
SysUserAccount
();
sysUserAccount
.
setId
(
user
.
getId
());
sysUserAccount
.
setPassword
(
encodedPassword
);
if
(!
userService
.
updateById
(
sysUserAccount
))
{
return
StarBosResult
.
fail
(
"数据更新失败"
);
}
return
StarBosResult
.
ok
();
}
}
}
lic-system/src/main/java/com/system/oauth/utils/JacksonUtil.java
0 → 100644
浏览文件 @
5750044f
package
com
.
system
.
oauth
.
utils
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
public
class
JacksonUtil
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
JacksonUtil
.
class
);
public
static
String
parseString
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
return
leaf
.
asText
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
List
<
String
>
parseStringList
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
return
mapper
.
convertValue
(
leaf
,
new
TypeReference
<
List
<
String
>>()
{
});
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Integer
parseInteger
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
return
leaf
.
asInt
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
List
<
Integer
>
parseIntegerList
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
return
mapper
.
convertValue
(
leaf
,
new
TypeReference
<
List
<
Integer
>>()
{
});
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Boolean
parseBoolean
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
return
leaf
.
asBoolean
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Short
parseShort
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
{
Integer
value
=
leaf
.
asInt
();
return
value
.
shortValue
();
}
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Byte
parseByte
(
String
body
,
String
field
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
JsonNode
leaf
=
node
.
get
(
field
);
if
(
leaf
!=
null
)
{
Integer
value
=
leaf
.
asInt
();
return
value
.
byteValue
();
}
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
<
T
>
T
parseObject
(
String
body
,
String
field
,
Class
<
T
>
clazz
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
node
;
try
{
node
=
mapper
.
readTree
(
body
);
node
=
node
.
get
(
field
);
return
mapper
.
treeToValue
(
node
,
clazz
);
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Object
toNode
(
String
json
)
{
if
(
json
==
null
)
{
return
null
;
}
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
return
mapper
.
readTree
(
json
);
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
Map
<
String
,
String
>
toMap
(
String
data
)
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
return
objectMapper
.
readValue
(
data
,
new
TypeReference
<
Map
<
String
,
String
>>()
{
});
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
String
toJson
(
Object
data
)
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
return
objectMapper
.
writeValueAsString
(
data
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论