根据传入的参数,返回不同的mock数据
'GET /monix/data/getDict': (req: any, res: any) => {
// 添加跨域请求头
const common = {
errorCode: 'E000000',
msg: '调用成功',
success: '1',
data: {},
}
let data = {}
switch (req.query.dictType) {
case '0': {
data = {
data: {
dataList: [
{code: "D", name: "DIVORCE"}
,{code: "N", name: "MARRIED-NONREGISTERED"}
,{code: "R", name: "MARRIED-REGISTERED"}
,{code: "O", name: "OTHERS"}
,{code: "S", name: "SEPARATE"}
,{code: "U", name: "SINGLE"}
,{code: "W", name: "WIDOW"}
],
},
}
break
}
case '1': {
data = {
data: {
dataList: [
{code: "16", name: "BACHELOR'S DEGREE"}
,{code: "20", name: "DOCTORATE'S DEGREE"}
,{code: "12", name: "HIGH SCHOOL"}
,{code: "14", name: "HIGH VOCATIONAL CERTIFICATE/DIPLOMA"}
,{code: "18", name: "MASTER'S DEGREE"}
,{code: "22", name: "OTHERS"}
,{code: "10", name: "PRIMARY SCHOOL"}
,{code: "13", name: "VOCATIONAL CERTIFICATE"}
],
},
}
break
}
case '2': {
data = {
data: {
dataList: [
{code: "Ms", name: "Miss/Ms."}
,{code: "Mr", name: "Mr."}
,{code: "Mrs", name: "Mrs."}
],
},
}
break
}
case '3': {
data = {
data: {
dataList: [
{code: "1", name: "Business owner"}
,{code: "2", name: "Employee"}
,{code: "3", name: "Self-employed"}
],
},
}
break
}
}
res.json({ ...common, ...data })
},