【毕业设计源码】基于Python的校园生活助手(二手+活动+论坛+新闻)信息系统

目录

一、程序介绍:

三、文档目录:

四、运行截图:

五、数据库表:

六、代码展示:

七、更多学习目录:

八、互动留言


一、程序介绍:

  1. 文档:开发技术文档、参考LW、答辩PPT,部分项目另有其他文档
  2. 开发环境:Pytharm(python3.7以上)丨微信开发者工具丨navicat12丨mysql5.7
  3. 配套工具:涉及项目开发运行的全部软件均提供
  4. 项目运行视频或截图:提供
  5. 运行电脑配置要求:内存≥8G,  CPU  i3及以上
  6. 运行教学:指导
  7. 项目修改教学:有
  8. 代码讲解:代码结构讲解

三、文档目录:

四、运行截图:

 

五、数据库表:

六、代码展示:

from app.service import service_select
from app.core.mysql import MysqlPool
import json
import csv
import ast
import os

mysqlPool = MysqlPool()


# 帮助方法,合并对象
def obj_update(*config):
	config_temp = {}
	for o in config:
		config_temp.update(o)
	return config_temp


# 权限集合
dict_auth = {}


# 控制器父类
class Controller:
	def __init__(self, config):
		"""
		构造函数
		@param {Dictionary} config 配置参数
		"""
		# 配置参数
		self.config = config or {}
		# 添加服务
		self.service = service_select(self.config["service"])
		cg = {
			# 选择的模板那路径模板
			"tpl":
			"./index/",
			# 选择的服务
			"service":
			"user",
			# 注册get请求路由
			"get": ["list", "view", "table"],
			# 注册post请求路由
			"post": [],
			# 注册get api路由
			"get_api": [
				"del",
				"get_list",
				"get_obj",
				"count",
				"count_group",
				"sum",
				"sum_group",
				"avg",
				"avg_group",
				"list_group",
				"bar_group",
				"get_hits_list"
			],
			# 注册post api路由
			"post_api": ["add", "del", "set", "import_db", "export_db", "upload"],
			"interact": [],
			"unique": []
		}
		if config:
			if "interact" in config:
				config["interact"].extend(cg["interact"])
			else:
				config["interact"] = cg["interact"]
			if "get" in config:
				config["get"].extend(cg["get"])
			else:
				config["get"] = cg["get"]
			if "post" in config:
				config["post"].extend(cg["post"])
			else:
				config["post"] = cg["post"]
			if "get_api" in config:
				config["get_api"].extend(cg["get_api"])
			else:
				config["get_api"] = cg["get_api"]
			if "post_api" in config:
				config["post_api"].extend(cg["post_api"])
			else:
				config["post_api"] = cg["post_api"]
			if "unique" in config:
				config["unique"].extend(cg["unique"])
			else:
				config["unique"] = cg["unique"]

	# 公共模型,用于在render()为传递模板数据补充
	def model(self, ctx, model):
		m = {}
		m.update(model)
		#
		# model_temp.user = ctx.session.user

		# 获取导航
		service = service_select("nav")
		m["nav_top"] = service.Get_list({"location": "top"})
		m["nav_side"] = service.Get_list({"location": "side"})
		m["nav_foot"] = service.Get_list({"location": "foot"})

		# 获取轮播图
		service = service_select("slides")
		m["list_slides"] = service.Get_list({})

		# 获取公告
		service = service_select("notice")
		m["list_notice"] = service.Get_list({},
											{"orderby": "`update_time` desc"})

		# 交互模型接口
		if ("interact" in self.config) and self.config["interact"]:
			m = self.model_interact(ctx, m)

		m["query"] = ctx.query
		m["body"] = ctx.body
		m["auth"] = ctx.auth

		return m

	# 交互对象
	def interact_obj(self, ctx, o):
		interact = self.config["interact"]
		if interact:
			source_table = service_select(
				self.config["service"]).config["table"]
			source_field = source_table + "_id"
			# 评论
			if "comment" in interact:
				service = service_select("comment")
				source_id = o[source_field]
				o["comment_list"] = service.Get_list(
					{
						"source_table": source_table,
						"source_field": source_field,
						"source_id": source_id
					}, {
						"page": 1,
						"size": 10,
					})
				o["comment_len"] = service.Count({
					"source_table": source_table,
					"source_field": source_field,
					"source_id": source_id,
				})
			# 评分
			if "score" in interact:
				service = service_select("score")
				source_id = o[source_field]
				o["score_list"] = service.Get_list(
					{
						"source_table": source_table,
						"source_field": source_field,
						"source_id": source_id
					}, {
						"page": 1,
					
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值