| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // Code scaffolded by goctl. Safe to edit.
- // goctl 1.10.2
- package applicationconfig
- import (
- "context"
- "udeServer/internal/apierr"
- "udeServer/internal/log"
- "udeServer/internal/model"
- "udeServer/internal/svc"
- "udeServer/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type ConfigListLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- // 配置分页列表
- func NewConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConfigListLogic {
- return &ConfigListLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *ConfigListLogic) ConfigList(req *types.ConfigListReq) (*types.ConfigListResp, error) {
- page, pageSize := normalizePage(req.Page, req.PageSize)
- rows, total, err := l.svcCtx.ConfigModel.FindPage(l.ctx, page, pageSize, req.ConfigItem, req.Description)
- if err != nil {
- log.RecordError(l.ctx, err)
- return nil, apierr.New(500, "查询配置列表失败")
- }
- configs := make([]types.Config, len(rows))
- for i := range rows {
- configs[i] = toConfig(&rows[i])
- }
- return &types.ConfigListResp{
- Total: total,
- Configs: configs,
- }, nil
- }
- // toConfig 模型行转响应体,字段名 descritpion 沿袭 sdf 契约。
- func toConfig(row *model.TConfig) types.Config {
- return types.Config{
- Id: row.Id,
- ConfigItem: row.ConfigItem,
- ConfigValue: row.ConfigValue,
- EditFlag: row.EditFlag,
- Description: row.Description.String,
- UpdatedBy: row.UpdatedBy,
- UpdatedAt: formatConfigTime(row.UpdatedAt),
- }
- }
|