作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -118,4 +118,8 @@ class ComController extends BaseController
}
$this->response('success');
}
public function uploads(){
}
}
... ...
<?php
namespace App\Http\Controllers\Bside;
use App\Helper\Arr;
use App\Http\Logic\Bside\DepartmentLogic;
use App\Http\Requests\Bside\DepartmentRequest;
use App\Rules\Ids;
use Illuminate\Http\Request;
/**
* Class DepartmentController
* @package App\Http\Controllers\Bside
* @author zbj
* @date 2023/4/18
*/
class DepartmentController extends BaseController
{
public function index(DepartmentLogic $logic)
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['title', 'like', "%{$this->param['search']}%"];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0);
return $this->success(Arr::listToTree($data));
}
public function info(Request $request, DepartmentLogic $logic){
$request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'manager_uids', 'remark']));
}
public function save(DepartmentRequest $request, DepartmentLogic $logic)
{
$data = $logic->save($this->param);
return $this->success($data);
}
public function delete(Request $request, DepartmentLogic $logic)
{
$request->validate([
'ids'=>['required', new Ids()]
],[
'ids.required' => 'ID不能为空'
]);
$data = $logic->delete($this->param['ids']);
return $this->success($data);
}
}
... ...
... ... @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Bside\News;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Requests\Bside\News\NewsCategoryRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
... ... @@ -20,7 +22,7 @@ class NewsCategoryController extends BaseController
*/
public function lists(NewsCategoryModel $newsCategory){
//搜索条件
$lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order);
$lists = $newsCategory->lists($this->map,$this->page,$this->row,'sort');
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -48,37 +50,12 @@ class NewsCategoryController extends BaseController
* @author :liyuhang
* @method
*/
public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategoryModel,NewsModel $newsModel){
public function add(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
$request->validated();
$this->param['project_id'] = $this->user['project_id'];
$this->param['operator_id'] = $this->uid;
$this->param['create_id'] = $this->uid;
DB::beginTransaction();
$rs = $newsCategoryModel->add($this->param);
if($rs === false){
DB::rollBack();
$this->response('error',Code::USER_ERROR);
}
//判断当前分内是否为一级分类
if(isset($this->param['pid']) && !empty($this->param['pid'])){
//查看当前上级分类下是否有其他分类
$cate_info = $newsCategoryModel->read(['pid'=>$this->param['pid'],'id'=>['!=',$newsCategoryModel->id]]);
if($cate_info === false){
//查看当前上一级分类下是否有商品
$news_info = $newsModel->read(['category_id'=>$this->param['pid'],'pid'=>0]);
if($news_info !== false){
//更新所有商品到当前分类
$rs = $newsModel->edit(['category_id'=>$newsCategoryModel->id],['category_id'=>$this->param['pid']]);
if($rs === false){
DB::rollBack();
$this->response('error',Code::USER_ERROR);
}
}
}
}
DB::commit();
//添加商品时,验证分类上级分类是否有商品,有则更新到当前分类中,没有时直接添加
$newsCategoryLogic->add_news_category();
//TODO::写入日志
$this->response('success',Code::SUCCESS);
$this->response('success',Code::SUCCESS,[]);
}
/**
... ...
... ... @@ -79,6 +79,8 @@ class NewsController extends BaseController
$this->param['create_id'] = $this->uid;
$this->param['operator_id'] = $this->uid;
$this->param['project_id'] = $this->user['project_id'];
//多个分类按逗号隔开
$this->param['category_id'] = ','.$this->param['category_id'].',';
//TODO::路由映射
$rs = $news->add($this->param);
if($rs === false){
... ... @@ -101,6 +103,8 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$this->param['operator_id'] = $this->uid;
//多个分类按逗号隔开
$this->param['category_id'] = ','.$this->param['category_id'].',';
$rs = $news->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->response('error',Code::USER_ERROR);
... ...
... ... @@ -56,6 +56,4 @@ class CategoryController extends BaseController
$data = $logic->delete($this->param['ids']);
return $this->success($data);
}
//todo Ai生成 关键词和描述
}
... ...
... ... @@ -138,7 +138,7 @@ class BaseLogic
$this->fail('数据不存在或者已经删除');
}
}
$param['project_id'] = $this->user['project_id'];
foreach ($param as $name => $value){
$this->model[$name] = $value;
}
... ...
<?php
namespace App\Http\Logic\Bside;
use App\Helper\Arr;
use App\Models\Department;
/**
* Class DepartmentLogic
* @package App\Http\Logic\Bside\Department
* @author zbj
* @date 2023/4/18
*/
class DepartmentLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Department();
}
public function save($param){
if(!empty($param['pid'])){
if(!empty($param['id']) && $param['pid'] == $param['id']){
$this->fail('上级部门不能是本部门');
}
$p_cate = $this->getCacheInfo($param['pid']);
if(!$p_cate){
$this->fail('上级部门不存在');
}
}
return parent::save($param);
}
public function delete($ids){
$ids= array_filter(Arr::splitFilterToArray($ids), 'intval');
foreach ($ids as $id){
$info = $this->getCacheInfo($id);
if(!$info){
continue;
}
//是否有子部门
if(Department::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
$this->fail("部门{$info['title']}存在下级部门,不能删除");
}
}
return parent::delete($ids);
}
}
... ...
... ... @@ -27,7 +27,7 @@ class CategoryLogic extends BaseLogic
if(!empty($param['id']) && $param['pid'] == $param['id']){
$this->fail('上级分类不能是本分类');
}
$p_cate = Category::find($param['pid']);
$p_cate = $this->getCacheInfo($param['pid']);
if(!$p_cate){
$this->fail('上级分类不存在');
}
... ... @@ -43,7 +43,7 @@ class CategoryLogic extends BaseLogic
continue;
}
//是否有子分类
if(Category::where('pid', $id)->count()){
if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){
$this->fail("分类{$info['title']}存在子分类,不能删除");
}
//是否有对应商品
... ...
<?php
namespace App\Http\Requests\Bside;
use Illuminate\Foundation\Http\FormRequest;
/**
* Class DepartmentRequest
* @package App\Http\Requests\Bside\product
* @author zbj
* @date 2023/4/18
*/
class DepartmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title'=>'required|max:50',
'remark'=>'max:200',
];
}
public function messages()
{
return [
'title.required' => '请输入部门名称',
'title.max' => '部门名称不能超过50个字符',
'remark.max' => '备注不能超过200个字符',
];
}
}
... ...
... ... @@ -24,7 +24,7 @@ class NewsCategoryRequest extends FormRequest
public function rules()
{
return [
'name'=>'required|max:100',
'name'=>'required|max:100||unique:gl_news_category',
];
}
... ...
... ... @@ -19,7 +19,7 @@ class ProjectGroupRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:255',
'name' => 'required|max:255||unique:gl_project_group',
];
}
... ...
... ... @@ -19,7 +19,7 @@ class ProjectRoleRequest extends FormRequest
public function rules()
{
return [
'name'=>'required|max:11',
'name'=>'required|max:11||unique:gl_project_role',
'role_menu'=>'required|string',
];
}
... ...
... ... @@ -24,7 +24,7 @@ class UserRequest extends FormRequest
public function rules()
{
return [
'mobile'=>'required|string|max:11',
'mobile'=>'required|string|max:11||unique:gl_project_user',
'password'=>'required|string|min:5',
'name'=>'required|max:20',
'role_id'=>'required'
... ...
... ... @@ -30,7 +30,7 @@ class AttrRequest extends FormRequest
public function rules()
{
return [
'title' => 'required|max:30',
'title' => 'required|max:50',
'remark' => 'max:200',
'values' => 'required|array'
];
... ... @@ -40,7 +40,7 @@ class AttrRequest extends FormRequest
{
return [
'title.required' => '请输入参数名称',
'title.max' => '参数名称不能超过30个字符',
'title.max' => '参数名称不能超过50个字符',
'remark.max' => '备注不能超过200个字符',
'values.required' => '请添加参数值',
'values.array' => '参数值格式异常',
... ...
... ... @@ -30,7 +30,7 @@ class CategoryRequest extends FormRequest
public function rules()
{
return [
'title'=>'required|max:20',
'title'=>'required|max:50',
'image'=>'required',
'keywords'=>'required|max:50',
'describe'=>'required|max:200',
... ... @@ -41,7 +41,7 @@ class CategoryRequest extends FormRequest
{
return [
'title.required' => '请输入分类名称',
'title.max' => '分类名称不能超过20个字符',
'title.max' => '分类名称不能超过50个字符',
'image.required' => '请上传分类图片',
'keywords.required' => '请输入分类关键词',
'keywords.max' => '分类关键词不能超过50个字符',
... ...
... ... @@ -30,7 +30,7 @@ class DescribeRequest extends FormRequest
public function rules()
{
return [
'title'=>'required|max:30',
'title'=>'required|max:50',
'describe'=>'required',
];
}
... ... @@ -39,7 +39,7 @@ class DescribeRequest extends FormRequest
{
return [
'title.required' => '请输入描述名称',
'title.max' => '描述名称不能超过30个字符',
'title.max' => '描述名称不能超过50个字符',
'seo_title.required' => '请输入描述内容',
];
}
... ...
... ... @@ -30,7 +30,7 @@ class KeywordRequest extends FormRequest
public function rules()
{
return [
'title'=>'required|max:30',
'title'=>'required|max:50',
'seo_title'=>'max:200',
'seo_keywords'=>'max:200',
'seo_description'=>'max:200',
... ... @@ -41,7 +41,7 @@ class KeywordRequest extends FormRequest
{
return [
'title.required' => '请输入关键词',
'title.max' => '关键词不能超过30个字符',
'title.max' => '关键词不能超过50个字符',
'seo_title.max' => 'SEO标题不能超过200个字符',
'seo_keywords.max' => 'SEO关键词不能超过200个字符',
'seo_description.max' => 'SEO描述不能超过200个字符',
... ...
... ... @@ -94,7 +94,7 @@ class ProductRequest extends FormRequest
'category_id.required' => '请选择分类',
'keywords.required' => '请添加关键词标签',
'intro.required' => '请输入短描述',
'intro.max' => '短描述不能超过20个字符',
'intro.max' => '短描述不能超过500个字符',
'content.required' => '请输入产品描述',
'describe.required' => '请添加描述切换栏',
'describe.array' => '描述切换栏格式异常',
... ...
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
class Department extends Base
{
use SoftDeletes;
//设置关联表名
protected $table = 'gl_department';
}
... ...
... ... @@ -88,7 +88,7 @@ Route::middleware(['bloginauth'])->group(function () {
//产品
Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product');
Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info');
Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name(' ');
Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save');
Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete');
//产品分类
... ... @@ -115,6 +115,14 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('describe/save', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'save'])->name('product_describe_save');
Route::any('describe/delete', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'delete'])->name('product_describe_delete');
});
//组织架构
Route::prefix('department')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\DepartmentController::class, 'index'])->name('department');
Route::get('/info', [\App\Http\Controllers\Bside\DepartmentController::class, 'info'])->name('department_info');
Route::post('/save', [\App\Http\Controllers\Bside\DepartmentController::class, 'save'])->name('department_save');
Route::any('/delete', [\App\Http\Controllers\Bside\DepartmentController::class, 'delete'])->name('department_delete');
});
});
//无需登录验证的路由组
... ...