v0.0.8系统通知

This commit is contained in:
zpc 2025-11-17 22:33:12 +08:00
parent 2d645dd699
commit b98ae8fbe3
12 changed files with 723 additions and 2 deletions

View File

@ -3,7 +3,7 @@ using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Service.Liveforum.ILiveforumService;
//创建时间2025-11-16
//创建时间2025-11-17
namespace ZR.Admin.WebApi.Controllers.Liveforum
{
/// <summary>

View File

@ -0,0 +1,110 @@
using Microsoft.AspNetCore.Mvc;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Service.Liveforum.ILiveforumService;
//创建时间2025-11-17
namespace ZR.Admin.WebApi.Controllers.Liveforum
{
/// <summary>
/// 系统公告
/// </summary>
[Route("liveforum/tsystemnotifications")]
public class T_SystemNotificationsController : BaseController
{
/// <summary>
/// 系统公告接口
/// </summary>
private readonly IT_SystemNotificationsService _T_SystemNotificationsService;
public T_SystemNotificationsController(IT_SystemNotificationsService T_SystemNotificationsService)
{
_T_SystemNotificationsService = T_SystemNotificationsService;
}
/// <summary>
/// 查询系统公告列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "tsystemnotifications:list")]
public IActionResult QueryT_SystemNotifications([FromQuery] T_SystemNotificationsQueryDto parm)
{
var response = _T_SystemNotificationsService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询系统公告详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "tsystemnotifications:query")]
public IActionResult GetT_SystemNotifications(long Id)
{
var response = _T_SystemNotificationsService.GetInfo(Id);
var info = response.Adapt<T_SystemNotificationsDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加系统公告
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "tsystemnotifications:add")]
[Log(Title = "系统公告", BusinessType = BusinessType.INSERT)]
public IActionResult AddT_SystemNotifications([FromBody] T_SystemNotificationsDto parm)
{
var modal = parm.Adapt<T_SystemNotifications>().ToCreate(HttpContext);
var response = _T_SystemNotificationsService.AddT_SystemNotifications(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新系统公告
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "tsystemnotifications:edit")]
[Log(Title = "系统公告", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateT_SystemNotifications([FromBody] T_SystemNotificationsDto parm)
{
if (parm.Id == 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
var oldal = _T_SystemNotificationsService.GetById(parm.Id);
if (oldal == null)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
}
var modal = parm.Adapt(oldal);
var response = _T_SystemNotificationsService.UpdateT_SystemNotifications(modal);
return ToResponse(response);
}
/// <summary>
/// 删除系统公告
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "tsystemnotifications:delete")]
[Log(Title = "系统公告", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteT_SystemNotifications([FromRoute]string ids)
{
var idArr = Tools.SplitAndConvert<long>(ids);
return ToResponse(_T_SystemNotificationsService.Delete(idArr));
}
}
}

View File

@ -6,6 +6,7 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
/// </summary>
public class T_FeedbacksQueryDto : PagerInfo
{
public long ? UserId { get; set; }
}
/// <summary>

View File

@ -0,0 +1,42 @@
namespace ZR.LiveForum.Model.Liveforum.Dto
{
/// <summary>
/// 系统公告查询对象
/// </summary>
public class T_SystemNotificationsQueryDto : PagerInfo
{
public string ? Title { get; set; }
}
/// <summary>
/// 系统公告输入输出对象
/// </summary>
public class T_SystemNotificationsDto
{
[Required(ErrorMessage = "通知ID不能为空")]
public long Id { get; set; }
[Required(ErrorMessage = "标题不能为空")]
public string Title { get; set; }
[Required(ErrorMessage = "正文内容不能为空")]
public string Content { get; set; }
[Required(ErrorMessage = "是否启用该通知不能为空")]
public bool IsActive { get; set; }
public DateTime ? PublishTime { get; set; }
public DateTime ? ExpireTime { get; set; }
public DateTime ? CreatedAt { get; set; }
public DateTime ? UpdatedAt { get; set; }
[ExcelColumn(Name = "是否启用该通知")]
public string? IsActiveLabel { get; set; }
}
}

View File

@ -0,0 +1,53 @@
namespace ZR.LiveForum.Model.Liveforum
{
/// <summary>
/// 系统公告
/// </summary>
[SugarTable("T_SystemNotifications")]
[Tenant("liveforum")]
public class T_SystemNotifications
{
/// <summary>
/// 通知ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long Id { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 正文内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 是否启用该通知
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// 发布时间
/// </summary>
public DateTime? PublishTime { get; set; }
/// <summary>
/// 过期时间
/// </summary>
public DateTime? ExpireTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreatedAt { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime? UpdatedAt { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
namespace ZR.Service.Liveforum.ILiveforumService
{
/// <summary>
/// 系统公告service接口
/// </summary>
public interface IT_SystemNotificationsService : IBaseService<T_SystemNotifications>
{
PagedInfo<T_SystemNotificationsDto> GetList(T_SystemNotificationsQueryDto parm);
T_SystemNotifications GetInfo(long Id);
T_SystemNotifications AddT_SystemNotifications(T_SystemNotifications parm);
int UpdateT_SystemNotifications(T_SystemNotifications parm);
}
}

View File

@ -97,6 +97,7 @@ namespace ZR.Service.Liveforum
{
var predicate = Expressionable.Create<T_Feedbacks>();
predicate = predicate.AndIF(parm.UserId != null, it => it.UserId == parm.UserId);
return predicate;
}
}

View File

@ -0,0 +1,81 @@
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Repository;
using ZR.Service.Liveforum.ILiveforumService;
namespace ZR.Service.Liveforum
{
/// <summary>
/// 系统公告Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IT_SystemNotificationsService), ServiceLifetime = LifeTime.Transient)]
public class T_SystemNotificationsService : BaseService<T_SystemNotifications>, IT_SystemNotificationsService
{
/// <summary>
/// 查询系统公告列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_SystemNotificationsDto> GetList(T_SystemNotificationsQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage<T_SystemNotifications, T_SystemNotificationsDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public T_SystemNotifications GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加系统公告
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public T_SystemNotifications AddT_SystemNotifications(T_SystemNotifications model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改系统公告
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateT_SystemNotifications(T_SystemNotifications model)
{
return Update(model, true);
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<T_SystemNotifications> QueryExp(T_SystemNotificationsQueryDto parm)
{
var predicate = Expressionable.Create<T_SystemNotifications>();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), it => it.Title.Contains(parm.Title));
return predicate;
}
}
}

View File

@ -0,0 +1,57 @@
import request from '@/utils/request'
/**
* 系统公告分页查询
* @param {查询条件} data
*/
export function listtsystemnotifications(query) {
return request({
url: 'liveforum/tsystemnotifications/list',
method: 'get',
params: query,
})
}
/**
* 新增系统公告
* @param data
*/
export function addtsystemnotifications(data) {
return request({
url: 'liveforum/tsystemnotifications',
method: 'post',
data: data,
})
}
/**
* 修改系统公告
* @param data
*/
export function updatetsystemnotifications(data) {
return request({
url: 'liveforum/tsystemnotifications',
method: 'PUT',
data: data,
})
}
/**
* 获取系统公告详情
* @param {Id}
*/
export function gettsystemnotifications(id) {
return request({
url: 'liveforum/tsystemnotifications/' + id,
method: 'get'
})
}
/**
* 删除系统公告
* @param {主键} pid
*/
export function deltsystemnotifications(pid) {
return request({
url: 'liveforum/tsystemnotifications/delete/' + pid,
method: 'POST'
})
}

View File

@ -1,11 +1,14 @@
<!--
* @Descripttion: (反馈记录/T_Feedbacks)
* @Author: (admin)
* @Date: (2025-11-16)
* @Date: (2025-11-17)
-->
<template>
<div>
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
<el-form-item label="反馈用户id" prop="userId">
<el-input v-model.number="queryParams.userId" placeholder="请输入反馈用户id" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
@ -181,6 +184,7 @@ const queryParams = reactive({
pageSize: 10,
sort: 'Id',
sortType: 'desc',
userId: undefined,
})
const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'id', label: 'Id' },

View File

@ -0,0 +1,327 @@
<!--
* @Descripttion: (系统公告/T_SystemNotifications)
* @Author: (admin)
* @Date: (2025-11-17)
-->
<template>
<div>
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
<el-form-item label="标题" prop="title">
<el-input v-model="queryParams.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
</el-form-item>
</el-form>
<!-- 工具区域 -->
<el-row :gutter="15" class="mb10">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['tsystemnotifications:add']" plain icon="plus" @click="handleAdd">
{{ $t('btn.add') }}
</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table
:data="dataList"
v-loading="loading"
ref="table"
border
header-cell-class-name="el-table-header-cell"
highlight-current-row
@sort-change="sortChange"
>
<el-table-column prop="id" label="通知ID" align="center" v-if="columns.showColumn('id')"/>
<el-table-column prop="title" label="标题" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('title')"/>
<el-table-column prop="content" label="正文内容" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('content')"/>
<el-table-column prop="isActive" label="是否启用该通知" align="center" v-if="columns.showColumn('isActive')">
<template #default="scope">
<dict-tag :options=" options.sys_common_status_bool " :value="scope.row.isActive" />
</template>
</el-table-column>
<el-table-column prop="publishTime" label="发布时间" :show-overflow-tooltip="true" v-if="columns.showColumn('publishTime')"/>
<el-table-column prop="expireTime" label="过期时间" :show-overflow-tooltip="true" v-if="columns.showColumn('expireTime')"/>
<el-table-column prop="createdAt" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdAt')"/>
<el-table-column prop="updatedAt" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedAt')"/>
<el-table-column label="操作" width="160">
<template #default="scope">
<el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['tsystemnotifications:edit']" @click="handleUpdate(scope.row)"></el-button>
<el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['tsystemnotifications:delete']" @click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
<el-dialog :title="title" :lock-scroll="false" v-model="open" >
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :lg="12">
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
</el-col>
<el-col :lg="24">
<el-form-item label="正文内容" prop="content">
<editor v-model="form.content" :min-height="200" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="是否启用该通知" prop="isActive">
<el-radio-group v-model="form.isActive">
<el-radio v-for="item in options.sys_common_status_bool" :key="item.dictValue" :value="item.dictValue">
{{item.dictLabel}}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="发布时间" prop="publishTime">
<el-date-picker
v-model="form.publishTime"
type="datetime"
placeholder="选择日期时间"
value-format="YYYY-MM-DD HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="过期时间" prop="expireTime">
<el-date-picker
v-model="form.expireTime"
type="datetime"
placeholder="选择日期时间"
value-format="YYYY-MM-DD HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer v-if="opertype != 3">
<el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
<el-button type="primary" :loading="state.submitLoading" @click="submitForm">{{ $t('btn.submit') }}</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup name="tsystemnotifications">
import { listtsystemnotifications,
addtsystemnotifications, deltsystemnotifications,
updatetsystemnotifications,gettsystemnotifications,
}
from '@/api/liveforum/tsystemnotifications.js'
import Editor from '@/components/Editor'
const { proxy } = getCurrentInstance()
const ids = ref([])
const loading = ref(false)
const showSearch = ref(true)
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
sort: 'Id',
sortType: 'desc',
title: undefined,
})
const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'id', label: '通知ID' },
{ visible: true, align: 'center', type: '', prop: 'title', label: '标题' ,showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'content', label: '正文内容' ,showOverflowTooltip: true },
{ visible: true, align: 'center', type: 'dict', prop: 'isActive', label: '是否启用该通知' ,dictType: 'sys_common_status_bool' },
{ visible: true, align: 'center', type: '', prop: 'publishTime', label: '发布时间' ,showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'expireTime', label: '过期时间' ,showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'createdAt', label: '创建时间' ,showOverflowTooltip: true },
{ visible: true, align: 'center', type: '', prop: 'updatedAt', label: '更新时间' ,showOverflowTooltip: true },
//{ visible: false, prop: 'actions', label: '', type: 'slot', width: '160' }
])
const total = ref(0)
const dataList = ref([])
const queryRef = ref()
const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)])
var dictParams = [
"sys_common_status_bool",
]
proxy.getDicts(dictParams).then((response) => {
response.data.forEach((element) => {
state.options[element.dictType] = element.list
})
})
function getList(){
loading.value = true
listtsystemnotifications(queryParams).then(res => {
const { code, data } = res
if (code == 200) {
dataList.value = data.result
total.value = data.totalNum
loading.value = false
}
})
}
//
function handleQuery() {
queryParams.pageNum = 1
getList()
}
//
function resetQuery(){
proxy.resetForm("queryRef")
handleQuery()
}
//
function sortChange(column) {
var sort = undefined
var sortType = undefined
if (column.prop != null && column.order != null) {
sort = column.prop
sortType = column.order
}
queryParams.sort = sort
queryParams.sortType = sortType
handleQuery()
}
/*************** form操作 ***************/
const formRef = ref()
const title = ref('')
// 1add 2edit 3view
const opertype = ref(0)
const open = ref(false)
const state = reactive({
single: true,
multiple: true,
submitLoading: false,
form: {},
rules: {
title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
content: [{ required: true, message: "正文内容不能为空", trigger: "blur" }],
isActive: [{ required: true, message: "是否启用该通知不能为空", trigger: "blur" }],
},
options: {
// eg:{ dictLabel: '', dictValue: '0'}
sys_common_status_bool: [],
}
})
const { form, rules, options, single, multiple } = toRefs(state)
// dialog
function cancel(){
open.value = false
reset()
}
//
function reset() {
form.value = {
id: null,
title: null,
content: null,
isActive: null,
publishTime: null,
expireTime: null,
createdAt: null,
updatedAt: null,
};
proxy.resetForm("formRef")
}
//
function handleAdd() {
reset();
open.value = true
state.submitLoading = false
title.value = '添加系统公告'
opertype.value = 1
}
//
function handleUpdate(row) {
reset()
const id = row.id || ids.value
gettsystemnotifications(id).then((res) => {
const { code, data } = res
if (code == 200) {
open.value = true
title.value = '修改系统公告'
opertype.value = 2
form.value = {
...data,
}
}
})
}
// &
function submitForm() {
proxy.$refs["formRef"].validate((valid) => {
if (valid) {
state.submitLoading = true
if (form.value.id != undefined && opertype.value === 2) {
updatetsystemnotifications(form.value).then((res) => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
.finally(() => {
state.submitLoading = false
})
} else {
addtsystemnotifications(form.value).then((res) => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
.finally(() => {
setTimeout(() => {
state.submitLoading = false
}, 800)
})
}
}
})
}
//
function handleDelete(row) {
const Ids = row.id || ids.value
proxy
.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?', "警告", {
confirmButtonText: proxy.$t('common.ok'),
cancelButtonText: proxy.$t('common.cancel'),
type: "warning",
})
.then(function () {
return deltsystemnotifications(Ids)
})
.then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
})
}
handleQuery()
</script>

View File

@ -0,0 +1,24 @@
use ZrAdmin;
-- 系统公告菜单
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time)
VALUES ('系统公告', 1233, 999, 'tsystemnotifications', 'liveforum/tsystemnotifications', 0, 0, 'C', '0', '0', 'tsystemnotifications:list', 'icon1', 'system', GETDATE());
-- 按钮父菜单id
declare @menuId int = @@identity
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('查询', @menuId, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tsystemnotifications:query', '', 'system', GETDATE());
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('新增', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', 'tsystemnotifications:add', '', 'system', GETDATE());
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('删除', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', 'tsystemnotifications:delete', '', 'system', GETDATE());
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time)
VALUES ('修改', @menuId, 4, '#', NULL, 0, 0, 'F', '0', '0', 'tsystemnotifications:edit', '', 'system', GETDATE());
SELECT * FROM sys_menu WHERE parentId = @menuId;
SELECT * FROM sys_menu WHERE menuId = @menuId;