💕💕作者:计算机源码社
💕💕个人简介:本人 八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!
1、研究背景
随着数字化时代的到来,传统纸质书籍正逐渐让位于电子书。然而,现有的电子书平台往往存在用户体验不佳、功能单一、作者权益保护不足等问题。同时,移动互联网的普及和5G技术的发展,为在线阅读带来了新的机遇和挑战。用户对于随时随地获取优质内容的需求日益增长,而作者也渴望一个能够充分展示才华并获得合理回报的平台。在这样的背景下,开发一个功能全面、体验优异的电子书在线阅读平台成为了市场的迫切需求。
2、研究目的和意义
本电子书在线阅读平台的开发旨在打造一个集阅读、听书、创作、社交于一体的综合性文学平台。通过整合先进的技术框架如Java、Spring Boot、Vue和MySQL,我们致力于为用户提供流畅的阅读体验和丰富的互动功能。平台将支持多角色管理,包括管理员、用户和作者,以满足不同群体的需求。我们的目标是建立一个生态完整的文学社区,让读者能够方便地发现喜爱的作品,让作者拥有展示才华的舞台,同时为管理员提供高效的内容管理工具。通过这个平台,我们希望能够推动数字阅读的普及,促进文学创作的繁荣。
开发这样一个电子书在线阅读平台具有深远的社会和文化意义=,它将大大提高优质文学作品的可访问性,让更多人能够便捷地获取知识和享受阅读的乐趣,从而推动全民阅读的风气。=通过提供多样化的功能如免费试读、听书和评论等,平台能够满足不同用户的阅读需求,培养新的阅读习惯。对于作者而言,这个平台提供了一个直接面向读者的发布渠道,有助于发掘新兴人才,促进文学创作的多元化发展。=平台的社交功能将有助于形成活跃的读者社区,促进文学交流和讨论。从长远来看,这个平台的成功将对推动数字出版产业的发展、保护知识产权、促进文化传播起到积极作用。
3、系统研究内容
系统功能:
1)管理员:登录、用户管理、作者管理、电子书分类管理、电子书管理、小说听书管理、公告管理、书架管理。
2)用户:注册、登录、小说排行、搜索电子书、点赞、收藏、评论、加入书架、免费试读、听书、下载、充值、查看公告。
3)作者:登录、个人信息管理、上传电子书、查看评论。
4、系统页面设计
5、参考文献
[1]Wang Q ,Esquivel A J .A Reinforcement Learning Based on Book Recommendation System[J].Academic Journal of Computing & Information Science,2023,6(13):1-13.
[2]刘烨.HD书城市场营销策略研究[D].河北科技大学,2023.
[3]许捷,琚森超.基于推荐系统的网上书城的研究进展综述[J].电脑知识与技术,2023,19(02):63-65.
[4]马海珠.基于ThinkPHP框架的网上书城设计与实现[J].信息技术与信息化,2022,(08):109-112.
[5]陈超.基于SSM的网上书城销售管理系统的设计与实现[D].北京邮电大学,2022.
[6]张昭.数字出版背景下电子书平台运营模式及发展趋势探究[J].中国编辑,2022,(05):76-80.
[7]邢明钢,王浩,李娟.基于SSM的电子书架微信小程序的设计与实现[J].电子技术与软件工程,2022,(08):65-69.
[8]吴保升,邵倩.基于JavaEE的网上书城系统设计[J].信息技术与信息化,2021,(11):58-61.
[9]牛希镭.基于JavaWeb的在线图书商城设计与实现[J].电子测试,2021,(01):73-75.
[10]吴杏平,曹雪.Web全栈项目开发入门与实战[M].人民邮电出版社:202009.451.
[11]You X .Architecture and Research of Smart Book Management System Based on Artificial Intelligence Technology[J].International Journal of New Developments in Engineering and Society,2020,4(2):36-55.
[12]Yan Z .Design and Implementation of Children’s Book Management System Based on Asp.Net Technology[J].Journal of Physics Conference Series,2020,1544(1):12-42.
[13]邓明杨,李忠雄.基于JAVA Web技术的网上书城的设计与实现[J].计算机产品与流通,2020,(05):159-160.
[14]陈刚.基于云知识库的图书荐购系统[J].大学图书情报学刊,2020,38(02):113-116+123.
[15]史展伟,曲秀敏.基于Web的网上书城设计与实现[J].电脑知识与技术,2020,16(02):278-279.
6、核心代码
<?php
session_start();
class DiscussremenxiaoshuoController 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','addtime'
,'refid'
,'userid'
,'avatarurl'
,'nickname'
,'content'
,'reply'
];
/**
* 分页,列表
* 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'=>401,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$where = " where 1 ";//查询条件
$orwhere = '';
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
if ($val != ''){
$where.= " and ".$k." like '".$val."'";
}
}
}
$sql = "select * from `discussremenxiaoshuo` ".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$where .= empty($orwhere) ? '' : "and (".$orwhere.")";
$lists = "select * from `discussremenxiaoshuo` ".$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(){
$sql = "select * from `discussremenxiaoshuo`";
$result = table_sql($sql);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' =>$arrayData
]));
}
/**
* 分页,列表list
* get
*/
public function list(){
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
$refid = isset($_REQUEST['refid']) ? $_REQUEST['refid'] : "0";
$where = " where 1 ";//查询条件
if(isset($_REQUEST['goodid'])) {
$where .= " and goodid = ".$_REQUEST['goodid']." ";
}
$sorts = explode(",", $sort);
$orders = explode(",", $order);
$sortorders = "";
foreach ($sorts as $index => $value) {
if($index == count($sorts)-1){
$sortorders =$sortorders.$value." ".$orders[$index];
}else{
$sortorders =$sortorders.$value." ".$orders[$index].",";
}
}
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
$where.= " and ".$k." like '".$val."'";
}
}
$sql = "select * from `discussremenxiaoshuo`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$lists = "select * from `discussremenxiaoshuo` ".$where." order by ".$sortorders." 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'=>401,'msg'=>"你还没有登录。"]));
$uid = $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) {
if ($key == 'id') {
continue;
}
array_push($keyArr,"`".$key."`");
if($key == 'clicktime') {
array_push($valArr,"'".date('Y-m-d h:i:s', time())."'");
} else {
array_push($valArr,"'".$value."'");
}
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `discussremenxiaoshuo` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 新增数据接口 add
* post
*/
public function add(){
$keyArr = $valArr = array();
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你还没有登录。"]));
$uid = $tokens['id'];
$tmpData = strval(file_get_contents("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) {
if ($key == 'id') {
continue;
}
array_push($keyArr,"`".$key."`");
if($key == 'clicktime') {
array_push($valArr,"'".date('Y-m-d h:i:s', time())."'");
} else {
array_push($valArr,"'".$value."'");
}
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `discussremenxiaoshuo` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 更新接口
* post
*/
public function update(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>401,'msg'=>"你还没有登录。"]));
$uid = $tokens['id'];
$tmpData = strval(file_get_contents("php://input"));
$postData = json_decode($tmpData,true);
$v = array();
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if ($key == "id"){
$id = $value;
}
if(!empty($value) || $value === 0) {
array_push($v,$key." = '".$value."'");
}
}
}
$value = implode(',',$v);
$sql = "UPDATE discussremenxiaoshuo SET ".$value." where id = ".$id;
$result = table_sql($sql);
exit(json_encode(['code'=>0]));
}
/**
* 删除
* post
*/
public function delete(){
$ids = strval(file_get_contents("php://input"));//发现接收的是字符串
preg_match_all('/\d+/',$ids,$arr);
$str = implode(',',$arr[0]);//拼接字符,
$sql = "delete from discussremenxiaoshuo WHERE id in({$str})";
$result = table_sql($sql);
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'=>401,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if (!empty($id)){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `discussremenxiaoshuo` where ".$where;
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
/**
* 查询一条数据
* get
*/
public function detail($id=false){
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if ($id){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `discussremenxiaoshuo` where ".$where;
$result = table_sql($sql);
if (!$result) exit(json_encode(['code'=>500,'msg'=>"查询数据发生错误。"]));
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
/**
* 按值统计接口
**/
public function value(){
$url = explode('?',$_SERVER['REQUEST_URI']);
$request = explode('/',$url[0]);
$xColumnName = $request[4];
$yColumnName = $request[5];
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$sql = "SELECT ".$xColumnName.",sum(".$yColumnName.") total FROM discussremenxiaoshuo ".$where." group by ".$xColumnName;
if(urldecode($request[6]) == '日') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') ".$xColumnName.", sum(".$yColumnName.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m-%d')";
}
if(urldecode($request[6]) == '月') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m') ".$xColumnName.", sum(".$yColumnName.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m')";
}
if(urldecode($request[6]) == '年') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y') ".$xColumnName.", sum(".$yColumnName.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y')";
}
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 输出数据
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => intval($row['total']),$xColumnName => $row[$xColumnName]));
}
}
exit(json_encode(['code'=>0,'data'=>$total]));
}
/**
* (按值统计)时间统计类型(多)
**/
public function valueMul(){
$url = explode('?',$_SERVER['REQUEST_URI']);
$request = explode('/',$url[0]);
$xColumnName = $request[4];
$yColumnName = isset($_REQUEST['yColumnNameMul'])? $_REQUEST['yColumnNameMul']:"";
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$valueData = array();
foreach(explode(",", $yColumnName) as $item){
$sql = "SELECT ".$xColumnName.",sum(".$item.") total FROM discussremenxiaoshuo ".$where." group by ".$xColumnName." LIMIT 10";
if(urldecode($request[6]) == '日') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') ".$xColumnName.", sum(".$item.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m-%d') LIMIT 10";
}
if(urldecode($request[6]) == '月') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y-%m') ".$xColumnName.", sum(".$item.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y-%m') LIMIT 10";
}
if(urldecode($request[6]) == '年') {
$sql = "SELECT DATE_FORMAT(".$xColumnName.", '%Y') ".$xColumnName.", sum(".$item.") total FROM discussremenxiaoshuo ".$where." GROUP BY DATE_FORMAT(".$xColumnName.", '%Y') LIMIT 10";
}
$result = table_sql($sql);
if ($result->num_rows > 0) {// 输出数据
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => intval($row['total']),$xColumnName => $row[$xColumnName]));
}
$valueData[] = $total;
}
}
exit(json_encode(['code'=>0,'data'=>$valueData]));
}
/**
* 获取需要提醒的记录数接口
* get
*/
public function remind($columnName,$type){
$remindStart = isset($_GET['remindstart'])?$_GET['remindstart']:"";
$remindEnd = isset($_GET['remindend'])?$_GET['remindend']:"";
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";//查询条件
if ($type == 1){//数字
if ($remindStart && $remindEnd){
$where .= " and ".$columnName."<='".$remindEnd."' and ".$columnName.">='".$remindStart."'";
}elseif($remindStart){
$where .= " and ".$columnName.">='".$remindStart."'";
}elseif($remindEnd){
$where .= " and ".$columnName."<='".$remindEnd."'";
}
}else{
if ($remindStart && $remindEnd){
$where .= " and ".$columnName."<='".date("Y-m-d",strtotime("+".$remindEnd." day"))."' and ".$columnName.">='".date("Y-m-d",strtotime("+".$remindStart." day"))."'";
}elseif($remindStart){
$where .= " and ".$columnName.">='".date("Y-m-d",strtotime("+".$remindStart." day"))."'";
}elseif($remindEnd){
$where .= " and ".$columnName."<='".date("Y-m-d",strtotime("+".$remindEnd." day"))."'";
}
}
$sql = "select * from `discussremenxiaoshuo` ".$where;
$result = table_sql($sql);
exit(json_encode(['code'=> 0 ,'count' => $result->num_rows]));
}
public function group($columnName){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
$where = " where 1 ";
$sql = "SELECT ".$columnName.",count(".$columnName.") as total FROM discussremenxiaoshuo ".$where." GROUP BY ".$columnName." ORDER BY $columnName asc";
$result = table_sql($sql);
if ($result->num_rows > 0) {
// 输出数据
$total = array();
while($row = $result->fetch_assoc()) {
array_push($total,array('total' => $row['total'],$columnName => $row[$columnName]));
}
}
exit(json_encode(['code'=>0,'data'=>$total]));
}
}