@@ -4,10 +4,8 @@
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
/// <summary>
|
||||
@@ -18,7 +16,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
IRepository<Dictionary> _dictionaryRepository,
|
||||
IRepository<ShortcutKey> _shortcutKeyRepository) : BaseService
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,58 +4,56 @@
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户WL模板
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Reading")]
|
||||
/// <summary>
|
||||
/// 用户WL模板
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Reading")]
|
||||
public class UserWLTemplateService(
|
||||
IRepository<UserWLTemplate> _userWLTemplateRepository,
|
||||
IRepository<User> _userRepository) : BaseService
|
||||
IRepository<UserWLTemplate> _userWLTemplateRepository,
|
||||
IRepository<User> _userRepository) : BaseService
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取模板
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<UserWLTemplateView>> GetUserWLTemplateList(UserWLTemplateQuery inQuery)
|
||||
{
|
||||
var userWLTemplateQueryable = _userWLTemplateRepository
|
||||
.Where(x=>x.UserId==_userInfo.Id)
|
||||
.ProjectTo<UserWLTemplateView>(_mapper.ConfigurationProvider);
|
||||
return await userWLTemplateQueryable.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改模板
|
||||
/// </summary>
|
||||
/// <param name="addOrEditUserWLTemplate"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> AddOrUpdateUserWLTemplate(UserWLTemplateAddOrEdit addOrEditUserWLTemplate)
|
||||
{
|
||||
addOrEditUserWLTemplate.UserId = _userInfo.Id;
|
||||
if (addOrEditUserWLTemplate.Id == null)
|
||||
{
|
||||
var count = await _userWLTemplateRepository.Where(x => x.UserId == _userInfo.Id).CountAsync();
|
||||
if (count >= 10)
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取模板
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<UserWLTemplateView>> GetUserWLTemplateList(UserWLTemplateQuery inQuery)
|
||||
{
|
||||
var userWLTemplateQueryable = _userWLTemplateRepository
|
||||
.Where(x => x.UserId == _userInfo.Id)
|
||||
.ProjectTo<UserWLTemplateView>(_mapper.ConfigurationProvider);
|
||||
return await userWLTemplateQueryable.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增修改模板
|
||||
/// </summary>
|
||||
/// <param name="addOrEditUserWLTemplate"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> AddOrUpdateUserWLTemplate(UserWLTemplateAddOrEdit addOrEditUserWLTemplate)
|
||||
{
|
||||
addOrEditUserWLTemplate.UserId = _userInfo.Id;
|
||||
if (addOrEditUserWLTemplate.Id == null)
|
||||
{
|
||||
var count = await _userWLTemplateRepository.Where(x => x.UserId == _userInfo.Id).CountAsync();
|
||||
if (count >= 10)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["UserWLTS_MaxTemplate"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(await _userWLTemplateRepository.AnyAsync(x=> x.UserId == _userInfo.Id&&x.TemplateName== addOrEditUserWLTemplate.TemplateName&&x.Id!= addOrEditUserWLTemplate.Id))
|
||||
{
|
||||
if (await _userWLTemplateRepository.AnyAsync(x => x.UserId == _userInfo.Id && x.TemplateName == addOrEditUserWLTemplate.TemplateName && x.Id != addOrEditUserWLTemplate.Id))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["UserWLTS_NameRepeated"]);
|
||||
}
|
||||
|
||||
@@ -65,53 +63,53 @@ namespace IRaCIS.Core.Application.Service
|
||||
}
|
||||
|
||||
var entity = await _userWLTemplateRepository.InsertOrUpdateAsync(addOrEditUserWLTemplate, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除模板
|
||||
/// </summary>
|
||||
/// <param name="userWLTemplateId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{userWLTemplateId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteUserWLTemplate(Guid userWLTemplateId)
|
||||
{
|
||||
var success = await _userWLTemplateRepository.DeleteFromQueryAsync(t => t.Id == userWLTemplateId, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除模板
|
||||
/// </summary>
|
||||
/// <param name="userWLTemplateId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{userWLTemplateId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteUserWLTemplate(Guid userWLTemplateId)
|
||||
{
|
||||
var success = await _userWLTemplateRepository.DeleteFromQueryAsync(t => t.Id == userWLTemplateId, true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取自动切换任务配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<object> GetAutoCutNextTask()
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取自动切换任务配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<object> GetAutoCutNextTask()
|
||||
{
|
||||
|
||||
return await _userRepository.Where(x=>x.Id==_userInfo.Id).Select(x => new
|
||||
{
|
||||
AutoCutNextTask = x.AutoCutNextTask
|
||||
}).FirstNotNullAsync();
|
||||
}
|
||||
return await _userRepository.Where(x => x.Id == _userInfo.Id).Select(x => new
|
||||
{
|
||||
AutoCutNextTask = x.AutoCutNextTask
|
||||
}).FirstNotNullAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置自动切换任务
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetAutoCutNextTask(SetAutoCutNextTaskInDto inDto)
|
||||
{
|
||||
await _userRepository.UpdatePartialNowNoQueryAsync(_userInfo.Id, x => new User()
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置自动切换任务
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetAutoCutNextTask(SetAutoCutNextTaskInDto inDto)
|
||||
{
|
||||
await _userRepository.UpdatePartialNowNoQueryAsync(_userInfo.Id, x => new User()
|
||||
{
|
||||
|
||||
AutoCutNextTask = inDto.AutoCutNextTask
|
||||
});
|
||||
AutoCutNextTask = inDto.AutoCutNextTask
|
||||
});
|
||||
|
||||
await _userRepository.SaveChangesAsync ();
|
||||
await _userRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
}
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user