feat 配送点管理

This commit is contained in:
cheche
2024-03-19 15:26:40 +08:00
parent ed25ab626a
commit 217d9f7770
12 changed files with 227 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
using Dlhis.Basic.MealUser.Request;
using Dlhis.Basic.MealUser.Response;
using Dlhis.Basic.MealUser.Services;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Basic.MealUser.Controllers
{
/// <summary>
/// 订餐地址
/// </summary>
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class BookingAddresController : ControllerBase
{
private readonly IBookingAddresService _bookingAddresService;
public BookingAddresController(IBookingAddresService bookingAddresService)
{
_bookingAddresService = bookingAddresService;
}
/// <summary>
/// 地址分页
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet("pageAddres")]
public async Task<Pagination<GetAddresPageResponse>> GetAddresPageAsync([FromQuery] GetAddresPageRequest request)
{
return await _bookingAddresService.GetAddresPageRequest(request);
}
/// <summary>
/// 地址保存
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("saveAddres")]
public async Task SaveAddresAsync(SaveAddresRequest request)
{
await _bookingAddresService.SaveAddresAsync(request);
}
}
}

View File

@@ -0,0 +1,8 @@
using Kurisu.Core.DataAccess.Dto;
namespace Dlhis.Basic.MealUser.Request
{
public class GetAddresPageRequest : PageDto
{
}
}

View File

@@ -0,0 +1,16 @@
using SqlSugar;
namespace Dlhis.Basic.MealUser.Request
{
public class SaveAddresRequest
{
public long? Id { get; set; }
/// <summary>
/// 订餐地址
/// </summary>
[SugarColumn(ColumnDescription = "订餐地址")]
public string Addres { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using SqlSugar;
namespace Dlhis.Basic.MealUser.Response
{
public class GetAddresPageResponse
{
public long Id { get; set; }
/// <summary>
/// 订餐地址
/// </summary>
public string Addres { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using Dlhis.Basic.MealUser.Request;
using Dlhis.Basic.MealUser.Response;
using Kurisu.Core.DataAccess.Dto;
namespace Dlhis.Basic.MealUser.Services
{
public interface IBookingAddresService : IScopeDependency
{
Task<Pagination<GetAddresPageResponse>> GetAddresPageRequest(GetAddresPageRequest request);
Task SaveAddresAsync(SaveAddresRequest request);
}
}

View File

@@ -0,0 +1,47 @@
using Dlhis.Basic.MealUser.Request;
using Dlhis.Basic.MealUser.Response;
using Dlhis.Entity.Basic.Entity;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Mapster;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Basic.MealUser.Services.Implements
{
public class BookingAddresService : IBookingAddresService
{
private readonly IDbContext _dbContext;
public BookingAddresService(IDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<Pagination<GetAddresPageResponse>> GetAddresPageRequest(GetAddresPageRequest request)
{
return await _dbContext.Queryable<BookingAddresEntity>()
.WhereIF(request.Search.IsPresent(),x=>x.Addres.Contains(request.Search))
.Select<GetAddresPageResponse>()
.ToPageListAsync(request);
}
public async Task SaveAddresAsync(SaveAddresRequest request)
{
if (!request.Id.HasValue)
{
var entity = request.Adapt<BookingAddresEntity>();
await _dbContext.InsertAsync(entity);
}
else
{
var entity = await _dbContext.Queryable<BookingAddresEntity>()
.Where(x => x.Id == request.Id)
.FirstAsync();
request.Adapt(entity);
await _dbContext.UpdateAsync(entity);
}
}
}
}

View File

@@ -0,0 +1,28 @@
using Kurisu.Core.DataAccess.Entity;
using Kurisu.SqlSugar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dlhis.Entity.Basic.Entity
{
/// <summary>
/// 就餐地址
/// </summary>
[SugarTable(TableName = "BookingAddres", TableDescription = "就餐地址")]
public class BookingAddresEntity : SugarBaseEntity, ITenantId
{
/// <summary>
/// 订餐地址
/// </summary>
[SugarColumn(ColumnDescription = "订餐地址")]
public string Addres { get; set; }
public string TenantId { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using SqlSugar;
using SqlSugar.DbConvert;
using Microsoft.Extensions.Logging;
using Kurisu.SqlSugar;
namespace Dlhis.Entity.Common;
@@ -8,7 +9,7 @@ namespace Dlhis.Entity.Common;
/// api日志表
/// </summary>
[SugarTable(TableName = "Logs", TableDescription = "api日志表")]
public class ApiLogEntity
public class ApiLogEntity
{
/// <summary>
/// 时间

View File

@@ -0,0 +1,32 @@
using Dlhis.Entity.Common;
using Kurisu.SqlSugar.Services;
using SqlSugar;
namespace Dlhis.ScheduledTask.CommonJobs;
public class DelApiLogTaskJob
{
private readonly IDbContext _dbContext;
public DelApiLogTaskJob(IDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task RunAsync()
{
DateTime now = DateTime.Now;
DateTime todayStart = now.Date;
DateTime threeDaysAgoStart = todayStart.AddDays(-3);
var logs = await _dbContext.ChangeDb("log")
.Queryable<ApiLogEntity>()
.Where(x => x._ts<= threeDaysAgoStart)
.OrderBy(x =>x._ts,OrderByType.Asc)
.ToListAsync();
await _dbContext.ChangeDb("log").DeleteReallyAsync(logs);
}
}

View File

@@ -64,5 +64,10 @@ public class JobPack : BaseAppPack
{
TimeZone = TimeZoneInfo.Local
});
//删除前三天前的日志
RecurringJob.AddOrUpdate<DelApiLogTaskJob>("DelApiLogTask", s => s.RunAsync(), "0 0 2 * * *", new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local
});
}
}

View File

@@ -25,6 +25,20 @@ public class SqlSugarPack : BaseAppPack
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new ConnectionConfig
{
ConfigId = "log",
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
DbType = DbType.MySql,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,

View File

@@ -18,6 +18,7 @@
"SlaveConnectionString": [],
"FaceConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=face;charset=utf8mb4;",
"IdentityConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;",
"LogConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;",
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": false