mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
版本预发布
This commit is contained in:
File diff suppressed because one or more lines are too long
217
server/resource/template/email/code.html
Normal file
217
server/resource/template/email/code.html
Normal file
@@ -0,0 +1,217 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>验证码邮件</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0 auto !important;
|
||||
padding: 0 !important;
|
||||
width: 100% !important;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.4;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-ms-text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
* {
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
table,
|
||||
td {
|
||||
mso-table-lspace: 0 !important;
|
||||
mso-table-rspace: 0 !important;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
border: none;
|
||||
max-width: 100%;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body
|
||||
leftmargin="0"
|
||||
marginwidth="0"
|
||||
topmargin="0"
|
||||
marginheight="0"
|
||||
offset="0"
|
||||
width="100%"
|
||||
style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly"
|
||||
>
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
valign="top"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
height="100%"
|
||||
width="100%"
|
||||
style="border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
text-align: center;"
|
||||
>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="600"
|
||||
bgcolor="#ffffff"
|
||||
style="max-width: 600px;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
background: #ffffff;"
|
||||
>
|
||||
<tr>
|
||||
<td height=40" style="height:40px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="440"
|
||||
style="max-width: 440px;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
text-align: center;"
|
||||
>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img
|
||||
src="@{.logo}"
|
||||
width="170"
|
||||
style="border: none; display: block; max-width: 170px; width: 100%"
|
||||
alt="logo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="40" style="height:40px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h1
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 24px;
|
||||
color: #010E28;
|
||||
font-weight: bold;
|
||||
margin: 0 0 5px;
|
||||
padding: 0"
|
||||
>
|
||||
这是你发送的验证码吗?
|
||||
</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="15" style="height: 15px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 15px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;"
|
||||
>
|
||||
@{.os} <br />
|
||||
@{.cityLabel} (estimated) <br />
|
||||
IP 地址: @{.ip}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="30" style="height: 30px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 15px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
font-weight: bold;"
|
||||
>
|
||||
如果是,请输入验证码:
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20" style="height: 20px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 35px;
|
||||
color: #010E28;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
font-weight: bold;"
|
||||
>
|
||||
@{.code}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="20" style="height: 20px"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 15px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
font-weight: bold;"
|
||||
>
|
||||
该验证码@{.expires}分钟内有效,请不要告诉于他人!
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="40" style="height:40px"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
301
server/resource/template/email/resetPwd.html
Normal file
301
server/resource/template/email/resetPwd.html
Normal file
@@ -0,0 +1,301 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>密码重置邮件</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0 auto !important;
|
||||
padding: 0 !important;
|
||||
width: 100% !important;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.4;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-ms-text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
* {
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
table,
|
||||
td {
|
||||
mso-table-lspace: 0 !important;
|
||||
mso-table-rspace: 0 !important;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
border: none;
|
||||
max-width: 100%;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body
|
||||
leftmargin="0"
|
||||
marginwidth="0"
|
||||
topmargin="0"
|
||||
marginheight="0"
|
||||
offset="0"
|
||||
bgcolor="#F3F5F9"
|
||||
width="100%"
|
||||
style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background: #F3F5F9;"
|
||||
>
|
||||
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
valign="top"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
height="100%"
|
||||
width="100%"
|
||||
bgcolor="#F3F5F9"
|
||||
style="border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
background: #F3F5F9"
|
||||
>
|
||||
<tr>
|
||||
<td height="30" style="height: 30px;"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td height=20" style="height: 20px;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="600"
|
||||
bgcolor="#ffffff"
|
||||
style="max-width: 600px;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
background: #ffffff;"
|
||||
>
|
||||
<tr>
|
||||
<td
|
||||
height="5"
|
||||
style="height: 5px;
|
||||
background-color: #0069FF;
|
||||
background-image: linear-gradient(-45deg, #0248FF, #0069FF);"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=40" style="height:40px"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<table
|
||||
role="presentation"
|
||||
align="center"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="440"
|
||||
style="max-width: 440px;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;"
|
||||
>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img
|
||||
src="@{.logo}"
|
||||
width="170"
|
||||
style="border: none; display: block; max-width: 170px; width: 100%"
|
||||
alt="logo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="40" style="height:40px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h1
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 24px;
|
||||
color: #010E28;
|
||||
font-weight: bold;
|
||||
margin: 0 0 5px;
|
||||
padding: 0"
|
||||
>
|
||||
Hi, @{.username}!
|
||||
</h1>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 16px;
|
||||
color: #010E28;
|
||||
margin: 0;
|
||||
padding: 0"
|
||||
>
|
||||
忘记密码请求
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="15" style="height: 15px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 15px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;"
|
||||
>
|
||||
你好像忘记了你的账户密码。你可以通过点击下面的按钮更改密码:
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="45" style="height: 45px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table
|
||||
role="presentation"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="440"
|
||||
style="max-width: 440px;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
vertical-align: top;
|
||||
margin: 0;
|
||||
width: 100%;"
|
||||
>
|
||||
<tr>
|
||||
<td width="70" style="width: 70px"></td>
|
||||
<td
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
width: 300px;
|
||||
background-color: #0248FF;
|
||||
background-image: linear-gradient(-45deg, #0248FF, #0069FF);
|
||||
color: #FFF;
|
||||
height: 55px;
|
||||
line-height: 55px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
font-weight: bold;"
|
||||
>
|
||||
<a
|
||||
href="@{.passwordResetLink}"
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
width: 100%;
|
||||
background-color: #0248FF;
|
||||
background-image: linear-gradient(-45deg, #0248FF, #0069FF);
|
||||
color: #FFF;
|
||||
height: 55px;
|
||||
line-height: 55px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
cursor: pointer;"
|
||||
>
|
||||
重置密码
|
||||
</a>
|
||||
</td>
|
||||
<td width="70" style="width: 70px"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="45" style="height: 45px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 15px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;"
|
||||
>
|
||||
Ms and the <strong style="font-weight: bold; color: #010E28">@{.name}</strong> Team.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="30" style="height: 30px"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
text-align: left;"
|
||||
>
|
||||
如果你在点击密码重置按钮时遇到麻烦,请将下面的URL复制并粘贴到你的浏览器中:
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="10" style="height: 10px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p
|
||||
style="font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
color: #5B6987;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
text-align: left;"
|
||||
>
|
||||
@{.passwordResetLink}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="40" style="height:40px"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="40"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
12
server/resource/template/email/text.html
Normal file
12
server/resource/template/email/text.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
@{.content}
|
||||
</body>
|
||||
</html>
|
@@ -28,16 +28,16 @@ type c@{.varName} struct{}
|
||||
func (c *c@{.varName}) List(ctx context.Context, req *@{.varName | ToLower}.ListReq) (res *@{.varName | ToLower}.ListRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}ListInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
list, totalCount, err := service.@{.templateGroup | UcFirst}@{.varName}().List(ctx, in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
res = new(@{.varName | ToLower}.ListRes)
|
||||
@@ -45,24 +45,22 @@ func (c *c@{.varName}) List(ctx context.Context, req *@{.varName | ToLower}.List
|
||||
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
|
||||
res.Page = req.Page
|
||||
res.PerPage = req.PerPage
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
@{ if eq .options.Step.HasExport true }
|
||||
// Export 导出@{.tableComment}列表
|
||||
func (c *c@{.varName}) Export(ctx context.Context, req *@{.varName | ToLower}.ExportReq) (res *@{.varName | ToLower}.ExportRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}ListInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, in)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasEdit true }
|
||||
@@ -70,17 +68,15 @@ func (c *c@{.varName}) Export(ctx context.Context, req *@{.varName | ToLower}.Ex
|
||||
func (c *c@{.varName}) Edit(ctx context.Context, req *@{.varName | ToLower}.EditReq) (res *@{.varName | ToLower}.EditRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}EditInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, in)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if and (eq .options.Step.HasEdit true) (eq .options.Step.HasMaxSort true) }
|
||||
@@ -88,12 +84,12 @@ func (c *c@{.varName}) Edit(ctx context.Context, req *@{.varName | ToLower}.Edit
|
||||
func (c *c@{.varName}) MaxSort(ctx context.Context, req *@{.varName | ToLower}.MaxSortReq) (res *@{.varName | ToLower}.MaxSortRes, err error) {
|
||||
data, err := service.@{.templateGroup | UcFirst}@{.varName}().MaxSort(ctx, sysin.@{.varName}MaxSortInp{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
res = new(@{.varName | ToLower}.MaxSortRes)
|
||||
res.@{.varName}MaxSortModel = data
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasView true }
|
||||
@@ -101,21 +97,21 @@ func (c *c@{.varName}) MaxSort(ctx context.Context, req *@{.varName | ToLower}.M
|
||||
func (c *c@{.varName}) View(ctx context.Context, req *@{.varName | ToLower}.ViewReq) (res *@{.varName | ToLower}.ViewRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}ViewInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
data, err := service.@{.templateGroup | UcFirst}@{.varName}().View(ctx, in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
res = new(@{.varName | ToLower}.ViewRes)
|
||||
res.@{.varName}ViewModel = data
|
||||
return res, nil
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasDel true }
|
||||
@@ -123,17 +119,15 @@ func (c *c@{.varName}) View(ctx context.Context, req *@{.varName | ToLower}.View
|
||||
func (c *c@{.varName}) Delete(ctx context.Context, req *@{.varName | ToLower}.DeleteReq) (res *@{.varName | ToLower}.DeleteRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}DeleteInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, in)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasStatus true }
|
||||
@@ -141,17 +135,15 @@ func (c *c@{.varName}) Delete(ctx context.Context, req *@{.varName | ToLower}.De
|
||||
func (c *c@{.varName}) Status(ctx context.Context, req *@{.varName | ToLower}.StatusReq) (res *@{.varName | ToLower}.StatusRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}StatusInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, in)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }
|
||||
@@ -159,17 +151,14 @@ func (c *c@{.varName}) Status(ctx context.Context, req *@{.varName | ToLower}.St
|
||||
func (c *c@{.varName}) Switch(ctx context.Context, req *@{.varName | ToLower}.SwitchReq) (res *@{.varName | ToLower}.SwitchRes, err error) {
|
||||
var in @{.templateGroup}in.@{.varName}SwitchInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
if err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, in)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
@{ if eq .options.Step.HasEdit true }
|
||||
// @{.varName}EditInp 修改/新增@{.tableComment}
|
||||
type @{.varName}EditInp struct {
|
||||
entity.Test
|
||||
entity.@{.daoName}
|
||||
}
|
||||
|
||||
func (in *@{.varName}EditInp) Filter(ctx context.Context) (err error) {
|
||||
@@ -38,6 +38,10 @@ type @{.varName}DeleteInp struct {
|
||||
@{.pk.GoName} interface{} `json:"@{.pk.TsName}" v:"required#@{.pk.Dc}不能为空" dc:"@{.pk.Dc}"`
|
||||
}
|
||||
|
||||
func (in *@{.varName}DeleteInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}DeleteModel struct{}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasView true }
|
||||
@@ -46,8 +50,12 @@ type @{.varName}ViewInp struct {
|
||||
@{.pk.GoName} @{.pk.GoType} `json:"@{.pk.TsName}" v:"required#@{.pk.Dc}不能为空" dc:"@{.pk.Dc}"`
|
||||
}
|
||||
|
||||
func (in *@{.varName}ViewInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}ViewModel struct {
|
||||
entity.Test
|
||||
entity.@{.daoName}
|
||||
}@{end}
|
||||
|
||||
// @{.varName}ListInp 获取@{.tableComment}列表
|
||||
@@ -56,13 +64,14 @@ type @{.varName}ListInp struct {
|
||||
@{.listInpColumns}
|
||||
}
|
||||
|
||||
func (in *@{.varName}ListInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}ListModel struct {
|
||||
@{.listModelColumns}
|
||||
}
|
||||
|
||||
func (in *@{.varName}ListInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
@{ if eq .options.Step.HasExport true }
|
||||
// @{.varName}ExportModel 导出@{.tableComment}
|
||||
type @{.varName}ExportModel struct {
|
||||
@@ -72,6 +81,10 @@ type @{.varName}ExportModel struct {
|
||||
// @{.varName}MaxSortInp 获取@{.tableComment}最大排序
|
||||
type @{.varName}MaxSortInp struct{}
|
||||
|
||||
func (in *@{.varName}MaxSortInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}MaxSortModel struct {
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
}
|
||||
@@ -83,6 +96,10 @@ type @{.varName}StatusInp struct {
|
||||
Status int `json:"status" dc:"状态"`
|
||||
}
|
||||
|
||||
func (in *@{.varName}StatusInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}StatusModel struct{}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }
|
||||
@@ -92,5 +109,9 @@ type @{.varName}SwitchInp struct {
|
||||
@{.pk.GoName} @{.pk.GoType} `json:"@{.pk.TsName}" v:"required#@{.pk.Dc}不能为空" dc:"@{.pk.Dc}"`
|
||||
}
|
||||
|
||||
func (in *@{.varName}SwitchInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type @{.varName}SwitchModel struct{}
|
||||
@{end}
|
@@ -21,6 +21,7 @@ import (
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/model/input/@{.templateGroup}in"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/service"
|
||||
@@ -39,46 +40,42 @@ func init() {
|
||||
service.Register@{.servFunName}(New@{.servFunName}())
|
||||
}
|
||||
|
||||
// Model @{.tableComment}Orm模型
|
||||
func (s *s@{.servFunName}) Model(ctx context.Context) *gdb.Model {
|
||||
return dao.@{.daoName}.Ctx(ctx)
|
||||
// Model @{.tableComment}ORM模型
|
||||
func (s *s@{.servFunName}) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
|
||||
return handler.Model(dao.@{.daoName}.Ctx(ctx), option...)
|
||||
}
|
||||
|
||||
// List 获取@{.tableComment}列表
|
||||
func (s *s@{.servFunName}) List(ctx context.Context, in @{.templateGroup}in.@{.varName}ListInp) (list []*@{.templateGroup}in.@{.varName}ListModel, totalCount int, err error) {
|
||||
mod := dao.@{.daoName}.Ctx(ctx)
|
||||
mod := s.Model(ctx)
|
||||
@{.listWhere}
|
||||
@{.listJoin.link}
|
||||
totalCount, err = mod.Clone().Count(1)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
return
|
||||
}
|
||||
|
||||
if totalCount == 0 {
|
||||
return list, totalCount, nil
|
||||
return
|
||||
}
|
||||
|
||||
@{.listJoin.select}
|
||||
if err = mod.Fields(fields).Handler(hgorm.HandlerFilterAuth).Page(in.Page, in.PerPage).@{.listOrder}.Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
}
|
||||
|
||||
return list, totalCount, err
|
||||
err = mod.Fields(fields).Page(in.Page, in.PerPage).@{.listOrder}.Scan(&list)
|
||||
return
|
||||
}
|
||||
@{ if eq .options.Step.HasExport true }
|
||||
// Export 导出@{.tableComment}
|
||||
func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{.varName}ListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
||||
tags, err := convert.GetEntityDescTags(@{.templateGroup}in.@{.varName}ExportModel{})
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -87,13 +84,11 @@ func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{
|
||||
exports []@{.templateGroup}in.@{.varName}ExportModel
|
||||
)
|
||||
|
||||
err = gconv.Scan(list, &exports)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName); err != nil {
|
||||
if err = gconv.Scan(list, &exports);err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
||||
return
|
||||
}@{end}
|
||||
@{ if eq .options.Step.HasEdit true }
|
||||
@@ -112,61 +107,50 @@ func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.v
|
||||
@{ if eq .options.Step.HasDel true }
|
||||
// Delete 删除@{.tableComment}
|
||||
func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{.varName}DeleteInp) (err error) {
|
||||
_, err = dao.@{.daoName}.Ctx(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = s.Model(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Delete()
|
||||
return
|
||||
}@{end}
|
||||
@{ if and (eq .options.Step.HasEdit true) (eq .options.Step.HasMaxSort true) }
|
||||
// MaxSort 获取@{.tableComment}最大排序
|
||||
func (s *s@{.servFunName}) MaxSort(ctx context.Context, in @{.templateGroup}in.@{.varName}MaxSortInp) (res *@{.templateGroup}in.@{.varName}MaxSortModel, err error) {
|
||||
if err = dao.@{.daoName}.Ctx(ctx).Fields(dao.@{.daoName}.Columns().Sort).OrderDesc(dao.@{.daoName}.Columns().Sort).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
res.Sort = res.Sort + g.Cfg().MustGet(ctx, "hotgo.admin.maxSortIncrement").Int()
|
||||
return res, nil
|
||||
if res == nil {
|
||||
res = new(@{.templateGroup}in.@{.varName}MaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasView true }
|
||||
// View 获取@{.tableComment}指定信息
|
||||
func (s *s@{.servFunName}) View(ctx context.Context, in @{.templateGroup}in.@{.varName}ViewInp) (res *@{.templateGroup}in.@{.varName}ViewModel, err error) {
|
||||
if err = dao.@{.daoName}.Ctx(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
err = s.Model(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Scan(&res)
|
||||
return
|
||||
}@{end}
|
||||
@{ if eq .options.Step.HasStatus true }
|
||||
// Status 更新@{.tableComment}状态
|
||||
func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{.varName}StatusInp) (err error) {
|
||||
if in.@{.pk.GoName} <= 0 {
|
||||
err = gerror.New("@{.pk.Dc}不能为空")
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
if in.Status <= 0 {
|
||||
err = gerror.New("状态不能为空")
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusMap, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
_, err = dao.@{.daoName}.Ctx(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(dao.@{.daoName}.Columns().Status, in.Status).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = s.Model(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(@{.statusUpdate}).Update()
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }
|
||||
@@ -179,15 +163,10 @@ func (s *s@{.servFunName}) Switch(ctx context.Context, in @{.templateGroup}in.@{
|
||||
|
||||
if !validate.InSliceString(fields, in.Key) {
|
||||
err = gerror.New("开关键名不在白名单")
|
||||
return err
|
||||
return
|
||||
}
|
||||
|
||||
_, err = dao.@{.daoName}.Ctx(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(in.Key, in.Value).Update()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err = s.Model(ctx).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(@{.switchUpdate}).Update()
|
||||
return
|
||||
}
|
||||
@{end}
|
@@ -1,31 +1,33 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-modal
|
||||
v-model:show="isShowModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
:title="params?.@{.pk.TsName} > 0 ? '编辑 #' + params?.@{.pk.TsName} : '添加'"
|
||||
:style="{
|
||||
width: dialogWidth,
|
||||
}"
|
||||
>
|
||||
<n-form
|
||||
:model="params"
|
||||
:rules="rules"
|
||||
ref="formRef"
|
||||
label-placement="left"
|
||||
:label-width="80"
|
||||
class="py-4"
|
||||
<n-spin :show="loading" description="请稍候...">
|
||||
<n-modal
|
||||
v-model:show="isShowModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
:title="params?.@{.pk.TsName} > 0 ? '编辑 #' + params?.@{.pk.TsName} : '添加'"
|
||||
:style="{
|
||||
width: dialogWidth,
|
||||
}"
|
||||
>
|
||||
<n-form
|
||||
:model="params"
|
||||
:rules="rules"
|
||||
ref="formRef"
|
||||
label-placement="left"
|
||||
:label-width="80"
|
||||
class="py-4"
|
||||
>
|
||||
@{.formItem}
|
||||
</n-form>
|
||||
</n-form>
|
||||
<template #action>
|
||||
<n-space>
|
||||
<n-button @click="closeForm">取消</n-button>
|
||||
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-modal>
|
||||
</n-modal>
|
||||
</n-spin>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -57,10 +59,8 @@
|
||||
},
|
||||
});
|
||||
|
||||
const params = computed(() => {
|
||||
return props.formParams;
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const params = ref<State>(props.formParams);
|
||||
const message = useMessage();
|
||||
const formRef = ref<any>({});
|
||||
const dialogWidth = ref('75%');
|
||||
|
Reference in New Issue
Block a user