💖💖更多项目资源,最下方联系IT实战课堂✨✨✨✨✨✨
博主拥有多年的T技术研发项目架构和教学经验,优快云/51CTO/腾讯课堂等平台优质作者、高级讲师,培训机构联合创始人!现专注项目定制Java、小程序、前端网页、Python、App、NodeJs、PHP、微服务、NET等远程部署、售后答疑、文档编写指导等。
目录
一、项目技术介绍
软件开发环境及开发工具:
后台语言:PHP
安卓框架:Uniapp
JDK版本:JDK1.8
服务器:tomcat9.0
数据库:mysql 5.7
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
本系统功能完整,适合作为毕业设计、课程设计、数据库大作业 参考 以及学习商用皆可。
下面是资料信息截图:
二、项目功能介绍
功能介绍:
随着网络技术水平的逐步提高,计算机系统的应用已延伸到社会的各个领域。所以人们把校园购物管理与现在网络相结合,利用计算机搭建校园购物网站。
校园购物网站的开发就是为了解决校园购物管理的问题,系统开发是基于Php语言前端编写实现,用Mysql数据库搭建存储校园购物网站的数据,实现前后端交互和页面动态效果。
实现后的校园购物网站基于PHP技术搭建的,系统主要包括:个人中心、用户管理、商品信息管理、二手商品管理、商品类型管理、留言板管理、系统管理、订单管理等基本功能。不仅能满足人们对于校园购物管理的需求,同时具有广阔的发展前景。
下面是系统运行起来后的一些截图:
三、相关代码
<?php
session_start();
class ConfigController extends CommonController {
public function __construct()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:Origin,Content-Type,Accept,token,X-Requested-With,device');
}
public $columData = [
'id','name','value'
];
/**
* 分页,列表
* get
*/
public function page(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$page = isset($_GET['page'])?$_GET['page']:"1";
$limt = isset($_GET['limit'])?$_GET['limit']:"10";
$sort = isset($_GET['sort'])?$_GET['sort']:"id";
$order = isset($_GET['order'])?$_GET['order']:"asc";
$where = "";//查询条件
$sql = "select * from `config`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 1;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*10;
$lists = "select * from `config` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 分页,列表list
* get
*/
public function lists(){
$page = isset($_GET['page'])?$_GET['page']:"1";
$limt = isset($_GET['limit'])?$_GET['limit']:"10";
$sort = isset($_GET['sort'])?$_GET['sort']:"id";
$order = isset($_GET['order'])?$_GET['order']:"asc";
$where = " where 1 ";//查询条件
$sql = "select * from `config`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 1;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*10;
$lists = "select * from `config` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 新增数据接口
* post
*/
public function save(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$keyArr = $valArr = array();
$tmpData = strval(file_get_contents("php://input"));//Content-Type: application/json 需要用到php://input 处理输入流
if (!empty($tmpData)&& isset($tmpData)){
$postData = json_decode($tmpData,true);
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if(!empty($value) || $value === 0) {
array_push($keyArr,"`".$key."`");
array_push($valArr,"'".$value."'");
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `config` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
if (!$result) exit(json_encode(['code'=>500,'msg'=>"新增失败"]));
exit(json_encode(['code'=>0]));
}
/**
* 更新接口
* post
*/
public function update(){
$tmpData = strval(file_get_contents("php://input"));
$postData = json_decode($tmpData,true);
$length = count($postData);
$v = array();
$i=0;
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if ($key == "id"){
$id = $value;
}
array_push($v,$key." = '".$value."'");
}
}
$value = implode(',',$v);
$sql = "UPDATE config SET ".$value." where id = ".$id;
$result = table_sql($sql);
if (!$result) echo json_encode(['code'=>500,'msg'=>"修改失败"]);
exit(json_encode(['code'=>0]));
}
/**
* 查询一条数据
* get
*/
public function info($id=false){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if (!empty($id)){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `config` where ".$where;
$result = table_sql($sql);
if (!$result) echo json_encode(['code'=>500,'msg'=>"查询数据发生错误。"]);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
}
资料获取
💖💖更多项目资源,最下方联系我们✨✨✨IT实战课堂官网✨✨✨