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
79c0f877
Commit
79c0f877
authored
Mar 11, 2019
by
zry
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/hangfire
parents
c4f1eb96
bd02894d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
15 deletions
+122
-15
performance/Performance.Api/Controllers/AccountController.cs
+27
-0
performance/Performance.Api/Controllers/HospitalController.cs
+1
-0
performance/Performance.Api/Startup.cs
+13
-13
performance/Performance.DtoModels/Request/UserRequest.cs
+14
-1
performance/Performance.DtoModels/Response/HospitalRequest.cs
+1
-1
performance/Performance.DtoModels/Response/UserResponse.cs
+1
-0
performance/Performance.Services/HospitalService.cs
+11
-0
performance/Performance.Services/UserService.cs
+54
-0
No files found.
performance/Performance.Api/Controllers/AccountController.cs
View file @
79c0f877
...
@@ -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.Api/Controllers/HospitalController.cs
View file @
79c0f877
...
@@ -36,6 +36,7 @@ public ApiResponse<HospitalResponse> Insert([CustomizeValidator(RuleSet = "Inser
...
@@ -36,6 +36,7 @@ public ApiResponse<HospitalResponse> Insert([CustomizeValidator(RuleSet = "Inser
{
{
var
userid
=
_claim
.
At
(
request
.
Token
).
UserID
;
var
userid
=
_claim
.
At
(
request
.
Token
).
UserID
;
var
hospital
=
_hospitalService
.
Insert
(
request
,
userid
);
var
hospital
=
_hospitalService
.
Insert
(
request
,
userid
);
_hospitalService
.
InsertUserHospital
(
userid
,
hospital
.
HosID
);
return
new
ApiResponse
<
HospitalResponse
>(
ResponseType
.
OK
,
hospital
);
return
new
ApiResponse
<
HospitalResponse
>(
ResponseType
.
OK
,
hospital
);
}
}
...
...
performance/Performance.Api/Startup.cs
View file @
79c0f877
...
@@ -96,10 +96,10 @@ public void ConfigureServices(IServiceCollection services)
...
@@ -96,10 +96,10 @@ public void ConfigureServices(IServiceCollection services)
.
Configure
<
Application
>(
Configuration
.
GetSection
(
"Application"
))
.
Configure
<
Application
>(
Configuration
.
GetSection
(
"Application"
))
.
Configure
<
HuyiSmsConfig
>(
Configuration
.
GetSection
(
"HuyiSmsConfig"
));
.
Configure
<
HuyiSmsConfig
>(
Configuration
.
GetSection
(
"HuyiSmsConfig"
));
services
.
AddSwaggerGen
(
c
=>
//
services.AddSwaggerGen(c =>
{
//
{
c
.
SwaggerDoc
(
"v1"
,
new
Info
{
Title
=
"My API"
,
Version
=
"v1"
});
//
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});
//
});
//huyi短信发送注入
//huyi短信发送注入
services
.
AddScoped
<
HuyiSmsNotify
>();
services
.
AddScoped
<
HuyiSmsNotify
>();
...
@@ -132,16 +132,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
...
@@ -132,16 +132,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
{
{
app
.
UseStatusCodePagesWithReExecute
(
"/error/{0}"
);
app
.
UseStatusCodePagesWithReExecute
(
"/error/{0}"
);
}
}
// Enable middleware to serve generated Swagger as a JSON endpoint.
//
//
Enable middleware to serve generated Swagger as a JSON endpoint.
app
.
UseSwagger
();
//
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
//
//
Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
//
//
specifying the Swagger JSON endpoint.
app
.
UseSwaggerUI
(
c
=>
//
app.UseSwaggerUI(c =>
{
//
{
c
.
SwaggerEndpoint
(
"/swagger/v1/swagger.json"
,
"My API V1"
);
//
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
c
.
RoutePrefix
=
string
.
Empty
;
//
c.RoutePrefix = string.Empty;
});
//
});
app
.
UseHangfireServer
();
app
.
UseHangfireServer
();
app
.
UseHangfireDashboard
();
app
.
UseHangfireDashboard
();
...
...
performance/Performance.DtoModels/Request/UserRequest.cs
View file @
79c0f877
...
@@ -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.DtoModels/Response/HospitalRequest.cs
View file @
79c0f877
...
@@ -12,6 +12,6 @@ public class HospitalResponse
...
@@ -12,6 +12,6 @@ public class HospitalResponse
public
string
AreaCode
{
get
;
set
;
}
public
string
AreaCode
{
get
;
set
;
}
public
string
HosLevel
{
get
;
set
;
}
public
string
HosLevel
{
get
;
set
;
}
public
string
HosType
{
get
;
set
;
}
public
string
HosType
{
get
;
set
;
}
public
string
States
{
get
;
set
;
}
public
int
States
{
get
;
set
;
}
}
}
}
}
performance/Performance.DtoModels/Response/UserResponse.cs
View file @
79c0f877
...
@@ -14,5 +14,6 @@ public class UserResponse
...
@@ -14,5 +14,6 @@ public class UserResponse
public
string
Mail
{
get
;
set
;
}
public
string
Mail
{
get
;
set
;
}
public
string
Mobile
{
get
;
set
;
}
public
string
Mobile
{
get
;
set
;
}
public
int
States
{
get
;
set
;
}
public
int
States
{
get
;
set
;
}
public
List
<
int
>
Hospital
{
get
;
set
;
}
}
}
}
}
performance/Performance.Services/HospitalService.cs
View file @
79c0f877
...
@@ -53,6 +53,17 @@ public sys_hospital GetHopital(int hosid)
...
@@ -53,6 +53,17 @@ public sys_hospital GetHopital(int hosid)
}
}
/// <summary>
/// <summary>
/// 新增
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
bool
InsertUserHospital
(
int
userid
,
int
hospitalid
)
{
var
uh
=
new
sys_user_hospital
{
UserID
=
userid
,
HospitalID
=
hospitalid
};
return
_joinRepository
.
Add
(
uh
);
}
/// <summary>
/// 新增医院
/// 新增医院
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
...
...
performance/Performance.Services/UserService.cs
View file @
79c0f877
...
@@ -66,6 +66,29 @@ public UserIdentity Login(LoginRequest request)
...
@@ -66,6 +66,29 @@ 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
);
var
result
=
Mapper
.
Map
<
List
<
UserResponse
>>(
userlist
);
if
(
result
!=
null
&&
result
.
Count
>
0
)
{
foreach
(
var
item
in
result
)
{
var
hoslist
=
_userhospitalRepository
.
GetEntities
(
p
=>
p
.
UserID
==
item
.
UserID
);
if
(
hoslist
!=
null
&&
hoslist
.
Count
()
>
0
)
{
item
.
Hospital
=
hoslist
.
Select
(
p
=>
p
.
HospitalID
.
Value
).
ToList
();
}
}
}
return
result
;
}
/// <summary>
/// 新增用户
/// 新增用户
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
...
@@ -141,6 +164,37 @@ public UserResponse Update(UserRequest request)
...
@@ -141,6 +164,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