def get_msg(): """ 显示站内信 :return: """ user_id = request.cookies.get('login_token').split('-')[0] try: res = email_service.get_all_msgs(user_id) except Exception as e: return ResponseUtil.error_response(data=[], msg=str(e)) return ResponseUtil.success_response(data=res, msg='success')
def get_all_experiment_pass(): """ 得到实验 :return: """ user_id = request.cookies.get('login_token').split('-')[0] try: experiment_infos = experiment_service.get_all_experiments_pass(user_id) except Exception as e: return ResponseUtil.error_response(data=[], msg=str(e)) return ResponseUtil.success_response(data=experiment_infos, msg='success')
def add_experiment(): """ 录入实验 :return: """ form = ExperimentAdd.from_json(formdata=request.json, meta={'locales': ['zh_CN', 'zh']}) user_id = request.cookies.get('login_token').split('-')[0] try: validate_form(form) experiment_service.add_experiment(form.data, user_id) except Exception as e: return ResponseUtil.error_response(msg=str(e)) return ResponseUtil.success_response(msg='success')
def update_status(): """ 删除用户 :return: """ user_id = request.cookies.get('login_token').split('-')[0] username = request.args.get('username') if not username: raise Exception('相关参数不能为空') try: user_service.delete_user(user_id, username) except Exception as e: return ResponseUtil.error_response(data={}, msg=str(e)) return ResponseUtil.success_response(msg='success')
def get_logistics(): """ 根据寄件人电话号/快递编号查询物流信息 :return: """ order_number = request.args.get('order_number', '') if not order_number: return ResponseUtil.error_response(msg='寄件人电话号和订单号必填一项') try: res = logistics_service.get_logistics_by_phone_and_order_number( order_number) except Exception as e: return ResponseUtil.error_response(msg=str(e)) return ResponseUtil.success_response(data=res, msg='success')
def get_all_user_info(): """ 得到所有用户信息 status:查询普通用户/快递员 :return: """ user_id = request.cookies.get('login_token').split('-')[0] identity_type = request.args.get('identity_type') if not identity_type: return ResponseUtil.error_response('请填写查询类型') try: user_infos = user_service.get_all_user_infos(user_id, identity_type) except Exception as e: return ResponseUtil.error_response(data={}, msg=str(e)) return ResponseUtil.success_response(data=user_infos, msg='success')
def register(): """ 注册接口 @:param {"username":"******","password":"******"} :return: """ form = RegisterForm.from_json(formdata=request.json, meta={'locales': ['zh_CN', 'zh']}) try: validate_form(form) user_service.user_register(form.data) except Exception as e: return ResponseUtil.error_response(msg=str(e)) return ResponseUtil.success_response(msg='success')
def send_msg(): """ 发送消息/公告 :return: """ user_id = request.cookies.get('login_token').split('-')[0] try: eid = request.args.get('eid') content = request.args.get('content') if not content: raise Exception('相关参数不能为空') email_service.send_msg_v1(user_id, eid, content) except Exception as e: return ResponseUtil.error_response(msg=str(e)) return ResponseUtil.success_response(msg='发送成功')
def make_employee_to_deliver(): """ 指派快递员去派件 :return: """ user_id = request.cookies.get('login_token').split('-')[0] employee_name = request.args.get('employee_name') order_number = request.args.get('order_number') if not employee_name or not order_number: return ResponseUtil.error_response(msg='相关参数不能为空') try: logistics_service.make_employee_to_deliver(user_id, employee_name, order_number) except Exception as e: return ResponseUtil.error_response(msg=str(e)) return ResponseUtil.success_response(msg='success')