public async Task <ActionResult <BaseResponse> > UpdateTypeModuleAsync(int typeId, [FromBody] TypeModuleUpdateDto req) { string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value; #region 检测类型 var type = await _ts.CheckTypeAsync(typeId); if (!type.IsExist) { return(new BaseResponse { Success = false, Message = "输入的类型编号不存在" }); } if (type.Status == 0) { return(new BaseResponse { Success = false, Message = "该类型为目录型节点,不允许添加数据" }); } #endregion var rm = await _tms.UpdateTypeModuleAsync(Account, typeId, req); return(rm); }
public async Task <BaseResponse> UpdateTypeModuleAsync(string Account, int TypeId, TypeModuleUpdateDto req) { var m = await _tmr.FindAsync(req.Id); if (m == null) { return(new BaseResponse { Success = false, Message = "数据的模块不存在" }); } var count = await _tmr.Find(a => a.TypeId == TypeId && a.ModuleName == req.ModuleName && a.Id != req.Id).CountAsync(); if (count > 0) { return(new BaseResponse { Success = false, Message = "该类型下已存在相同名称的模块" }); } try { var entity = _map.Map(req, m); entity.Modify = Account; entity.ModifyTime = DateTime.Now; await _tmr.SaveAsync(entity); _log.LogInformation($"{Account}修改标示为{req.Id}的模块数据成功"); return(new BaseResponse { Success = true, Message = "修改数据成功" }); } catch (Exception ex) { _log.LogError($"{Account}修改标示为{req.Id}的类型模块数据失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}"); return(new BaseResponse { Success = false, Message = "修改数据失败,请联系管理员" }); } }