worker.cpp 753 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "worker.h"
  2. #include <QThread>
  3. Worker::Worker(QObject *parent) : QObject(parent)
  4. {
  5. }
  6. void Worker::doWork(const int type, const QString &func, const QString &cmd)
  7. {
  8. qDebug() << "[Worker::doWork]type=" << type << "func=" << func;
  9. RstData rstData;
  10. rstData.func = func;
  11. rstData.retCode = RET_OK;
  12. rstData.msg = RET_MSG[rstData.retCode];
  13. if (type == WORK_DB_QUERY)
  14. {
  15. if (cmd == "0")
  16. {
  17. rstData.retCode = RET_PARAMERR;
  18. rstData.msg = "用户名或密码错误";
  19. }
  20. }
  21. else if (type == WORK_DB_RUN)
  22. {
  23. }
  24. else
  25. {
  26. rstData.retCode = RET_NOWORKTYPE;
  27. rstData.msg = RET_MSG[rstData.retCode];
  28. }
  29. emit resultReady(rstData); // Qt接口
  30. }