def post(uid=None): if not check_utils.check_param_format(request.path, [r"^/v1/bms/user/$"]): return status_code.URL_ERROR data = request.json if not (data and isinstance(data, dict)): return status_code.JSON_PARAMS_ERROR for k, v in USER_REQUIRED_FIELD.items(): if not data.get(k): return { "code": status_code.REQUIRED_PARAM_CODE, "msg_cn": status_code.REQUIRED_PARAM_MSG_CN.format(v), "msg_en": status_code.REQUIRED_PARAM_MSG_EN.format(k) } # 正则验证 try: user_service = UserService() user = user_service.get_user_by_account( account=data.get("account")) if user: return status_code.USER_ACCOUNT_EXIST user_service.create_user(account=data.get("account"), password=data.get("password"), phone=data.get("phone"), username=data.get("username"), gender=data.get("gender"), email=data.get("email"), birth=data.get("birth"), is_active=data.get("is_active")) return status_code.SUCCESS except Exception as ex: print(ex) logger.error("创建用户失败,{}".format(ex)) return status_code.FAIL