yf_csx %!s(int64=5) %!d(string=hai) anos
pai
achega
3267278e99
Modificáronse 6 ficheiros con 628 adicións e 3 borrados
  1. 1 0
      .gitignore
  2. 440 0
      apps/Home/allocation.py
  3. 2 1
      apps/Home/urls.py
  4. 149 2
      apps/Home/views.py
  5. 10 0
      templates/static/web.config
  6. 26 0
      web.config

+ 1 - 0
.gitignore

@@ -73,3 +73,4 @@ docs/_build/
 /crop_photo/
 /sightsee_photos/
 /user_photo/
+*.config

+ 440 - 0
apps/Home/allocation.py

@@ -0,0 +1,440 @@
+
+#普通用户默认基本配置
+ordinary = [{
+		"id": 1,
+		"title": "首页",
+		"icon": "",
+		"url": "map",
+		"children": []
+	},
+	{
+		"id": 3,
+		"title": "信息发布",
+		"icon": "",
+		"url": "",
+		"children": [{
+				"id": 3.1,
+				"title": "新闻资讯",
+				"url": "news_pub",
+			},
+			{
+				"id": 3.2,
+				"title": "视频资讯",
+				"url": "video_pub",
+			},
+			{
+				"id": 3.2,
+				"title": "产品展厅",
+				"url": "equip_pub",
+			},
+			{
+				"id": 3.3,
+				"title": "四季采摘",
+				"url": "garden_pub",
+			},
+			{
+				"id": 3.4,
+				"title": "民宿导览",
+				"url": "dorm_pub",
+			},
+			{
+				"id": 3.5,
+				"title": "旅游景点",
+				"url": "sightsee_pub",
+			},
+		]
+	},
+	{
+		"id": 4,
+		"title": "我的发布",
+		"icon": "",
+		"url": "my_pub",
+		"children": []
+	},
+	{
+		"id": 8,
+		"title": "开心农场",
+		"icon": "",
+		"url": "",
+		"children": [{
+				"id": 8.1,
+				"title": "我的农场",
+				"url": "person_farm_edit",
+			},
+			{
+				"id": 8.2,
+				"title": "农场管理",
+				"url": "garden_manage_view",
+			},
+			{
+				"id": 8.4,
+				"title": "库存管理",
+				"url": "repertory_view",
+			},
+			{
+				"id": 8.5,
+				"title": "种植管理",
+				"url": "cropcount",
+			},
+			{
+				"id": 8.6,
+				"title": "入库管理",
+				"url": "pick",
+			},
+			{
+				"id": 8.7,
+				"title": "销售管理",
+				"url": "sell_view",
+			}
+		]
+	},
+	{
+		"id": 9,
+		"title": "数据中心",
+		"icon": "",
+		"url": "",
+		"children": [{
+				"id": 9.1,
+				"title": "产业数据",
+				"url": "industrydata",
+			},
+			{
+				"id": 9.2,
+				"title": "类型分析",
+				"url": "type",
+			},
+			{
+				"id": 9.3,
+				"title": "对比分析",
+				"url": "contrast",
+			},
+		]
+	},
+	{
+		"id": 13,
+		"title": "系统设置",
+		"icon": "",
+		"url": "",
+		"children": [{
+			"id": 13.2,
+			"title": "地图设置",
+			"url": "setMap",
+		}, ]
+	},
+	{
+		"id": 14,
+		"title": "专家诊断",
+		"icon": "",
+		"url": "",
+		"children": [{
+			"id": 14.1,
+			"title": "在线专家",
+			"url": "expert",
+			"disabled": "true",
+		}, ]
+	},
+]
+
+
+
+
+#管理员权限
+administrators = [
+    {
+        "id": 1,
+        "title": "首页",
+        "icon": "",
+        "url": "map",
+        "children": []
+    },
+    {
+        "id": 2,
+        "title": "设备分配",
+        "icon": "",
+        "url": "equipallot",
+        "disabled": "true",
+        "children": []
+    },
+    {
+        "id": 3,
+        "title": "信息发布",
+        "icon": "",
+        "url": "",
+        "children": [
+            {
+                "id": 3.1,
+                "title": "新闻资讯",
+                "url": "news_pub",
+            },
+            {
+                "id": 3.2,
+                "title": "视频资讯",
+                "url": "video_pub",
+            },
+            {
+                "id": 3.2,
+                "title": "产品展厅",
+                "url": "equip_pub",
+            },
+            {
+                "id": 3.3,
+                "title": "四季采摘",
+                "url": "garden_pub",
+            },
+            {
+                "id": 3.4,
+                "title": "民宿导览",
+                "url": "dorm_pub",
+            },
+            {
+                "id": 3.5,
+                "title": "旅游景点",
+                "url": "sightsee_pub",
+            },
+        ]
+    },
+    {
+        "id": 4,
+        "title": "我的发布",
+        "icon": "",
+        "url": "my_pub",
+        "children": []
+    },
+    {
+        "id": 5,
+        "title": "视频监控",
+        "icon": "",
+        "url": "jkview",
+        "children": []
+    },
+    {
+        "id": 6,
+        "title": "传感及控制",
+        "icon": "",
+        "url": "",
+        "children": [
+            {
+                "id": 6.1,
+                "title": "控制模块",
+                "url": "qxzcontrol",
+            },
+            {
+                "id": 6.2,
+                "title": "趋势分析",
+                "url": "qxzchart",
+            },
+            {
+                "id": 6.3,
+                "title": "数据统计",
+                "url": "qxz_status",
+            }
+        ]
+    },
+    {
+        "id": 7,
+        "title": "预警中心",
+        "icon": "",
+        "url": "",
+        "children": [
+            {
+                "id": 7.1,
+                "title": "阈值设置",
+                "url": "qxz_warning_view",
+            },
+            {
+                "id": 7.2,
+                "title": "生产方式设置",
+                "url": "productionset",
+            },
+            {
+                "id": 7.3,
+                "title": "预警记录",
+                "url": "qxz_warning_list",
+            },
+        ]
+    },
+    {
+        "id": 8,
+        "title": "开心农场",
+        "icon": "",
+        "url": "",
+        "children": [
+            {
+                "id": 8.1,
+                "title": "我的农场",
+                "url": "person_farm_edit",
+            },
+            {
+                "id": 8.2,
+                "title": "农场管理",
+                "url": "garden_manage_view",
+            },
+            {
+                "id": 8.4,
+                "title": "库存管理",
+                "url": "repertory_view",    
+            },
+            {
+                "id": 8.5,
+                "title": "种植管理",
+                "url": "cropcount",
+            },
+            {
+                "id": 8.6,
+                "title": "入库管理",
+                "url": "pick",
+            },
+            {
+                "id": 8.7,
+                "title": "销售管理",
+                "url": "sell_view",
+            }
+        ]
+    },
+    {
+        "id": 9,
+        "title": "数据中心",
+        "icon": "",
+        "url": "",
+        "children": [
+            {
+                "id": 9.1,
+                "title": "产业数据",
+                "url": "industrydata",
+            },
+            {
+                "id": 9.2,
+                "title": "类型分析",
+                "url": "type",
+            },
+            {
+                "id": 9.3,
+                "title": "对比分析",
+                "url": "contrast",
+            },
+        ]
+    },
+    {
+        "id": 10,
+        "title": "通知公告",
+        "icon": "",
+        "url": "",
+        "disabled": "true",
+        "children": [
+            {
+                "id": 10.1,
+                "title": "发布公告",
+                "url": "policy_pub",
+                "disabled": "true",
+            },
+            {
+                "id": 10.2,
+                "title": "查看公告",
+                "url": "policy_list_view",
+                "disabled": "true",
+            },
+        ]
+    },
+    {
+        "id": 11,
+        "title": "信息审核",
+        "icon": "",
+        "url": "",
+        "disabled": "true",
+        "children": [
+            {
+                "id": 11.1,
+                "title": "新闻资讯",
+                "url": "news_check",
+                "disabled": "true",
+            },
+
+            {
+                "id": 11.2,
+                "title": "视频资讯",
+                "url": "video_check",
+                "disabled": "true",
+            },
+            {
+                "id": 11.3,
+                "title": "产品展厅",
+                "url": "equip_check",
+                "disabled": "true",
+            },
+            {
+                "id": 11.4,
+                "title": "四季采摘",
+                "url": "garden_check",
+                "disabled": "true",
+            },
+            {
+                "id": 11.5,
+                "title": "民宿导览",
+                "url": "dorm_check",
+                "disabled": "true",
+            },
+            {
+                "id": 11.6,
+                "title": "旅游景点",
+                "url": "sightsee_check",
+                "disabled": "true",
+            },
+            {
+                "id": 11.7,
+                "title": "个人农场",
+                "url": "farm_check",
+                "disabled": "true",
+            },
+        ]
+    },
+    {
+        "id": 12,
+        "title": "权限",
+        "icon": "",
+        "url": "limit_view",
+        "disabled": "true",
+        "children": []
+    },
+    {
+        "id": 13,
+        "title": "系统设置",
+        "icon": "",
+        "url": "",
+        "disabled": "true",
+        "children": [
+            {
+                "id": 13.1,
+                "title": "用户管理",
+                "url": "person_view",
+                "disabled": "true",
+            },
+            {
+                "id": 13.2,
+                "title": "地图设置",
+                "url": "setMap",
+                "disabled": "true",
+            },
+            {
+                "id": 13.3,
+                "title": "合作伙伴",
+                "url": "add_relation",
+                "disabled": "true",
+            }
+        ]
+    },
+    {
+        "id": 14,
+        "title": "专家诊断",
+        "icon": "",
+        "url": "",
+        "disabled": "true",
+        "children": [
+            {
+                "id": 14.1,
+                "title": "在线专家",
+                "url": "expert",
+                "disabled": "true",
+            },
+        ]
+    },
+]

+ 2 - 1
apps/Home/urls.py

@@ -1,6 +1,6 @@
 from django.conf.urls import url
 from django.views.static import serve
-from apps.Home.views import Home_Test,Home,Login_View,Login2_View,ForgetPaw_View,register_View,Modify_Head ,User_Img,User_News,User_Land,User_Check,Prove_Code,Reset_Password
+from apps.Home.views import Home_Test,Home,Login_View,Login2_View,ForgetPaw_View,register_View,Modify_Head ,User_Img,User_News,User_Land,User_Check,Prove_Code,Reset_Password,Log_Verify
 from . import views
 
 app_name = 'Home'
@@ -23,4 +23,5 @@ urlpatterns = [
     url(r'^prove_code$',Prove_Code.as_view(), name='prove_code'),#注册账号
     url(r'^reset_password$',Reset_Password.as_view(), name='reset_password'),#重置密码
     url(r'^logout$', views.logout, name='logout'),
+    url(r'^log_verify$',Log_Verify.as_view(), name='log_verify'),#登陆校验
 ]

+ 149 - 2
apps/Home/views.py

@@ -30,11 +30,155 @@ from apps.AppInfo.models import Equip, Equip_type, MyUser, QXZdata, QXZstatus, Q
 Product, Pick_Pub, FarmList, Hotel_Info, GardenArea, Sightsee_Info,Hotel_Info, Relations
 from qcloudsms_py import SmsSingleSender
 from qcloudsms_py.httpclient import HTTPError
-
+import requests
 from django.utils.decorators import method_decorator
-
+from .allocation import administrators,ordinary
 # Create your views here.
 
+"""
+appkey 和 AppSecret
+1、先调用我们开放的接口,获取 userid和code
+2、然后使用userid 和code 带上appkey 和 AppSecret 请求客户提供的接口地址,获取用户信息
+3、根据返回的数据进行判断是否登陆
+"""
+
+
+"""
+{
+	"timestamp": "2020-09-04 10:04:37",
+	"status": 404,
+	"error": "Not Found",
+	"message": "No message available",
+	"path": "/ducore//oauth/oauthLogin/oauthLogin/"
+}
+
+
+{
+	"success": true,
+	"message": "操作成功!",
+	"code": 200,
+	"result": {
+		"address": "",
+		"sex": 1,
+		"telephone": "",
+		"avatar": "files/20200902/3184478c3fe1ae8c6e2aa3828a6e62c_1599017263910.jpg",
+		"isAdmin": "N",
+		"delFlag": "0",
+		"realname": "黄豪",
+		"workNo": "11111",
+		"kodaE": "",
+		"post": "",
+		"phone": "15959191107",
+		"identity": "",
+		"orgCode": "A01A03",
+		"kodaPassword": "888888",
+		"id": "5b75626a-1559-4596-aca5-3dcfaa736254",
+		"kodaUsername": "0591002000007",
+		"kodaId": "0591002000007",
+		"email": "",
+		"status": 1,
+		"username": "15959191107"
+	},
+	"timestamp": 1599184606585
+}
+"""
+
+app_key = "u8dF3opl0xCq1a"
+app_secret = "Qz4jLdSisLDzyDxCdog7"
+urls = "http://10.10.0.227:17022/ducore/oauth/oauthLogin/oauthLogin/" 
+# url = "http://47.104.218.216:80/tests"
+# url = ""
+headers = {"app_key":app_key,"app_secret":app_secret}
+#登陆校验
+class Log_Verify(View):
+    def get(self,request):
+        user_news = CKArticle.objects.filter(art_type=5)[0:10]
+        zero_news = CKArticle.objects.filter(art_type=0)[0:10]
+        one_news = CKArticle.objects.filter(art_type=1)[0:10]
+        two_news = CKArticle.objects.filter(art_type=2)[0:10]
+        video_news = Video_data.objects.all()[0:4]
+        product = Product.objects.all()[0:8]
+        pick = Pick_Pub.objects.filter(hidden=True)[0:8]
+        farm = FarmList.objects.all()[0:8]
+        garden = GardenArea.objects.filter(hidden=True)[0:6]
+        hotel = Hotel_Info.objects.filter(hidden=True)[0:6]
+        article = CKArticle.objects.filter(hidden=True)[0:12]
+        sightsee = Sightsee_Info.objects.filter(hidden=True)[0:6]
+        hotel2 = Hotel_Info.objects.filter(hidden=True).order_by('-upl_time')[0:6]
+        relation = Relations.objects.all()
+
+        userId = request.GET.get("userId")
+        print("userId",userId)
+        code = request.GET.get("code")
+        print("code",code)
+        data = {"userId":userId,"code":code}
+        data = json.dumps(data)
+        url = urls + userId + "/" + code
+        res = requests.post(url,headers=headers)
+        rest = json.loads(res.text)
+        #校验登陆是否成功
+        try:
+            code  = rest["code"]
+        except:
+            code = 400
+        if code == 200:
+            username = rest["result"]["username"]
+            try:
+                curr_user = MyUser.objects.get(username=username)
+            except:
+                curr_user = ""
+            isadmin = rest["result"]["isAdmin"]
+            # 普通用户
+            if isadmin == "N":
+                limit = ordinary
+                num = 1
+
+            # 管理员
+            else:
+                limit = administrators
+                num = 2
+
+            # 设置默认密码
+            password = "qwerdf123456"
+
+            # 修改
+            if curr_user:
+                curr_user.user_remark = rest["result"]["realname"]
+                curr_user.user_picture = rest["result"]["avatar"]
+                curr_user.user_phone = rest["result"]["phone"]
+                curr_user.save()
+
+            # 新增
+            else:
+                if num == 1:
+                    # 普通用户
+                    MyUser.objects.create_user(
+                        user_remark = rest["result"]["realname"],
+                        user_picture = rest["result"]["avatar"],
+                        user_phone = rest["result"]["phone"],
+                        username = rest["result"]["username"],
+                        password=password,
+                        limit=limit
+                    )
+                else:
+                    # 管理员
+                    MyUser.objects.create_user(
+                        user_remark = rest["result"]["realname"],
+                        user_picture = rest["result"]["avatar"],
+                        user_phone = rest["result"]["phone"],
+                        username = rest["result"]["username"],
+                        password=password,
+                        limit=limit,
+                        is_superuser=1,
+                        is_staff=1
+                    )
+            request.session['username'] = username
+            return render(request, 'outerNet/index2.html', context={"user_news": user_news,"zero_news": zero_news, "one_news": one_news,"article":article,"relation":relation,
+                                                               "two_news": two_news, "video_news": video_news,"hotel":hotel,"garden":garden,"hotel2":hotel2,
+                                                               "product": product, "pick": pick, "farm": farm, "curr_user": curr_user,"sightsee":sightsee})
+        else:
+            return HttpResponse("1")
+
 
 class Home_Test(View):
     def get(self, request):
@@ -122,6 +266,9 @@ class Login2_View(View):
     def post(self, request):
         pass
 
+
+
+
 # 注册
 class ForgetPaw_View(View):
     def get(self, request):

+ 10 - 0
templates/static/web.config

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <configuration>
+      <system.webServer>
+      <!-- this configuration overrides the FastCGI handler to let IIS serve the static files -->
+      <handlers>
+        <clear/>
+   <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
+     </handlers>
+   </system.webServer>
+</configuration>

+ 26 - 0
web.config

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <configuration>
+        <system.webServer>
+            <defaultDocument>
+            <files>
+                <remove value="default.aspx" />
+                <remove value="iisstart.htm" />
+                <remove value="Default.asp" />
+                <remove value="Default.htm" />
+                <add value="index.php" />
+            </files>
+            </defaultDocument>
+
+            <handlers>
+                <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\python\python.exe|c:\python\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
+            </handlers>
+        </system.webServer>
+        <appSettings>
+            <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
+            <add key="PYTHONPATH" value="C:\webproject\second" />
+            <add key="DJANGO_SETTINGS_MODULE" value="second_pro.settings" />
+        </appSettings>
+    <system.web>
+        <identity impersonate="true" />
+    </system.web>
+    </configuration>