233
This commit is contained in:
parent
2863559ba0
commit
6c521672f5
|
|
@ -12,9 +12,11 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using CoreCms.Net.Model.Entities;
|
using CoreCms.Net.Model.Entities;
|
||||||
using CoreCms.Net.Model.ViewModels.Basics;
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace CoreCms.Net.IServices
|
namespace CoreCms.Net.IServices
|
||||||
|
|
@ -95,5 +97,13 @@ namespace CoreCms.Net.IServices
|
||||||
Expression<Func<SQRooms, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
Expression<Func<SQRooms, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||||
int pageSize = 20, bool blUseNoLock = false);
|
int pageSize = 20, bool blUseNoLock = false);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 获取所有数据
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SQRooms>> GetRoomList();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||||
using CoreCms.Net.Configuration;
|
using CoreCms.Net.Configuration;
|
||||||
using CoreCms.Net.IRepository;
|
using CoreCms.Net.IRepository;
|
||||||
using CoreCms.Net.IRepository.UnitOfWork;
|
using CoreCms.Net.IRepository.UnitOfWork;
|
||||||
|
|
@ -19,6 +21,7 @@ using CoreCms.Net.IServices;
|
||||||
using CoreCms.Net.Model.Entities;
|
using CoreCms.Net.Model.Entities;
|
||||||
using CoreCms.Net.Model.ViewModels.Basics;
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -31,12 +34,14 @@ namespace CoreCms.Net.Services
|
||||||
{
|
{
|
||||||
private readonly ISQRoomsRepository _dal;
|
private readonly ISQRoomsRepository _dal;
|
||||||
private readonly IUnitOfWork _unitOfWork;
|
private readonly IUnitOfWork _unitOfWork;
|
||||||
|
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||||
public SQRoomsServices(IUnitOfWork unitOfWork, ISQRoomsRepository dal)
|
public SQRoomsServices(IUnitOfWork unitOfWork, ISQRoomsRepository dal,
|
||||||
|
IRedisOperationRepository redisOperationRepository)
|
||||||
{
|
{
|
||||||
this._dal = dal;
|
this._dal = dal;
|
||||||
base.BaseDal = dal;
|
base.BaseDal = dal;
|
||||||
_unitOfWork = unitOfWork;
|
_unitOfWork = unitOfWork;
|
||||||
|
_redisOperationRepository = redisOperationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 实现重写增删改查操作==========================================================
|
#region 实现重写增删改查操作==========================================================
|
||||||
|
|
@ -131,6 +136,22 @@ namespace CoreCms.Net.Services
|
||||||
{
|
{
|
||||||
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<SQRooms>> GetRoomList()
|
||||||
|
{
|
||||||
|
var key = $"room:GetRoomList";
|
||||||
|
var list = await _redisOperationRepository.Get<List<SQRooms>>(key);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
list = await _dal.QueryAsync(true);
|
||||||
|
await _redisOperationRepository.Set(key, list, TimeSpan.FromSeconds(60));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using CoreCms.Net.Model.Entities;
|
||||||
using CoreCms.Net.Model.Entities.Expression;
|
using CoreCms.Net.Model.Entities.Expression;
|
||||||
using CoreCms.Net.Model.ViewModels.SQ;
|
using CoreCms.Net.Model.ViewModels.SQ;
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
|
using CoreCms.Net.Services;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -102,7 +103,7 @@ public class SQController : ControllerBase
|
||||||
{
|
{
|
||||||
var userId = _user.ID;
|
var userId = _user.ID;
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
var roomList = await _SQRoomsServices.GetRoomList();
|
||||||
var where = PredicateBuilder.True<SQReservations>();
|
var where = PredicateBuilder.True<SQReservations>();
|
||||||
where = where.And(it => it.end_time > now);
|
where = where.And(it => it.end_time > now);
|
||||||
where = where.And(it => it.status < 2);
|
where = where.And(it => it.status < 2);
|
||||||
|
|
@ -134,6 +135,12 @@ public class SQController : ControllerBase
|
||||||
foreach (var item in pageList)
|
foreach (var item in pageList)
|
||||||
{
|
{
|
||||||
var temp = participants.Where(it => it.reservation_id == item.id).OrderBy(it => it.role).ThenBy(it => it.status).ToList();
|
var temp = participants.Where(it => it.reservation_id == item.id).OrderBy(it => it.role).ThenBy(it => it.status).ToList();
|
||||||
|
var room = roomList.Find(it => it.id == item.room_id);
|
||||||
|
if (room != null)
|
||||||
|
{
|
||||||
|
item.room_name = $"{room.name} {room.price_per_hour}/小时 {room.capacity}/人数";
|
||||||
|
|
||||||
|
}
|
||||||
var dto = _mapper.Map<List<SQReservationParticipantsApiDto>>(temp);
|
var dto = _mapper.Map<List<SQReservationParticipantsApiDto>>(temp);
|
||||||
item.Participants = dto;
|
item.Participants = dto;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user