执行代码清理,修复warning

This commit is contained in:
2023-11-06 19:59:12 +08:00
parent c6b8dfc861
commit 1dbb17f103
118 changed files with 5046 additions and 4111 deletions

View File

@@ -36,7 +36,7 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task<string> Publish(SpotInsTemPublishInput input)
{
var db = _repository.AsSugarClient();
ISqlSugarClient db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
EqpSpotInsTemH eqpSpotInsTemH = await _repository.GetSingleAsync(x => x.id == input.id);
@@ -44,13 +44,13 @@ namespace Tnb.EquipMgr
if (input.equipIds != null && input.equipIds.Length > 0)
{
List<EqpSpotInsTemEquipH> insertEqpSpotInsTemEquipHs = new List<EqpSpotInsTemEquipH>();
List<EqpSpotInsTemEquipD> insertEqpSpotInsTemEquipDs = new List<EqpSpotInsTemEquipD>();
foreach (var equipId in input.equipIds)
List<EqpSpotInsTemEquipH> insertEqpSpotInsTemEquipHs = new();
List<EqpSpotInsTemEquipD> insertEqpSpotInsTemEquipDs = new();
foreach (string equipId in input.equipIds)
{
string id = SnowflakeIdHelper.NextId();
string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new EqpSpotInsTemEquipH()
EqpSpotInsTemEquipH eqpSpotInsTemEquipH = new()
{
id = id,
code = code,
@@ -79,9 +79,9 @@ namespace Tnb.EquipMgr
if (eqpSpotInsTemDs != null && eqpSpotInsTemDs.Count > 0)
{
foreach (var eqpSpotInsTem in eqpSpotInsTemDs)
foreach (EqpSpotInsTemD eqpSpotInsTem in eqpSpotInsTemDs)
{
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new EqpSpotInsTemEquipD()
EqpSpotInsTemEquipD eqpSpotInsTemEquipD = new()
{
id = SnowflakeIdHelper.NextId(),
spot_ins_item_id = eqpSpotInsTem?.spot_ins_item_id ?? "",
@@ -92,27 +92,28 @@ namespace Tnb.EquipMgr
}
EqpSpotInsTemEquipH oldSpotInsTemEquipH = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id == equipId).FirstAsync();
await db.Deleteable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id == equipId).ExecuteCommandAsync();
_ = await db.Deleteable<EqpSpotInsTemEquipH>().Where(x => x.spot_ins_tem_id == input.id && x.equip_id == equipId).ExecuteCommandAsync();
if (oldSpotInsTemEquipH != null)
await db.Deleteable<EqpSpotInsTemEquipD>().Where(x => x.spot_ins_tem_equip_id == oldSpotInsTemEquipH.id).ExecuteCommandAsync();
{
_ = await db.Deleteable<EqpSpotInsTemEquipD>().Where(x => x.spot_ins_tem_equip_id == oldSpotInsTemEquipH.id).ExecuteCommandAsync();
}
}
if (insertEqpSpotInsTemEquipHs != null && insertEqpSpotInsTemEquipHs.Count > 0)
{
await db.Insertable(insertEqpSpotInsTemEquipHs).ExecuteCommandAsync();
_ = await db.Insertable(insertEqpSpotInsTemEquipHs).ExecuteCommandAsync();
}
if (insertEqpSpotInsTemEquipDs != null && insertEqpSpotInsTemEquipDs.Count > 0)
{
await db.Insertable(insertEqpSpotInsTemEquipDs).ExecuteCommandAsync();
_ = await db.Insertable(insertEqpSpotInsTemEquipDs).ExecuteCommandAsync();
}
}
});
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result.IsSuccess ? "发布成功" : result.ErrorMessage;
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "发布成功" : result.ErrorMessage;
}
}
}