init: 1.0.0
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/perfect-panel/ppanel-server/initialize"
|
||||
"github.com/perfect-panel/ppanel-server/internal/svc"
|
||||
"github.com/perfect-panel/ppanel-server/internal/types"
|
||||
"github.com/perfect-panel/ppanel-server/pkg/logger"
|
||||
"github.com/perfect-panel/ppanel-server/pkg/tool"
|
||||
"github.com/perfect-panel/ppanel-server/pkg/xerr"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type GetVerifyConfigLogic struct {
|
||||
logger.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetVerifyConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVerifyConfigLogic {
|
||||
return &GetVerifyConfigLogic{
|
||||
Logger: logger.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetVerifyConfigLogic) GetVerifyConfig() (*types.VerifyConfig, error) {
|
||||
resp := &types.VerifyConfig{}
|
||||
// get verify config from db
|
||||
verifyConfigs, err := l.svcCtx.SystemModel.GetVerifyConfig(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get verify config failed: %v", err.Error())
|
||||
}
|
||||
// reflect to response
|
||||
tool.SystemConfigSliceReflectToStruct(verifyConfigs, resp)
|
||||
// update verify config to system
|
||||
initialize.Verify(l.svcCtx)
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user