Commit e536777d authored by Alex朱枝文's avatar Alex朱枝文

接口调整

parent 2647e66b
......@@ -252,18 +252,18 @@ class YHCustomerInformationQuestionnaireVC: YHBaseViewController {
} else {
topImageView.image = UIImage(named: "plan_question_top_old")
if let first = questions.first, surveyContainerModel.defaultAnswers.contains(where: { answer in
answer.questionId == first.id
answer.questionKey == first.businessKey
}) {
for answer in surveyContainerModel.defaultAnswers {
if let question = questions.first(where: { item in
item.id == answer.questionId
item.businessKey == answer.questionKey
}) {
displayedQuestions.append(question)
let options = answer.optionId.compactMap { optionId in
let title = question.options.first { optionItem in
optionItem.id == optionId
}?.title ?? ""
return YHSurveyConditionOptionExtra(extra: "", optionId: optionId, title: title)
let options = answer.optionKey.compactMap { optionKey in
let option = question.options.first { optionItem in
optionItem.businessKey == optionKey
}
return YHSurveyConditionOptionExtra(extra: "", optionId: option?.id ?? "", title: option?.title ?? "", optionKey: answer.questionKey)
}
self.answerDic[question.id] = options
}
......@@ -328,7 +328,7 @@ extension YHCustomerInformationQuestionnaireVC: UITableViewDelegate, UITableView
}
let option = model.options.count > index ? model.options[index] : nil
if let option = option {
self.answerDic[model.id] = [YHSurveyConditionOptionExtra(extra: "", optionId: option.id, title: option.title)]
self.answerDic[model.id] = [YHSurveyConditionOptionExtra(extra: "", optionId: option.id, title: option.title, optionKey: option.businessKey)]
if let currentIndex = self.displayedQuestions.firstIndex(where: { $0.id == model.id }) {
if self.displayedQuestions.count > currentIndex + 1 {
let nextQuestion = self.displayedQuestions[currentIndex + 1]
......
......@@ -34,12 +34,12 @@ class YHSurveyContainerModel: SmartCodable {
// MARK: - YHSurveyDefaultAnswers
class YHSurveyDefaultAnswers: SmartCodable {
var questionId: String = ""
var optionId: [String] = []
var questionKey: String = ""
var optionKey: [String] = []
enum CodingKeys: String, CodingKey {
case questionId = "question_id"
case optionId = "option_id"
case questionKey = "question_key"
case optionKey = "option_key"
}
required init() {
......@@ -225,16 +225,21 @@ class YHSurveyConditionOptionExtra: SmartCodable {
/// 选项标题 可选 提交答案时,建议设置该字段,会作为提交记录留底;show_when场景下,忽略该字段
var title: String = ""
init(extra: String, optionId: String, title: String) {
/// 选项key 必需
var optionKey: String = ""
init(extra: String, optionId: String, title: String, optionKey: String) {
self.extra = extra
self.optionId = optionId
self.title = title
self.optionKey = optionKey
}
enum CodingKeys: String, CodingKey {
case extra
case title
case optionId = "option_id"
case optionKey = "option_key"
}
required init() {
......
......@@ -8,8 +8,6 @@
import Foundation
/// RenewalAdviceSubmitSurveyAnswerRequest 续期建议-提交问卷答案-请求
// MARK: - YHSurveySubmitRequestModel
class YHSurveySubmitRequestModel {
......@@ -24,8 +22,6 @@ class YHSurveySubmitRequestModel {
}
}
/// AnswerItem 单个问题答案项
// MARK: - YHSurveyArticleAnswerItem
class YHSurveyArticleAnswerItem {
......@@ -55,8 +51,6 @@ class YHSurveyArticleAnswerItem {
}
}
/// AnswerItemFileItem
// MARK: - YHSurveyAnswerItemFileItem
class YHSurveyAnswerItemFileItem {
......@@ -80,8 +74,6 @@ class YHSurveyAnswerItemFileItem {
}
}
/// AnswerItemOptionExtra
// MARK: - YHSurveyAnswerItemOptionExtra
class YHSurveyAnswerItemOptionExtra {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment