Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gmalpha_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
gmalpha_flutter
Commits
9d52fc12
Commit
9d52fc12
authored
Oct 09, 2019
by
何碧荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f9e8e9f5
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
475 additions
and
381 deletions
+475
-381
build.gradle
.android/app/build.gradle
+3
-3
local.properties
.android/local.properties
+4
-0
DioUtil.dart
lib/commonModel/net/DioUtil.dart
+2
-2
main.dart
lib/main.dart
+2
-1
QuestionRouter.dart
lib/questionModel/QuestionRouter.dart
+5
-1
QuestionRouterImpl.dart
lib/questionModel/QuestionRouterImpl.dart
+10
-4
QuestionPage.dart
lib/questionModel/page/QuestionPage.dart
+0
-87
QuestionPageModel.dart
lib/questionModel/page/QuestionPageModel.dart
+0
-46
QuestionPage.dart
lib/questionModel/page/questionPage/QuestionPage.dart
+146
-0
QuestionPageModel.dart
lib/questionModel/page/questionPage/QuestionPageModel.dart
+65
-0
QuestionRepository.dart
lib/questionModel/service/QuestionRepository.dart
+15
-36
QuestionLocal.dart
lib/questionModel/service/local/QuestionLocal.dart
+15
-20
QuestionRemote.dart
lib/questionModel/service/remote/QuestionRemote.dart
+18
-23
QuestionApi.dart
lib/questionModel/service/remote/api/QuestionApi.dart
+2
-8
QuestionApi.serv.dart
lib/questionModel/service/remote/api/QuestionApi.serv.dart
+4
-3
QuestionEntity.dart
lib/questionModel/service/remote/entity/QuestionEntity.dart
+184
-147
No files found.
.android/app/build.gradle
View file @
9d52fc12
...
@@ -35,9 +35,9 @@ buildDir = new File(rootProject.projectDir, "../build/host")
...
@@ -35,9 +35,9 @@ buildDir = new File(rootProject.projectDir, "../build/host")
dependencies
{
dependencies
{
implementation
project
(
':flutter'
)
implementation
project
(
':flutter'
)
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.android.support:appcompat-v7:2
7.1.1
'
implementation
'com.android.support:appcompat-v7:2
8.0.0
'
implementation
'com.android.support.constraint:constraint-layout:1.1.
2
'
implementation
'com.android.support.constraint:constraint-layout:1.1.
3
'
implementation
'com.android.support:design:2
7.1.1
'
implementation
'com.android.support:design:2
8.0.0
'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
...
...
.android/local.properties
View file @
9d52fc12
sdk.dir
=
/Users/apple/Library/Android/sdk
sdk.dir
=
/Users/apple/Library/Android/sdk
flutter.sdk
=
/Users/apple/Applications/flutter
flutter.sdk
=
/Users/apple/Applications/flutter
flutter.buildMode
=
debug
flutter.versionName
=
1.0.0
flutter.versionCode
=
1
\ No newline at end of file
lib/commonModel/net/DioUtil.dart
View file @
9d52fc12
...
@@ -555,9 +555,9 @@ class DioUtil {
...
@@ -555,9 +555,9 @@ class DioUtil {
// options.contentType = ContentType.parse('application/x-www-form-urlencoded');
// options.contentType = ContentType.parse('application/x-www-form-urlencoded');
options
.
contentType
=
ContentType
.
json
;
options
.
contentType
=
ContentType
.
json
;
options
.
responseType
=
ResponseType
.
plain
;
options
.
responseType
=
ResponseType
.
plain
;
//
options.baseUrl = 'https://earth.iyanzhi.com/';
options
.
baseUrl
=
'https://earth.iyanzhi.com/'
;
// options.baseUrl = 'http://earth.gmapp.env/';
// options.baseUrl = 'http://earth.gmapp.env/';
options
.
baseUrl
=
"https://www.wanandroid.com/"
;
//
options.baseUrl = "https://www.wanandroid.com/";
Map
<
String
,
dynamic
>
headers
=
Map
<
String
,
dynamic
>();
Map
<
String
,
dynamic
>
headers
=
Map
<
String
,
dynamic
>();
headers
[
'Accept'
]
=
'application/json'
;
headers
[
'Accept'
]
=
'application/json'
;
headers
[
'version'
]
=
'1.0.0'
;
headers
[
'version'
]
=
'1.0.0'
;
...
...
lib/main.dart
View file @
9d52fc12
...
@@ -68,7 +68,8 @@ class _MyAppState extends State<MyApp> {
...
@@ -68,7 +68,8 @@ class _MyAppState extends State<MyApp> {
if
(
findQuestionRouter
==
null
)
{
if
(
findQuestionRouter
==
null
)
{
return
null
;
return
null
;
}
}
return
findQuestionRouter
.
getQuestionPage
();
findQuestionRouter
.
getAskPage
(
"1"
);
return
findQuestionRouter
.
getQuestionPage
(
"1"
);
// var findUserRouter = RouterCenterImpl().findUserRouter();
// var findUserRouter = RouterCenterImpl().findUserRouter();
// if(findUserRouter==null){
// if(findUserRouter==null){
// return null;
// return null;
...
...
lib/questionModel/QuestionRouter.dart
View file @
9d52fc12
...
@@ -11,5 +11,8 @@ import 'package:gmalpha_flutter/questionModel/QuestionRouterImpl.dart';
...
@@ -11,5 +11,8 @@ import 'package:gmalpha_flutter/questionModel/QuestionRouterImpl.dart';
@Router
(
"questionModel"
,
QuestionRouterImpl
)
@Router
(
"questionModel"
,
QuestionRouterImpl
)
abstract
class
QuestionRouter
implements
RouterBaser
{
abstract
class
QuestionRouter
implements
RouterBaser
{
Widget
getQuestionPage
();
Widget
getQuestionPage
(
String
id
);
Widget
getAskPage
(
String
id
);
}
}
\ No newline at end of file
lib/questionModel/QuestionRouterImpl.dart
View file @
9d52fc12
...
@@ -2,13 +2,19 @@
...
@@ -2,13 +2,19 @@
* @author lsy
* @author lsy
* @date 2019-09-03
* @date 2019-09-03
**/
**/
import
'package:flutter/
src/widgets/framework
.dart'
;
import
'package:flutter/
widgets
.dart'
;
import
'package:gmalpha_flutter/questionModel/QuestionRouter.dart'
;
import
'package:gmalpha_flutter/questionModel/QuestionRouter.dart'
;
import
'package:gmalpha_flutter/questionModel/page/question/QuestionPage.dart'
;
import
'package:gmalpha_flutter/questionModel/page/question
Page
/QuestionPage.dart'
;
class
QuestionRouterImpl
implements
QuestionRouter
{
class
QuestionRouterImpl
implements
QuestionRouter
{
@override
@override
Widget
getQuestionPage
()
{
Widget
getQuestionPage
(
String
id
)
{
return
QuestionWidget
();
return
QuestionPage
(
id
);
}
@override
Widget
getAskPage
(
String
id
)
{
return
null
;
}
}
}
}
lib/questionModel/page/QuestionPage.dart
deleted
100644 → 0
View file @
f9e8e9f5
/*
* @author hbr
* @date 2019-09-18
**/
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/questionModel/page/QuestionPageModel.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
class
QuestionPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
=>
QuestionState
();
}
class
QuestionState
extends
State
<
QuestionPage
>
{
QuestionPageModel
_model
;
@override
void
initState
()
{
super
.
initState
();
_model
=
new
QuestionPageModel
();
}
@override
void
dispose
()
{
super
.
dispose
();
_model
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"User"
,
style:
TextStyle
(
fontSize:
16
),
),
centerTitle:
true
,
),
body:
Column
(
children:
<
Widget
>[
Container
(
margin:
EdgeInsets
.
fromLTRB
(
16
,
10
,
16
,
20
),
child:
TextField
(
cursorColor:
Colors
.
black
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
all
(
10.0
),
icon:
Icon
(
Icons
.
text_fields
,
color:
Colors
.
black
),
labelText:
'name1'
,
labelStyle:
TextStyle
(
color:
Colors
.
black
)),
autofocus:
false
,
),
),
Container
(
margin:
EdgeInsets
.
fromLTRB
(
16
,
0
,
16
,
20
),
child:
TextField
(
cursorColor:
Colors
.
black
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
all
(
10.0
),
icon:
Icon
(
Icons
.
text_fields
,
color:
Colors
.
black
,
),
labelText:
'word2'
,
labelStyle:
TextStyle
(
color:
Colors
.
black
)),
autofocus:
false
,
),
),
Container
(
width:
double
.
maxFinite
,
margin:
EdgeInsets
.
fromLTRB
(
16
,
0
,
16
,
0
),
child:
OutlineButton
(
onPressed:
()
=>
_model
.
logout
(
context
),
child:
Text
(
"退出"
),
shape:
BeveledRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
3
),
),
)),
],
),
);
}
}
lib/questionModel/page/QuestionPageModel.dart
deleted
100644 → 0
View file @
f9e8e9f5
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/commonModel/live/BaseModel.dart'
;
import
'package:gmalpha_flutter/commonModel/live/LiveData.dart'
;
import
'package:gmalpha_flutter/commonModel/toast/toast.dart'
;
import
'package:gmalpha_flutter/questionModel/service/QuestionRepository.dart'
;
import
'package:gmalpha_flutter/QuestionModel/service/remote/entity/QuestionEntity.dart'
;
class
QuestionPageModel
extends
BaseModel
{
LiveData
<
QuestionEntity
>
resignLive
=
new
LiveData
();
// LiveData<String> userTokenLive = new LiveData();
QuestionPageModel
()
{}
void
logout
(
BuildContext
context
)
{
QuestionRepository
.
getInstance
().
logout
().
listen
((
data
)
{
logoutLive
.
notifyView
(
data
);
}).
onError
((
error
)
{
Toast
.
show
(
context
,
"error
${error}
"
);
print
(
error
);
});
}
void
resignUser
(
BuildContext
context
,
String
name
,
String
word
)
{
QuestionRepository
.
getInstance
().
resignUser
(
name
,
word
,
word
).
listen
((
data
)
{
print
(
"data !! :
${data}
"
);
resignLive
.
notifyView
(
data
);
}).
onError
((
error
)
{
Toast
.
show
(
context
,
"error :
${error}
"
);
print
(
error
);
});
}
@override
void
dispose
()
{
logoutLive
.
dispost
();
resignLive
.
dispost
();
}
}
lib/questionModel/page/questionPage/QuestionPage.dart
0 → 100644
View file @
9d52fc12
//
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/questionModel/page/questionPage/QuestionPageModel.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
///*
// * @author hbr
// * @date 2019-09-18
// **/
//
class
QuestionPage
extends
StatefulWidget
{
QuestionPageModel
_model
;
QuestionPage
(
String
id
){
_model
=
QuestionPageModel
(
id
);
}
@override
State
<
StatefulWidget
>
createState
()
{
// TODO: implement createState
return
QuestionPageState
(
_model
);
}
}
class
QuestionPageState
extends
State
<
QuestionPage
>{
QuestionPageModel
_model
;
QuestionPageState
(
this
.
_model
);
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Container
(
child:
StreamBuilder
<
QuestionEntity
>(
stream:
_model
.
live
.
stream
,
initialData:
_model
.
live
.
data
,
builder:
(
content
,
data
){
print
(
data
.
data
);
return
Container
(
child:
Text
(
"
${data.data}
"
),
);
}),
),
);
}
@override
void
initState
()
{
super
.
initState
();
_model
.
init
(
context
);
}
@override
void
dispose
()
{
super
.
dispose
();
_model
.
dispose
();
}
}
//import 'package:flutter/material.dart';
//import 'package:gmalpha_flutter/questionModel/page/questionPage/QuestionPageModel.dart';
//
//class QuestionPage extends StatefulWidget {
// QuestionPageModel _model;
//
// QuestionPage(String id){
// _model=QuestionPageModel(id);
// }
//
// _QuestionPageState createState() => _QuestionPageState(_model);
//}
//
//class _QuestionPageState extends State<QuestionPage> {
// QuestionPageModel _model;
//
// _QuestionPageState(this._model);
//
// @override
// void initState() {
// super.initState();
// _model.init(context);
// }
//
// @override
// void dispose() {
// super.dispose();
// _model.dispose();
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: Text(
// "User",
// style: TextStyle(fontSize: 16),
// ),
// centerTitle: true,
// ),
// body: Column(
// children: <Widget>[
//
// Container(
// margin: EdgeInsets.fromLTRB(16, 10, 16, 20),
// child: TextField(
// cursorColor: Colors.black,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.all(10.0),
// icon: Icon(Icons.text_fields, color: Colors.black),
// labelText: 'name1',
// labelStyle: TextStyle(color: Colors.black)),
// autofocus: false,
// ),
// ),
// Container(
// margin: EdgeInsets.fromLTRB(16, 0, 16, 20),
// child: TextField(
// cursorColor: Colors.black,
// decoration: InputDecoration(
// contentPadding: EdgeInsets.all(10.0),
// icon: Icon(
// Icons.text_fields,
// color: Colors.black,
// ),
// labelText: 'word2',
// labelStyle: TextStyle(color: Colors.black)),
// autofocus: false,
// ),
// ),
//
// Container(
// width: double.maxFinite,
// margin: EdgeInsets.fromLTRB(16, 0, 16, 0),
// child: OutlineButton(
// onPressed: () => {},
// child: Text("退出"),
// shape: BeveledRectangleBorder(
// borderRadius: BorderRadius.circular(3),
// ),
// )),
//
// ],
// ),
// );
// }
//}
lib/questionModel/page/questionPage/QuestionPageModel.dart
0 → 100644
View file @
9d52fc12
import
'package:flutter/src/widgets/framework.dart'
;
import
'package:gmalpha_flutter/commonModel/live/BaseModel.dart'
;
import
'package:gmalpha_flutter/commonModel/live/LiveData.dart'
;
import
'package:gmalpha_flutter/questionModel/service/QuestionRepository.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
///*
// * @author lsy
// * @date 2019-09-04
// **/
//
//import 'package:flutter/material.dart';
//import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
//import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
//import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
//import 'package:gmalpha_flutter/questionModel/service/QuestionRepository.dart';
//import 'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart';
//
class
QuestionPageModel
extends
BaseModel
{
LiveData
<
QuestionEntity
>
live
=
LiveData
();
final
String
id
;
QuestionPageModel
(
this
.
id
);
@override
void
dispose
()
{
live
.
dispost
();
}
void
init
(
BuildContext
context
)
{
QuestionRepository
.
getInstance
().
getQuestion
(
id
).
listen
((
value
)
{
live
.
notifyView
(
value
);
}).
onError
((
error
)
{
print
(
error
);
});
}
}
//
//class QuestionPageModel extends BaseModel {
// LiveData<QuestionEntity> questionLive = new LiveData();
//
// final String id;
// QuestionPageModel(this.id);
//
// init(BuildContext context) {
// QuestionRepository.getInstance()
// .getQuestion(id)
// .listen((value) {
// if (value != null) {
// questionLive.notifyView(value);
// }
// }).onError((error) {
// Toast.show(context, "${error.toString()}");
// print(error);
// });
// }
//
//
// @override
// void dispose() {
// questionLive.dispost();
// }
//}
lib/questionModel/service/QuestionRepository.dart
View file @
9d52fc12
/*
import
'package:gmalpha_flutter/questionModel/service/local/QuestionLocal.dart'
;
* @author lsy
import
'package:gmalpha_flutter/questionModel/service/remote/QuestionRemote.dart'
;
* @date 2019-09-04
import
'package:gmalpha_flutter/questionModel/service/remote/api/QuestionApi.serv.dart'
;
**/
import
'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'
;
import
'package:gmalpha_flutter/userModel/service/local/UserLocal.dart'
;
import
'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/TestQuestionEntity.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
import
'package:rxdart/rxdart.dart'
;
class
QuestionRepository
{
class
QuestionRepository
{
UserRemote
_remote
;
static
QuestionRepository
_instance
;
UserLocal
_local
;
static
QuestionRepository
_questionRepository
;
QuestionRemote
_remote
;
QuestionLocal
_local
;
QuestionRepository
.
_
()
{
QuestionRepository
.
_
()
{
_remote
=
User
Remote
.
getInstance
();
_remote
=
Question
Remote
.
getInstance
();
_local
=
User
Local
.
getInstance
();
_local
=
Question
Local
.
getInstance
();
}
}
static
QuestionRepository
getInstance
()
{
static
QuestionRepository
getInstance
()
{
if
(
_
questionRepository
==
null
)
{
if
(
_
instance
==
null
)
{
_
questionRepository
=
QuestionRepository
.
_
();
_
instance
=
QuestionRepository
.
_
();
}
}
return
_
questionRepository
;
return
_
instance
;
}
}
Observable
<
QuestionEntity
>
getUserInfo
(
String
token
)
{
Map
<
int
,
List
<
String
>>
restore
={};
_remote
.
getUserInfo
(
token
).
map
((
value
)
{
if
(
value
!=
null
)
{
_local
.
saveUserInfo
(
value
);
}
return
value
;
});
}
Observable
<
TestQuestionEntity
>
resignUser
(
Observable
<
QuestionEntity
>
getQuestion
(
String
id
)
{
String
name
,
String
word
,
String
reword
)
{
return
_remote
.
getQuestion
(
id
).
map
((
value
)
{
return
_remote
.
resignUser
(
name
,
word
,
reword
).
map
((
value
)
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
_local
.
saveUser
(
value
);
_local
.
saveQuestionResult
(
value
);
}
return
value
;
});
}
Observable
<
SimpleResponce
>
logout
()
{
return
_remote
.
logout
().
map
((
value
)
{
if
(
value
!=
null
)
{
_local
.
logout
();
}
}
return
value
;
return
value
;
});
});
...
...
lib/questionModel/service/local/QuestionLocal.dart
View file @
9d52fc12
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:gmalpha_flutter/questionModel/service/remote/entity/TestQuestionEntity.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
class
UserLocal
{
class
QuestionLocal
{
static
UserLocal
_userRemote
;
UserLocal
.
_
()
{}
static
QuestionLocal
_instance
;
static
UserLocal
getInstance
()
{
QuestionLocal
.
_
(){
if
(
_userRemote
==
null
)
{
_userRemote
=
new
UserLocal
.
_
();
}
return
_userRemote
;
}
void
saveUserInfo
(
QuestionEntity
value
)
{
//TODO
}
}
void
saveUser
(
TestQuestionEntity
value
)
{
static
QuestionLocal
getInstance
(){
//TODO
if
(
_instance
==
null
){
_instance
=
QuestionLocal
.
_
();
}
return
_instance
;
}
}
void
logout
()
{
//TODO
void
saveQuestionResult
(
QuestionEntity
entity
){
}
}
}
}
\ No newline at end of file
lib/questionModel/service/remote/QuestionRemote.dart
View file @
9d52fc12
/*
import
'package:gmalpha_flutter/questionModel/service/remote/api/QuestionApi.serv.dart'
;
* @author lsy
* @date 2019-09-04
**/
import
'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart'
;
import
'package:gmalpha_flutter/userModel/service/remote/api/UserLoginApi.serv.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/TestQuestionEntity.dart'
;
import
'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
import
'package:rxdart/rxdart.dart'
;
import
'entity/QuestionEntity.dart'
;
class
QuestionRemote
{
class
QuestionRemote
{
static
QuestionRemote
_userRemote
;
QuestionRemote
.
_
()
{}
static
QuestionRemote
_instance
;
static
QuestionRemote
getInstance
()
{
if
(
_userRemote
==
null
)
{
_userRemote
=
new
QuestionRemote
.
_
();
}
return
_userRemote
;
}
Observable
<
QuestionEntity
>
getUserInfo
(
String
token
)
{
QuestionRemote
.
_
()
{
// return UserLoginApiImpl().getUserInfo(token);
}
}
Observable
<
TestQuestionEntity
>
resignUser
(
static
QuestionRemote
getInstance
(){
String
name
,
String
word
,
String
reWord
)
{
if
(
_instance
==
null
){
// return UserLoginApiImpl().resign(name, word, reWord);
_instance
=
new
QuestionRemote
.
_
();
}
return
_instance
;
}
}
Observable
<
SimpleResponce
>
logout
()
{
Observable
<
QuestionEntity
>
getQuestion
(
String
id
){
return
UserLoginApiImpl
().
logout
();
return
QuestionApiImpl
().
getQuestion
(
int
.
parse
(
id
));
}
}
}
}
\ No newline at end of file
lib/questionModel/service/remote/api/QuestionApi.dart
View file @
9d52fc12
/*
* @author lsy
* @date 2019-09-04
**/
import
'package:gmalpha_flutter/Annotations/anno/Get.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Get.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Query.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Query.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'
;
...
@@ -9,8 +5,6 @@ import 'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEnti
...
@@ -9,8 +5,6 @@ import 'package:gmalpha_flutter/questionModel/service/remote/entity/QuestionEnti
@ServiceCenter
()
@ServiceCenter
()
abstract
class
QuestionApi
{
abstract
class
QuestionApi
{
@Get
(
'api/v1/survey_question/get'
)
@Get
(
"api/v1/survey_question/get"
)
QuestionEntity
getQuestion
(
@Query
(
"id"
)
int
id
);
QuestionEntity
getUserInfo
(
@Query
(
"templateId"
)
String
templateId
);
}
}
lib/questionModel/service/remote/api/QuestionApi.serv.dart
View file @
9d52fc12
...
@@ -28,9 +28,10 @@ class QuestionApiImpl {
...
@@ -28,9 +28,10 @@ class QuestionApiImpl {
return
_instance
;
return
_instance
;
}
}
Observable
<
QuestionEntity
>
getUserInfo
(
String
templateId
)
{
Observable
<
QuestionEntity
>
getQuestion
(
int
id
)
{
return
Observable
.
fromFuture
(
DioUtil
().
get
(
'api/v1/survey_question/get'
,
return
Observable
.
fromFuture
(
data:
{
'templateId'
:
templateId
})).
map
((
value
)
{
DioUtil
().
get
(
'api/v1/survey_question/get'
,
data:
{
'id'
:
id
}))
.
map
((
value
)
{
if
(
value
.
statusCode
==
200
)
{
if
(
value
.
statusCode
==
200
)
{
Map
map
=
json
.
decode
(
value
.
toString
());
Map
map
=
json
.
decode
(
value
.
toString
());
return
QuestionEntity
.
fromJson
(
map
);
return
QuestionEntity
.
fromJson
(
map
);
...
...
lib/questionModel/service/remote/entity/QuestionEntity.dart
View file @
9d52fc12
import
'package:gmalpha_flutter/Annotations/anno/User.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/UserCenter.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
const
String
USER_ID
=
"user_uid"
;
const
String
NICKNAME
=
"username"
;
const
String
PORTRAIT
=
"potrait"
;
const
String
GENDER
=
"gender"
;
const
String
PERSONAL_QA
=
"personal_qa"
;
const
String
HAS_SCAN_FACE
=
"has_scan_face"
;
const
String
CURRENT_CITY_ID
=
"current_city_id"
;
const
String
QUESTION_URL
=
"question_url"
;
const
String
DETAIL_SETTED
=
"detail_setted"
;
const
String
BIRTHDAY
=
"birthday"
;
const
String
COUNTRY_ID
=
"country_id"
;
const
String
USER_BIND_MOBILE
=
"user_bind_mobile"
;
const
String
COUNTRY_LANGUAGE
=
"country_language"
;
const
String
COUNTRY_NAME
=
"country_name"
;
@UserCenter
()
class
QuestionEntity
{
class
QuestionEntity
{
/**
int
error
;
* 用户id
String
message
;
*/
Null
extra
;
@User
(
USER_ID
,
""
)
Data
data
;
String
userId
;
/**
QuestionEntity
({
this
.
error
,
this
.
message
,
this
.
extra
,
this
.
data
});
* 用户昵称
*/
@User
(
NICKNAME
,
""
)
String
nickName
;
/**
* 用户头像
*/
@User
(
PORTRAIT
,
""
)
String
profilePic
;
/**
* 是否需要答题
*/
@User
(
PERSONAL_QA
,
true
)
bool
hasAnswered
=
true
;
/**
* 是否扫过脸
*/
@User
(
HAS_SCAN_FACE
,
true
)
bool
hasScanFace
=
false
;
String
id
;
@User
(
GENDER
,
""
)
String
gender
;
@User
(
CURRENT_CITY_ID
,
""
)
String
cityId
;
@User
(
BIRTHDAY
,
0
)
int
birth
;
@User
(
COUNTRY_ID
,
""
)
String
countryId
;
bool
logined
;
// 用户是否设置过个人信息
@User
(
DETAIL_SETTED
,
true
)
bool
detailSetted
=
true
;
//用户是否选择了标签
bool
tagSetted
=
false
;
//注册流程中断后返回之前的登录页面
@User
(
QUESTION_URL
,
""
)
String
questionUrl
;
@User
(
USER_BIND_MOBILE
,
true
)
bool
isBind
;
@User
(
COUNTRY_NAME
,
""
)
String
countryInfoName
;
@User
(
COUNTRY_ID
,
""
)
String
countryInfoId
;
@User
(
COUNTRY_LANGUAGE
,
""
)
String
countryInfoLanguage
;
String
insBindId
;
String
registerTime
;
QuestionEntity
(
{
this
.
userId
,
this
.
nickName
,
this
.
profilePic
,
this
.
hasAnswered
,
this
.
hasScanFace
,
this
.
id
,
this
.
gender
,
this
.
cityId
,
this
.
birth
,
this
.
countryId
,
this
.
logined
,
this
.
detailSetted
,
this
.
tagSetted
,
this
.
questionUrl
,
this
.
isBind
,
this
.
countryInfoName
,
this
.
countryInfoId
,
this
.
countryInfoLanguage
,
this
.
insBindId
,
this
.
registerTime
});
QuestionEntity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
QuestionEntity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
userId
=
json
[
'user_id'
];
error
=
json
[
'error'
];
nickName
=
json
[
'nick_name'
];
message
=
json
[
'message'
];
profilePic
=
json
[
'profile_pic'
];
extra
=
json
[
'extra'
];
hasAnswered
=
json
[
'has_answered'
];
data
=
json
[
'data'
]
!=
null
?
new
Data
.
fromJson
(
json
[
'data'
])
:
null
;
hasScanFace
=
json
[
'has_scan_face'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
data
[
'extra'
]
=
this
.
extra
;
if
(
this
.
data
!=
null
)
{
data
[
'data'
]
=
this
.
data
.
toJson
();
}
return
data
;
}
}
class
Data
{
int
id
;
String
name
;
List
<
Questions
>
questions
;
Data
({
this
.
id
,
this
.
name
,
this
.
questions
});
Data
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
if
(
json
[
'questions'
]
!=
null
)
{
questions
=
new
List
<
Questions
>();
json
[
'questions'
].
forEach
((
v
)
{
questions
.
add
(
new
Questions
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
if
(
this
.
questions
!=
null
)
{
data
[
'questions'
]
=
this
.
questions
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
Questions
{
int
id
;
String
content
;
String
image
;
String
questionType
;
int
relatedId1
;
List
<
Answers
>
answers
;
Questions
(
{
this
.
id
,
this
.
content
,
this
.
image
,
this
.
questionType
,
this
.
relatedId1
,
this
.
answers
});
Questions
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
content
=
json
[
'content'
];
image
=
json
[
'image'
];
questionType
=
json
[
'question_type'
];
relatedId1
=
json
[
'related_id_1'
];
if
(
json
[
'answers'
]
!=
null
)
{
answers
=
new
List
<
Answers
>();
json
[
'answers'
].
forEach
((
v
)
{
answers
.
add
(
new
Answers
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'content'
]
=
this
.
content
;
data
[
'image'
]
=
this
.
image
;
data
[
'question_type'
]
=
this
.
questionType
;
data
[
'related_id_1'
]
=
this
.
relatedId1
;
if
(
this
.
answers
!=
null
)
{
data
[
'answers'
]
=
this
.
answers
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
Answers
{
int
id
;
String
content
;
String
image
;
List
<
HotTags
>
hotTags
;
List
<
ExpertTags
>
expertTags
;
int
experience
;
int
relatedId1
;
int
relatedId2
;
Answers
(
{
this
.
id
,
this
.
content
,
this
.
image
,
this
.
hotTags
,
this
.
expertTags
,
this
.
experience
,
this
.
relatedId1
,
this
.
relatedId2
});
Answers
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
content
=
json
[
'content'
];
image
=
json
[
'image'
];
if
(
json
[
'hot_tags'
]
!=
null
)
{
hotTags
=
new
List
<
HotTags
>();
json
[
'hot_tags'
].
forEach
((
v
)
{
hotTags
.
add
(
new
HotTags
.
fromJson
(
v
));
});
}
if
(
json
[
'expert_tags'
]
!=
null
)
{
expertTags
=
new
List
<
ExpertTags
>();
json
[
'expert_tags'
].
forEach
((
v
)
{
expertTags
.
add
(
new
ExpertTags
.
fromJson
(
v
));
});
}
experience
=
json
[
'experience'
];
relatedId1
=
json
[
'related_id_1'
];
relatedId2
=
json
[
'related_id_2'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'content'
]
=
this
.
content
;
data
[
'image'
]
=
this
.
image
;
if
(
this
.
hotTags
!=
null
)
{
data
[
'hot_tags'
]
=
this
.
hotTags
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
if
(
this
.
expertTags
!=
null
)
{
data
[
'expert_tags'
]
=
this
.
expertTags
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
data
[
'experience'
]
=
this
.
experience
;
data
[
'related_id_1'
]
=
this
.
relatedId1
;
data
[
'related_id_2'
]
=
this
.
relatedId2
;
return
data
;
}
}
class
HotTags
{
int
id
;
String
name
;
HotTags
({
this
.
id
,
this
.
name
});
HotTags
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
id
=
json
[
'id'
];
gender
=
json
[
'gender'
];
name
=
json
[
'name'
];
cityId
=
json
[
'city_id'
];
birth
=
json
[
'birth'
];
countryId
=
json
[
'country_id'
];
logined
=
json
[
'logined'
];
detailSetted
=
json
[
'detail_setted'
];
tagSetted
=
json
[
'tag_setted'
];
questionUrl
=
json
[
'question_url'
];
isBind
=
json
[
'is_bind'
];
countryInfoName
=
json
[
'country_info_name'
];
countryInfoId
=
json
[
'country_info_id'
];
countryInfoLanguage
=
json
[
'country_info_language'
];
insBindId
=
json
[
'ins_bind_id'
];
registerTime
=
json
[
'register_time'
];
}
}
Map
<
String
,
dynamic
>
toJson
()
{
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'user_id'
]
=
this
.
userId
;
data
[
'nick_name'
]
=
this
.
nickName
;
data
[
'profile_pic'
]
=
this
.
profilePic
;
data
[
'has_answered'
]
=
this
.
hasAnswered
;
data
[
'has_scan_face'
]
=
this
.
hasScanFace
;
data
[
'id'
]
=
this
.
id
;
data
[
'id'
]
=
this
.
id
;
data
[
'gender'
]
=
this
.
gender
;
data
[
'name'
]
=
this
.
name
;
data
[
'city_id'
]
=
this
.
cityId
;
data
[
'birth'
]
=
this
.
birth
;
data
[
'country_id'
]
=
this
.
countryId
;
data
[
'logined'
]
=
this
.
logined
;
data
[
'detail_setted'
]
=
this
.
detailSetted
;
data
[
'tag_setted'
]
=
this
.
tagSetted
;
data
[
'question_url'
]
=
this
.
questionUrl
;
data
[
'is_bind'
]
=
this
.
isBind
;
data
[
'country_info_name'
]
=
this
.
countryInfoName
;
data
[
'country_info_id'
]
=
this
.
countryInfoId
;
data
[
'country_info_language'
]
=
this
.
countryInfoLanguage
;
data
[
'ins_bind_id'
]
=
this
.
insBindId
;
data
[
'register_time'
]
=
this
.
registerTime
;
return
data
;
return
data
;
}
}
}
class
ExpertTags
{
int
id
;
String
name
;
ExpertTags
({
this
.
id
,
this
.
name
});
ExpertTags
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
name
=
json
[
'name'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'name'
]
=
this
.
name
;
return
data
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment