public async Task <IActionResult> ModuleDetail(int id, AdModule model, int pid = 0) { var now = DateTime.Now; var result = new Result(); if (model.Name.IsNullOrEmpty()) { result.Error("请输入中文名称"); return(Json(result)); } if (id > 0 && pid == 0) { var old = DefaultStorage.AdModuleGet(id); if (old == null) { result.Message = "数据不存在"; return(Json(result)); } var status = await TryUpdateModelAsync(old); if (status) { result.Status = DefaultStorage.AdModuleUpdate(old); if (!result.Status) { result.Message = "更新失败"; } } else { result.Message = "参数有误"; } return(Json(result)); } if (id == 0 && pid == 0) { result.Message = "参数错误"; return(Json(result)); } model.Pid = pid; model.Extra = string.Empty; model.CreatedOn = now; model.ModifiedBy = string.Empty; model.ModifiedOn = now; var hs = GetParendIds(pid); model.Depth = hs.Count + 1; model.Path = string.Join(",", hs); var newId = DefaultStorage.AdModuleCreate(model); if (result.Status = newId > 0) { hs.Add(newId);//补全path var path = string.Join(",", hs); DefaultStorage.AdModulePathUpdate(newId, path); result.Success(); } return(Json(result)); }