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

接口调整

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