1,修复安全问题相关bug
2,新增修改安全问题的接口及逻辑
This commit is contained in:
parent
58f24b6cee
commit
06e599b990
@ -73,6 +73,7 @@ class SafetyProblemData {
|
|||||||
int? questionId;
|
int? questionId;
|
||||||
String? question;
|
String? question;
|
||||||
String? answer;
|
String? answer;
|
||||||
|
int? answerId;
|
||||||
|
|
||||||
SafetyProblemData({this.questionId, this.question});
|
SafetyProblemData({this.questionId, this.question});
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ class SafetyProblemData {
|
|||||||
questionId = json['questionId'];
|
questionId = json['questionId'];
|
||||||
question = json['question'];
|
question = json['question'];
|
||||||
answer = json['answer'];
|
answer = json['answer'];
|
||||||
|
answerId = json['answerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@ -87,6 +89,7 @@ class SafetyProblemData {
|
|||||||
data['questionId'] = questionId;
|
data['questionId'] = questionId;
|
||||||
data['question'] = question;
|
data['question'] = question;
|
||||||
data['answer'] = answer;
|
data['answer'] = answer;
|
||||||
|
data['answerId'] = answerId;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -96,18 +99,23 @@ class SafetyProblemData2 {
|
|||||||
int? questionId;
|
int? questionId;
|
||||||
String? question;
|
String? question;
|
||||||
String? answer;
|
String? answer;
|
||||||
|
int? answerId;
|
||||||
|
|
||||||
SafetyProblemData2({this.questionId, this.question});
|
SafetyProblemData2({this.questionId, this.question});
|
||||||
|
|
||||||
SafetyProblemData2.fromJson(Map<String, dynamic> json) {
|
SafetyProblemData2.fromJson(Map<String, dynamic> json) {
|
||||||
questionId = json['questionId'];
|
questionId = json['questionId'];
|
||||||
question = json['question'];
|
question = json['question'];
|
||||||
|
answer = json['answer'];
|
||||||
|
answerId = json['answerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
data['questionId'] = questionId;
|
data['questionId'] = questionId;
|
||||||
data['question'] = question;
|
data['question'] = question;
|
||||||
|
data['answer'] = answer;
|
||||||
|
data['answerId'] = answerId;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,18 +124,23 @@ class SafetyProblemData3 {
|
|||||||
int? questionId;
|
int? questionId;
|
||||||
String? question;
|
String? question;
|
||||||
String? answer;
|
String? answer;
|
||||||
|
int? answerId;
|
||||||
|
|
||||||
SafetyProblemData3({this.questionId, this.question});
|
SafetyProblemData3({this.questionId, this.question});
|
||||||
|
|
||||||
SafetyProblemData3.fromJson(Map<String, dynamic> json) {
|
SafetyProblemData3.fromJson(Map<String, dynamic> json) {
|
||||||
questionId = json['questionId'];
|
questionId = json['questionId'];
|
||||||
question = json['question'];
|
question = json['question'];
|
||||||
|
answer = json['answer'];
|
||||||
|
answerId = json['answerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
data['questionId'] = questionId;
|
data['questionId'] = questionId;
|
||||||
data['question'] = question;
|
data['question'] = question;
|
||||||
|
data['answer'] = answer;
|
||||||
|
data['answerId'] = answerId;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/appRouters.dart';
|
import 'package:star_lock/appRouters.dart';
|
||||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_state.dart';
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoSetSafetyProblem/minePersonInfoSetSafetyProblem_state.dart';
|
||||||
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/minePersonInfoViewSafetyProblem_entity.dart';
|
||||||
import 'package:star_lock/translations/trans_lib.dart';
|
import 'package:star_lock/translations/trans_lib.dart';
|
||||||
import '../../../../network/api_repository.dart';
|
import '../../../../network/api_repository.dart';
|
||||||
import '../../../../tools/baseGetXController.dart';
|
import '../../../../tools/baseGetXController.dart';
|
||||||
@ -22,6 +23,7 @@ class MineSetSafetyProblemLogic extends BaseGetXController {
|
|||||||
|
|
||||||
//设置安全信息
|
//设置安全信息
|
||||||
Future<void> setSafeAnswerRequest() async {
|
Future<void> setSafeAnswerRequest() async {
|
||||||
|
getRequestAnswerList();
|
||||||
var entity =
|
var entity =
|
||||||
await ApiRepository.to.setSafeAnswer(state.questionAndAnswerList.value);
|
await ApiRepository.to.setSafeAnswer(state.questionAndAnswerList.value);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
@ -30,6 +32,51 @@ class MineSetSafetyProblemLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//修改安全信息
|
||||||
|
Future<void> updateSafeAnswerRequest() async {
|
||||||
|
getRequestAnswerList();
|
||||||
|
var entity = await ApiRepository.to
|
||||||
|
.updateSafeAnswer(state.questionAndAnswerList.value);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
showToast("操作成功");
|
||||||
|
Get.until((route) => route.settings.name == Routers.minePersonInfoPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getRequestAnswerList() {
|
||||||
|
state.questionAndAnswerList.value.clear();
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (i == 0) {
|
||||||
|
SafetyProblemData data = SafetyProblemData();
|
||||||
|
data.question = state.firstProblemStr.value;
|
||||||
|
data.answer = state.firstAnswerStr.value;
|
||||||
|
data.questionId = state.firstQuestionId.value;
|
||||||
|
if (state.isUpdateAnswer.value) {
|
||||||
|
data.answerId = state.firstAnswerId.value;
|
||||||
|
}
|
||||||
|
state.questionAndAnswerList.value.add(data);
|
||||||
|
} else if (i == 1) {
|
||||||
|
SafetyProblemData data = SafetyProblemData();
|
||||||
|
data.question = state.secondProblemStr.value;
|
||||||
|
data.answer = state.secondAnswerStr.value;
|
||||||
|
data.questionId = state.secondQuestionId.value;
|
||||||
|
if (state.isUpdateAnswer.value) {
|
||||||
|
data.answerId = state.secondAnswerId.value;
|
||||||
|
}
|
||||||
|
state.questionAndAnswerList.value.add(data);
|
||||||
|
} else if (i == 2) {
|
||||||
|
SafetyProblemData data = SafetyProblemData();
|
||||||
|
data.question = state.thirdProblemStr.value;
|
||||||
|
data.answer = state.thirdAnswerStr.value;
|
||||||
|
data.questionId = state.thirdQuestionId.value;
|
||||||
|
if (state.isUpdateAnswer.value) {
|
||||||
|
data.answerId = state.thirdAnswerId.value;
|
||||||
|
}
|
||||||
|
state.questionAndAnswerList.value.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void checkNext(TextEditingController controller) {
|
void checkNext(TextEditingController controller) {
|
||||||
changeInput(controller);
|
changeInput(controller);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,30 +78,13 @@ class _MinePersonInfoSetSafetyProblemPageState
|
|||||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||||
isDisabled: state.canSub.value,
|
isDisabled: state.canSub.value,
|
||||||
onClick: () {
|
onClick: () {
|
||||||
state.questionAndAnswerList.value.clear();
|
if (state.isUpdateAnswer.value) {
|
||||||
for (int i = 0; i < 3; i++) {
|
//修改安全信息
|
||||||
if (i == 0) {
|
logic.updateSafeAnswerRequest();
|
||||||
SafetyProblemData data = SafetyProblemData();
|
} else {
|
||||||
data.question = state.firstProblemStr.value;
|
//设置安全信息
|
||||||
data.answer = state.firstAnswerStr.value;
|
logic.setSafeAnswerRequest();
|
||||||
data.questionId = state.firstQuestionId.value;
|
|
||||||
state.questionAndAnswerList.value.add(data);
|
|
||||||
} else if (i == 1) {
|
|
||||||
SafetyProblemData data = SafetyProblemData();
|
|
||||||
data.question = state.secondProblemStr.value;
|
|
||||||
data.answer = state.secondAnswerStr.value;
|
|
||||||
data.questionId = state.secondQuestionId.value;
|
|
||||||
state.questionAndAnswerList.value.add(data);
|
|
||||||
} else if (i == 2) {
|
|
||||||
SafetyProblemData data = SafetyProblemData();
|
|
||||||
data.question = state.thirdProblemStr.value;
|
|
||||||
data.answer = state.thirdAnswerStr.value;
|
|
||||||
data.questionId = state.thirdQuestionId.value;
|
|
||||||
state.questionAndAnswerList.value.add(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//设置安全信息接口
|
|
||||||
logic.setSafeAnswerRequest();
|
|
||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
@ -175,6 +158,7 @@ class _MinePersonInfoSetSafetyProblemPageState
|
|||||||
state.thirdProblemStr.value = getSelectProblem;
|
state.thirdProblemStr.value = getSelectProblem;
|
||||||
state.thirdQuestionId.value = data.questionId!;
|
state.thirdQuestionId.value = data.questionId!;
|
||||||
}
|
}
|
||||||
|
state.canSub.value = true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,12 +19,17 @@ class MineSetSafetyProblemState {
|
|||||||
var secondQuestionId = 0.obs;
|
var secondQuestionId = 0.obs;
|
||||||
var thirdQuestionId = 0.obs;
|
var thirdQuestionId = 0.obs;
|
||||||
|
|
||||||
|
var firstAnswerId = 0.obs;
|
||||||
|
var secondAnswerId = 0.obs;
|
||||||
|
var thirdAnswerId = 0.obs;
|
||||||
|
|
||||||
var firstAnswerStr = ''.obs;
|
var firstAnswerStr = ''.obs;
|
||||||
var secondAnswerStr = ''.obs;
|
var secondAnswerStr = ''.obs;
|
||||||
var thirdAnswerStr = ''.obs;
|
var thirdAnswerStr = ''.obs;
|
||||||
var countryCode = ''.obs;
|
var countryCode = ''.obs;
|
||||||
|
|
||||||
var questionAndAnswerList = [].obs;
|
var questionAndAnswerList = [].obs;
|
||||||
|
var isUpdateAnswer = false.obs;
|
||||||
|
|
||||||
bool get answerIsOK =>
|
bool get answerIsOK =>
|
||||||
firstAnswerStr.value.isNotEmpty &&
|
firstAnswerStr.value.isNotEmpty &&
|
||||||
@ -35,6 +40,7 @@ class MineSetSafetyProblemState {
|
|||||||
MineSetSafetyProblemState() {
|
MineSetSafetyProblemState() {
|
||||||
if (Get.arguments != null) {
|
if (Get.arguments != null) {
|
||||||
Map map = Get.arguments;
|
Map map = Get.arguments;
|
||||||
|
isUpdateAnswer.value = true;
|
||||||
firstProblemStr.value = map["firstProblemStr"];
|
firstProblemStr.value = map["firstProblemStr"];
|
||||||
secondProblemStr.value = map["secondProblemStr"];
|
secondProblemStr.value = map["secondProblemStr"];
|
||||||
thirdProblemStr.value = map["thirdProblemStr"];
|
thirdProblemStr.value = map["thirdProblemStr"];
|
||||||
@ -44,6 +50,9 @@ class MineSetSafetyProblemState {
|
|||||||
firstQuestionId.value = map["firstQuestionId"];
|
firstQuestionId.value = map["firstQuestionId"];
|
||||||
secondQuestionId.value = map["secondQuestionId"];
|
secondQuestionId.value = map["secondQuestionId"];
|
||||||
thirdQuestionId.value = map["thirdQuestionId"];
|
thirdQuestionId.value = map["thirdQuestionId"];
|
||||||
|
firstAnswerId.value = map["firstAnswerId"];
|
||||||
|
secondAnswerId.value = map["secondAnswerId"];
|
||||||
|
thirdAnswerId.value = map["thirdAnswerId"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ class SafetyProblemData {
|
|||||||
String? answer;
|
String? answer;
|
||||||
int? uid;
|
int? uid;
|
||||||
String? question;
|
String? question;
|
||||||
|
int? answerId;
|
||||||
|
|
||||||
SafetyProblemData({this.questionId, this.answer, this.uid, this.question});
|
SafetyProblemData({this.questionId, this.answer, this.uid, this.question});
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ class SafetyProblemData {
|
|||||||
answer = json['answer'];
|
answer = json['answer'];
|
||||||
uid = json['uid'];
|
uid = json['uid'];
|
||||||
question = json['question'];
|
question = json['question'];
|
||||||
|
answerId = json['answerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@ -52,6 +54,7 @@ class SafetyProblemData {
|
|||||||
data['answer'] = answer;
|
data['answer'] = answer;
|
||||||
data['uid'] = uid;
|
data['uid'] = uid;
|
||||||
data['question'] = question;
|
data['question'] = question;
|
||||||
|
data['answerId'] = answerId;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,16 +18,19 @@ class MineViewSafetyProblemLogic extends BaseGetXController {
|
|||||||
state.firstProblemStr.value = safeData1.question!;
|
state.firstProblemStr.value = safeData1.question!;
|
||||||
state.firstAnswerStr.value = safeData1.answer!;
|
state.firstAnswerStr.value = safeData1.answer!;
|
||||||
state.firstQuestionId.value = safeData1.questionId!;
|
state.firstQuestionId.value = safeData1.questionId!;
|
||||||
|
state.firstAnswerId.value = safeData1.answerId!;
|
||||||
|
|
||||||
SafetyProblemData safeData2 = entity.dataList![1];
|
SafetyProblemData safeData2 = entity.dataList![1];
|
||||||
state.secondProblemStr.value = safeData2.question!;
|
state.secondProblemStr.value = safeData2.question!;
|
||||||
state.secondAnswerStr.value = safeData2.answer!;
|
state.secondAnswerStr.value = safeData2.answer!;
|
||||||
state.secondQuestionId.value = safeData2.questionId!;
|
state.secondQuestionId.value = safeData2.questionId!;
|
||||||
|
state.secondAnswerId.value = safeData2.answerId!;
|
||||||
|
|
||||||
SafetyProblemData safeData3 = entity.dataList![2];
|
SafetyProblemData safeData3 = entity.dataList![2];
|
||||||
state.thirdProblemStr.value = safeData3.question!;
|
state.thirdProblemStr.value = safeData3.question!;
|
||||||
state.thirdAnswerStr.value = safeData3.answer!;
|
state.thirdAnswerStr.value = safeData3.answer!;
|
||||||
state.thirdQuestionId.value = safeData3.questionId!;
|
state.thirdQuestionId.value = safeData3.questionId!;
|
||||||
|
state.thirdAnswerId.value = safeData3.answerId!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,9 @@ class _MinePersonInfoViewSafetyProblemPageState
|
|||||||
'firstQuestionId': state.firstQuestionId.value,
|
'firstQuestionId': state.firstQuestionId.value,
|
||||||
'secondQuestionId': state.secondQuestionId.value,
|
'secondQuestionId': state.secondQuestionId.value,
|
||||||
'thirdQuestionId': state.thirdQuestionId.value,
|
'thirdQuestionId': state.thirdQuestionId.value,
|
||||||
|
'firstAnswerId': state.firstAnswerId.value,
|
||||||
|
'secondAnswerId': state.secondAnswerId.value,
|
||||||
|
'thirdAnswerId': state.thirdAnswerId.value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -13,4 +13,8 @@ class MineViewSafetyProblemState {
|
|||||||
var firstQuestionId = 0.obs;
|
var firstQuestionId = 0.obs;
|
||||||
var secondQuestionId = 0.obs;
|
var secondQuestionId = 0.obs;
|
||||||
var thirdQuestionId = 0.obs;
|
var thirdQuestionId = 0.obs;
|
||||||
|
|
||||||
|
var firstAnswerId = 0.obs;
|
||||||
|
var secondAnswerId = 0.obs;
|
||||||
|
var thirdAnswerId = 0.obs;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,6 +162,7 @@ abstract class Api {
|
|||||||
final String getQuestionListURL = '/safeAnswer/getQuestionList'; //获取安全信息列表
|
final String getQuestionListURL = '/safeAnswer/getQuestionList'; //获取安全信息列表
|
||||||
final String getOwnQuestionListURL =
|
final String getOwnQuestionListURL =
|
||||||
'/safeAnswer/getOwnQuestionList'; //获取已设置的安全信息
|
'/safeAnswer/getOwnQuestionList'; //获取已设置的安全信息
|
||||||
|
final String updateSafeAnswerURL = '/safeAnswer/update'; //修改安全信息
|
||||||
final String setSafeAnswerURL = '/safeAnswer/set'; //设置安全信息
|
final String setSafeAnswerURL = '/safeAnswer/set'; //设置安全信息
|
||||||
final String getUpTokenURL =
|
final String getUpTokenURL =
|
||||||
'/file/getUploadParams'; //上传头像 先获取upToken 再调用updateUserInfo
|
'/file/getUploadParams'; //上传头像 先获取upToken 再调用updateUserInfo
|
||||||
|
|||||||
@ -1477,6 +1477,11 @@ class ApiProvider extends BaseProvider {
|
|||||||
setSafeAnswerURL.toUrl,
|
setSafeAnswerURL.toUrl,
|
||||||
jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
|
jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
|
||||||
|
|
||||||
|
//修改安全信息
|
||||||
|
Future<Response> updateSafeAnswer(List questionAndAnswerList) => post(
|
||||||
|
updateSafeAnswerURL.toUrl,
|
||||||
|
jsonEncode({"questionAndAnswerList": questionAndAnswerList}));
|
||||||
|
|
||||||
// 获取上传文件的upToken 再调用updateUserInfo
|
// 获取上传文件的upToken 再调用updateUserInfo
|
||||||
Future<Response> getUpToken(String module, String typeKey, String type,
|
Future<Response> getUpToken(String module, String typeKey, String type,
|
||||||
String filename, int size) =>
|
String filename, int size) =>
|
||||||
|
|||||||
@ -1479,6 +1479,12 @@ class ApiRepository {
|
|||||||
return LoginEntity.fromJson(res.body);
|
return LoginEntity.fromJson(res.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//修改安全信息
|
||||||
|
Future<LoginEntity> updateSafeAnswer(List questionAndAnswerList) async {
|
||||||
|
final res = await apiProvider.updateSafeAnswer(questionAndAnswerList);
|
||||||
|
return LoginEntity.fromJson(res.body);
|
||||||
|
}
|
||||||
|
|
||||||
//上传头像 先获取upToken 再调用updateUserInfo
|
//上传头像 先获取upToken 再调用updateUserInfo
|
||||||
Future<MinePersonGetUploadFileInfoEntity> getUpToken(
|
Future<MinePersonGetUploadFileInfoEntity> getUpToken(
|
||||||
{required String module,
|
{required String module,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user