Explorar el Código

feat(admin): 添加共富区推荐奖励配置的详情查看和编辑功能

- 在路由文件中新增 detail 和 update 接口
- 实现控制器中的 detail 方法获取推荐奖励配置详情
- 实现控制器中的 update 方法处理配置编辑请求
- 在 Dao 层添加 getDetailById 方法查询指定 ID 配置
- 在 Repository 层添加 getDetail 和 update 方法封装业务逻辑
- 集成 Entity 类进行数据转换处理
shichen hace 6 meses
padre
commit
338f609375

+ 23 - 1
app/common/dao/shared/SharedProsperityRecommendConfigDao.php

@@ -4,6 +4,7 @@ namespace app\common\dao\shared;
4 4
 
5 5
 use app\common\dao\BaseDao;
6 6
 use app\common\model\shared\SharedProsperityRecommendConfig;
7
+use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
7 8
 
8 9
 class SharedProsperityRecommendConfigDao extends BaseDao
9 10
 {
@@ -25,11 +26,32 @@ class SharedProsperityRecommendConfigDao extends BaseDao
25 26
         try {
26 27
             /** @var SharedProsperityRecommendConfig $model */
27 28
             $model = $this->getModel();
28
-            return $model::getDB()
29
+            $dataRes =  $model::getDB()
29 30
                 ->select()
30 31
                 ->toArray();
32
+            if (!empty($dataRes)) {
33
+                $entityList = array_map(function ($data) {
34
+                    return SharedProsperityRecommendConfigEntity::newInstance($data);
35
+                }, $dataRes);
36
+            }
31 37
         } catch (\Exception $e) {
32 38
         }
33 39
         return $entityList;
34 40
     }
41
+
42
+    /**
43
+     * @param $id
44
+     * @return mixed
45
+     * @author 史晨
46
+     * @date 2026/2/5 14:43
47
+     * 获取推荐配置详情
48
+     */
49
+    public function getDetailById($id)
50
+    {
51
+        /** @var SharedProsperityRecommendConfig $model */
52
+        $model = $this->getModel();
53
+        return $model::getDB()
54
+            ->where(['id'=>$id])
55
+            ->find();
56
+    }
35 57
 }

+ 27 - 0
app/common/repositories/shared/SharedProsperityRecommendConfigRepository.php

@@ -46,4 +46,31 @@ class SharedProsperityRecommendConfigRepository extends BaseRepository
46 46
     {
47 47
         return $this->dao->getConfigList();
48 48
     }
49
+
50
+    /**
51
+     * @param $id
52
+     * @return array
53
+     * @author 史晨
54
+     * @date 2026/2/5 14:12
55
+     */
56
+    public function getDetail($id)
57
+    {
58
+        return $this->dao->getDetailById($id);
59
+    }
60
+
61
+    /**
62
+     * @param $params
63
+     * @return bool
64
+     * @author 史晨
65
+     * @date 2026/2/5 14:12
66
+     */
67
+    public function update($params)
68
+    {
69
+        $id = $params['id'];
70
+        unset($params['id']);
71
+        if (!$this->dao->update($id, $params)){
72
+            return false;
73
+        }
74
+        return true;
75
+    }
49 76
 }

+ 33 - 0
app/controller/admin/system/sharedProsperity/SharedProsperityRecommend.php

@@ -19,4 +19,37 @@ class SharedProsperityRecommend
19 19
         $list = $repository->getList();
20 20
         return app('json')->success($list);
21 21
     }
22
+
23
+    /**
24
+     * @return mixed
25
+     * @author 史晨
26
+     * @date 2026/2/5 14:28
27
+     * 获取推荐奖励配置详情
28
+     */
29
+    public function detail()
30
+    {
31
+        $id = app('request')->params(['id']);
32
+        /** @var SharedProsperityRecommendConfigRepository $repository */
33
+        $repository = app()->make(SharedProsperityRecommendConfigRepository::class);
34
+        $data = $repository->getDetail($id);
35
+        return app('json')->success($data);
36
+    }
37
+
38
+    /**
39
+     * @return void
40
+     * @author 史晨
41
+     * @date 2026/2/6 14:03
42
+     * 编辑
43
+     */
44
+    public function update()
45
+    {
46
+        $params = app('request')->params(['id', 'reward_ratio', 'profit_ratio', 'pv']);
47
+        /** @var SharedProsperityRecommendConfigRepository $repository */
48
+        $repository = app()->make(SharedProsperityRecommendConfigRepository::class);
49
+        $res = $repository->update($params);
50
+        if (!$res) {
51
+            return app('json')->fail();
52
+        }
53
+        return app('json')->success();
54
+    }
22 55
 }

+ 2 - 0
route/admin.php

@@ -115,6 +115,8 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
115 115
 
116 116
         // 共富区配置
117 117
         Route::get('sharedProsperity/Recommend', 'admin.system.sharedProsperity.SharedProsperityRecommend/list');
118
+        Route::get('sharedProsperity/detail', 'admin.system.sharedProsperity.SharedProsperityRecommend/detail');
119
+        Route::post('sharedProsperity/update', 'admin.system.sharedProsperity.SharedProsperityRecommend/update');
118 120
 
119 121
         //组合数据
120 122
         Route::group('group', function () {