BoleMbti.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // 导入BoleMbti脚本
  2. // 引用Parse JS SDK
  3. const Parse = require("parse/node");
  4. Parse.initialize("dev"); // 设置applicationId
  5. Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
  6. let mbtiData = {
  7. "ISTJ": {
  8. "personality": "ISTJ - 守护者",
  9. "suitable_jobs": ["会计师", "行政助理", "工程师"]
  10. },
  11. "ISFJ": {
  12. "personality": "ISFJ - 慈爱者",
  13. "suitable_jobs": ["护士", "社会工作者", "图书管理员"]
  14. },
  15. "INFJ": {
  16. "personality": "INFJ - 门徒",
  17. "suitable_jobs": ["心理学家", "作家", "艺术家"]
  18. },
  19. "INTJ": {
  20. "personality": "INTJ - 学者",
  21. "suitable_jobs": ["科学家", "律师", "企业家"]
  22. },
  23. "ISTP": {
  24. "personality": "ISTP - 冒险家",
  25. "suitable_jobs": ["机械师", "飞行员", "摄影师"]
  26. },
  27. "ISFP": {
  28. "personality": "ISFP - 艺术家",
  29. "suitable_jobs": ["插画师", "音乐家", "花艺设计师"]
  30. },
  31. "INFP": {
  32. "personality": "INFP - 梦想家",
  33. "suitable_jobs": ["心理咨询师", "作家", "教师"]
  34. },
  35. "INTP": {
  36. "personality": "INTP - 学者",
  37. "suitable_jobs": ["程序员", "研究员", "工程师"]
  38. },
  39. "ESTP": {
  40. "personality": "ESTP - 实干家",
  41. "suitable_jobs": ["销售员", "运动员", "警察"]
  42. },
  43. "ESFP": {
  44. "personality": "ESFP - 表演者",
  45. "suitable_jobs": ["演员", "主持人", "舞蹈编导"]
  46. },
  47. "ENFP": {
  48. "personality": "ENFP - 公关者",
  49. "suitable_jobs": ["市场营销专员", "活动策划师", "公关顾问"]
  50. },
  51. "ENTP": {
  52. "personality": "ENTP - 挑战者",
  53. "suitable_jobs": ["企业顾问", "律师", "投资者"]
  54. },
  55. "ESTJ": {
  56. "personality": "ESTJ - 主管",
  57. "suitable_jobs": ["项目经理", "军官", "警察"]
  58. },
  59. "ESFJ": {
  60. "personality": "ESFJ - 供应者",
  61. "suitable_jobs": ["教育工作者", "医生", "社会工作者"]
  62. },
  63. "ENFJ": {
  64. "personality": "ENFJ - 慈善家",
  65. "suitable_jobs": ["心理咨询师", "教育家", "公益组织工作者"]
  66. },
  67. "ENTJ": {
  68. "personality": "ENTJ - 指挥官",
  69. "suitable_jobs": ["CEO", "政治家", "项目经理"]
  70. }
  71. }
  72. function importAll(){
  73. let MbtiList = []
  74. Object.keys(mbtiData).forEach(key=>{
  75. MbtiList.push({
  76. result:key,
  77. personality:mbtiData[key]?.personality,
  78. suitableJobs:mbtiData[key]?.suitable_jobs,
  79. })
  80. })
  81. console.log(MbtiList)
  82. MbtiList.forEach(async mbti => {
  83. // 查重
  84. let exists = await checkExists(mbti)
  85. if(exists?.id) return;
  86. // 新增
  87. let BoleMbti = Parse.Object.extend("BoleMbti");
  88. let bm = new BoleMbti();
  89. bm.set(mbti);
  90. bm.save();
  91. });
  92. }
  93. async function checkExists(mbti){
  94. let query = new Parse.Query("BoleMbti");
  95. query.equalTo("result",mbti?.result);
  96. query.equalTo("personality",mbti?.personality);
  97. await query.first();
  98. return await query.first();
  99. }
  100. importAll()