moonsflyer 5 месяцев назад
Родитель
Сommit
0bc3ad06e0

+ 113 - 0
app/adminapi/controller/info/InfoCategoryController.php

@@ -0,0 +1,113 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\controller\info;
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\banner\BannerLists;
+use app\adminapi\lists\info\InfoCategoryLists;
+use app\adminapi\logic\goods\GoodsBrandLogic;
+use app\adminapi\logic\banner\BannerLogic;
+use app\adminapi\validate\banner\BannerValidate;
+use app\adminapi\validate\info\InfoCategoryValidate;
+use app\adminapi\logic\info\InfoCategoryLogic;
+class InfoCategoryController extends BaseAdminController
+{
+    /**
+     * @notes 添加分类
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2021/7/14 3:04
+     */
+    public function add()
+    {
+        $params = (new InfoCategoryValidate())->post()->goCheck('add');
+        (new InfoCategoryLogic())->add($params);
+        return $this->success('添加分类成功',[],1,1);
+    }
+
+    /**
+     * @notes 查看分类信息
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2021/7/14 5:41
+     */
+    public function lists()
+    {
+        return $this->dataLists(new InfoCategoryLists());
+    }
+
+    /**
+     * @notes 删除分类
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2021/7/14 7:07
+     */
+    public function del()
+    {
+        $params = (new InfoCategoryValidate())->post()->goCheck('del');
+        (new InfoCategoryLogic())->del($params);
+        return $this->success('删除成功',[],1,1);
+    }
+
+    /**
+     * @notes 编辑分类
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2021/7/15 10:55
+     */
+    public function edit()
+    {
+        $params = (new InfoCategoryValidate())->post()->goCheck('edit');
+        (new InfoCategoryLogic())->edit($params);
+        return $this->success('修改成功',[],1,1);
+    }
+
+    /**
+     * @notes 修改分类状态
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/15 11:42
+     */
+    public function status()
+    {
+        $params = (new InfoCategoryValidate())->post()->goCheck('status');
+        (new InfoCategoryLogic())->status($params);
+        return $this->success('状态修改成功',[],1,1);
+    }
+
+    /**
+     * @notes 查看分类详情
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/19 4:46 下午
+     */
+    public function detail()
+    {
+        $params = (new InfoCategoryValidate())->goCheck('detail');
+        $result = (new InfoCategoryLogic())->detail($params);
+        return $this->success('分类详情获取成功',$result,1,0);
+    }
+}

+ 79 - 0
app/adminapi/lists/info/InfoCategoryLists.php

@@ -0,0 +1,79 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop开源商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
+// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | likeshop团队版权所有并拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshop.cn.team
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\info;
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\Banner;
+use app\common\model\InfoCategory;
+
+
+class InfoCategoryLists extends BaseAdminDataLists
+{
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author ljj
+     * @date 2022/3/30 5:12 下午
+     */
+    public function setSearch(): array
+    {
+        $where = [];
+        $params = $this->params;
+
+        if (isset($params['type']) && $params['type'] != '') {
+            $where[] = ['type', '=', $params['type']];
+        }
+
+        return $where;
+    }
+
+    /**
+     * @notes 分类列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2022/3/30 5:40 下午
+     */
+    public function lists(): array
+    {
+        $lists = InfoCategory::where($this->setSearch())
+            ->field('id,type,name,is_show,sort,create_time')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->append(['is_show_desc','type_desc'])
+            ->order('id', 'desc')
+            ->select()
+            ->toArray();
+
+        return $lists;
+    }
+
+    /**
+     * @notes 分类数量
+     * @return int
+     * @author ljj
+     * @date 2022/3/30 5:40 下午
+     */
+    public function count(): int
+    {
+        return InfoCategory::where($this->setSearch())->count();
+    }
+}

+ 108 - 0
app/adminapi/logic/info/InfoCategoryLogic.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\info;
+
+
+use app\common\enum\DefaultEnum;
+use app\common\enum\YesNoEnum;
+use app\common\model\InfoCategory;
+class InfoCategoryLogic
+{
+    /**
+     * @notes 添加分类
+     * @param $params
+     * @return bool
+     * @author ljj
+     * @date 2021/7/14 5:00
+     */
+    public function add($params)
+    {
+        $InfoCategory = new InfoCategory;
+        $InfoCategory->type = $params['type'];
+        $InfoCategory->name = $params['name'] ?? '';
+        $InfoCategory->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 50;
+        $InfoCategory->is_show = $params['is_show'] ?? YesNoEnum::YES;
+        return $InfoCategory->save();
+    }
+
+    /**
+     * @notes 删除分类
+     * @param $params
+     * @return bool
+     * @author ljj
+     * @date 2021/7/15 10:37
+     */
+    public function del($params)
+    {
+        return InfoCategory::destroy($params['id']);
+    }
+
+    /**
+     * @notes 编辑分类
+     * @param $params
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/15 11:05
+     */
+    public function edit($params)
+    {
+        $InfoCategory = InfoCategory::find($params['id']);
+        $InfoCategory->type = $params['type'];
+        $InfoCategory->name = $params['name'] ?? '';
+        $InfoCategory->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 1;
+        $InfoCategory->is_show = $params['is_show'] ?? YesNoEnum::YES;
+        return $InfoCategory->save();
+    }
+
+    /**
+     * @notes 修改分类状态
+     * @param $params
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/15 11:41
+     */
+    public function status($params)
+    {
+        $InfoCategory = InfoCategory::find($params['id']);
+        $InfoCategory->is_show = $params['is_show'];
+        return $InfoCategory->save();
+    }
+
+    /**
+     * @notes 查看分类详情
+     * @param $params
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/19 4:45 下午
+     */
+    public function detail($params)
+    {
+        return InfoCategory::find($params['id'])->toArray();
+    }
+}

+ 90 - 0
app/adminapi/validate/info/InfoCategoryValidate.php

@@ -0,0 +1,90 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\info;
+
+use app\common\model\InfoCategory;
+use app\common\validate\BaseValidate;
+
+class InfoCategoryValidate extends BaseValidate
+{
+    protected $rule = [
+        'id' => 'require',
+        'type' => 'require|in:1,2,3,4,5,6,7,8',
+        'name' => 'require|checkName',
+        'is_show' => 'in:0,1',
+        'sort' => 'number',
+    ];
+
+    protected $message = [
+        'id.require' => '分类id不能为空',
+        'name.require' => '分类名称不能为空',
+    ];
+
+    public function sceneAdd()
+    {
+        return $this->only(['type','name','sort']);
+    }
+
+    public function sceneDel()
+    {
+        return $this->only(['id']);
+    }
+
+    public function sceneEdit()
+    {
+        return $this->only(['id','type','name']);
+    }
+
+    public function sceneStatus()
+    {
+        return $this->only(['id','is_show']);
+    }
+
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+    /**
+     * @notes 验证分类是否已存在
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author ljj
+     * @date 2021/7/14 3:51
+     */
+    public function checkName($value,$rule,$data)
+    {
+        $where[] = ['name', '=', $value];
+        $where[] = ['type', '=', $data['type']];
+        // 编辑的情况,要排除自身ID
+        if (isset($data['id'])) {
+            $where[] = ['id', '<>', $data['id']];
+        }
+        $result = InfoCategory::where($where)->select()->toArray();
+        if ($result) {
+            return '该分类已存在';
+        }
+        return true;
+    }
+}

+ 0 - 10
app/common/model/Banner.php

@@ -28,16 +28,6 @@ class Banner extends BaseModel
     use SoftDelete;
     protected $deleteTime = 'delete_time';
 
-    /**
-     * @notes 一对多关联商品模型
-     * @return \think\model\relation\HasMany
-     * @author ljj
-     * @date 2021/7/15 10:37
-     */
-    public function goods()
-    {
-        return $this->hasMany(Goods::class,'brand_id','id');
-    }
 
     /**
      * @notes 状态获取器

+ 67 - 0
app/common/model/Info.php

@@ -0,0 +1,67 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model;
+
+use app\common\enum\YesNoEnum;
+use app\common\service\FileService;
+use think\model\concern\SoftDelete;
+
+class Info extends BaseModel
+{
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
+
+
+    /**
+     * @notes 状态获取器
+     * @param $value
+     * @param $data
+     * @return string
+     * @author ljj
+     * @date 2021/7/31 3:26 下午
+     */
+    public function getStatusDescAttr($value, $data)
+    {
+        return YesNoEnum::getStatusDesc($data['status']);
+    }
+
+    /**
+     * @notes 类型获取器
+     * @param $value
+     * @param $data
+     * @return string
+     * @author ljj
+     * @date 2021/7/31 3:26 下午
+     */
+    public function getTypeDescAttr($value, $data)
+    {
+        $datas = [
+            1 => '自然风光',
+            2 => '酒店',
+            3 => '餐饮',
+            4 => '交通枢纽',
+            5 => '休闲赶海',
+            6 => '集市',
+            7 => '牡蛎品鲜',
+            8 => '红色记忆',
+        ];
+        return $datas[$data['type']];
+    }
+}

+ 68 - 0
app/common/model/InfoCategory.php

@@ -0,0 +1,68 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeshop100%开源免费商用商城系统
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | 商业版本务必购买商业授权,以免引起法律纠纷
+// | 禁止对系统程序代码以任何目的,任何形式的再发布
+// | gitee下载:https://gitee.com/likeshop_gitee
+// | github下载:https://github.com/likeshop-github
+// | 访问官网:https://www.likeshop.cn
+// | 访问社区:https://home.likeshop.cn
+// | 访问手册:http://doc.likeshop.cn
+// | 微信公众号:likeshop技术社区
+// | likeshop团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeshopTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model;
+
+use app\common\enum\YesNoEnum;
+use app\common\service\FileService;
+use think\model\concern\SoftDelete;
+
+class InfoCategory extends BaseModel
+{
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
+
+
+    /**
+     * @notes 状态获取器
+     * @param $value
+     * @param $data
+     * @return string
+     * @author ljj
+     * @date 2021/7/31 3:26 下午
+     */
+    public function getIsShowDescAttr($value, $data)
+    {
+        return YesNoEnum::getStatusDesc($data['is_show']);
+    }
+
+    /**
+     * @notes 类型获取器
+     * @param $value
+     * @param $data
+     * @return string
+     * @author ljj 类别 1:自然风光 2:酒店 3:餐饮 4 :交通枢纽 5:休闲赶海 6:集市  7:牡蛎品鲜 8:红色记忆
+     * @date 2021/7/31 3:26 下午
+     */
+    public function getTypeDescAttr($value, $data)
+    {
+        $datas = [
+            1 => '自然风光',
+            2 => '酒店',
+            3 => '餐饮',
+            4 => '交通枢纽',
+            5 => '休闲赶海',
+            6 => '集市',
+            7 => '牡蛎品鲜',
+            8 => '红色记忆',
+        ];
+
+        return $datas[$data['type']];
+    }
+}