diff --git a/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs b/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs index 8b7d251..1027660 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysNoticeController.cs @@ -45,7 +45,7 @@ namespace ZR.Admin.WebApi.Controllers.System { var predicate = Expressionable.Create(); - predicate = predicate.And(m => m.Status == "0"); + predicate = predicate.And(m => m.Status == 0); var response = _SysNoticeService.GetPages(predicate.ToExpression(), parm); return SUCCESS(response); } @@ -61,9 +61,9 @@ namespace ZR.Admin.WebApi.Controllers.System var predicate = Expressionable.Create(); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NoticeTitle), m => m.NoticeTitle.Contains(parm.NoticeTitle)); - predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NoticeType), m => m.NoticeType == parm.NoticeType); + predicate = predicate.AndIF(parm.NoticeType != null, m => m.NoticeType == parm.NoticeType); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CreateBy), m => m.Create_by.Contains(parm.CreateBy) || m.Update_by.Contains(parm.CreateBy)); - predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status); + predicate = predicate.AndIF(parm.Status != null, m => m.Status == parm.Status); var response = _SysNoticeService.GetPages(predicate.ToExpression(), parm); return SUCCESS(response); } @@ -88,14 +88,9 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPost] [ActionPermissionFilter(Permission = "system:notice:add")] - [Log(Title = "通知公告表", BusinessType = BusinessType.INSERT)] + [Log(Title = "发布通告", BusinessType = BusinessType.INSERT)] public IActionResult AddSysNotice([FromBody] SysNoticeDto parm) { - if (parm == null) - { - throw new CustomException("请求参数错误"); - } - //从 Dto 映射到 实体 var modal = parm.Adapt().ToCreate(HttpContext); modal.Create_by = HttpContext.GetName(); modal.Create_time = DateTime.Now; @@ -120,19 +115,13 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPut] [ActionPermissionFilter(Permission = "system:notice:update")] - [Log(Title = "通知公告表", BusinessType = BusinessType.UPDATE)] + [Log(Title = "修改公告", BusinessType = BusinessType.UPDATE)] public IActionResult UpdateSysNotice([FromBody] SysNoticeDto parm) { - if (parm == null) - { - throw new CustomException("请求实体不能为空"); - } - //从 Dto 映射到 实体 var model = parm.Adapt().ToUpdate(HttpContext); - + model.Update_by = HttpContext.GetName(); var response = _SysNoticeService.Update(w => w.NoticeId == model.NoticeId, it => new SysNotice() { - //Update 字段映射 NoticeTitle = model.NoticeTitle, NoticeType = model.NoticeType, NoticeContent = model.NoticeContent, @@ -150,7 +139,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPut("send/{NoticeId}")] [ActionPermissionFilter(Permission = "system:notice:update")] - [Log(Title = "通知公告表", BusinessType = BusinessType.OTHER)] + [Log(Title = "发送通知公告", BusinessType = BusinessType.OTHER)] public IActionResult SendNotice(int NoticeId = 0) { if (NoticeId <= 0) @@ -158,7 +147,7 @@ namespace ZR.Admin.WebApi.Controllers.System throw new CustomException("请求实体不能为空"); } var response = _SysNoticeService.GetFirst(x => x.NoticeId == NoticeId); - if (response != null && response.Status == "0") + if (response != null && response.Status == 0) { _hubContext.Clients.All.SendAsync(HubsConstant.ReceiveNotice, response.NoticeTitle, response.NoticeContent); } @@ -171,7 +160,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpDelete("{ids}")] [ActionPermissionFilter(Permission = "system:notice:delete")] - [Log(Title = "通知公告表", BusinessType = BusinessType.DELETE)] + [Log(Title = "通知公告", BusinessType = BusinessType.DELETE)] public IActionResult DeleteSysNotice(string ids) { int[] idsArr = Tools.SpitIntArrary(ids); @@ -181,20 +170,5 @@ namespace ZR.Admin.WebApi.Controllers.System return SUCCESS(response); } - - /// - /// 通知公告表导出 - /// - /// - [Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "通知公告表")] - [HttpGet("export")] - [ActionPermissionFilter(Permission = "system:notice:export")] - public IActionResult Export() - { - var list = _SysNoticeService.GetAll(); - - string sFileName = ExportExcel(list, "SysNotice", "通知公告表"); - return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); - } } } \ No newline at end of file diff --git a/ZR.Model/System/Dto/SysNoticeDto.cs b/ZR.Model/System/Dto/SysNoticeDto.cs index 26e23d9..e770064 100644 --- a/ZR.Model/System/Dto/SysNoticeDto.cs +++ b/ZR.Model/System/Dto/SysNoticeDto.cs @@ -1,3 +1,5 @@ +using System.ComponentModel.DataAnnotations; + namespace ZR.Model.System.Dto { /// @@ -6,10 +8,11 @@ namespace ZR.Model.System.Dto public class SysNoticeDto { public int NoticeId { get; set; } + [Required] public string NoticeTitle { get; set; } - public string NoticeType { get; set; } + public int NoticeType { get; set; } public string NoticeContent { get; set; } - public string Status { get; set; } + public int Status { get; set; } public string Remark { get; set; } } @@ -19,8 +22,8 @@ namespace ZR.Model.System.Dto public class SysNoticeQueryDto : PagerInfo { public string NoticeTitle { get; set; } - public string NoticeType { get; set; } + public int? NoticeType { get; set; } public string CreateBy { get; set; } - public string Status { get; set; } + public int? Status { get; set; } } } diff --git a/ZR.Model/System/SysNotice.cs b/ZR.Model/System/SysNotice.cs index accf568..758fc03 100644 --- a/ZR.Model/System/SysNotice.cs +++ b/ZR.Model/System/SysNotice.cs @@ -26,7 +26,7 @@ namespace ZR.Model.System /// 公告类型 (1通知 2公告) /// [SugarColumn(ColumnName = "notice_type")] - public string NoticeType { get; set; } + public int NoticeType { get; set; } /// /// 公告内容 /// @@ -35,6 +35,6 @@ namespace ZR.Model.System /// /// 公告状态 (0正常 1关闭) /// - public string Status { get; set; } + public int Status { get; set; } } } \ No newline at end of file diff --git a/ZR.Service/System/SysNoticeService.cs b/ZR.Service/System/SysNoticeService.cs index bbe99e9..168297a 100644 --- a/ZR.Service/System/SysNoticeService.cs +++ b/ZR.Service/System/SysNoticeService.cs @@ -28,7 +28,7 @@ namespace ZR.Service.System var predicate = Expressionable.Create(); //搜索条件查询语法参考Sqlsugar - predicate = predicate.And(m => m.Status == "0"); + predicate = predicate.And(m => m.Status == 0); return GetList(predicate.ToExpression()); } diff --git a/ZR.Vue/src/views/system/notice/index.vue b/ZR.Vue/src/views/system/notice/index.vue index ee85336..301947c 100644 --- a/ZR.Vue/src/views/system/notice/index.vue +++ b/ZR.Vue/src/views/system/notice/index.vue @@ -23,13 +23,28 @@ 新增 - + 修改 - 删除 + 删除 @@ -58,15 +73,20 @@ - + @@ -80,14 +100,14 @@ - + - {{dict.dictLabel}} + {{ dict.dictLabel }} @@ -115,10 +135,10 @@ import { updateNotice, sendNotice, // exportNotice, -} from "@/api/system/notice"; +} from '@/api/system/notice' export default { - name: "notice", + name: 'notice', data() { return { // 遮罩层 @@ -136,7 +156,7 @@ export default { // 公告表格数据 noticeList: [], // 弹出层标题 - title: "", + title: '', // 是否显示弹出层 open: false, // 类型数据字典 @@ -155,38 +175,34 @@ export default { form: {}, // 表单校验 rules: { - noticeTitle: [ - { required: true, message: "公告标题不能为空", trigger: "blur" }, - ], - noticeType: [ - { required: true, message: "公告类型不能为空", trigger: "change" }, - ], + noticeTitle: [{ required: true, message: '公告标题不能为空', trigger: 'blur' }], + noticeType: [{ required: true, message: '公告类型不能为空', trigger: 'change' }], }, - }; + } }, created() { - this.getList(); - this.getDicts("sys_notice_status").then((response) => { - this.statusOptions = response.data; - }); - this.getDicts("sys_notice_type").then((response) => { - this.typeOptions = response.data; - }); + this.getList() + this.getDicts('sys_notice_status').then((response) => { + this.statusOptions = response.data + }) + this.getDicts('sys_notice_type').then((response) => { + this.typeOptions = response.data + }) }, methods: { /** 查询公告列表 */ getList() { - this.loading = true; + this.loading = true listNotice(this.queryParams).then((res) => { - this.noticeList = res.data.result; - this.total = res.data.totalNum; - this.loading = false; - }); + this.noticeList = res.data.result + this.total = res.data.totalNum + this.loading = false + }) }, // 取消按钮 cancel() { - this.open = false; - this.reset(); + this.open = false + this.reset() }, // 表单重置 reset() { @@ -195,93 +211,89 @@ export default { noticeTitle: undefined, noticeType: undefined, noticeContent: undefined, - status: "0", - }; - this.resetForm("form"); + status: 0, + } + this.resetForm('form') }, /** 搜索按钮操作 */ handleQuery() { - this.queryParams.pageNum = 1; - this.getList(); + this.queryParams.pageNum = 1 + this.getList() }, /** 重置按钮操作 */ resetQuery() { - this.resetForm("queryForm"); - this.handleQuery(); + this.resetForm('queryForm') + this.handleQuery() }, // 多选框选中数据 handleSelectionChange(selection) { - this.ids = selection.map((item) => item.noticeId); - this.single = selection.length != 1; - this.multiple = !selection.length; + this.ids = selection.map((item) => item.noticeId) + this.single = selection.length != 1 + this.multiple = !selection.length }, /** 新增按钮操作 */ handleAdd() { - this.reset(); - this.open = true; - this.title = "添加公告"; + this.reset() + this.open = true + this.title = '添加公告' }, /** 修改按钮操作 */ handleUpdate(row) { - this.reset(); - const noticeId = row.noticeId || this.ids; + this.reset() + const noticeId = row.noticeId || this.ids getNotice(noticeId).then((response) => { - this.form = response.data; - this.open = true; - this.title = "修改公告"; - }); + this.form = response.data + this.open = true + this.title = '修改公告' + }) }, - // 发送通知 + // 发送通知 handleNotice(row) { - const noticeId = row.noticeId || this.ids; - sendNotice(noticeId).then(res => { - this.msgSuccess("发送通知成功"); - }); + const noticeId = row.noticeId || this.ids + sendNotice(noticeId).then((res) => { + this.msgSuccess('发送通知成功') + }) }, /** 提交按钮 */ submitForm: function () { - this.$refs["form"].validate((valid) => { + this.$refs['form'].validate((valid) => { if (valid) { if (this.form.noticeId != undefined) { updateNotice(this.form).then((response) => { if (!response.data) { - this.msgError("修改失败"); - return; + this.msgError('修改失败') + return } - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - }); + this.msgSuccess('修改成功') + this.open = false + this.getList() + }) } else { addNotice(this.form).then((response) => { - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - }); + this.msgSuccess('新增成功') + this.open = false + this.getList() + }) } } - }); + }) }, /** 删除按钮操作 */ handleDelete(row) { - const noticeIds = row.noticeId || this.ids; - this.$confirm( - '是否确认删除公告编号为"' + noticeIds + '"的数据项?', - "警告", - { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning", - } - ) + const noticeIds = row.noticeId || this.ids + this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', '警告', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) .then(function () { - return delNotice(noticeIds); + return delNotice(noticeIds) }) .then(() => { - this.getList(); - this.msgSuccess("删除成功"); - }); + this.getList() + this.msgSuccess('删除成功') + }) }, }, -}; +} diff --git a/document/images/qrcodeH5.png b/document/images/qrcodeH5.png index 0f27fa5..584c0b0 100644 Binary files a/document/images/qrcodeH5.png and b/document/images/qrcodeH5.png differ diff --git a/document/mysql/admin-mysql.sql b/document/mysql/admin-mysql.sql index 7b56701..2743423 100644 --- a/document/mysql/admin-mysql.sql +++ b/document/mysql/admin-mysql.sql @@ -35,38 +35,52 @@ CREATE TABLE `sys_tasks` ( -- ---------------------------- -- Table structure for sys_tasks_log -- ---------------------------- -DROP TABLE IF EXISTS `sys_tasks_log`; -CREATE TABLE `sys_tasks_log` ( - `jobLogId` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务日志ID', - `jobId` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务id', - `jobName` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称', - `jobGroup` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务组名', - `jobMessage` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '日志信息', - `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '执行状态(0正常 1失败)', - `exception` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '异常信息', - `createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', - `invokeTarget` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '调用目标', - `elapsed` double(10, 0) NULL DEFAULT NULL COMMENT '作业用时', - PRIMARY KEY (`jobLogId`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 198 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时任务调度日志表' ROW_FORMAT = Dynamic; - +DROP TABLE +IF + EXISTS `sys_tasks_log`; +CREATE TABLE `sys_tasks_log` ( + `jobLogId` BIGINT ( 20 ) NOT NULL AUTO_INCREMENT COMMENT '任务日志ID', + `jobId` VARCHAR ( 20 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务id', + `jobName` VARCHAR ( 64 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称', + `jobGroup` VARCHAR ( 64 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务组名', + `jobMessage` VARCHAR ( 500 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '日志信息', + `status` CHAR ( 1 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '执行状态(0正常 1失败)', + `exception` VARCHAR ( 2000 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '异常信息', + `createTime` DATETIME ( 0 ) NULL DEFAULT NULL COMMENT '创建时间', + `invokeTarget` VARCHAR ( 200 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '调用目标', + `elapsed` DOUBLE ( 10, 0 ) NULL DEFAULT NULL COMMENT '作业用时', + PRIMARY KEY ( `jobLogId` ) USING BTREE +) ENGINE = INNODB AUTO_INCREMENT = 198 CHARACTER +SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时任务调度日志表' ROW_FORMAT = Dynamic; -- ---------------------------- -- 通知公告表 -- ---------------------------- -drop table if exists sys_notice; -create table sys_notice ( - notice_id int(4) not null auto_increment comment '公告ID', - notice_title varchar(50) not null comment '公告标题', - notice_type char(1) not null comment '公告类型(1通知 2公告)', - notice_content varchar(500) default null comment '公告内容', - status char(1) default '0' comment '公告状态(0正常 1关闭)', - create_by varchar(64) default '' comment '创建者', - create_time datetime comment '创建时间', - update_by varchar(64) default '' comment '更新者', - update_time datetime comment '更新时间', - remark varchar(255) default null comment '备注', - primary key (notice_id) -) engine=innodb auto_increment=10 comment = '通知公告表'; +DROP TABLE +IF + EXISTS sys_notice; +CREATE TABLE sys_notice ( + notice_id INT ( 4 ) NOT NULL auto_increment COMMENT '公告ID', + notice_title VARCHAR ( 50 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '公告标题', + notice_type INT NOT NULL COMMENT '公告类型(1通知 2公告)', + notice_content TEXT CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '公告内容', + `status` INT DEFAULT 0 COMMENT '公告状态(0正常 1关闭)', + create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者', + create_time DATETIME COMMENT '创建时间', + update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者', + update_time DATETIME COMMENT '更新时间', + remark VARCHAR ( 255 ) CHARACTER + SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', + PRIMARY KEY ( notice_id ) +) ENGINE = INNODB auto_increment = 1 COMMENT = '通知公告表'; -- ---------------------------- diff --git a/document/pgsql/admin-pg15.sql b/document/pgsql/admin-pg15.sql index d14fb75..31ad71b 100644 --- a/document/pgsql/admin-pg15.sql +++ b/document/pgsql/admin-pg15.sql @@ -683,9 +683,9 @@ DROP TABLE IF EXISTS "public"."sys_notice"; CREATE TABLE "public"."sys_notice" ( "notice_id" int4 NOT NULL DEFAULT nextval('sys_noticeid_seq'::regclass), "notice_title" varchar(50) COLLATE "pg_catalog"."default" NOT NULL, - "notice_type" char(1) COLLATE "pg_catalog"."default" NOT NULL, + "notice_type" int4 NOT NULL, "notice_content" varchar(500) COLLATE "pg_catalog"."default", - "status" char(1) COLLATE "pg_catalog"."default", + "status" int4, "create_by" varchar(64) COLLATE "pg_catalog"."default", "create_time" timestamp(6), "update_by" varchar(64) COLLATE "pg_catalog"."default", diff --git a/document/sqlserver/admin-sqlserver.sql b/document/sqlserver/admin-sqlserver.sql index 3c72ac8..e49d7f6 100644 --- a/document/sqlserver/admin-sqlserver.sql +++ b/document/sqlserver/admin-sqlserver.sql @@ -31,7 +31,6 @@ CREATE TABLE sys_tasks requestMethod VARCHAR(10) --请求方法 ) GO -GO if OBJECT_ID(N'sys_tasks_log',N'U') is not NULL DROP TABLE sys_tasks_log GO /**定时任务调度日志表*/ @@ -55,9 +54,9 @@ GO CREATE TABLE [dbo].[sys_notice]( [notice_id] [int] NOT NULL PRIMARY KEY IDENTITY(1,1), [notice_title] [varchar](100) NULL, - [notice_type] [char](1) NULL, + [notice_type] int NULL, [notice_content] [text] NULL, - [status] [char](1) NULL, + [status] int NULL, [create_by] [varchar](64) NULL, [create_time] [datetime] NULL, [update_by] [varchar](64) NULL,