ClassSet.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #include "ClassSet.h"
  2. #include "DBServiceSet.h"
  3. #include <QCryptographicHash>
  4. #include <QDebug>
  5. QList<NodeMatrixInfo *> ClassSet::datas;
  6. ClassSet::ClassSet()
  7. {
  8. datas.clear();
  9. NodeMatrixInfo *testData = new NodeMatrixInfo();
  10. testData->expertName = "luoyc";
  11. testData->expertId = "1";
  12. testData->engineerId = 1;
  13. testData->node = "1.1";
  14. testData->abscissa = "A";
  15. testData->ordinate = "A";
  16. datas.append(testData);
  17. NodeMatrixInfo *testData1 = new NodeMatrixInfo();
  18. testData1->expertName = "luoyc";
  19. testData1->expertId = "1";
  20. testData1->engineerId = 1;
  21. testData1->node = "1.1";
  22. testData1->abscissa = "A";
  23. testData1->ordinate = "B";
  24. datas.append(testData1);
  25. NodeMatrixInfo *testData2 = new NodeMatrixInfo();
  26. testData2->expertName = "luoyc";
  27. testData2->expertId = "1";
  28. testData2->engineerId = 1;
  29. testData2->node = "1.2";
  30. testData2->abscissa = "B";
  31. testData2->ordinate = "A";
  32. datas.append(testData2);
  33. NodeMatrixInfo *testData3 = new NodeMatrixInfo();
  34. testData3->expertName = "luoyc";
  35. testData3->expertId = "1";
  36. testData3->engineerId = 1;
  37. testData3->node = "1.2";
  38. testData3->abscissa = "B";
  39. testData3->ordinate = "B";
  40. datas.append(testData3);
  41. NodeMatrixInfo *testData4 = new NodeMatrixInfo();
  42. testData4->expertName = "luoyc";
  43. testData4->expertId = "1";
  44. testData4->engineerId = 1;
  45. testData4->node = "1.1.1";
  46. testData4->abscissa = "A1";
  47. testData4->ordinate = "A1";
  48. datas.append(testData4);
  49. NodeMatrixInfo *testData5 = new NodeMatrixInfo();
  50. testData5->expertName = "luoyc";
  51. testData5->expertId = "1";
  52. testData5->engineerId = 1;
  53. testData5->node = "1.1.1";
  54. testData5->abscissa = "A1";
  55. testData5->ordinate = "A2";
  56. datas.append(testData5);
  57. NodeMatrixInfo *testData6 = new NodeMatrixInfo();
  58. testData6->expertName = "luoyc";
  59. testData6->expertId = "1";
  60. testData6->engineerId = 1;
  61. testData6->node = "1.1.2";
  62. testData6->abscissa = "A2";
  63. testData6->ordinate = "A1";
  64. datas.append(testData6);
  65. NodeMatrixInfo *testData7 = new NodeMatrixInfo();
  66. testData7->expertName = "luoyc";
  67. testData7->expertId = "1";
  68. testData7->engineerId = 1;
  69. testData7->node = "1.1.2";
  70. testData7->abscissa = "A2";
  71. testData7->ordinate = "A2";
  72. datas.append(testData7);
  73. NodeMatrixInfo *testData8 = new NodeMatrixInfo();
  74. testData8->expertName = "luoyc";
  75. testData8->expertId = "1";
  76. testData8->engineerId = 1;
  77. testData8->node = "1.2.1";
  78. testData8->abscissa = "B1";
  79. testData8->ordinate = "B1";
  80. datas.append(testData8);
  81. NodeMatrixInfo *testData9 = new NodeMatrixInfo();
  82. testData9->expertName = "luoyc";
  83. testData9->expertId = "1";
  84. testData9->engineerId = 1;
  85. testData9->node = "1.2.1";
  86. testData9->abscissa = "B1";
  87. testData9->ordinate = "B2";
  88. datas.append(testData9);
  89. NodeMatrixInfo *testData10 = new NodeMatrixInfo();
  90. testData10->expertName = "luoyc";
  91. testData10->expertId = "1";
  92. testData10->engineerId = 1;
  93. testData10->node = "1.2.2";
  94. testData10->abscissa = "B2";
  95. testData10->ordinate = "B1";
  96. datas.append(testData10);
  97. NodeMatrixInfo *testData11 = new NodeMatrixInfo();
  98. testData11->expertName = "luoyc";
  99. testData11->expertId = "1";
  100. testData11->engineerId = 1;
  101. testData11->node = "1.2.2";
  102. testData11->abscissa = "B2";
  103. testData11->ordinate = "B2";
  104. datas.append(testData11);
  105. }
  106. static QFUser m_currentUser;
  107. QFUser::QFUser() { }
  108. QFUser::QFUser(const QString userId, const QString password) : userNo(userId), password(password) { }
  109. QFUser QFUser::currentUser()
  110. {
  111. return m_currentUser;
  112. }
  113. int QFUser::login()
  114. {
  115. if (!DBServiceSet().QueryUserByNo(this, userNo)) {
  116. return QF_CODE_USER_NOT_EXISTS;
  117. }
  118. QCryptographicHash ch(QCryptographicHash::Md5);
  119. QString md5str;
  120. QByteArray md5bytes = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5);
  121. md5str.prepend(md5bytes.toHex());
  122. if (!DBServiceSet().QueryUserByNoAndPassword(this, userNo, md5str)) {
  123. return QF_CODE_WRONG_PASSWORD;
  124. }
  125. m_currentUser = *this;
  126. return QF_CODE_COMPLETED;
  127. }
  128. int QFUser::logout()
  129. {
  130. return QF_CODE_COMPLETED;
  131. }