Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
08bf8e0c
Commit
08bf8e0c
authored
Mar 07, 2019
by
Junling Bu
Browse files
chore[litemall-admin, litemall-admin-api]: 管理后台不支持管理员添加用户、编辑用户和删除用户操作。
parent
baceacea
Changes
4
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
View file @
08bf8e0c
...
@@ -49,86 +49,4 @@ public class AdminUserController {
...
@@ -49,86 +49,4 @@ public class AdminUserController {
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
data
);
}
}
@GetMapping
(
"/username"
)
public
Object
username
(
@NotEmpty
String
username
)
{
boolean
exist
=
userService
.
checkByUsername
(
username
);
if
(
exist
)
{
return
ResponseUtil
.
ok
(
"已存在"
);
}
return
ResponseUtil
.
ok
(
"不存在"
);
}
private
Object
validate
(
LitemallUser
user
)
{
String
username
=
user
.
getUsername
();
if
(
StringUtils
.
isEmpty
(
user
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isUsername
(
username
))
{
return
ResponseUtil
.
fail
(
USER_INVALID_NAME
,
"用户名不符合规定"
);
}
String
password
=
user
.
getPassword
();
if
(
StringUtils
.
isEmpty
(
password
)
||
password
.
length
()
<
6
)
{
return
ResponseUtil
.
fail
(
USER_INVALID_PASSWORD
,
"用户密码长度不能小于6"
);
}
String
mobile
=
user
.
getMobile
();
if
(
StringUtils
.
isEmpty
(
mobile
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isMobileExact
(
mobile
))
{
return
ResponseUtil
.
fail
(
USER_INVALID_MOBILE
,
"用户手机号码格式不正确"
);
}
return
null
;
}
@RequiresPermissions
(
"admin:user:create"
)
@RequiresPermissionsDesc
(
menu
={
"用户管理"
,
"会员管理"
},
button
=
"添加"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestBody
LitemallUser
user
)
{
Object
error
=
validate
(
user
);
if
(
error
!=
null
)
{
return
error
;
}
String
username
=
user
.
getUsername
();
String
mobile
=
user
.
getMobile
();
List
<
LitemallUser
>
userList
=
userService
.
queryByUsername
(
username
);
if
(
userList
.
size
()
>
0
)
{
return
ResponseUtil
.
fail
(
USER_NAME_EXIST
,
"用户名已注册"
);
}
userList
=
userService
.
queryByMobile
(
mobile
);
if
(
userList
.
size
()
>
0
)
{
return
ResponseUtil
.
fail
(
USER_MOBILE_EXIST
,
"手机号已注册"
);
}
if
(!
RegexUtil
.
isMobileExact
(
mobile
))
{
return
ResponseUtil
.
fail
(
USER_INVALID_MOBILE
,
"手机号格式不正确"
);
}
String
password
=
user
.
getPassword
();
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
String
encodedPassword
=
encoder
.
encode
(
password
);
user
.
setPassword
(
encodedPassword
);
userService
.
add
(
user
);
return
ResponseUtil
.
ok
(
user
);
}
@RequiresPermissions
(
"admin:user:update"
)
@RequiresPermissionsDesc
(
menu
={
"用户管理"
,
"会员管理"
},
button
=
"编辑"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@RequestBody
LitemallUser
user
)
{
Object
error
=
validate
(
user
);
if
(
error
!=
null
)
{
return
error
;
}
// 用户密码加密存储
String
password
=
user
.
getPassword
();
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
String
encodedPassword
=
encoder
.
encode
(
password
);
user
.
setPassword
(
encodedPassword
);
if
(
userService
.
updateById
(
user
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
(
user
);
}
}
}
litemall-admin/src/api/user.js
View file @
08bf8e0c
...
@@ -8,30 +8,6 @@ export function fetchList(query) {
...
@@ -8,30 +8,6 @@ export function fetchList(query) {
})
})
}
}
export
function
createUser
(
data
)
{
return
request
({
url
:
'
/user/create
'
,
method
:
'
post
'
,
data
})
}
export
function
readUser
(
data
)
{
return
request
({
url
:
'
/user/detail
'
,
method
:
'
get
'
,
data
})
}
export
function
updateUser
(
data
)
{
return
request
({
url
:
'
/user/update
'
,
method
:
'
post
'
,
data
})
}
export
function
listAddress
(
query
)
{
export
function
listAddress
(
query
)
{
return
request
({
return
request
({
url
:
'
/address/list
'
,
url
:
'
/address/list
'
,
...
...
litemall-admin/src/router/index.js
View file @
08bf8e0c
...
@@ -94,7 +94,7 @@ export const asyncRouterMap = [
...
@@ -94,7 +94,7 @@ export const asyncRouterMap = [
component
:
()
=>
import
(
'
@/views/user/user
'
),
component
:
()
=>
import
(
'
@/views/user/user
'
),
name
:
'
user
'
,
name
:
'
user
'
,
meta
:
{
meta
:
{
perms
:
[
'
GET /admin/user/list
'
,
'
POST /admin/user/create
'
,
'
POST /admin/user/update
'
],
perms
:
[
'
GET /admin/user/list
'
],
title
:
'
会员管理
'
,
title
:
'
会员管理
'
,
noCache
:
true
noCache
:
true
}
}
...
...
litemall-admin/src/views/user/user.vue
View file @
08bf8e0c
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
<el-input
v-model=
"listQuery.username"
clearable
class=
"filter-item"
style=
"width: 200px;"
placeholder=
"请输入用户名"
/>
<el-input
v-model=
"listQuery.username"
clearable
class=
"filter-item"
style=
"width: 200px;"
placeholder=
"请输入用户名"
/>
<el-input
v-model=
"listQuery.mobile"
clearable
class=
"filter-item"
style=
"width: 200px;"
placeholder=
"请输入手机号"
/>
<el-input
v-model=
"listQuery.mobile"
clearable
class=
"filter-item"
style=
"width: 200px;"
placeholder=
"请输入手机号"
/>
<el-button
class=
"filter-item"
type=
"primary"
icon=
"el-icon-search"
@
click=
"handleFilter"
>
查找
</el-button>
<el-button
class=
"filter-item"
type=
"primary"
icon=
"el-icon-search"
@
click=
"handleFilter"
>
查找
</el-button>
<el-button
class=
"filter-item"
type=
"primary"
icon=
"el-icon-edit"
@
click=
"handleCreate"
>
添加
</el-button>
<el-button
:loading=
"downloadLoading"
class=
"filter-item"
type=
"primary"
icon=
"el-icon-download"
@
click=
"handleDownload"
>
导出
</el-button>
<el-button
:loading=
"downloadLoading"
class=
"filter-item"
type=
"primary"
icon=
"el-icon-download"
@
click=
"handleDownload"
>
导出
</el-button>
</div>
</div>
...
@@ -38,65 +37,15 @@
...
@@ -38,65 +37,15 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
align=
"center"
label=
"操作"
width=
"200"
class-name=
"small-padding fixed-width"
>
<
template
slot-scope=
"scope"
>
<el-button
type=
"primary"
size=
"mini"
@
click=
"handleUpdate(scope.row)"
>
编辑
</el-button>
<el-button
type=
"danger"
size=
"mini"
@
click=
"handleDelete(scope.row)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
</el-table>
<pagination
v-show=
"total>0"
:total=
"total"
:page.sync=
"listQuery.page"
:limit.sync=
"listQuery.limit"
@
pagination=
"getList"
/>
<pagination
v-show=
"total>0"
:total=
"total"
:page.sync=
"listQuery.page"
:limit.sync=
"listQuery.limit"
@
pagination=
"getList"
/>
<!-- 添加或修改对话框 -->
<el-dialog
:title=
"textMap[dialogStatus]"
:visible.sync=
"dialogFormVisible"
>
<el-form
ref=
"dataForm"
:rules=
"rules"
:model=
"dataForm"
status-icon
label-position=
"left"
label-width=
"100px"
style=
"width: 400px; margin-left:50px;"
>
<el-form-item
label=
"用户名"
prop=
"username"
>
<el-input
v-model=
"dataForm.username"
/>
</el-form-item>
<el-form-item
label=
"手机号码"
prop=
"mobile"
>
<el-input
v-model=
"dataForm.mobile"
/>
</el-form-item>
<el-form-item
label=
"密码"
prop=
"password"
>
<el-input
v-model=
"dataForm.password"
type=
"password"
auto-complete=
"off"
/>
</el-form-item>
<el-form-item
label=
"性别"
prop=
"gender"
>
<el-select
v-model=
"dataForm.gender"
>
<el-option
:value=
"0"
label=
"未知"
/>
<el-option
:value=
"1"
label=
"男"
/>
<el-option
:value=
"2"
label=
"女"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"生日"
prop=
"birthday"
>
<el-date-picker
v-model=
"dataForm.birthday"
type=
"date"
value-format=
"yyyy-MM-dd"
/>
</el-form-item>
<el-form-item
label=
"用户等级"
prop=
"userLevel"
>
<el-select
v-model=
"dataForm.userLevel"
>
<el-option
:value=
"0"
label=
"普通用户"
/>
<el-option
:value=
"1"
label=
"VIP用户"
/>
<el-option
:value=
"2"
label=
"高级VIP用户"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"状态"
prop=
"status"
>
<el-select
v-model=
"dataForm.status"
>
<el-option
:value=
"0"
label=
"可用"
/>
<el-option
:value=
"1"
label=
"禁用"
/>
<el-option
:value=
"2"
label=
"注销"
/>
</el-select>
</el-form-item>
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
@
click=
"dialogFormVisible = false"
>
取消
</el-button>
<el-button
v-if=
"dialogStatus=='create'"
type=
"primary"
@
click=
"createData"
>
确定
</el-button>
<el-button
v-else
type=
"primary"
@
click=
"updateData"
>
确定
</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
{
fetchList
,
createUser
,
updateUser
}
from
'
@/api/user
'
import
{
fetchList
}
from
'
@/api/user
'
import
Pagination
from
'
@/components/Pagination
'
// Secondary package based on el-pagination
import
Pagination
from
'
@/components/Pagination
'
// Secondary package based on el-pagination
export
default
{
export
default
{
...
@@ -115,27 +64,6 @@ export default {
...
@@ -115,27 +64,6 @@ export default {
sort
:
'
add_time
'
,
sort
:
'
add_time
'
,
order
:
'
desc
'
order
:
'
desc
'
},
},
dataForm
:
{
id
:
undefined
,
username
:
''
,
mobile
:
''
,
password
:
undefined
,
gender
:
0
,
userLevel
:
0
,
birthday
:
undefined
,
status
:
0
},
dialogFormVisible
:
false
,
dialogStatus
:
''
,
textMap
:
{
update
:
'
编辑
'
,
create
:
'
创建
'
},
rules
:
{
username
:
[{
required
:
true
,
message
:
'
用户名不能为空
'
,
trigger
:
'
blur
'
}],
mobile
:
[{
required
:
true
,
message
:
'
手机号码不能为空
'
,
trigger
:
'
blur
'
}],
password
:
[{
required
:
true
,
message
:
'
密码不能为空
'
,
trigger
:
'
blur
'
}]
},
downloadLoading
:
false
,
downloadLoading
:
false
,
genderDic
:
[
'
未知
'
,
'
男
'
,
'
女
'
],
genderDic
:
[
'
未知
'
,
'
男
'
,
'
女
'
],
levelDic
:
[
'
普通用户
'
,
'
VIP用户
'
,
'
高级VIP用户
'
],
levelDic
:
[
'
普通用户
'
,
'
VIP用户
'
,
'
高级VIP用户
'
],
...
@@ -162,85 +90,6 @@ export default {
...
@@ -162,85 +90,6 @@ export default {
this
.
listQuery
.
page
=
1
this
.
listQuery
.
page
=
1
this
.
getList
()
this
.
getList
()
},
},
resetForm
()
{
this
.
dataForm
=
{
id
:
undefined
,
username
:
''
,
mobile
:
''
,
pass
:
undefined
,
checkPass
:
undefined
,
gender
:
0
,
userLevel
:
0
,
birthday
:
undefined
,
status
:
0
}
},
handleCreate
()
{
this
.
resetForm
()
this
.
dialogStatus
=
'
create
'
this
.
dialogFormVisible
=
true
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'
dataForm
'
].
clearValidate
()
})
},
createData
()
{
this
.
$refs
[
'
dataForm
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
createUser
(
this
.
dataForm
).
then
(
response
=>
{
this
.
list
.
unshift
(
response
.
data
.
data
)
this
.
dialogFormVisible
=
false
this
.
$notify
.
success
({
title
:
'
成功
'
,
message
:
'
添加用户成功
'
})
}).
catch
(
response
=>
{
this
.
$notify
.
error
({
title
:
'
失败
'
,
message
:
response
.
data
.
errmsg
})
})
}
})
},
handleUpdate
(
row
)
{
this
.
dataForm
=
Object
.
assign
({},
row
)
this
.
dialogStatus
=
'
update
'
this
.
dialogFormVisible
=
true
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'
dataForm
'
].
clearValidate
()
})
},
updateData
()
{
this
.
$refs
[
'
dataForm
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
updateUser
(
this
.
dataForm
).
then
(()
=>
{
for
(
const
v
of
this
.
list
)
{
if
(
v
.
id
===
this
.
dataForm
.
id
)
{
const
index
=
this
.
list
.
indexOf
(
v
)
this
.
list
.
splice
(
index
,
1
,
this
.
dataForm
)
break
}
}
this
.
dialogFormVisible
=
false
this
.
$notify
.
success
({
title
:
'
成功
'
,
message
:
'
更新成功
'
})
}).
catch
(
response
=>
{
this
.
$notify
.
error
({
title
:
'
失败
'
,
message
:
response
.
data
.
errmsg
})
})
}
})
},
handleDelete
(
row
)
{
this
.
$notify
.
error
({
title
:
'
警告
'
,
message
:
'
用户删除操作不支持!
'
})
},
handleDownload
()
{
handleDownload
()
{
this
.
downloadLoading
=
true
this
.
downloadLoading
=
true
import
(
'
@/vendor/Export2Excel
'
).
then
(
excel
=>
{
import
(
'
@/vendor/Export2Excel
'
).
then
(
excel
=>
{
...
...
Write
Preview
Supports
Markdown
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