Ver código fonte

后台算法管理接口

zhangdongming 2 anos atrás
pai
commit
6b7f84e865

+ 82 - 0
AdminController/AlgorithmShopManageController.py

@@ -0,0 +1,82 @@
+# -*- encoding: utf-8 -*-
+"""
+@File    : AlgorithmShopManageController.py
+@Time    : 2023/7/25 9:48
+@Author  : stephen
+@Email   : zhangdongming@asj6.wecom.work
+@Software: PyCharm
+"""
+from django.views import View
+
+from Model.models import DeviceAlgorithmExplain
+from Object.ResponseObject import ResponseObject
+from Object.TokenObject import TokenObject
+
+
+class AlgorithmShopManageView(View):
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        api_version = kwargs.get('apiVersion')
+        return self.validation(request.GET, request, operation, api_version)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        api_version = kwargs.get('apiVersion')
+        return self.validation(request.POST, request, operation, api_version)
+
+    def validation(self, request_dict, request, operation, api_version='v1'):
+        token = TokenObject(request.META.get('HTTP_AUTHORIZATION'))
+        response = ResponseObject()
+        if token.code != 0:
+            return response.json(token.code)
+
+        ''' 后台管理'''
+        response = ResponseObject(returntype='pc')
+        if operation == 'save':
+            pass
+        if operation == 'update':
+            return self.algorithm_update(request_dict, response, api_version)
+        else:
+            return response.json(404)
+
+    @classmethod
+    def algorithm_add(cls, request_dict, response):
+        pass
+        return response.json(0)
+
+    @classmethod
+    def algorithm_update(cls, request_dict, response, api_version):
+        try:
+            a_id = request_dict.get('aId', None)
+            lang = request_dict.get('lang', None)
+            title = request_dict.get('title', None)
+            subtitle = request_dict.get('subtitle', None)
+            introduction = request_dict.get('introduction', None)
+            install_explain = request_dict.get('installExplain', None)
+            concerning = request_dict.get('concerning', None)
+            risk_warning = request_dict.get('riskWarning', None)
+            if not all([a_id, lang]):
+                return response.json()
+            a_explain_qs = DeviceAlgorithmExplain.objects.filter(algorithm_type_id=int(a_id), lang=lang)
+            if not a_explain_qs.exists():
+                return response.json(173)
+            data = {}
+            if title:
+                data['title'] = title
+            if subtitle:
+                data['subtitle'] = subtitle
+            if introduction:
+                data['introduction'] = introduction
+            if install_explain:
+                data['install_explain'] = install_explain
+            if concerning:
+                data['concerning'] = concerning
+            if risk_warning:
+                data['risk_warning'] = risk_warning
+            a_explain_qs.update(**data)
+            return response.json(0)
+        except Exception as e:
+            print(repr(e))
+            return response.json(500)

+ 4 - 4
Object/ETkObject.py

@@ -59,10 +59,10 @@ class ETkObject(object):
             ss += characterSet[random.randint(0, length)]
         return ss
 
-
-# etkObj = ETkObject(etk='')
-# PP = etkObj.encrypt('jLBDSU9547NTRSMF111A')
-# print('encode_data:')
+if __name__ == '__main__':
+    etkObj = ETkObject(etk='')
+    etk = etkObj.encrypt('Z4X5B1F3LCGJ6W9T111A')
+    print(etk)
 # print(PP)
 # print('decode_data:')
 # eobj = ETkObject(etk=PP)

+ 2 - 2
Object/RedisObject.py

@@ -1,7 +1,7 @@
 import redis
-from Ansjer.config import SERVER_HOST
+# from Ansjer.config import SERVER_HOST
 # 本地调试把注释打开
-# SERVER_HOST = '127.0.0.1'
+SERVER_HOST = '127.0.0.1'
 
 
 class RedisObject:

+ 45 - 0
Object/utils/LocalDateTimeUtil.py

@@ -268,3 +268,48 @@ def time_format_date(timestamp, tz):
     # 格式化日期时间字符串
     formatted_date = dt.strftime('%Y-%m-%d %H:%M:%S')
     return formatted_date
+
+
+if __name__ == '__main__':
+
+    print(time_format_date(int(time.time()), '+01:00'))
+
+
+    zero_today, last_today = get_today_date(True)
+    month_end = get_cur_month_end()
+    start_time, month_end_time = get_start_and_end_time(month_end, '%Y-%m-%d')
+    print(zero_today)
+    print(month_end_time)
+
+    # # 获取当前月
+    # print('当前月', get_cur_month())
+    # # 获取上一个月
+    # print('上一个月', get_last_month_num())
+    # # 获取上两个月
+    # print('上两个月', get_last_month_num(number=2))
+    # # 获取下一个月
+    # print('下一个月', get_next_month())
+    # # 获取下两个月
+    # print('下两个月', get_next_month(number=2))
+    # # 获取当前月的第一天
+    # print('当前月的第一天', get_cur_month_start())
+    # # 获取当前月的最后一天
+    # print('当前月的最后一天', get_cur_month_end())
+    # # 获取上个月的第一天
+    # print('上个月的第一天', get_last_month_start())
+    # # 获取下个月的第一天
+    # print('下个月的第一天', get_next_month_start())
+    # # 获取上个月的最后一天
+    # print('上个月的最后一天', get_last_month_end())
+    # # 获取下个月的最后一天
+    # print('下个月的最后一天', get_next_month_end())
+    dd = str(1650791368303)
+    print(dd[0:10])
+    print(dd[10:])
+    dateArray = datetime.datetime.utcfromtimestamp(1650791368)
+    print(dateArray.date())
+    next_start_time, next_end_time = get_start_and_end_time(get_next_month_start(), '%Y-%m-%d')
+    print(type(next_end_time))
+    print('下月开始时间{}'.format(next_start_time))
+    start_time, end_time = get_start_and_end_time(get_next_month_end(), '%Y-%m-%d')
+    print('下月结束时间{}'.format(end_time))