项目修改增加校验
parent
a099dd3b0f
commit
5f7004b500
|
|
@ -25,6 +25,12 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
|
||||
public async Task<Response<bool>> UpdateProject(GoviewProject project)
|
||||
{
|
||||
var exist = await Repository.AsQueryable().CountAsync(a => a.Id == project.Id);
|
||||
if (exist == 0)
|
||||
{
|
||||
return new Response<bool> { Code = 500, Message = "项目不存在" };
|
||||
}
|
||||
|
||||
var flag = await Repository.AsUpdateable(project).IgnoreNullColumns().ExecuteCommandAsync();
|
||||
return new Response<bool>
|
||||
{ Code = 200, Result = flag > 0, Message = flag > 0 ? "修改成功" : "修改失败" };
|
||||
|
|
@ -38,7 +44,8 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
project.CreateUserId = userId;
|
||||
project.Id = Guid.NewGuid().ToString();
|
||||
var flag = await Repository.InsertAsync(project);
|
||||
return new Response<GoviewProject> { Code = 200, Result = flag ? project : null, Message = flag ? "创建成功" : "创建失败" };
|
||||
return new Response<GoviewProject>
|
||||
{ Code = 200, Result = flag ? project : null, Message = flag ? "创建成功" : "创建失败" };
|
||||
}
|
||||
|
||||
public async Task<Response<bool>> Publish(GoViewProjectRequest req)
|
||||
|
|
@ -121,6 +128,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
.IgnoreNullColumns()
|
||||
.ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
return new Response<bool> { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" };
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue