1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "ExpertManager.h"
- #include <dbService/ClassSet.h>
- #include <dbService/UserService.h>
- #include <QCryptographicHash>
- int ExpertManager::addUser(QFUser user)
- {
- if (user.userNo.isEmpty()) {
- return QF_CODE_EMPTY_ACCOUNT;
- }
- if (user.rawPassword().isEmpty()) {
- return QF_CODE_EMPTY_PASSWORD;
- }
- if (user.userName.isEmpty()) {
- return QF_CODE_EMPTY_USERNAME;
- }
- QCryptographicHash ch(QCryptographicHash::Md5);
- QString md5str;
- QByteArray md5bytes = QCryptographicHash::hash(user.password.toLatin1(), QCryptographicHash::Md5);
- md5str.prepend(md5bytes.toHex());
- user.password = md5str;
- if (-1 == UserService().AddUserInfo(user)) {
- return QF_CODE_ACCOUNT_OCCUPIED;
- }
- return QF_CODE_ADD_USER_SUCCEEDED;
- }
- int ExpertManager::deleteUser(int userId)
- {
- bool ret = UserService().DeleteUserById(userId);
- if (!ret) {
- return QF_CODE_DELETE_USER_FAILED;
- }
- // UserService().DeleteUserConfigByEngineerId(userId);
- return QF_CODE_DELETE_USER_SUCCEEDED;
- }
|