feat 配送点管理
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Src/Dlhis.Basic/MealUser/Request/GetAddresPageRequest.cs
Normal file
8
Src/Dlhis.Basic/MealUser/Request/GetAddresPageRequest.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.MealUser.Request
|
||||
{
|
||||
public class GetAddresPageRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
16
Src/Dlhis.Basic/MealUser/Request/SaveAddresRequest.cs
Normal file
16
Src/Dlhis.Basic/MealUser/Request/SaveAddresRequest.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
15
Src/Dlhis.Basic/MealUser/Response/GetAddresPageResponse.cs
Normal file
15
Src/Dlhis.Basic/MealUser/Response/GetAddresPageResponse.cs
Normal 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; }
|
||||
|
||||
}
|
||||
}
|
||||
12
Src/Dlhis.Basic/MealUser/Services/IBookingAddresService.cs
Normal file
12
Src/Dlhis.Basic/MealUser/Services/IBookingAddresService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Src/Dlhis.Entity/Basic/Entity/BookingAddresEntity.cs
Normal file
28
Src/Dlhis.Entity/Basic/Entity/BookingAddresEntity.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
/// 时间
|
||||
|
||||
32
Src/Dlhis.ScheduledTask/CommonJobs/DelApiLogTaskJob.cs
Normal file
32
Src/Dlhis.ScheduledTask/CommonJobs/DelApiLogTaskJob.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user