添加AllModels

This commit is contained in:
eson
2023-06-21 11:29:09 +08:00
parent edeb2bb5f1
commit 389f12b8c5
8 changed files with 143 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ import (
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type UserSaveBasicInfoLogic struct {
@@ -51,7 +52,7 @@ func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoFo
if err != nil {
logx.Error(err)
switch err {
case gmodel.ErrRecordNotFound:
case gorm.ErrRecordNotFound:
return resp.SetStatus(basic.CodeUserIdNotFoundErr)
default:
return resp.SetStatusWithMessage(basic.CodeDbUpdateErr, err.Error())

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"fusenapi/initalize"
"fusenapi/model/gmodel"
"fusenapi/server/home-user-auth/internal/config"
"net/http"
@@ -14,12 +15,14 @@ import (
type ServiceContext struct {
Config config.Config
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
MysqlConn: initalize.InitMysql(c.SourceMysql),
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
}
}