api noti เพิ่มฟารอ่านข้อความ
This commit is contained in:
parent
a1bd2ec4b8
commit
78b0ad7d1d
8 changed files with 17042 additions and 12 deletions
|
|
@ -48,7 +48,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
var data_search = await _dbContext.Set<Inbox>()
|
||||
.Where(x => x.ReceiverUserId == profile.Id)
|
||||
.Where(x => x.IsOpen == false)
|
||||
.Where(x => x.DeleteDate == null)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.Select(x => new InboxResponse
|
||||
{
|
||||
|
|
@ -67,7 +67,8 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
var _data = new { data, total = data_search.Count() };
|
||||
|
||||
var _data = new { data, total = data_search.Count(), totalNoti = data_search.Where(x => x.IsOpen == false).Count() };
|
||||
return _data;
|
||||
}
|
||||
catch
|
||||
|
|
@ -85,7 +86,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
if (inbox != null)
|
||||
{
|
||||
inbox.IsOpen = true;
|
||||
inbox.DeleteDate = DateTime.Now;
|
||||
// _dbContext.Set<Inbox>().Remove(inbox);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
|
@ -105,6 +106,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
if (inbox != null)
|
||||
{
|
||||
inbox.IsOpen = true;
|
||||
inbox.OpenDate = DateTime.Now;
|
||||
// _dbContext.Set<Inbox>().Remove(inbox);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
var data_search = await _dbContext.Set<Notification>()
|
||||
.Where(x => x.ReceiverUserId == profile.Id)
|
||||
.Where(x => x.IsOpen == false)
|
||||
.Where(x => x.DeleteDate == null)
|
||||
.OrderByDescending(x => x.ReceiveDate)
|
||||
.Select(x => new NotificationResponse
|
||||
{
|
||||
|
|
@ -71,7 +71,15 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
var _data = new { data, total = data_search.Count() };
|
||||
|
||||
var data_opens = data.Where(x => x.IsOpen == false).ToList();
|
||||
foreach (var data_open in data_opens)
|
||||
{
|
||||
data_open.IsOpen = true;
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var _data = new { data, total = data_search.Count(), totalNoti = data_search.Where(x => x.IsOpen == false).Count() };
|
||||
return _data;
|
||||
}
|
||||
catch
|
||||
|
|
@ -89,7 +97,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
|
||||
if (notification != null)
|
||||
{
|
||||
notification.IsOpen = true;
|
||||
notification.DeleteDate = DateTime.Now;
|
||||
// _dbContext.Set<Notification>().Remove(notification);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,19 +13,22 @@ namespace BMA.EHR.Domain.Models.Notifications
|
|||
[Required, Column(TypeName = "text"), Comment("รายละเอียดข้อความ")]
|
||||
public string Body { get; set; }
|
||||
|
||||
[Required,Comment("รหัสผู้รับข้อความ")]
|
||||
[Required, Comment("รหัสผู้รับข้อความ")]
|
||||
public Guid ReceiverUserId { get; set; }
|
||||
|
||||
[Column(TypeName = "text"),Comment("สิงที่แนบมาด้วย")]
|
||||
[Column(TypeName = "text"), Comment("สิงที่แนบมาด้วย")]
|
||||
public string Payload { get; set; }
|
||||
|
||||
[Comment("เปิดอ่านแล้วหรือยัง")]
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
[Required,Comment("วันที่ได้รับ")]
|
||||
[Required, Comment("วันที่ได้รับ")]
|
||||
public DateTime ReceiveDate { get; set; } = DateTime.Now;
|
||||
|
||||
[Comment("วันที่เปิดอ่าน")]
|
||||
public DateTime? OpenDate { get; set; }
|
||||
|
||||
[Comment("วันที่ลบข้อมูล")]
|
||||
public DateTime? DeleteDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace BMA.EHR.Domain.Models.Notifications
|
|||
[Required, Comment("รหัสผู้รับข้อความ")]
|
||||
public Guid ReceiverUserId { get; set; }
|
||||
|
||||
[Required,Comment("ประเภทการแจ้งเตือน")]
|
||||
[Required, Comment("ประเภทการแจ้งเตือน")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Column(TypeName = "text"), Comment("สิงที่แนบมาด้วย")]
|
||||
|
|
@ -27,5 +27,8 @@ namespace BMA.EHR.Domain.Models.Notifications
|
|||
|
||||
[Comment("วันที่เปิดอ่าน")]
|
||||
public DateTime? OpenDate { get; set; }
|
||||
|
||||
[Comment("วันที่ลบข้อมูล")]
|
||||
public DateTime? DeleteDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16965
BMA.EHR.Infrastructure/Migrations/20240118061643_update table noti add DeleteDate.Designer.cs
generated
Normal file
16965
BMA.EHR.Infrastructure/Migrations/20240118061643_update table noti add DeleteDate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetablenotiaddDeleteDate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeleteDate",
|
||||
table: "Notifications",
|
||||
type: "datetime(6)",
|
||||
nullable: true,
|
||||
comment: "วันที่ลบข้อมูล");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DeleteDate",
|
||||
table: "Inboxes",
|
||||
type: "datetime(6)",
|
||||
nullable: true,
|
||||
comment: "วันที่ลบข้อมูล");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeleteDate",
|
||||
table: "Notifications");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DeleteDate",
|
||||
table: "Inboxes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9083,6 +9083,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<DateTime?>("DeleteDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ลบข้อมูล");
|
||||
|
||||
b.Property<bool>("IsOpen")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("เปิดอ่านแล้วหรือยัง");
|
||||
|
|
@ -9267,6 +9271,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnOrder(101)
|
||||
.HasComment("User Id ที่สร้างข้อมูล");
|
||||
|
||||
b.Property<DateTime?>("DeleteDate")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("วันที่ลบข้อมูล");
|
||||
|
||||
b.Property<bool>("IsOpen")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("เปิดอ่านแล้วหรือยัง");
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
"ConnectionStrings": {
|
||||
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
|
||||
// "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"ExamConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue