30 lines
847 B
Go
30 lines
847 B
Go
// 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"
|
|
)
|
|
|
|
type CreateDictLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCreateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictLogic {
|
|
return &CreateDictLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
|
}
|
|
|
|
func (l *CreateDictLogic) CreateDict(req *types.DictReq) error {
|
|
dict := sysModel.SundynixDict{Type: req.Type, Label: req.Label, Value: req.Value, Sort: req.Sort, Desc: req.Desc}
|
|
if err := l.svcCtx.DB.Create(&dict).Error; err != nil {
|
|
return fmt.Errorf("创建字典失败")
|
|
}
|
|
return nil
|
|
}
|