public ReturnMsg AddOrUpdateAppMstrInfo(WctAppMstrDto dto, ReturnMsg rm) { var entity = new WctAppMstr(); var isAdd = string.IsNullOrEmpty(dto.Id) ? true : false; if (string.IsNullOrEmpty(dto.Id)) { dto.Id = Guid.NewGuid().ToString("N"); dto.APP_KEY = "primary"; _initHelper.InitAdd(dto, AbpSession.USR_ID, AbpSession.ORG_NO, AbpSession.BG_NO); using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { entity = dto.ToEntity(); _wctAppMstrRepository.Insert(entity); unitOfWork.Complete(); } } else { _initHelper.InitUpdate(dto, AbpSession.USR_ID); using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { entity = dto.ToEntity(); _wctAppMstrRepository.Update(entity); unitOfWork.Complete(); } } if (dto.WCT_MODULE_TYPE == "1") { var appItem = new WctAppItem(); if (!isAdd) { using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { _wctAppItemRepository.DelAppItemInfo(dto.Id); unitOfWork.Complete(); } } var i = 1; foreach (var item in dto.appItemList) { item.Id = Guid.NewGuid().ToString("N"); item.ITEM_SORT = i; _initHelper.InitAdd(item, AbpSession.USR_ID, AbpSession.ORG_NO, AbpSession.BG_NO); using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { appItem = item.ToEntity(); _wctAppItemRepository.Insert(appItem); unitOfWork.Complete(); } } } rm.IsSuccess = true; return(rm); }
public ActionResult SaveAppInfo([FromBody] WctAppMstrDto dto) { try { var result = _wctAppMstrService.SaveAppInfo(dto); if (!result.IsSuccess) { return(Fail(result.msg)); } return(Success("保存成功")); } catch (Exception ex) { return(Fail(ex.Message)); } }
/// <summary> /// 保存app菜单信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> public ReturnMsg SaveAppInfo(WctAppMstrDto dto) { var rm = new ReturnMsg(); var isOk = CheckAppInfo(dto, rm); if (!isOk.IsSuccess) { return(rm); } var excute = AddOrUpdateAppMstrInfo(dto, rm); if (!excute.IsSuccess) { return(rm); } var redisNum = Convert.ToInt32(rm.result); var appList = GetAppInfoList(rm); if (!appList.IsSuccess) { return(rm); } var redis = _redisHelper.GetRedisClient(redisNum); var key = AbpSession.ORG_NO + "-APP_ID"; if (redis.Exists(key) != 1) { redis.Add(key, JsonConvert.DeserializeObject <List <WctAppInfoModel> >(rm.result)); } else { redis.Set(key, JsonConvert.DeserializeObject <List <WctAppInfoModel> >(rm.result)); } rm.IsSuccess = true; return(rm); }
/// <summary> /// 校验app应用信息 /// </summary> /// <param name="dto"></param> /// <param name="rm"></param> /// <returns></returns> public ReturnMsg CheckAppInfo(WctAppMstrDto dto, ReturnMsg rm) { var basConfig = _wctBasConfigRepository.FirstOrDefault(c => c.BG_NO == AbpSession.BG_NO); if (basConfig == null) { rm.IsSuccess = false; rm.msg = "请先维护微信基础配置"; return(rm); } if (dto.APP_SORT == null) { rm.IsSuccess = false; rm.msg = "请填写序号"; return(rm); } if (dto.APP_SORT < 0) { rm.IsSuccess = false; rm.msg = "序号必须大于0"; return(rm); } if (string.IsNullOrEmpty(dto.UDF2)) { rm.IsSuccess = false; rm.msg = "模块KEY不可为空"; return(rm); } if (string.IsNullOrEmpty(dto.UDF3)) { rm.IsSuccess = false; rm.msg = "模块图标不可为空"; return(rm); } if (string.IsNullOrEmpty(dto.WCT_MODULE_TYPE)) { rm.IsSuccess = false; rm.msg = "模块类型不可为空"; return(rm); } if (dto.WCT_MODULE_TYPE == "1") { if (string.IsNullOrEmpty(dto.SYS_MODULE_IDS)) { rm.IsSuccess = false; rm.msg = "请选择子模块"; return(rm); } if (dto.appItemList == null || dto.appItemList.Count == 0) { rm.IsSuccess = false; rm.msg = "请选择子模块"; return(rm); } } var result = new List <WctAppMstr>(); result = GetExpressionResult(dto.Id, c => c.APP_SORT == dto.APP_SORT && c.APP_KEY == "primary"); if (result.Count > 0) { rm.IsSuccess = false; rm.msg = "该序号已存在,请修改"; return(rm); } result = GetExpressionResult(dto.Id, c => c.WCT_MODULE_ID == dto.WCT_MODULE_ID && c.APP_KEY == "primary"); if (result.Count > 0) { rm.IsSuccess = false; rm.msg = "该关联模块已存在,请修改"; return(rm); } rm.IsSuccess = true; rm.result = JsonConvert.SerializeObject(basConfig.REDIS_NUM); return(rm); }