Exemple #1
0
        public async Task <SysDto> GetAsync()
        {
            var sys = await _sysRepo.GetAsync();

            if (sys == null)
            {
                throw new IamException(System.Net.HttpStatusCode.InternalServerError, "系统信息不存在");
            }

            return(_mapper.Map <SysDto>(sys));
        }
Exemple #2
0
        /// <summary>
        /// 验证用户的手机号,工号是否符合系统配置
        /// </summary>
        /// <param name="jobNo"></param>
        /// <param name="phone"></param>
        /// <returns></returns>
        private async Task ValidateUserAsync(string jobNo, string phone)
        {
            var sys = await _sysRepo.GetAsync();

            if (sys == null)
            {
                return;
            }

            if (!String.IsNullOrWhiteSpace(jobNo) && sys.IsJobNoUnique)
            {
                // 如果新用户提供了工号,则必须检查
                if (await _userRepo.IsExistedAsync(jobNo: jobNo))
                {
                    throw new IamException(HttpStatusCode.BadRequest, "该工号用户已经存在!");
                }
            }

            if (!String.IsNullOrWhiteSpace(phone) && sys.IsUserPhoneUnique)
            {
                // 如果新用户提供了手机号,则必须检查
                if (await _userRepo.IsExistedAsync(phone: phone))
                {
                    throw new IamException(HttpStatusCode.BadRequest, "该手机号用户已经存在!");
                }
            }
        }