Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aimeiyue
service
Commits
f6a3d8a2
Commit
f6a3d8a2
authored
Sep 09, 2024
by
lizhilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
1d5d5949
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
193 additions
and
10 deletions
+193
-10
app/Admin/Controllers/CategoryController.php
+6
-6
app/Admin/Controllers/GoodController.php
+24
-0
app/Admin/Controllers/UserController.php
+1
-1
app/Http/Controllers/Api/ArticleController.php
+59
-0
app/Http/Controllers/Api/CategoryController.php
+2
-1
app/Http/Controllers/Api/CommentController.php
+67
-0
app/Http/Controllers/Api/CommentTplController.php
+21
-0
routes/api.php
+13
-2
No files found.
app/Admin/Controllers/CategoryController.php
View file @
f6a3d8a2
...
@@ -90,12 +90,12 @@ protected function form()
...
@@ -90,12 +90,12 @@ protected function form()
return
$v
??
0
;
return
$v
??
0
;
});
});
$form
->
text
(
'title'
);
$form
->
text
(
'title'
);
$form
->
image
(
'icon'
,
'分类图标'
)
//
$form->image('icon', '分类图标')
->
accept
(
'jpg,jpeg,png'
)
//
->accept('jpg,jpeg,png')
->
maxSize
(
4096
)
//
->maxSize(4096)
->
url
(
'upload/category'
)
//
->url('upload/category')
->
help
(
'仅支持jpg、jpeg、png格式图片上传(750px * 420px)'
)
//
->help('仅支持jpg、jpeg、png格式图片上传(750px * 420px)')
->
autoUpload
();
//
->autoUpload();
$form
->
text
(
'order'
)
->
help
(
'越小越靠前'
);
$form
->
text
(
'order'
)
->
help
(
'越小越靠前'
);
$form
->
switch
(
'show'
,
'状态'
)
->
default
(
1
);
$form
->
switch
(
'show'
,
'状态'
)
->
default
(
1
);
...
...
app/Admin/Controllers/GoodController.php
View file @
f6a3d8a2
...
@@ -164,6 +164,30 @@ protected function form()
...
@@ -164,6 +164,30 @@ protected function form()
return
$sku
;
return
$sku
;
})
->
required
();
})
->
required
();
})
->
tab
(
'文字标签'
,
function
(
Form
$form
)
{
$fieldArr
=
[
'field1'
=>
''
,
'field2'
=>
''
,
'field3'
=>
''
,
'field4'
=>
''
,
'field5'
=>
''
,
'field6'
=>
''
,
'field7'
=>
''
,
'field8'
=>
''
,
'field9'
=>
''
,
'field10'
=>
''
,
'field11'
=>
''
,
'field12'
=>
''
,
'field13'
=>
''
,
'field14'
=>
''
,
'field15'
=>
''
,
'field16'
=>
''
,
];
$form
->
keyValue
(
'tags'
,
'标签'
)
->
default
(
$fieldArr
)
->
setKeyLabel
(
'键 (field开头拼上数字)'
)
->
setValueLabel
(
'值'
);
//->disableCreateButton();
//->disableDelete();
})
->
tab
(
'详情'
,
function
(
Form
$form
)
{
})
->
tab
(
'详情'
,
function
(
Form
$form
)
{
$form
->
editor
(
'goods_desc'
);
$form
->
editor
(
'goods_desc'
);
...
...
app/Admin/Controllers/UserController.php
View file @
f6a3d8a2
...
@@ -46,7 +46,7 @@ protected function grid()
...
@@ -46,7 +46,7 @@ protected function grid()
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
{
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
{
// 添加一个按钮,并设置其属性
// 添加一个按钮,并设置其属性
$actions
->
append
(
'<a href="/user-share?id='
.
$this
->
id
.
'" alt="查看下级" target="_blank">查看
详情
</a>'
);
$actions
->
append
(
'<a href="/user-share?id='
.
$this
->
id
.
'" alt="查看下级" target="_blank">查看
下级
</a>'
);
// 或者使用 RowAction 来添加按钮
// 或者使用 RowAction 来添加按钮
//$actions->append(RowAction::make('自定义按钮')->route('custom.route'));
//$actions->append(RowAction::make('自定义按钮')->route('custom.route'));
...
...
app/Http/Controllers/Api/ArticleController.php
0 → 100644
View file @
f6a3d8a2
<?php
namespace
App\Http\Controllers\Api
;
use
App\Command\Log
;
use
App\Models\Article
;
use
Illuminate\Http\Request
;
class
ArticleController
extends
BaseController
{
public
function
getList
()
{
$page
=
$request
->
page
??
1
;
$limit
=
$request
->
limit
??
10
;
$cat_id
=
$request
->
cat_id
??
0
;
$where
=
[
'is_show'
=>
1
];
if
(
$cat_id
)
{
$where
[
'cat_id'
]
=
$cat_id
;
}
$sql
=
Article
::
where
(
$where
);
$data
=
[
'total'
=>
$sql
->
count
(),
'total_page'
=>
ceil
(
$sql
->
count
()
/
$limit
),
'list'
=>
[]
];
$listData
=
$sql
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
orderBy
(
'created_at'
,
'DESC'
)
->
get
();
if
(
$listData
->
toArray
())
{
foreach
(
$listData
as
$item
)
{
$data
[
'list'
][]
=
[
'id'
=>
$item
->
id
,
'title'
=>
$item
->
title
,
'cover'
=>
$item
->
cover
?
env
(
'IMAGE_URL'
)
.
$item
->
cover
:
''
,
'content'
=>
$item
->
content
,
'created_at'
=>
$item
->
created_at
,
];
}
}
return
$this
->
JsonResponse
(
$data
);
}
public
function
getDetail
(
Request
$request
)
{
$aid
=
$request
->
aid
??
null
;
$aObj
=
Article
::
find
(
$aid
);
if
(
!
$aObj
)
{
return
$this
->
JsonResponse
(
''
,
'参数错误'
,
201
);
}
$data
=
[
'id'
=>
$aid
,
'title'
=>
$aObj
->
title
,
'content'
=>
$aObj
->
content
,
'created_at'
=>
$aObj
->
created_at
?
date
(
"Y-m-d H:i:s"
,
strtotime
(
$aObj
->
created_at
))
:
''
,
];
return
$this
->
JsonResponse
(
$data
);
}
}
app/Http/Controllers/Api/CategoryController.php
View file @
f6a3d8a2
...
@@ -26,10 +26,11 @@ public function getList(Request $request)
...
@@ -26,10 +26,11 @@ public function getList(Request $request)
'id'
=>
$item
->
id
,
'id'
=>
$item
->
id
,
'parent_id'
=>
$item
->
parent_id
,
'parent_id'
=>
$item
->
parent_id
,
'title'
=>
$item
->
title
,
'title'
=>
$item
->
title
,
'icon'
=>
(
isset
(
$item
->
icon
)
?
env
(
'IMAGE_URL'
)
.
$item
->
icon
:
''
)
//
'icon' => (isset($item->icon) ? env('IMAGE_URL') . $item->icon : '')
];
];
}
}
}
}
array_unshift
(
$data
[
'list'
],
[
'id'
=>
0
,
'parent_id'
=>
0
,
'title'
=>
'全部'
]);
return
$this
->
JsonResponse
(
$data
);
return
$this
->
JsonResponse
(
$data
);
}
}
...
...
app/Http/Controllers/Api/CommentController.php
0 → 100644
View file @
f6a3d8a2
<?php
namespace
App\Http\Controllers\Api
;
use
App\Command\Log
;
use
App\Handlers\FileUploadHandler
;
use
App\Models\Comment
;
use
App\Models\CommentTpl
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Http\Request
;
class
CommentController
extends
BaseController
{
public
function
add
(
Request
$request
)
{
$useObj
=
$request
->
user
();
$gid
=
$request
->
gid
??
0
;
$star
=
$request
->
star
??
0
;
$content
=
$request
->
content
??
''
;
DB
::
beginTransaction
();
try
{
$comObj
=
new
Comment
();
$comObj
->
goods_id
=
$gid
;
$comObj
->
star
=
$star
;
$comObj
->
content
=
$content
;
$comObj
->
nickname
=
$useObj
->
name
;
$comObj
->
avatar
=
$useObj
->
avatar
??
''
;
$comObj
->
phone
=
$useObj
->
phone
;
$comObj
->
save
();
DB
::
commit
();
return
$this
->
JsonResponse
(
''
);
}
catch
(
\Exception
$exception
)
{
Log
::
add
(
'添加评论失败'
,
$exception
->
getMessage
());
DB
::
rollBack
();
return
$this
->
JsonResponse
(
''
,
'添加评论失败'
,
201
);
}
}
public
function
getList
(
Request
$request
)
{
$gid
=
$request
->
gid
??
0
;
$page
=
$request
->
page
??
1
;
$limit
=
$request
->
limit
??
10
;
$sql
=
Comment
::
where
([
'goods_id'
=>
$gid
,
'deleted_at'
=>
null
])
->
select
(
'id'
,
'nickname'
,
'avatar'
,
'content'
,
'addtime'
);
$data
=
[
'total'
=>
$sql
->
count
(),
'total_page'
=>
ceil
(
$sql
->
count
()
/
$limit
),
'list'
=>
[]
];
$listData
=
$sql
->
offset
((
$page
-
1
)
*
$limit
)
->
limit
(
$limit
)
->
orderBy
(
'created_at'
,
'DESC'
)
->
get
();
if
(
$listData
->
toArray
())
{
foreach
(
$listData
as
$item
)
{
$data
[
'list'
][]
=
[
'id'
=>
$item
->
id
,
'nickname'
=>
$item
->
nickname
,
'avatar'
=>
$item
->
avatar
?
env
(
'IMAGE_URL'
)
.
$item
->
avatar
:
''
,
'content'
=>
$item
->
content
,
'addtime'
=>
$item
->
addtime
,
];
}
}
return
$this
->
JsonResponse
(
$data
);
}
}
app/Http/Controllers/Api/CommentTplController.php
0 → 100644
View file @
f6a3d8a2
<?php
namespace
App\Http\Controllers\Api
;
use
App\Command\Log
;
use
App\Handlers\FileUploadHandler
;
use
App\Models\CommentTpl
;
use
Illuminate\Http\Request
;
class
CommentTplController
extends
BaseController
{
public
function
getList
()
{
$list
=
(
new
CommentTpl
())
->
select
(
"id"
,
"title"
,
"content"
)
->
orderBy
(
"id"
,
"desc"
)
->
limit
(
30
)
->
get
();
return
$this
->
JsonResponse
(
$list
);
}
}
routes/api.php
View file @
f6a3d8a2
...
@@ -39,11 +39,16 @@
...
@@ -39,11 +39,16 @@
Route
::
get
(
'carousel'
,
'CarouselController@getList'
);
//轮播列表
Route
::
get
(
'carousel'
,
'CarouselController@getList'
);
//轮播列表
Route
::
get
(
'comment-tpl'
,
'CommentTplController@getList'
);
//评价模板
Route
::
get
(
'get-cate-list'
,
'CategoryController@getList'
);
//一级分类列表
Route
::
get
(
'get-cate-list'
,
'CategoryController@getList'
);
//一级分类列表
Route
::
get
(
'get-seccate-list'
,
'CategoryController@getSecList'
);
//二级分类列表
Route
::
get
(
'article-list'
,
'ArticleController@getList'
);
//文章列表
Route
::
get
(
'article-detail'
,
'ArticleController@getDetail'
);
//文章详情
// Route::get('get-seccate-list', 'CategoryController@getSecList'); //二级分类列表
Route
::
get
(
'get-third-list'
,
'CategoryController@getThirdList'
);
//三级分类列表
//
Route::get('get-third-list', 'CategoryController@getThirdList'); //三级分类列表
Route
::
get
(
'recommend-good'
,
'GoodController@getIndexGoods'
);
//首页商品列表
Route
::
get
(
'recommend-good'
,
'GoodController@getIndexGoods'
);
//首页商品列表
...
@@ -61,6 +66,8 @@
...
@@ -61,6 +66,8 @@
Route
::
get
(
'get-good-detail'
,
'GoodController@getDetail'
);
//商品详情
Route
::
get
(
'get-good-detail'
,
'GoodController@getDetail'
);
//商品详情
Route
::
get
(
'comment-list'
,
'CommentController@getList'
);
//评价列表
Route
::
get
(
'send/config/update'
,
'SystemController@update'
);
Route
::
get
(
'send/config/update'
,
'SystemController@update'
);
Route
::
middleware
(
'auth:sanctum'
)
->
group
(
function
()
{
Route
::
middleware
(
'auth:sanctum'
)
->
group
(
function
()
{
...
@@ -126,5 +133,9 @@
...
@@ -126,5 +133,9 @@
Route
::
post
(
'upload-img'
,
'UserController@uploadImg'
);
//图片统一上传接口
Route
::
post
(
'upload-img'
,
'UserController@uploadImg'
);
//图片统一上传接口
Route
::
post
(
'edit-user'
,
'UserController@editUser'
);
//更新用户
Route
::
post
(
'edit-user'
,
'UserController@editUser'
);
//更新用户
Route
::
post
(
'add-comment'
,
'CommentController@add'
);
//去评价
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment