mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-27 19:35:49 +08:00
发布v2.8.4版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
@@ -65,6 +65,7 @@ type DeleteRes struct{}
|
||||
// MaxSortReq 获取@{.tableComment}最大排序
|
||||
type MaxSortReq struct {
|
||||
g.Meta `path:"/@{.varName | LcFirst}/maxSort" method:"get" tags:"@{.tableComment}" summary:"获取@{.tableComment}最大排序"`
|
||||
@{.templateGroup}in.@{.varName}MaxSortInp
|
||||
}
|
||||
|
||||
type MaxSortRes struct {
|
||||
|
@@ -9,9 +9,7 @@ package @{.templateGroup}
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"@{.importApi}"
|
||||
"@{.importInput}"
|
||||
"hotgo/internal/model/input/form"
|
||||
"@{.importService}"
|
||||
"hotgo/utility/validate"
|
||||
@@ -25,63 +23,34 @@ type c@{.varName} struct{}
|
||||
|
||||
// List 查看@{.tableComment}列表
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
list, totalCount, err := service.@{.templateGroup | UcFirst}@{.varName}().List(ctx, in)
|
||||
list, totalCount, err := service.@{.templateGroup | UcFirst}@{.varName}().List(ctx, &req.@{.varName}ListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(@{.varName | ToLower}.ListRes)
|
||||
res.List = list
|
||||
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
|
||||
res.Page = req.Page
|
||||
res.PerPage = req.PerPage
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, in)
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, &req.@{.varName}ListInp)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasEdit true }
|
||||
// Edit 更新@{.tableComment}
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, in)
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, &req.@{.varName}EditInp)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if and (eq .options.Step.HasEdit true) (eq .options.Step.HasMaxSort true) }
|
||||
// MaxSort 获取@{.tableComment}最大排序
|
||||
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{})
|
||||
data, err := service.@{.templateGroup | UcFirst}@{.varName}().MaxSort(ctx, &req.@{.varName}MaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -94,16 +63,7 @@ func (c *c@{.varName}) MaxSort(ctx context.Context, req *@{.varName | ToLower}.M
|
||||
@{ if or (eq .options.Step.HasView true) (eq .options.Step.HasEdit true) }
|
||||
// View 获取指定@{.tableComment}信息
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := service.@{.templateGroup | UcFirst}@{.varName}().View(ctx, in)
|
||||
data, err := service.@{.templateGroup | UcFirst}@{.varName}().View(ctx, &req.@{.varName}ViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -116,48 +76,21 @@ func (c *c@{.varName}) View(ctx context.Context, req *@{.varName | ToLower}.View
|
||||
@{ if eq .options.Step.HasDel true }
|
||||
// Delete 删除@{.tableComment}
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, in)
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, &req.@{.varName}DeleteInp)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasStatus true }
|
||||
// Status 更新@{.tableComment}状态
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, in)
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, &req.@{.varName}StatusInp)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }
|
||||
// Switch 更新@{.tableComment}开关状态
|
||||
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
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, in)
|
||||
err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, &req.@{.varName}SwitchInp)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
|
@@ -44,7 +44,7 @@ func (s *s@{.servFunName}) Model(ctx context.Context, option ...*handler.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) {
|
||||
func (s *s@{.servFunName}) List(ctx context.Context, in *@{.templateGroup}in.@{.varName}ListInp) (list []*@{.templateGroup}in.@{.varName}ListModel, totalCount int, err error) {
|
||||
mod := s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end})
|
||||
@{.listWhere}
|
||||
@{.listJoin.link}
|
||||
@@ -68,7 +68,7 @@ func (s *s@{.servFunName}) List(ctx context.Context, in @{.templateGroup}in.@{.v
|
||||
}
|
||||
@{ if eq .options.Step.HasExport true }
|
||||
// Export 导出@{.tableComment}
|
||||
func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{.varName}ListInp) (err error) {
|
||||
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
|
||||
@@ -95,9 +95,8 @@ func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{
|
||||
}@{end}
|
||||
@{ if eq .options.Step.HasEdit true }
|
||||
// Edit 修改/新增@{.tableComment}
|
||||
func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.varName}EditInp) (err error) {
|
||||
@{.edit.unique}
|
||||
// 修改
|
||||
func (s *s@{.servFunName}) Edit(ctx context.Context, in *@{.templateGroup}in.@{.varName}EditInp) (err error) {
|
||||
@{.edit.unique} // 修改
|
||||
if in.@{.pk.GoName} > 0 {
|
||||
@{.edit.update}
|
||||
}
|
||||
@@ -109,7 +108,7 @@ func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.v
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasDel true }
|
||||
// Delete 删除@{.tableComment}
|
||||
func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{.varName}DeleteInp) (err error) {
|
||||
func (s *s@{.servFunName}) Delete(ctx context.Context, in *@{.templateGroup}in.@{.varName}DeleteInp) (err error) {
|
||||
if _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Delete();err != nil {
|
||||
err = gerror.Wrap(err, "删除@{.tableComment}失败,请稍后重试!")
|
||||
return
|
||||
@@ -118,7 +117,7 @@ func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{
|
||||
}@{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) {
|
||||
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, "获取@{.tableComment}最大排序,请稍后重试!")
|
||||
return
|
||||
@@ -128,13 +127,13 @@ func (s *s@{.servFunName}) MaxSort(ctx context.Context, in @{.templateGroup}in.@
|
||||
res = new(@{.templateGroup}in.@{.varName}MaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
@{end}
|
||||
@{ if or (eq .options.Step.HasView true) (eq .options.Step.HasEdit true) }
|
||||
// View 获取@{.tableComment}指定信息
|
||||
func (s *s@{.servFunName}) View(ctx context.Context, in @{.templateGroup}in.@{.varName}ViewInp) (res *@{.templateGroup}in.@{.varName}ViewModel, err error) {
|
||||
func (s *s@{.servFunName}) View(ctx context.Context, in *@{.templateGroup}in.@{.varName}ViewInp) (res *@{.templateGroup}in.@{.varName}ViewModel, err error) {
|
||||
if err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Scan(&res);err != nil {
|
||||
err = gerror.Wrap(err, "获取@{.tableComment}信息,请稍后重试!")
|
||||
return
|
||||
@@ -143,7 +142,7 @@ func (s *s@{.servFunName}) View(ctx context.Context, in @{.templateGroup}in.@{.v
|
||||
}@{end}
|
||||
@{ if eq .options.Step.HasStatus true }
|
||||
// Status 更新@{.tableComment}状态
|
||||
func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{.varName}StatusInp) (err error) {
|
||||
func (s *s@{.servFunName}) Status(ctx context.Context, in *@{.templateGroup}in.@{.varName}StatusInp) (err error) {
|
||||
if _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Data(@{.statusUpdate}).Update();err != nil {
|
||||
err = gerror.Wrap(err, "更新@{.tableComment}状态失败,请稍后重试!")
|
||||
return
|
||||
@@ -153,7 +152,7 @@ func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{
|
||||
@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }
|
||||
// Switch 更新@{.tableComment}开关
|
||||
func (s *s@{.servFunName}) Switch(ctx context.Context, in @{.templateGroup}in.@{.varName}SwitchInp) (err error) {
|
||||
func (s *s@{.servFunName}) Switch(ctx context.Context, in *@{.templateGroup}in.@{.varName}SwitchInp) (err error) {
|
||||
var fields = []string{
|
||||
@{.switchFields}
|
||||
// ...
|
||||
|
Reference in New Issue
Block a user