Skip to content

Commit a5a886b

Browse files
author
1877682825@qq.com
committed
update
1 parent 39d0a3a commit a5a886b

File tree

5 files changed

+17
-52
lines changed

5 files changed

+17
-52
lines changed

ant.mgr/Repository/Repository/AdminRepository/AccountRespository.cs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ from ro in this.Entitys.SystemRole.Where(r => r.Tid.Equals(u.RoleTid)).DefaultIf
5858
where u.Eid.Equals(info.eid)
5959
select new { user = u, role = ro }).FirstOrDefaultAsync();
6060

61-
var systemUser = systemUserAndRole != null ? systemUserAndRole.user : null;
61+
var systemUser = systemUserAndRole?.user;
6262

6363
if (systemUser == null)
6464
{
@@ -70,11 +70,7 @@ where u.Eid.Equals(info.eid)
7070
return new Tuple<bool, string>(false, "该账号已被禁用,请联系系统管理员!");
7171
}
7272

73-
var role = systemUserAndRole.role;
74-
if (role == null)
75-
{
76-
role = new SystemRole();
77-
}
73+
var role = systemUserAndRole.role ?? new SystemRole();
7874

7975
var loginIp = WebUtils.GetClientIP();
8076
var userAgent = WebUtils.GetUserAgent();
@@ -176,8 +172,7 @@ from role in this.Entitys.SystemRole.Where(r => r.Tid.Equals(u.RoleTid)).Default
176172
Phone = u.Phone,
177173
CreateUser = u.CreateUser
178174
})
179-
.DynamicOrderBy(string.IsNullOrEmpty(model.OrderBy) ? "DataChangeLastTime" : model.OrderBy,
180-
model.OrderSequence)
175+
.DynamicOrderBy(string.IsNullOrEmpty(model.OrderBy) ? "DataChangeLastTime" : model.OrderBy,model.OrderSequence)
181176
.Skip((model.PageIndex - 1) * model.PageSize)
182177
.Take(model.PageSize)
183178
.ToListAsync();
@@ -222,11 +217,7 @@ public async Task<Tuple<bool, string>> UserAddRole(UserAddRoleVm info)
222217
.Set(r => r.CreateRoleName, "," + string.Join(",", createRoleList) + ",")
223218
.UpdateAsync() > 0;
224219

225-
if (!updateResult)
226-
{
227-
return new Tuple<bool, string>(false, Tip.UpdateError);
228-
}
229-
return new Tuple<bool, string>(true, string.Empty);
220+
return !updateResult ? new Tuple<bool, string>(false, Tip.UpdateError) : new Tuple<bool, string>(true, string.Empty);
230221
}
231222

232223
/// <summary>
@@ -327,12 +318,7 @@ public async Task<Tuple<bool, string>> UserAdd(SystemUsers info, Token user)
327318
info.CreateUser = user.Eid;
328319

329320
var inertResult = DB.Insert(info) > 0;
330-
if (!inertResult)
331-
{
332-
return new Tuple<bool, string>(false, Tip.SystemError);
333-
}
334-
335-
return new Tuple<bool, string>(true, string.Empty);
321+
return !inertResult ? new Tuple<bool, string>(false, Tip.SystemError) : new Tuple<bool, string>(true, string.Empty);
336322
}
337323

338324
/// <summary>
@@ -376,8 +362,7 @@ public async Task<string> UpdateUserInfo(SystemUsers user)
376362

377363
var rt = await query.UpdateAsync() > 0;
378364

379-
if (!rt) return Tip.UpdateError;
380-
return string.Empty;
365+
return !rt ? Tip.UpdateError : string.Empty;
381366
}
382367

383368
/// <summary>
@@ -405,8 +390,7 @@ public async Task<string> UpdatePwd(UpdatePwdVm user)
405390

406391
var newPwd = CodingUtils.MD5(user.Pwd);
407392
var rt = this.Entity.Where(r => r.Eid.Equals(user.Eid)).Set(r => r.DataChangeLastTime, DateTime.Now).Set(r => r.Pwd, newPwd).Update() > 0;
408-
if (!rt) return Tip.UpdateError;
409-
return string.Empty;
393+
return !rt ? Tip.UpdateError : string.Empty;
410394
}
411395

412396
private void GetRoleName(SystemRole role, List<long> roleList)

ant.mgr/Repository/Repository/AdminRepository/MenuRespository.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,7 @@ public string DisableMenu(long menuTid)
211211
.Set(r=>r.IsActive,false)
212212
.Set(r => r.Level, DisableMenuLevel)//目前最多支持2级。。 88是代表这个菜单不用了
213213
.Update() > 0;
214-
if (!updateResult)
215-
{
216-
return Tip.UpdateError;
217-
}
218-
return String.Empty;
214+
return !updateResult ? Tip.UpdateError : String.Empty;
219215
}
220216

221217
/// <summary>
@@ -226,11 +222,7 @@ public string DisableMenu(long menuTid)
226222
public SystemMenuSM GetCurrentMenu(long menuTid)
227223
{
228224
var menu = this.Entity.FirstOrDefault(r => r.Tid.Equals(menuTid));
229-
if (menu != null)
230-
{
231-
return MapperTo<SystemMenu, SystemMenuSM>(menu);
232-
}
233-
return new SystemMenuSM();
225+
return menu != null ? MapperTo<SystemMenu, SystemMenuSM>(menu) : new SystemMenuSM();
234226
}
235227

236228
/// <summary>
@@ -253,11 +245,7 @@ public string UpdateMenu(AddMenuVm model)
253245
.Set(r => r.OrderRule, model.OrderRule)
254246
.Set(r => r.IsActive, model.IsActive)
255247
.Update() > 0;
256-
if (!updateResult)
257-
{
258-
return Tip.UpdateError;
259-
}
260-
return String.Empty;
248+
return !updateResult ? Tip.UpdateError : String.Empty;
261249
}
262250

263251
/// <summary>
@@ -299,11 +287,7 @@ public string AddMenu(AddMenuVm model)
299287
DataChangeLastTime = DateTime.Now
300288
};
301289
var result = this.Save(menu) > 0;
302-
if (!result)
303-
{
304-
return Tip.InserError;
305-
}
306-
return String.Empty;
290+
return !result ? Tip.InserError : String.Empty;
307291
}
308292

309293
/// <summary>

ant.mgr/Repository/Repository/AdminRepository/RoleRespository.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Collections.Generic;
1111
using System.Linq;
1212
using System.Threading.Tasks;
13+
using System.Transactions;
1314
using Autofac.Aspect;
1415
using DbModel;
1516
using Repository.Interceptors;
@@ -29,6 +30,7 @@ public class RoleRespository : BaseRepository<SystemRole>, IRoleRespository
2930
/// </summary>
3031
/// <param name="model"></param>
3132
/// <returns></returns>
33+
[EnableTransactionScope]
3234
public async Task<string> AddRoleActions(RoleAction model)
3335
{
3436
if (model == null || model.MenuId < 1 || string.IsNullOrEmpty(model.ActionId)) return Tip.BadRequest;
@@ -90,13 +92,7 @@ public async Task<string> DeleteRole(long tid, Token user)
9092
}
9193

9294
var rt = this.Entity.Where(r => r.Tid.Equals(tid)).Delete() > 0;
93-
if (!rt)
94-
{
95-
return Tip.UpdateError;
96-
}
97-
98-
return string.Empty;
99-
95+
return !rt ? Tip.UpdateError : string.Empty;
10096
}
10197

10298
/// <summary>
@@ -214,6 +210,7 @@ public async Task<string> AddRole(AddRoleVm role, Token user)
214210

215211
if (!updateResult)
216212
{
213+
Transaction.Current.Rollback();
217214
return Tip.UpdateError;
218215
}
219216

ant.mgr/Repository/Repository/Repository.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Autofac.Annotation" Version="3.0.3" />
12+
<PackageReference Include="Autofac.Annotation" Version="3.0.4" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

ant.mgr/mgr.core/ant.mgr.core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
<ItemGroup>
16-
<PackageReference Include="Autofac.Annotation" Version="3.0.3" />
16+
<PackageReference Include="Autofac.Annotation" Version="3.0.4" />
1717
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
1818
<PackageReference Include="Microsoft.AspNetCore.App" />
1919
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />

0 commit comments

Comments
 (0)