mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-10-12 13:03:45 +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:
@@ -7,12 +7,9 @@ package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/api/admin/dict"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,58 +20,32 @@ type cDictData struct{}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cDictData) Delete(ctx context.Context, req *dict.DataDeleteReq) (res *dict.DataDeleteRes, err error) {
|
||||
var in sysin.DictDataDeleteInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysDictData().Delete(ctx, in)
|
||||
err = service.SysDictData().Delete(ctx, &req.DictDataDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cDictData) Edit(ctx context.Context, req *dict.DataEditReq) (res *dict.DataEditRes, err error) {
|
||||
var in sysin.DictDataEditInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysDictData().Edit(ctx, in)
|
||||
err = service.SysDictData().Edit(ctx, &req.DictDataEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cDictData) List(ctx context.Context, req *dict.DataListReq) (res *dict.DataListRes, err error) {
|
||||
var in sysin.DictDataListInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
list, totalCount, err := service.SysDictData().List(ctx, in)
|
||||
list, totalCount, err := service.SysDictData().List(ctx, &req.DictDataListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(dict.DataListRes)
|
||||
res.List = list
|
||||
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
|
||||
res.Page = req.Page
|
||||
res.PerPage = req.PerPage
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Select 指定选项
|
||||
func (c *cDictData) Select(ctx context.Context, req *dict.DataSelectReq) (res dict.DataSelectRes, err error) {
|
||||
var in sysin.DataSelectInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
list, err := service.SysDictData().Select(ctx, in)
|
||||
list, err := service.SysDictData().Select(ctx, &req.DataSelectInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -87,7 +58,7 @@ func (c *cDictData) Select(ctx context.Context, req *dict.DataSelectReq) (res di
|
||||
func (c *cDictData) Selects(ctx context.Context, req *dict.DataSelectsReq) (res dict.DataSelectsRes, err error) {
|
||||
res = make(dict.DataSelectsRes)
|
||||
for _, v := range req.Types {
|
||||
option, err := service.SysDictData().Select(ctx, sysin.DataSelectInp{Type: v})
|
||||
option, err := service.SysDictData().Select(ctx, &sysin.DataSelectInp{Type: v})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user