代码生成新增加权限判断
This commit is contained in:
parent
c24c243dc3
commit
8cf4273bd3
18
Infrastructure/Model/SendEmailDto.cs
Normal file
18
Infrastructure/Model/SendEmailDto.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Infrastructure.Model
|
||||
{
|
||||
public class SendEmailDto
|
||||
{
|
||||
public string FileUrl { get; set; } = "";
|
||||
public string Subject { get; set; }
|
||||
public string ToUser { get; set; }
|
||||
public string Content { get; set; } = "";
|
||||
public string HtmlContent { get; set; }
|
||||
public DateTime AddTime { get; set; }
|
||||
}
|
||||
}
|
||||
165
ZR.Common/MailHelper.cs
Normal file
165
ZR.Common/MailHelper.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using MailKit.Net.Smtp;
|
||||
using MimeKit;
|
||||
using MimeKit.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace ZR.Common
|
||||
{
|
||||
public class MailHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 发送人邮箱
|
||||
/// </summary>
|
||||
public string FromEmail { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 发送人密码
|
||||
/// </summary>
|
||||
public string FromPwd { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 发送协议
|
||||
/// </summary>
|
||||
public string Smtp { get; set; } = "smtp.qq.com";
|
||||
/// <summary>
|
||||
/// 协议端口
|
||||
/// </summary>
|
||||
public int Port { get; set; } = 587;
|
||||
/// <summary>
|
||||
/// 是否使用SSL协议
|
||||
/// </summary>
|
||||
public bool UseSsl { get; set; } = false;
|
||||
public string mailSign = @"";
|
||||
|
||||
public MailHelper(string fromEmail, string smtp, int port, string fromPwd)
|
||||
{
|
||||
FromEmail = fromEmail;
|
||||
Smtp = smtp;
|
||||
FromPwd = fromPwd;
|
||||
Port = port;
|
||||
}
|
||||
|
||||
public MailHelper(string fromEmail, string fromPwd)
|
||||
{
|
||||
FromEmail = fromEmail;
|
||||
FromPwd = fromPwd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送一个人
|
||||
/// </summary>
|
||||
/// <param name="toAddress"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="path"></param>
|
||||
public void SendMail(string toAddress, string subject, string text, string path = "", string html = "")
|
||||
{
|
||||
IEnumerable<MailboxAddress> mailboxes = new List<MailboxAddress>() {
|
||||
new MailboxAddress(toAddress)
|
||||
};
|
||||
|
||||
SendMail(mailboxes, subject, text, path, html);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送多个邮箱
|
||||
/// </summary>
|
||||
/// <param name="toAddress"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="path"></param>
|
||||
public void SendMail(string[] toAddress, string subject, string text, string path = "", string html = "")
|
||||
{
|
||||
IList<MailboxAddress> mailboxes = new List<MailboxAddress>() { };
|
||||
foreach (var item in toAddress)
|
||||
{
|
||||
mailboxes.Add(new MailboxAddress(item));
|
||||
}
|
||||
|
||||
SendMail(mailboxes, subject, text, path, html);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
/// <param name="toName"></param>
|
||||
/// <param name="toAddress"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="path">附件url地址</param>
|
||||
private void SendMail(IEnumerable<MailboxAddress> toAddress, string subject, string text, string path = "", string html = "")
|
||||
{
|
||||
MimeMessage message = new MimeMessage();
|
||||
//发件人
|
||||
message.From.Add(new MailboxAddress(FromEmail, FromEmail));
|
||||
|
||||
//收件人
|
||||
//message.To.Add(new MailboxAddress(toAddress));
|
||||
//IList<InternetAddress> internets = null;
|
||||
//internets.Add(new MailboxAddress(toAddress));
|
||||
|
||||
message.To.AddRange(toAddress);
|
||||
message.Subject = subject;
|
||||
message.Date = DateTime.Now;
|
||||
|
||||
//创建附件Multipart
|
||||
Multipart multipart = new Multipart("mixed");
|
||||
|
||||
//html内容
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
{
|
||||
var Html = new TextPart(TextFormat.Html)
|
||||
{
|
||||
Text = html
|
||||
};
|
||||
multipart.Add(Html);
|
||||
}
|
||||
//文本内容
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
var plain = new TextPart(TextFormat.Plain)
|
||||
{
|
||||
Text = text + "\r\n\n\n" + mailSign
|
||||
};
|
||||
multipart.Add(plain);
|
||||
}
|
||||
|
||||
//附件
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
MimePart attachment = new MimePart()
|
||||
{
|
||||
Content = new MimeContent(File.OpenRead(path), ContentEncoding.Default),
|
||||
//读取文件,只能用绝对路径
|
||||
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
|
||||
ContentTransferEncoding = ContentEncoding.Base64,
|
||||
//文件名字
|
||||
FileName = Path.GetFileName(path)
|
||||
};
|
||||
multipart.Add(attachment);
|
||||
}
|
||||
|
||||
//赋值邮件内容
|
||||
message.Body = multipart;
|
||||
|
||||
//开始发送
|
||||
using (var client = new SmtpClient())
|
||||
{
|
||||
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
|
||||
//Smtp服务器
|
||||
//client.Connect("smtp.qq.com", 587, false);
|
||||
client.Connect(Smtp, Port, true);
|
||||
//登录,发送
|
||||
//特别说明,对于服务器端的中文相应,Exception中有编码问题,显示乱码了
|
||||
client.Authenticate(FromEmail, FromPwd);
|
||||
|
||||
client.Send(message);
|
||||
//断开
|
||||
client.Disconnect(true);
|
||||
Console.WriteLine($"发送邮件成功{DateTime.Now}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -43,16 +43,6 @@
|
||||
<el-table :data="dataList" ref="table" border>
|
||||
<el-table-column prop="id" label="id" width="60" sortable> </el-table-column>
|
||||
<el-table-column prop="saveStore" label="存储位置" :show-overflow-tooltip="true"> </el-table-column>
|
||||
<!-- 显示图片 -->
|
||||
<el-table-column prop="photo" label="图片预览" width="110">
|
||||
<template slot-scope="scope">
|
||||
<el-popover placement="right" trigger="hover">
|
||||
<!-- click显示的大图 -->
|
||||
<img :src="scope.row.photo" />
|
||||
<img slot="reference" :src="scope.row.photo" width="100" height="50">
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="savePath" label="文件仓库" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="fileName" label="文件名" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="fileExt" label="文件扩展名" />
|
||||
@ -108,20 +98,10 @@ export default {
|
||||
dictLabel: "本地",
|
||||
},
|
||||
],
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + "/upload/SaveFile?token=zr",
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + "/upload/SaveFile",
|
||||
// 数据列表
|
||||
dataList: [
|
||||
{
|
||||
id: 1,
|
||||
photo:
|
||||
"https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/d788d43f8794a4c2b124d0000df41bd5ad6e3991.jpg",
|
||||
name: "你好",
|
||||
userId: 1000001,
|
||||
sortId: 1,
|
||||
address: "浙江省杭州市西湖区",
|
||||
content: "我是一个超长超长的文字啊",
|
||||
addtime: "2021-8-7 23:00:00",
|
||||
},
|
||||
|
||||
],
|
||||
// 总记录数
|
||||
total: 0,
|
||||
@ -129,8 +109,6 @@ export default {
|
||||
btnSubmitVisible: true,
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||
userId: [{ required: true, message: "id不能为空", trigger: "blur" }],
|
||||
},
|
||||
};
|
||||
},
|
||||
@ -223,14 +201,9 @@ export default {
|
||||
this.title = "详情";
|
||||
// TODO 给表单赋值
|
||||
this.form = {
|
||||
content: row.content,
|
||||
userId: row.userId,
|
||||
name: row.name,
|
||||
sortId: row.sortId,
|
||||
|
||||
};
|
||||
},
|
||||
handleImport() {},
|
||||
handleExport() {},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@ -16,7 +16,7 @@
|
||||
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportTable" v-hasPermi="['tool:gen:import']">导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" :disabled="multiple" plain icon="el-icon-delete" @click="handleDelete" size="mini" v-hasPermi="['tool:gen:delete']">删除</el-button>
|
||||
<el-button type="danger" :disabled="multiple" plain icon="el-icon-delete" @click="handleDelete" size="mini" v-hasPermi="['tool:gen:remove']">删除</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table ref="gridtable" v-loading="tableloading" :data="tableData" border @selection-change="handleSelectionChange" highlight-current-row height="480px">
|
||||
@ -33,9 +33,9 @@
|
||||
<el-table-column prop="updateTime" label="更新时间" />
|
||||
<el-table-column label="操作" align="center" width="300">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" icon="el-icon-view" @click="handlePreview(scope.row)">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:delete']">删除</el-button>
|
||||
<el-button type="text" icon="el-icon-view" @click="handlePreview(scope.row)" v-hasPermi="['tool:gen:preview']">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:gen:edit']">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:remove']">删除</el-button>
|
||||
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row)" v-hasPermi="['tool:gen:code']">生成代码</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@ -251,7 +251,7 @@ INSERT INTO sys_menu VALUES (103, '部门管理', 1, 4, 'dept', 'system/dept/ind
|
||||
INSERT INTO sys_menu VALUES (104, '岗位管理', 1, 5, 'post', 'system/post/index', 0, 0, 'C', '0', '0', 'system:post:list', 'post', '', SYSDATE(), '', NULL, '岗位管理菜单');
|
||||
INSERT INTO sys_menu VALUES (108, '日志管理', 1, 9, 'log', '', 0, 0, 'M', '0', '0', '', 'log', '', SYSDATE(), '', NULL, '日志管理菜单');
|
||||
INSERT INTO sys_menu VALUES (105, '字典管理', 1, 5, 'dict', 'system/dict/index', 0, 0, 'C', '0', '0', 'system:dict:list', 'dict', '', SYSDATE(), '', NULL, '');
|
||||
INSERT INTO sys_menu VALUES (106, '分配用户', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', '', SYSDATE(), '', NULL, NULL);
|
||||
INSERT INTO sys_menu VALUES (106, '权限分配', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', '', SYSDATE(), '', NULL, NULL);
|
||||
|
||||
-- 一级菜单 缓存监控
|
||||
INSERT INTO sys_menu VALUES (113, '缓存监控', 2, 5, 'cache', 'monitor/cache/index', 0, 0, 'C', '1', '1', 'monitor:cache:list', 'redis', '', SYSDATE(), '', NULL, '缓存监控菜单');
|
||||
@ -260,8 +260,7 @@ INSERT INTO sys_menu VALUES (113, '缓存监控', 2, 5, 'cache', 'monitor/cache/
|
||||
INSERT INTO sys_menu VALUES (114, '表单构建', 3, 1, 'build', 'tool/build/index', 0, 0, 'C', '0', '0', 'tool:build:list', 'build', '', SYSDATE(), '', NULL, '表单构建菜单');
|
||||
INSERT INTO sys_menu VALUES (115, '代码生成', 3, 1, 'gen', 'tool/gen/index', 0, 0, 'C', '0', '0', 'tool:gen:list', 'code', '', SYSDATE(), '', NULL, '代码生成菜单');
|
||||
INSERT INTO sys_menu VALUES (116, '系统接口', 3, 3, 'swagger', 'tool/swagger/index', 0, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', '', SYSDATE(), '', NULL, '系统接口菜单');
|
||||
INSERT INTO sys_menu VALUES (117, '编辑表格', 3, 3, 'editTable', 'tool/gen/editTable', 0, 0, 'C', '1', '0', 'tool:gen:edittable', '', '', SYSDATE(), '', NULL, '代码生成编辑表格菜单');
|
||||
|
||||
INSERT INTO sys_menu VALUES (117, '发送邮件', 3, 4, '/sendEmail', 'tool/email/sendEmail', 0, 0, 'C', '0', '0', 'tool:email:send', 'message', '', GETDATE(), '', NULL, '发送邮件菜单');
|
||||
|
||||
-- 日志管理
|
||||
INSERT INTO sys_menu VALUES (500, '操作日志', 108, 1, 'operlog', 'monitor/operlog/index', 0, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', '', SYSDATE(), '', NULL, '操作日志菜单');
|
||||
@ -324,6 +323,13 @@ INSERT INTO sys_menu VALUES (2062, '新增', 2057, 1, '#', NULL, 0, 0, 'F', '0',
|
||||
INSERT INTO sys_menu VALUES (2063, '修改', 2057, 2, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:update', '', '', SYSDATE(), '', NULL, NULL);
|
||||
INSERT INTO sys_menu VALUES (2064, '删除', 2057, 3, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:delete', '', '', SYSDATE(), '', NULL, NULL);
|
||||
|
||||
--代码生成页面权限
|
||||
INSERT INTO sys_menu(menuId, menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES (2070, '编辑', 115, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tool:ten:edit', '', '', GETDATE());
|
||||
INSERT INTO sys_menu(menuId, menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES (2071, '预览', 115, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tool:ten:preview', '', '', GETDATE());
|
||||
INSERT INTO sys_menu(menuId, menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES (2072, '删除', 115, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tool:ten:remove', '', '', GETDATE());
|
||||
INSERT INTO sys_menu(menuId, menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES (2073, '导入', 115, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tool:ten:import', '', '', GETDATE());
|
||||
INSERT INTO sys_menu(menuId, menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time) VALUES (2074, '生成代码', 115, 1, '#', NULL, 0, 0, 'F', '0', '0', 'tool:ten:code', '', '', GETDATE());
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_oper_log
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user