12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package dictionary
- import (
- "context"
- "github.com/suyuan32/simple-admin-core/api/internal/svc"
- "github.com/suyuan32/simple-admin-core/api/internal/types"
- "github.com/suyuan32/simple-admin-core/rpc/types/core"
- "github.com/zeromicro/go-zero/core/logx"
- "github.com/suyuan32/simple-admin-common/i18n"
- )
- type GetDictionaryByIdLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewGetDictionaryByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDictionaryByIdLogic {
- return &GetDictionaryByIdLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *GetDictionaryByIdLogic) GetDictionaryById(req *types.IDReq) (resp *types.DictionaryInfoResp, err error) {
- data, err := l.svcCtx.CoreRpc.GetDictionaryById(l.ctx, &core.IDReq{Id: req.Id})
- if err != nil {
- return nil, err
- }
- return &types.DictionaryInfoResp{
- BaseDataInfo: types.BaseDataInfo{
- Code: 0,
- Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
- },
- Data: types.DictionaryInfo{
- BaseIDInfo: types.BaseIDInfo{
- Id: data.Id,
- CreatedAt: data.CreatedAt,
- UpdatedAt: data.UpdatedAt,
- },
- Title: data.Title,
- Name: data.Name,
- Status: data.Status,
- Desc: data.Desc,
- },
- }, nil
- }
|