feat: 初次启动
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type GetDictListLogic struct {
|
||||
@@ -20,23 +18,12 @@ func NewGetDictListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDi
|
||||
return &GetDictListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetDictListLogic) GetDictList(req *types.DictListReq) (resp interface{}, err error) {
|
||||
var dicts []sysModel.SundynixDict
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixDict{})
|
||||
if req.Type != "" {
|
||||
db = db.Where("type = ?", req.Type)
|
||||
func (l *GetDictListLogic) GetDictList(req *types.DictListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetDictList(l.ctx, &system.DictListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize), Type: req.Type,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("sort").Find(&dicts).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询字典列表失败")
|
||||
}
|
||||
return map[string]interface{}{"list": dicts, "total": total, "current": current, "size": pageSize}, nil
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user