mysql 跑通
This commit is contained in:
		
							parent
							
								
									340c7966e0
								
							
						
					
					
						commit
						e1e0e5ef21
					
				@ -1,3 +1,4 @@
 | 
			
		||||
Name: home-user-auth
 | 
			
		||||
Host: 0.0.0.0
 | 
			
		||||
Port: 8888
 | 
			
		||||
DataSource: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
 | 
			
		||||
 | 
			
		||||
@ -4,4 +4,5 @@ import "github.com/zeromicro/go-zero/rest"
 | 
			
		||||
 | 
			
		||||
type Config struct {
 | 
			
		||||
	rest.RestConf
 | 
			
		||||
	DataSource string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,15 @@ func NewUserFontsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFon
 | 
			
		||||
 | 
			
		||||
func (l *UserFontsLogic) UserFonts(req *types.Request) (resp *types.Response, err error) {
 | 
			
		||||
	// todo: add your logic here and delete this line
 | 
			
		||||
 | 
			
		||||
	f, err := l.svcCtx.FsFontModel.FindOne(context.TODO(), 10)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		// panic(err)
 | 
			
		||||
		logx.Error(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	logx.Info(f)
 | 
			
		||||
	resp = &types.Response{
 | 
			
		||||
		Data: f,
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -15,6 +15,6 @@ type ServiceContext struct {
 | 
			
		||||
func NewServiceContext(c config.Config) *ServiceContext {
 | 
			
		||||
	return &ServiceContext{
 | 
			
		||||
		Config:      c,
 | 
			
		||||
		FsFontModel: model.NewFsFontModel(sqlx.NewMysql("")),
 | 
			
		||||
		FsFontModel: model.NewFsFontModel(sqlx.NewMysql(c.DataSource)),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user