Skip to content

Commit

Permalink
fix(backend): 🐛 更新计划作业在sqlite数据库环境报错 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsnail authored May 14, 2024
1 parent 40e8eff commit 3152a8d
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,25 @@ public async Task<int> DeleteAsync(DelReq req)
public async Task<QueryJobRsp> EditAsync(UpdateJobReq req)
{
req.ThrowIfInvalid();
var ret = await Rpo.UpdateDiy.Set(a => a.ExecutionCron == req.ExecutionCron)
.Set(a => a.HttpMethod == req.HttpMethod)
.Set(a => a.JobName == req.JobName)
.SetIf(req.RequestHeaders == null, a => a.RequestHeader, null)
.SetIf(req.RequestHeaders != null, a => a.RequestHeader, req.RequestHeaders.Json())
.Set(a => a.RequestBody == req.RequestBody)
.Set(a => a.RequestUrl == req.RequestUrl)
.Set(a => a.UserId == req.UserId)
.Where(a => a.Id == req.Id)
.ExecuteUpdatedAsync()
.ConfigureAwait(false);
return ret[0].Adapt<QueryJobRsp>();
var update = Rpo.UpdateDiy.Set(a => a.ExecutionCron == req.ExecutionCron)
.Set(a => a.HttpMethod == req.HttpMethod)
.Set(a => a.JobName == req.JobName)
.SetIf(req.RequestHeaders == null, a => a.RequestHeader, null)
.SetIf(req.RequestHeaders != null, a => a.RequestHeader, req.RequestHeaders.Json())
.Set(a => a.RequestBody == req.RequestBody)
.Set(a => a.RequestUrl == req.RequestUrl)
.Set(a => a.UserId == req.UserId)
.Where(a => a.Id == req.Id);

#pragma warning disable IDE0046
if (Rpo.Orm.Ado.DataType == DataType.Sqlite) {
#pragma warning restore IDE0046
return await update.ExecuteAffrowsAsync().ConfigureAwait(false) <= 0
? null
: await GetAsync(new QueryJobReq { Id = req.Id }).ConfigureAwait(false);
}

return (await update.ExecuteUpdatedAsync().ConfigureAwait(false))[0].Adapt<QueryJobRsp>();
}

/// <inheritdoc />
Expand Down

0 comments on commit 3152a8d

Please sign in to comment.