feat 添加心愿单接口

This commit is contained in:
lwh 2023-08-24 17:50:06 +08:00
parent 669a897106
commit 6212f9e864
4 changed files with 48 additions and 239 deletions

View File

@ -1,93 +0,0 @@
<?php
namespace app\api\controller\News;
use app\BaseController;
use app\common\model\News\News as ModelNews;
use app\common\model\Dictionary\Dictionary as ModelDictionary;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;
class News extends BaseController
{
/**
* 获取新闻类型
*/
public function getNewsType(Request $request): array
{
$params = $request->param();
$query = ModelDictionary::getDictionaryData('news_type');
return msg("获取新闻类型成功!", $query);
}
/**
* 获取新闻列表
*/
public function getNewsList(Request $request)
{
$params = $request->param();
$this->validate($params, ['idx' => 'require']);
// 根据字典index获取新闻类型的值
$news_type_arr = ModelDictionary::getDictionaryData('news_type');
$news_type = $news_type_arr[$params['idx']];
if (!$news_type) throwErrorMsg("传值不正确!");
$news_type_value = $news_type['dictionary_value'];
$con = [];
$con = Tool::getOptionalQuery(['news_title', 'LIKE'],);
$query = ModelNews::where($con)
->where('news_type', $news_type_value)
->field([
'news_id',
'news_type',
'news_title',
'news_intro',
'news_cover',
'news_link',
'news_issue_date',
'news_sort',
])
->order('news_sort', 'asc');
return msg("获取新闻列表成功!", $query);
}
/**
* 获取新闻详情
*/
public function getNewsInfo(Request $request): array
{
$params = $request->param();
$this->validate($params, ['news_id' => 'require']);
$find = ModelNews::field([
'news_id',
'news_type',
'news_title',
'news_intro',
'news_source',
'news_link',
'news_issue_date',
'news_views_num',
'news_sort',
'news_content'
])
->where('news_id', $params['news_id'])
->find();
return msg(0, '获取新闻详情成功!', ['data' => $find]);
}
}

View File

@ -1,76 +0,0 @@
<?php
namespace app\api\controller\Products;
use app\BaseController;
use app\common\model\Products\Product as ModelProduct;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;
class Product extends BaseController
{
/**
* 获取产品列表
*/
public function getProductList(Request $request): array
{
$params = $request->param();
$con = [];
$con = Tool::getOptionalQuery(['product_type_guid', '='], ['product_name', 'LIKE'],);
$query = ModelProduct::where($con)
->field([
'product_id',
'product_guid',
'product_type_guid',
'product_name',
'product_img',
'product_description',
'product_link',
'product_details',
'product_sort'
])
->order('product_sort', 'asc')
->select();
return msg(0, "获取产品列表成功!", [
'data' => $query,
'count' => count($query)
]);
}
/**
* 获取产品详情
*/
public function getProductInfo(Request $request): array
{
$params = $request->param();
$this->validate($params, ['product_id' => 'require']);
$find = ModelProduct::field([
'product_id',
'product_guid',
'product_type_guid',
'product_name',
'product_img',
'product_description',
'product_link',
'product_details',
'product_sort'
])
->where('product_id', $params['product_id'])
->find();
return msg(0, '获取产品详情成功!', ['data' => $find]);
}
}

View File

@ -1,70 +0,0 @@
<?php
namespace app\api\controller\Products;
use app\BaseController;
use app\common\model\Products\ProductType as ModelProductType;
use app\common\arw\adjfut\src\Traverse;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use app\common\exception\Tool;
use think\facade\Db;
use think\facade\Env;
class ProductType extends BaseController
{
/**
* 获取产品系列树形列表接口接口
*
* @param Request request
* @date 2023-04-03
* @example
* @author xjh
* @since 1.0.0
*/
public function getProductTypeTree(Request $request): array
{
$con = Tool::getOptionalQuery(
['b.product_delete_time', 'NULL'],
['a.product_type_name', 'LIKE']
);
$product_type = ModelProductType::field([
'a.product_type_parent_guid',
'a.product_type_name',
'a.product_type_title',
'a.product_type_link',
'b.product_type_name' => "product_type_parent_name",
'a.product_type_order',
'a.product_type_guid',
'a.product_type_id',
'a.product_type_icon',
])
->alias('a')
->leftjoin('product_type b', 'a.product_type_parent_guid = b.product_type_guid')
->where($con)
->order(['product_type_order' => 'asc'])
->select()->toArray();
$Traverse = new Traverse('product_type_guid', 'product_type_parent_guid');
$product_type_tree = $Traverse->tree($product_type, '0', function ($v) {
return [
'product_type_name' => $v['product_type_name'],
'product_type_title' => $v['product_type_title'],
'product_type_link' => $v['product_type_link'],
'product_type_parent_name' => $v['product_type_parent_name'],
'product_type_guid' => $v['product_type_guid'],
'product_type_id' => $v['product_type_id'],
'product_type_parent_guid' => $v['product_type_parent_guid'],
'product_type_order' => $v['product_type_order'],
'product_type_icon' => $v['product_type_icon'],
];
});
return msg("获取产品系列列表成功!", $product_type_tree);
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace app\api\controller\WishList;
use app\BaseController;
use app\common\model\WishList\WishList as ModelWishList;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;
class WishList extends BaseController
{
/**
* 获取心愿单列表
*/
public function getWishListList(Request $request): array
{
$params = $request->param();
$con = [];
$con = Tool::getOptionalQuery(['wish_list_name', 'LIKE'], ['wish_list_author', 'LIKE'], ['wish_list_status', '='],);
$query = ModelWishList::where($con)
->field([
'wish_list_id',
'wish_list_name',
'wish_list_author',
'wish_list_status',
'wish_list_create_time',
'wish_list_sort'
])
->order('wish_list_sort', 'desc')
->select();
return msg(0, "获取心愿单列表成功!", [
'data' => $query,
'count' => count($query)
]);
}
}