Browse Source

0712

master
wxd 1 year ago
parent
commit
8dc167dc01
  1. 5
      src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs
  2. 56
      src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
  3. 1
      src/Shentun.WebPeis.HttpApi.Host/appsettings.json

5
src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs

@ -30,5 +30,10 @@ namespace Shentun.WebPeis
/// 会话键值
/// </summary>
public string SessionKeyValue { get; set; }
/// <summary>
/// 是否开启个人预约
/// </summary>
public char IsOpenPersonalAppointment { get; set; }
}
}

56
src/Shentun.WebPeis.Application/Persons/PersonAppService.cs

@ -38,6 +38,7 @@ using Shentun.Utilities.Enums;
using Shentun.Sms.Client;
using Shentun.Utilities;
using IdentityModel;
using Shentun.WebPeis.SysParmValues;
namespace Shentun.WebPeis.Persons
{
/// <summary>
@ -61,6 +62,7 @@ namespace Shentun.WebPeis.Persons
private readonly CacheService _cacheService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IRepository<CustomerOrg> _customerOrgRepository;
private readonly SysParmValueManager _sysParmValueManager;
public PersonAppService(IRepository<Person> repository,
IConfiguration configuration,
IRepository<Volo.Abp.Identity.IdentityUser, Guid> identityUserRepository,
@ -74,7 +76,8 @@ namespace Shentun.WebPeis.Persons
CacheService cacheService,
IHttpContextAccessor httpContextAccessor,
IRepository<CustomerOrg> customerOrgRepository,
IRepository<QuestionRegister> questionRegisterRepository)
IRepository<QuestionRegister> questionRegisterRepository,
SysParmValueManager sysParmValueManager)
{
_repository = repository;
_configuration = configuration;
@ -90,6 +93,7 @@ namespace Shentun.WebPeis.Persons
_httpContextAccessor = httpContextAccessor;
_customerOrgRepository = customerOrgRepository;
_questionRegisterRepository = questionRegisterRepository;
_sysParmValueManager = sysParmValueManager;
}
public async Task<PersonDto> GetByIdAsync(PersonIdInputDto input)
@ -102,8 +106,8 @@ namespace Shentun.WebPeis.Persons
entityDto.SexName = await _cacheService.GetSexNameAsync(entityDto.SexId);
entityDto.MaritalStatusName = await _cacheService.GetMaritalStatusNameAsync(entityDto.MaritalStatusId);
entityDto.NationName = await _cacheService.GetNationNameAsync(entityDto.NationId);
var questionRegister = await _questionRegisterRepository.FindAsync(o=>o.PersonId == input.PersonId);
if(questionRegister != null)
var questionRegister = await _questionRegisterRepository.FindAsync(o => o.PersonId == input.PersonId);
if (questionRegister != null)
{
entityDto.IsHaveQuestionRegister = 'Y';
}
@ -154,7 +158,10 @@ namespace Shentun.WebPeis.Persons
_cache.Set(sessionKey, sessionKeyValue, options);
token.SessionKey = sessionKey;
token.SessionKeyValue = sessionKeyValue;
var isOpenPersonalAppointmentStr = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "is_open_personal_appointment");
if (string.IsNullOrWhiteSpace(isOpenPersonalAppointmentStr))
isOpenPersonalAppointmentStr = "Y";
token.IsOpenPersonalAppointment = Convert.ToChar(isOpenPersonalAppointmentStr);
return token;
}
@ -164,7 +171,7 @@ namespace Shentun.WebPeis.Persons
[UnitOfWork(IsDisabled = false)]
public async Task<UserTokenDto> CreateAsync(CreatePersonDto input)
{
if(input == null) throw new UserFriendlyException("input参数不能为空");
if (input == null) throw new UserFriendlyException("input参数不能为空");
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
@ -200,7 +207,7 @@ namespace Shentun.WebPeis.Persons
throw new UserFriendlyException("无效的短信校验码或已过期");
}
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo);
if (person != null)
{
@ -293,15 +300,15 @@ namespace Shentun.WebPeis.Persons
throw new UserFriendlyException("无效的短信校验码或已过期");
}
//更新人员信息
var person = await _repository.GetAsync(o =>o.PersonId == input.PersonId);
var person = await _repository.GetAsync(o => o.PersonId == input.PersonId);
await _personManager.UpdateAsync(entity, person);
await _repository.UpdateAsync(person);
//更新用户信息
var user = await _identityUserRepository.GetAsync(person.PersonId);
user.Name = input.PersonName;
user.SetPhoneNumber(input.MobileTelephone,false);
user.SetPhoneNumber(input.MobileTelephone, false);
await _identityUserRepository.UpdateAsync(user);
return ObjectMapper.Map<Person, PersonDto>(person);
}
@ -318,21 +325,21 @@ namespace Shentun.WebPeis.Persons
var entity = ObjectMapper.Map<UpdatePersonDto, Person>(input);
//更新人员信息
var person = await _repository.GetAsync(o => o.PersonId == input.PersonId);
await _personManager.UpdateAsync(entity, person);
await _repository.UpdateAsync(person,true);
await _repository.UpdateAsync(person, true);
//更新用户信息
var user = await _identityUserRepository.GetAsync(person.PersonId);
user.Name = input.PersonName;
await _identityUserRepository.UpdateAsync(user,true);
await _identityUserRepository.UpdateAsync(user, true);
var personDto = await GetByIdAsync(new PersonIdInputDto() { PersonId = input.PersonId });
//personDto.MobileTelephone = user.PhoneNumber;
//personDto.PersonName = user.Name;
@ -596,7 +603,7 @@ namespace Shentun.WebPeis.Persons
}
/// <summary>
/// 获取校验码
@ -765,12 +772,25 @@ namespace Shentun.WebPeis.Persons
var verifySmsValidTimeStr = _configuration.GetSection("Sms")
.GetSection("VerifySmsValidTime").Value;
var isTemplateTimeStr = _configuration.GetSection("Sms")
.GetSection("IsTemplateTime").Value;
if (!int.TryParse(verifySmsValidTimeStr, out var verifySmsValidTime))
{
throw new Exception("解析校验短信有效时间错误");
}
createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString();
if (isTemplateTimeStr == "N")
{
createSmsTaskDto.Content = message;
}
else
{
createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString();
}
//发送短信
createSmsTaskDto.TaskCycleType = '0';
await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto);

1
src/Shentun.WebPeis.HttpApi.Host/appsettings.json

@ -54,6 +54,7 @@
"Password": "888888",
"VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d",
"VerifySmsValidTime": "1",
"IsTemplateTime": "N",
"SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6"
},
"Redis": {

Loading…
Cancel
Save