4
-
5 3
 from utils.redis.connect import r
6 4
 from utils.redis.rkeys import GUEST_ENTRANCE_CONTROL_INFO
7 5
 
@@ -11,13 +9,13 @@ from utils.redis.rkeys import GUEST_ENTRANCE_CONTROL_INFO
11 9
 
12 10
 def set_guest_entrance_control(gen):
13 11
     """ 设置游客入口控制 """
14
-    r.set(GUEST_ENTRANCE_CONTROL_INFO, json.dumps(gen.data))
12
+    r.setjson(GUEST_ENTRANCE_CONTROL_INFO, gen.data)
15 13
     return gen.data
16 14
 
17 15
 
18 16
 def get_guest_entrance_control():
19 17
     """ 获取游客入口控制 """
20
-    return json.loads(r.get(GUEST_ENTRANCE_CONTROL_INFO) or '{}')
18
+    return r.getjson(GUEST_ENTRANCE_CONTROL_INFO)
21 19
 
22 20
 
23 21
 def delete_guest_entrance_control():

+ 4 - 6
utils/redis/rmessage.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from message.models import SystemMessageDeleteInfo, SystemMessageReadInfo
6 4
 from utils.redis.connect import r
7 5
 from utils.redis.rkeys import SYSTEM_MESSAGE_DELETED_INFO, SYSTEM_MESSAGE_READ_INFO
@@ -14,23 +12,23 @@ def set_system_message_read_info(user_id):
14 12
     """ 设置系统消息读取信息 """
15 13
     read_messages = SystemMessageReadInfo.objects.filter(user_id=user_id, status=True)
16 14
     read_message_ids = [msg.msg_id for msg in read_messages]
17
-    r.setex(SYSTEM_MESSAGE_READ_INFO % user_id, r.REDIS_EXPIRED_ONE_MONTH, json.dumps(read_message_ids))
15
+    r.setexjson(SYSTEM_MESSAGE_READ_INFO % user_id, r.REDIS_EXPIRED_ONE_MONTH, read_message_ids)
18 16
     return read_message_ids
19 17
 
20 18
 
21 19
 def get_system_message_read_info(user_id):
22 20
     """ 获取系统消息读取信息 """
23
-    return json.loads(r.get(SYSTEM_MESSAGE_READ_INFO % user_id) or '[]') or set_system_message_read_info(user_id)
21
+    return r.getjson(SYSTEM_MESSAGE_READ_INFO % user_id, default='[]') or set_system_message_read_info(user_id)
24 22
 
25 23
 
26 24
 def set_system_message_delete_info(user_id):
27 25
     """ 设置系统消息删除信息 """
28 26
     deleted_messages = SystemMessageDeleteInfo.objects.filter(user_id=user_id, status=True)
29 27
     deleted_message_ids = [msg.msg_id for msg in deleted_messages]
30
-    r.setex(SYSTEM_MESSAGE_DELETED_INFO % user_id, r.REDIS_EXPIRED_ONE_MONTH, json.dumps(deleted_message_ids))
28
+    r.setexjson(SYSTEM_MESSAGE_DELETED_INFO % user_id, r.REDIS_EXPIRED_ONE_MONTH, deleted_message_ids)
31 29
     return deleted_message_ids
32 30
 
33 31
 
34 32
 def get_system_message_delete_info(user_id):
35 33
     """ 获取系统消息删除信息 """
36
-    return json.loads(r.get(SYSTEM_MESSAGE_DELETED_INFO % user_id) or '[]') or set_system_message_delete_info(user_id)
34
+    return r.getjson(SYSTEM_MESSAGE_DELETED_INFO % user_id, default='[]') or set_system_message_delete_info(user_id)

+ 2 - 4
utils/redis/rorder.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from django.core.serializers.json import DjangoJSONEncoder
6 4
 
7 5
 from utils.redis.connect import r
@@ -14,7 +12,7 @@ from utils.redis.rkeys import LENSMAN_PHOTO_ORDER_RECORD
14 12
 def set_lensman_order_record(porder):
15 13
     """ 设置摄影师照片购买记录 """
16 14
     porder_info = porder.porder_info
17
-    r.setex(LENSMAN_PHOTO_ORDER_RECORD % (porder.photo_id, porder.user_id), r.REDIS_EXPIRED_ONE_MONTH, json.dumps(porder_info, cls=DjangoJSONEncoder))
15
+    r.setexjson(LENSMAN_PHOTO_ORDER_RECORD % (porder.photo_id, porder.user_id), r.REDIS_EXPIRED_ONE_MONTH, porder_info, cls=DjangoJSONEncoder)
18 16
     return porder_info
19 17
 
20 18
 
@@ -30,4 +28,4 @@ def set_lensman_order_record_by_id(photo_id, user_id):
30 28
 
31 29
 def get_lensman_order_record(photo_id, user_id):
32 30
     """ 获取摄影师照片购买记录 """
33
-    return json.loads(r.get(LENSMAN_PHOTO_ORDER_RECORD % (photo_id, user_id)) or '{}') or set_lensman_order_record_by_id(photo_id, user_id)
31
+    return r.getjson(LENSMAN_PHOTO_ORDER_RECORD % (photo_id, user_id)) or set_lensman_order_record_by_id(photo_id, user_id)

+ 2 - 4
utils/redis/rpatch.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from pai2.basemodels import PlatformMixin
6 4
 from utils.redis.connect import r
7 5
 from utils.redis.rkeys import APP_PATCH_INFO
@@ -9,7 +7,7 @@ from utils.redis.rkeys import APP_PATCH_INFO
9 7
 
10 8
 def set_app_patch_info(apppatch):
11 9
     """ 设置 APP 补丁信息 """
12
-    r.set(APP_PATCH_INFO % (apppatch.platform, apppatch.version, apppatch.src), json.dumps(apppatch.data))
10
+    r.setjson(APP_PATCH_INFO % (apppatch.platform, apppatch.version, apppatch.src), apppatch.data)
13 11
 
14 12
 
15 13
 def del_app_patch_info(apppatch):
@@ -20,4 +18,4 @@ def del_app_patch_info(apppatch):
20 18
 def get_app_patch_info(platform, version, src):
21 19
     """ 获取 APP 补丁信息 """
22 20
     platform = platform if isinstance(platform, int) else PlatformMixin.Platforms.get(platform)
23
-    return json.loads(r.get(APP_PATCH_INFO % (platform, version, src)) or '{}')
21
+    return r.getjson(APP_PATCH_INFO % (platform, version, src))

+ 2 - 4
utils/redis/rprice.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from account.models import LensmanInfo
6 4
 from utils.redis.connect import r
7 5
 from utils.redis.rkeys import LENSMAN_PHOTO_PRICE_FIXED
@@ -22,11 +20,11 @@ def set_lensman_price_fixed(user_id):
22 20
         'origin': (lensman and lensman.origin) or 999,
23 21
     }
24 22
 
25
-    r.set(LENSMAN_PHOTO_PRICE_FIXED % user_id, json.dumps(price_fixed))
23
+    r.setjson(LENSMAN_PHOTO_PRICE_FIXED % user_id, price_fixed)
26 24
 
27 25
     return price_fixed
28 26
 
29 27
 
30 28
 def get_lensman_price_fixed(user_id):
31 29
     """ 获取摄影师价格设定 """
32
-    return json.loads(r.get(LENSMAN_PHOTO_PRICE_FIXED % user_id) or '{}') or set_lensman_price_fixed(user_id)
30
+    return r.getjson(LENSMAN_PHOTO_PRICE_FIXED % user_id) or set_lensman_price_fixed(user_id)

+ 2 - 4
utils/redis/rprofile.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from utils.redis.connect import r
6 4
 from utils.redis.rkeys import PROFILE_INFO
7 5
 
@@ -11,7 +9,7 @@ from utils.redis.rkeys import PROFILE_INFO
11 9
 
12 10
 def set_profile_info(user):
13 11
     """ 设置用户信息 """
14
-    r.set(PROFILE_INFO % user.user_id, json.dumps(user.data))
12
+    r.setjson(PROFILE_INFO % user.user_id, user.data)
15 13
     return user.data
16 14
 
17 15
 
@@ -27,4 +25,4 @@ def set_profile_by_uid(user_id):
27 25
 
28 26
 def get_profile_by_id(user_id):
29 27
     """ 获取用户信息 """
30
-    return json.loads(r.get(PROFILE_INFO % user_id) or '{}') or set_profile_by_uid(user_id)
28
+    return r.getjson(PROFILE_INFO % user_id) or set_profile_by_uid(user_id)

+ 2 - 4
utils/redis/rsettings.py

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-import json
4
-
5 3
 from pai2.basemodels import PlatformMixin
6 4
 from utils.redis.connect import r
7 5
 from utils.redis.rkeys import APP_SETTINGS_INFO
@@ -9,7 +7,7 @@ from utils.redis.rkeys import APP_SETTINGS_INFO
9 7
 
10 8
 def set_app_settings_info(appset):
11 9
     """ 设置 APP 设置信息 """
12
-    r.set(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version), json.dumps(appset.data))
10
+    r.setjson(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version), appset.data)
13 11
 
14 12
 
15 13
 def del_app_settings_info(appset):
@@ -20,4 +18,4 @@ def del_app_settings_info(appset):
20 18
 def get_app_settings_info(platform, channel, version):
21 19
     """ 获取 APP 设置信息 """
22 20
     platform = platform if isinstance(platform, int) else PlatformMixin.Platforms[platform]
23
-    return json.loads(r.get(APP_SETTINGS_INFO % (platform, channel, version)) or '{}')
21
+    return r.getjson(APP_SETTINGS_INFO % (platform, channel, version))

kodo - Gogs: Go Git Service

Нет описания

errno_utils.py 12KB

    # -*- coding: utf-8 -*- from StatusCode import BaseStatusCode, StatusCodeField class ParamStatusCode(BaseStatusCode): """ 4000xx 参数相关错误码 """ PARAM_NOT_FOUND = StatusCodeField(400000, 'Param Not Found', description=u'参数不存在') class PermissionStatusCode(BaseStatusCode): """ 4099xx 权限相关错误码 """ PERMISSION_DENIED = StatusCodeField(409900, 'Permission Denied', description=u'权限不足') class AdministratorStatusCode(BaseStatusCode): """ 操作员相关错误码 4002xx """ ADMINISTRATOR_NOT_FOUND = StatusCodeField(400201, 'Administrator Not Found', description=u'管理员不存在') ADMINISTRATOR_PERMISSION_DENIED = StatusCodeField(400202, 'Administrator Permission Denied', description=u'管理员权限不足') # 手机号 ADMINISTRATOR_PHONE_ALREADY_EXISTS = StatusCodeField(400205, 'Administrator Phone Already Exists', description=u'管理员手机号已经存在') # 密码 ADMINISTRATOR_PASSWORD_ERROR = StatusCodeField(400210, 'Administrator Password Error', description=u'管理员密码错误') # 状态 ADMINISTRATOR_NOT_ACTIVATED = StatusCodeField(400215, 'Administrator Not Activated', description=u'管理员未激活') ADMINISTRATOR_HAS_DISABLED = StatusCodeField(400216, 'Administrator Has Disabled', description=u'管理员已禁用') ADMINISTRATOR_HAS_DELETED = StatusCodeField(400217, 'Administrator Has Deleted', description=u'管理员已删除') # 核销员 MAINTENANCE_NOT_FOUND = StatusCodeField(400251, 'Maintenance Not Found', description=u'核销员不存在') class OperatorStatusCode(BaseStatusCode): """ 操作员相关错误码 4003xx """ OPERATOR_NOT_FOUND = StatusCodeField(400301, 'Operator Not Found', description=u'操作员不存在') # 密码 OPERATOR_PASSWORD_ERROR = StatusCodeField(400302, 'Operator Password Error', description=u'操作员密码错误') # 手机号 OPERATOR_PHONE_ALREADY_EXISTS = StatusCodeField(400305, 'Operator Phone Already Exists', description=u'操作员手机号已经存在') # 状态 OPERATOR_NOT_ACTIVATED = StatusCodeField(400315, 'Operator Not Activated', description=u'操作员未激活') OPERATOR_HAS_DISABLED = StatusCodeField(400316, 'Operator Has Disabled', description=u'操作员已禁用') OPERATOR_HAS_DELETED = StatusCodeField(400317, 'Operator Has Deleted', description=u'操作员已删除') class UserStatusCode(BaseStatusCode): """ 用户相关错误码 4005xx """ USER_NOT_FOUND = StatusCodeField(400501, 'User Not Found', description=u'用户不存在') USER_PASSWORD_ERROR = StatusCodeField(400502, 'User Password Error', description=u'用户密码错误') USERNAME_HAS_REGISTERED = StatusCodeField(400503, 'Username Has Registered', description=u'用户名已注册') # 游客 GUEST_NOT_ALLOWED = StatusCodeField(400511, 'Guest Not ALLOWED', description=u'游客登录未开启') # 身份 USER_NOT_LENSMAN = StatusCodeField(400521, 'User Not Lensman', description=u'用户非摄影师') USER_NOT_TOURGUIDE = StatusCodeField(400522, 'User Not Tourguide', description=u'用户非导游') class PhoneStatusCode(BaseStatusCode): """ 手机相关错误码 4006xx """ PHONE_NOT_FOUND = StatusCodeField(400601, 'Phone Not Found', description=u'手机不存在') class WechatStatusCode(BaseStatusCode): """ 微信相关错误码 4007xx """ WECHAT_NOT_FOUND = StatusCodeField(400701, 'Wechat Not Found', description=u'微信不存在') UNIONID_NOT_FOUND = StatusCodeField(400702, 'Unionid Not Found', description=u'微信 UNIONID 不存在') OPENID_NOT_FOUND = StatusCodeField(400703, 'OPENID Not Found', description=u'微信 OPENID 不存在') class ScreenStatusCode(BaseStatusCode): """ 群组/团相关错误码 4030xx """ QRCODE_NOT_SCAN = StatusCodeField(403001, 'QRCode Not Scan', description=u'二维码未扫描') class CouponStatusCode(BaseStatusCode): """ 4050xx 优惠劵相关错误码 """ COUPON_NOT_FOUND = StatusCodeField(405001, 'Coupon Not Found', description=u'劵不存在') COUPON_EXPIRED = StatusCodeField(405002, 'Coupon Expired', description=u'劵已过期') COUPON_PERMISSION_DENIED = StatusCodeField(405003, 'Permission Denied', description=u'核销劵权限不足') COUPON_HAS_USED = StatusCodeField(405004, 'Coupon Has Used', description=u'劵已核销') class SaleclerkStatusCode(BaseStatusCode): """ 店员相关错误码 5001xx """ CLERK_NOT_FOUND = StatusCodeField(500101, 'Clerk Not Found', description=u'店员不存在') # 手机号 CLERK_PHONE_ALREADY_EXISTS = StatusCodeField(500105, 'Clerk Phone Already Exists', description=u'手机号已经存在') # 状态 CLERK_ALREADY_NOT_UNVERIFIED = StatusCodeField(500110, 'Clerk Already Not Unverified', description=u'店员帐号已激活') CLERK_NOT_ACTIVATED = StatusCodeField(500115, 'Clerk Not Activated', description=u'店员帐号未激活') CLERK_NOT_AUTH = StatusCodeField(500116, 'Clerk Not AUTH', description=u'店员帐号未认证') # 上传 DUPLICATE_SUBMIT = StatusCodeField(500199, 'Duplicate Submit', description=u'重复提交') class SalesResponsibilityStatusCode(BaseStatusCode): """ 销售担当相关错误码 5002xx """ SR_NOT_FOUND = StatusCodeField(500201, 'SR Not Found', description=u'销售担当不存在') # 手机号 SR_PHONE_ALREADY_EXISTS = StatusCodeField(500205, 'SR Phone Already Exists', description=u'手机号已经存在') class ProductBrandStatusCode(BaseStatusCode): """ 品牌相关错误码 5010xx """ BRAND_NOT_FOUND = StatusCodeField(501001, 'Brand Not Found', description=u'品牌不存在') BRAND_NOT_MATCH = StatusCodeField(501011, 'Brand Not Match', description=u'品牌不匹配') class ProductModelStatusCode(BaseStatusCode): """ 型号相关错误码 5011xx """ MODEL_NOT_FOUND = StatusCodeField(501101, 'Model Not Found', description=u'型号不存在') class ProductDistributorStatusCode(BaseStatusCode): """ 经销商相关错误码 5012xx """ DISTRIBUTOR_NOT_FOUND = StatusCodeField(501201, 'Distributor Not Found', description=u'经销商不存在') class ProductMachineStatusCode(BaseStatusCode): """ 机器相关错误码 5013xx """ SN_NOT_FOUND = StatusCodeField(501301, 'SN Not Found', description=u'序列号不存在') # 快递单号校验 DUPLICATE_TRACKING_NUMBER = StatusCodeField(501311, 'Duplicate Tracking Number', description=u'快递单号重复') class ProductCouponStatusCode(BaseStatusCode): """ 优惠券相关错误码 5014xx """ COUPON_NOT_FOUND = StatusCodeField(501401, 'Coupon Not Found', description=u'优惠券不存在') COUPON_HAS_EXPIRED = StatusCodeField(501411, 'Coupon Has Expired', description=u'优惠券已过期') class ComplementCodeStatusCode(BaseStatusCode): """ 补码相关错误码 5016xx """ COMPLEMENT_CODE_NOT_FOUND = StatusCodeField(501601, 'Complement Code Not Found', description=u'补码记录不存在') COMPLEMENT_CODE_HAS_AUDITED = StatusCodeField(501605, 'Complement Code Has Audited', description=u'补码记录已审核') COMPLEMENT_CODE_STATUS_INVALID = StatusCodeField(501611, 'Complement Code Status Invalid', description=u'补码记录状态不合法') class ProductStatusCode(BaseStatusCode): """ 产品相关错误码 5020xx """ PRODUCT_NOT_FOUND = StatusCodeField(502001, 'Product Not Found', description=u'产品不存在') # 状态 PRODUCT_HAS_USED = StatusCodeField(502011, 'Product Has Used', description=u'产品已使用') PRODUCT_NOT_USED = StatusCodeField(502012, 'Product Not Used', description=u'产品未使用') class MemberGoodStatusCode(BaseStatusCode): """ 会员商品相关错误码 5035xx """ GOOD_NOT_FOUND = StatusCodeField(503501, 'Good Not Found', description=u'商品不存在') GOOD_NO_EXCHANGE_PERMISSION = StatusCodeField(503502, 'Good No Exchange Permission', description=u'商品无兑换权限') GOOD_INTEGRAL_NOT_ENOUGH = StatusCodeField(503503, 'Good Integral Not Enough', description=u'商品兑换积分不足') GOOD_STOCK_NOT_ENOUGH = StatusCodeField(503504, 'Good Integral Not Enough', description=u'商品库存不足') GOOD_EXCHANGE_ONLY_ONCE = StatusCodeField(503505, 'Good Exchange Only Once', description=u'商品仅可兑换一次') GOOD_NO_ADDRESS = StatusCodeField(503506, 'Good Exchange No Address', description=u'实物商品需填写地址') class MemberRightStatusCode(BaseStatusCode): """ 会员商品相关错误码 5036xx """ RIGHT_NOT_FOUND = StatusCodeField(503601, 'Right Not Found', description=u'权益不存在') class MemberActivityStatusCode(BaseStatusCode): """ 会员活动相关错误码 5037xx """ ACTIVITY_NOT_FOUND = StatusCodeField(503701, 'Activity Not Found', description=u'活动不存在') class MemberActivityContributionStatusCode(BaseStatusCode): """ 会员活动投稿相关错误码 5038xx """ ACTIVITY_CONTRIBUTION_NOT_FOUND = StatusCodeField(503801, 'Activity Contribution Not Found', description=u'活动投稿不存在') class MemberActivityContributionWelfareStatusCode(BaseStatusCode): """ 会员活动投稿福利相关错误码 5039xx """ ACTIVITY_CONTRIBUTION_WELFARE_NOT_FOUND = StatusCodeField(503901, 'Activity Contribution Welfare Not Found', description=u'活动投稿福利不存在') class MemberActivityContributionWelfareUnblockingStatusCode(BaseStatusCode): """ 会员活动投稿福利相关错误码 5039xx """ ACTIVITY_CONTRIBUTION_WELFARE_UNBLOCKING_NOT_FOUND = StatusCodeField(503901, 'Activity Contribution Welfare Unblocking Not Found', description=u'活动投稿福利解锁不存在') ACTIVITY_CONTRIBUTION_WELFARE_UNBLOCKING_HAS_HANDLED = StatusCodeField(503902, 'Activity Contribution Welfare Unblocking Has Handled', description=u'活动投稿福利解锁已处理') class MemberCouponStatusCode(BaseStatusCode): """ 会员优惠券相关错误码 5040xx """ USER_COUPON_NOT_FOUND = StatusCodeField(504001, 'User Coupon Not Found', description=u'用户优惠券不存在') USER_COUPON_HAS_USED = StatusCodeField(504010, 'User Coupon Has Used', description=u'用户优惠券已使用') USER_COUPON_NOT_ACTIVED = StatusCodeField(504011, 'User Coupon Not Actived', description=u'用户优惠券未生效') USER_COUPON_HAS_EXPIRED = StatusCodeField(504012, 'User Coupon Has Expired', description=u'用户优惠券已过期') class MarketCodeStatusCode(BaseStatusCode): """ 一物一码相关错误码 5050xx """ MARKET_CODE_NOT_FOUND = StatusCodeField(505001, 'Market Code Not Found', description=u'一物一码不存在') class CiphertextStatusCode(BaseStatusCode): """ 加解密相关错误码 5050xx """ CIPHERTEXT_INVALID = StatusCodeField(505011, 'Ciphertext Invalid', description=u'密文无效') class MaintenancePointStatusCode(BaseStatusCode): """ 维修点相关错误码 5060xx """ MAINTENACE_POINT_NOT_FOUND = StatusCodeField(506001, 'Maintenance Point Not Found', description=u'维修点不存在') class ExpressStatusCode(BaseStatusCode): """ 快递公司相关错误码 5070xx """ EXPRESS_NOT_FOUND = StatusCodeField(507001, 'Express Not Found', description=u'快递公司不存在') class MaintenanceStatusCode(BaseStatusCode): """ 维修相关错误码 5080xx """ MAINTENACE_NOT_FOUND = StatusCodeField(508001, 'Maintenance Not Found', description=u'维修不存在') MAINTENACE_PERMISSION_DENIED = StatusCodeField(508002, 'Maintenance Permission Denied', description=u'维修权限不足') class TenancyStatusCode(BaseStatusCode): """ 租赁相关错误码 5090xx """ TENANCY_SHOT_NOT_FOUND = StatusCodeField(509001, 'Tenancy Shot Not Found', description=u'租赁镜头不存在') TENANCY_SHOT_ALREADY_EXIST = StatusCodeField(509002, 'Tenancy Shot Already Exist', description=u'租赁镜头已存在') TENANCY_SHOT_REQUEST_NOT_FOUND = StatusCodeField(509011, 'Tenancy Shot Request Not Found', description=u'租赁镜头申请不存在') class ContractStatusCode(BaseStatusCode): """ 合同相关错误码 5091xx """ CONTRACT_NOT_FOUND = StatusCodeField(509101, 'Contract Not Found', description=u'合同不存在') class TencentCloudStatusCode(BaseStatusCode): """ 腾讯云SDK错误码 5099xx """ TENCENT_CLOUD_SDK_EXCEPTION = StatusCodeField(509901, 'Tencent Cloud SDK Exception', description=u'腾讯云SDK报错')