Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
a6b44fbe
Commit
a6b44fbe
authored
Mar 11, 2019
by
zry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v2 dbug
parent
357849be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
1 deletions
+83
-1
performance/Performance.Api/Controllers/AccountController.cs
+27
-0
performance/Performance.DtoModels/Request/UserRequest.cs
+14
-1
performance/Performance.Services/UserService.cs
+42
-0
No files found.
performance/Performance.Api/Controllers/AccountController.cs
View file @
a6b44fbe
...
@@ -69,6 +69,33 @@ public ApiResponse<UserIdentity> Login([FromBody]LoginRequest request)
...
@@ -69,6 +69,33 @@ public ApiResponse<UserIdentity> Login([FromBody]LoginRequest request)
}
}
/// <summary>
/// <summary>
/// 修改个人信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
Route
(
"updateself"
)]
[
HttpPost
]
public
ApiResponse
<
UserResponse
>
UpdateSelf
([
CustomizeValidator
(
RuleSet
=
"Self"
),
FromBody
]
UserRequest
request
)
{
request
.
ID
=
_claim
.
At
(
request
.
Token
).
UserID
;
var
user
=
_userService
.
UpdateSelf
(
request
);
return
new
ApiResponse
<
UserResponse
>(
ResponseType
.
OK
,
user
);
}
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
Route
(
"list"
)]
[
HttpPost
]
public
ApiResponse
<
List
<
UserResponse
>>
List
([
FromBody
]
ApiRequest
request
)
{
var
userList
=
_userService
.
GetUserList
(
_claim
.
At
(
request
.
Token
).
UserID
);
return
new
ApiResponse
<
List
<
UserResponse
>>(
ResponseType
.
OK
,
"ok"
,
userList
);
}
/// <summary>
/// 新增用户
/// 新增用户
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
...
...
performance/Performance.DtoModels/Request/UserRequest.cs
View file @
a6b44fbe
...
@@ -61,7 +61,20 @@ public UserRequestValidator()
...
@@ -61,7 +61,20 @@ public UserRequestValidator()
{
{
action
();
action
();
RuleFor
(
x
=>
x
.
ID
).
NotNull
().
NotEmpty
().
GreaterThan
(
0
);
RuleFor
(
x
=>
x
.
ID
).
NotNull
().
NotEmpty
().
GreaterThan
(
0
);
RuleFor
(
x
=>
x
.
States
).
NotNull
().
NotEmpty
().
InclusiveBetween
(
1
,
2
);
RuleFor
(
x
=>
x
.
States
).
InclusiveBetween
(
1
,
2
);
RuleFor
(
x
=>
x
.
Password
).
Length
(
4
,
20
);
});
RuleSet
(
"Self"
,
()
=>
{
RuleFor
(
x
=>
x
.
Password
).
Length
(
4
,
20
);
RuleFor
(
x
=>
x
.
Mobile
).
Must
((
pre
)
=>
{
if
(!
string
.
IsNullOrEmpty
(
pre
))
return
CustomValidator
.
IsMobile
(
pre
);
return
true
;
});
RuleFor
(
x
=>
x
.
Mail
).
EmailAddress
().
When
(
pre
=>
{
return
!
string
.
IsNullOrEmpty
(
pre
.
Mail
);
});
});
});
}
}
}
}
...
...
performance/Performance.Services/UserService.cs
View file @
a6b44fbe
...
@@ -66,6 +66,17 @@ public UserIdentity Login(LoginRequest request)
...
@@ -66,6 +66,17 @@ public UserIdentity Login(LoginRequest request)
}
}
/// <summary>
/// <summary>
/// 查询用户列表
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public
List
<
UserResponse
>
GetUserList
(
int
userID
)
{
var
userlist
=
_userRepository
.
GetEntities
(
t
=>
t
.
CreateUser
==
userID
);
return
Mapper
.
Map
<
List
<
UserResponse
>>(
userlist
);
}
/// <summary>
/// 新增用户
/// 新增用户
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
...
@@ -141,6 +152,37 @@ public UserResponse Update(UserRequest request)
...
@@ -141,6 +152,37 @@ public UserResponse Update(UserRequest request)
user
.
RealName
=
request
.
RealName
;
user
.
RealName
=
request
.
RealName
;
user
.
Mail
=
request
.
Mail
;
user
.
Mail
=
request
.
Mail
;
user
.
States
=
request
.
States
;
user
.
States
=
request
.
States
;
user
.
Password
=
string
.
IsNullOrEmpty
(
request
.
Password
)
?
user
.
Password
:
request
.
Password
;
if
(!
_userRepository
.
Update
(
user
))
throw
new
PerformanceException
(
"保存失败"
);
return
Mapper
.
Map
<
UserResponse
>(
user
);
}
/// <summary>
/// 修改个人信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
UserResponse
UpdateSelf
(
UserRequest
request
)
{
var
user
=
_userRepository
.
GetEntity
(
t
=>
t
.
ID
==
request
.
ID
);
if
(
null
==
user
)
throw
new
PerformanceException
(
$"用户不存在 UserId:
{
request
.
ID
}
"
);
var
vlist
=
_userRepository
.
GetEntities
(
t
=>
t
.
ID
!=
user
.
ID
&&
t
.
Login
==
request
.
Login
);
if
(
null
!=
vlist
&&
vlist
.
Count
()
>
0
)
throw
new
PerformanceException
(
"登录名重复"
);
vlist
=
_userRepository
.
GetEntities
(
t
=>
t
.
ID
!=
user
.
ID
&&
t
.
Mobile
==
request
.
Mobile
);
if
(
null
!=
vlist
&&
vlist
.
Count
()
>
0
)
throw
new
PerformanceException
(
"手机号重复"
);
user
.
Mobile
=
string
.
IsNullOrEmpty
(
request
.
RealName
)
?
user
.
Mobile
:
request
.
Mobile
;
user
.
RealName
=
string
.
IsNullOrEmpty
(
request
.
RealName
)
?
user
.
RealName
:
request
.
RealName
;
user
.
Mail
=
string
.
IsNullOrEmpty
(
request
.
Mail
)
?
user
.
Mail
:
request
.
Mail
;
user
.
Password
=
string
.
IsNullOrEmpty
(
request
.
Password
)
?
user
.
Password
:
request
.
Password
;
if
(!
_userRepository
.
Update
(
user
))
if
(!
_userRepository
.
Update
(
user
))
throw
new
PerformanceException
(
"保存失败"
);
throw
new
PerformanceException
(
"保存失败"
);
...
...
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