def handler_function(self): args = self.get_request_data() newPermissions = {} for p in UserConfig.permissions: if p in args['setPermissions']: newPermissions[p] = 1 else: newPermissions[p] = 0 DBOps.setOneDoc( DBCollonfig.users, {'_id': args['_id']}, { '$set': { # 'department': args['department'], 'company': args['company'], 'tel': args['tel'], 'email': args['email'], 'qq': args['qq'], 'permissions': newPermissions } }) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditUser) args['permissions'] = newPermissions self.result['result'] = {'userObj': AccountUtil.resUserData(args)} return self.response_success(msg=args['username'] + u'用户信息设置成功!')
def handler_function(self): args = self.get_request_data() username = args['username'] password = args['password'] user = DBOps.getOneDoc(DBCollonfig.users, {'username': username}) if not user: return self.response_failure(username + u'用户不存在') if user['password'] != Encrypt.password_encrypt(password): return self.response_failure(username + u'用户密码错误') DBOps.setOneDoc(DBCollonfig.users, {'_id': user['_id']}, { '$set': { 'lastLogin': datetime.now().strftime('%Y-%m-%d %H:%M:%S') } }) self.result['result'] = { 'userObj': AccountUtil.resUserData(user), 'token': Authentication.generateToken(user['_id']) } # 记录日志 LogDBOps.writeLog(user['_id'], LogDBConfig.doLogin) return self.response_success()
def handler_function(self): args = self.get_request_data() username = args.get('username', None) password1 = args.get('password1', None) password2 = args.get('password2', None) key = args.get('registerKey', None) if key != 'szx2018': return self.response_failure(username + u'验证码错误') if password1 != password2: return self.response_failure(username + u'两次密码不一致') if re.findall(' ', username): return self.response_failure(u'账号不能有空格符号') if re.findall(' ', password1): return self.response_failure(u'密码不能有空格符号') user = DBOps.getOneDoc(DBCollonfig.users, {'username': username}) if user: return self.response_failure(username + u'用户已存在') userId = self.createUser(username, password1) # 记录日志 LogDBOps.writeLog(userId, LogDBConfig.doRegister) LogDBOps.writeLog(userId, LogDBConfig.doLogin) self.response_success()
def handler_function(self): args = self.get_request_data() DBOps.removeDoc(DBCollonfig.orders, {'_id': args['orderId']}) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doDelOrder) self.response_success()
def handler_function(self): args = self.get_request_data() createUser = args.get('createUser', None) newContacts = args.get('contacts', None) error_list = [] for each in newContacts: isExist = DBOps.getOneDoc( DBCollonfig.options, { '_id': DBCollonfig.orderOption, 'contacts.name': each['name'] } ) if isExist: error_list.append(each['name']) if error_list: msg = u','.join([err for err in error_list]) + u'已存在' return self.response_failure(msg=msg) for each in newContacts: DBOps.setOneDoc( DBCollonfig.options, {'_id': DBCollonfig.orderOption}, { '$push': { 'contacts': { 'name': each['name'], 'realName': each['realName'], 'createTime': TimeUtil.time_conversion( each['time'], 2 ), 'createTimeStamp': each['time'], 'createUser': createUser, 'tel': each['tel'], 'email': each['email'], 'qq': each['qq'], 'payInfo': each['payInfo'], 'workClass': each['workClass'] } } } ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doCreateContact) return self.response_success()
def handler_function(self): args = self.get_request_data() now = datetime.now() orderId = str(args['userId']) + now.strftime('%Y%m%d%H%M%S') nowString = now.strftime('%Y-%m-%d %H:%M:%S') order = { '_id': orderId, 'orderId': orderId, 'userId': args['userId'], 'title': args['title'], 'createUser': args['createUser'], # 'department': args['department'], 'company': args['company'], 'className': args['className'], 'customerName': args['customerName'], 'contactName': args['contactName'], 'expectDate': args['expectDate'], 'expect': { 'price': args['price'], 'tax': args['tax'], 'num': args['num'], 'unit': args['unit'], 'unitNum': args['unitNum'], 'sumPrice': round(args['sumPrice'], 2), }, 'price': args['price'], 'sumPrice': round(args['sumPrice'], 2), 'tax': args['tax'], 'num': args['num'], 'unit': args['unit'], 'unitNum': args['unitNum'], 'desc': args['desc'], 'createTime': nowString, 'completeTime': '', 'paymentTime': '', 'createTimeStamp': TimeUtil.time_conversion(nowString, 1), 'completeTimeStamp': 0, 'paymentTimeStamp': 0, 'status': 1, 'evaluation': 0 } DBOps.insertDoc(DBCollonfig.orders, order) # 记录日志 LogDBOps.writeLog(args['userId'], LogDBConfig.doCreateOrder) self.response_success()
def handler_function(self): args = self.get_request_data() DBOps.setOneDoc( DBCollonfig.options, {'_id': DBCollonfig.orderOption}, { '$pull': { args['optionType']: { 'name': args['name'] } } } ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], self.LogAction[args['optionType']]) return self.response_success()
def handler_function(self): args = self.get_request_data() page = args['page'] pageSize = args['pageSize'] logType = args['logType'] self.result['result'] = LogDBOps.getlist(page, pageSize, logType) self.response_success()
def handler_function(self): args = self.get_request_data() now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') DBOps.setOneDoc( DBCollonfig.options, {'_id': DBCollonfig.orderHelpInfo}, { '$set': { 'helpInfo': [{ 'content': args['helpInfo'], 'createTime': now, 'createTimeStamp': TimeUtil.time_conversion(now, 1) }] } } ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditHelpInfo) return self.response_success()
def handler_function(self): args = self.get_request_data() option = args['option'] createUser = args['createUser'] now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') if args['optionType'] == 'contacts': oldContact = DBOps.getOneDoc( DBCollonfig.options, { '_id': DBCollonfig.orderContact, 'contacts.name': option['oldName'] } ) if not oldContact: return self.response_failure(msg=u'外包人员不存在') DBOps.setOneDoc( DBCollonfig.options, { '_id': DBCollonfig.orderContact, 'contacts.name': option['oldName'] }, { '$set': { 'contacts.$.name': option['name'], 'contacts.$.realName': option['realName'], 'contacts.$.tel': option['tel'], 'contacts.$.email': option['email'], 'contacts.$.workClass': option['workClass'], 'contacts.$.payInfo': option['payInfo'], 'contacts.$.qq': option['qq'], 'contacts.$.createUser': createUser, 'contacts.$.createTime': now, 'contacts.$.createTimeStamp': TimeUtil.time_conversion( now, 1 ), } } ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditContact) return self.response_success() elif args['optionType'] == 'customers': DBOps.setOneDoc( DBCollonfig.options, { '_id': DBCollonfig.orderCustomer, 'customers.name': option['name'] }, { '$set': { 'customers.$.billInfo': option['billInfo'], 'customers.$.mailAddress': option['mailAddress'], 'customers.$.createUser': createUser, 'customers.$.createTime': now, 'customers.$.createTimeStamp': TimeUtil.time_conversion( now, 1 ), } } ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doEditCustomer) return self.response_success() else: return self.response_failure(msg=u'没有需要修改的信息')
def handler_function(self): args = self.get_request_data() # 记录日志 LogDBOps.writeLog(args['opsUserId'], LogDBConfig.doDownloadTable)
def handler_function(self): args = self.get_request_data() setStatus = args.get('status', None) orderId = args.get('orderId', None) nowStatus = DBOps.getOneDoc( DBCollonfig.orders, {'_id': orderId} )['status'] if nowStatus == setStatus: return self.response_failure(msg='订单状态已被修改!') logAction = None nowString = datetime.now().strftime(DATETIME_FORMAT) setParams = {} if setStatus == 1: setParams = self.setStatus1(setStatus, args) logAction = LogDBConfig.doEditOrder if args['opsUserId'] != args['userId']: content = { 'status': setStatus, 'sendUserId': args['opsUserId'], 'rcvUserId': args['userId'], 'orderTitle': args['title'], 'createUser': args['createUser'] } AccountMsg.setOrderMsg(content) elif setStatus == 2: setParams = self.setStatus2(setStatus, nowString, args) logAction = LogDBConfig.doCompleteOrder content = { 'status': setStatus, 'sendUserId': args['opsUserId'], 'rcvUserId': 'summaryUser', 'orderTitle': args['title'], 'createUser': args['createUser'] } AccountMsg.setOrderMsg(content) elif setStatus == 3: setParams = self.setStatus3(setStatus, nowString, args) logAction = LogDBConfig.doPaymentOrder if args['opsUserId'] != args['userId']: content = { 'status': setStatus, 'sendUserId': args['opsUserId'], 'rcvUserId': args['userId'], 'orderTitle': args['title'], 'createUser': args['createUser'] } AccountMsg.setOrderMsg(content) DBOps.setOneDoc( DBCollonfig.orders, {'_id': orderId}, {'$set': setParams} ) # 记录日志 LogDBOps.writeLog(args['opsUserId'], logAction) self.result['result'] = {'opsTime': nowString} return self.response_success(msg='订单状态修改成功!')