Commit 8237f91297c4327520a547420f6d005039c634f9
1 parent
cb9961d8
Exists in
master
app-ht(v1.8.6 build 14)
1.所有物理删除改为逻辑删除 2.版本管理添加厂商过滤
Showing
11 changed files
with
62 additions
and
14 deletions
Show diff stats
app-ht/config/params.php
app-ht/modules/upgrade/controllers/UpgradeController.php
... | ... | @@ -69,6 +69,10 @@ class UpgradeController extends BaseController |
69 | 69 | if ($dataType) { |
70 | 70 | $where[] = ['=', 'u.type', $dataType]; |
71 | 71 | } |
72 | + $user = Yii::$app->user->identity; | |
73 | + if (isset($user->is_manufacture) && $user->is_manufacture == 1) { | |
74 | + $where[] = ['like', 'mf.sys_user_id', $user->id]; | |
75 | + } | |
72 | 76 | if ($type == 0) { |
73 | 77 | $pageList = UpgradeRepository::getPageList($where, 0 , 0); |
74 | 78 | $pages = null; |
... | ... | @@ -95,6 +99,15 @@ class UpgradeController extends BaseController |
95 | 99 | public function actionCreate() |
96 | 100 | { |
97 | 101 | $gets = $this->request->get(); |
102 | + $user = Yii::$app->user->identity; | |
103 | + if (isset($user->is_manufacture) && $user->is_manufacture == 1) { | |
104 | + $gets["is_manufacture"] = 1; | |
105 | + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]); | |
106 | + if ($manufacturer) { | |
107 | + $gets["manufacture_name"] = $manufacturer->name; | |
108 | + $gets["manufacture_id"] = $manufacturer->id; | |
109 | + } | |
110 | + } | |
98 | 111 | return $this->render('create', ['gets' => $gets]); |
99 | 112 | } |
100 | 113 | |
... | ... | @@ -110,6 +123,14 @@ class UpgradeController extends BaseController |
110 | 123 | Yii::$app->session->setFlash('error', '版本不能为空'); |
111 | 124 | return $this->render('create'); |
112 | 125 | } |
126 | + $user = Yii::$app->user->identity; | |
127 | + if (isset($user->is_manufacture) && $user->is_manufacture == 1) { | |
128 | + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]); | |
129 | + if (empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) { | |
130 | + Yii::$app->session->setFlash('error', '添加失败'); | |
131 | + return $this->render('create'); | |
132 | + } | |
133 | + } | |
113 | 134 | $result = Upgrade::create($request->post()); |
114 | 135 | if ($result === -1) { |
115 | 136 | Yii::$app->session->setFlash('error', '添加失败,版本' . $version . '已存在'); |
... | ... | @@ -157,6 +178,15 @@ class UpgradeController extends BaseController |
157 | 178 | $params = $this->dataList(1); |
158 | 179 | return $this->render('index', $params); |
159 | 180 | } |
181 | + $user = Yii::$app->user->identity; | |
182 | + if (isset($user->is_manufacture) && $user->is_manufacture == 1) { | |
183 | + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]); | |
184 | + if (empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) { | |
185 | + Yii::$app->session->setFlash('error', '编辑失败'); | |
186 | + $params = $this->dataList(1); | |
187 | + return $this->render('index', $params); | |
188 | + } | |
189 | + } | |
160 | 190 | $upgrade = UpgradeRepository::selectOne($uid,true); |
161 | 191 | if (isset($upgrade["path"])) { |
162 | 192 | $upgrade["oldName"] = $upgrade["path"]; |
... | ... | @@ -207,6 +237,16 @@ class UpgradeController extends BaseController |
207 | 237 | $request = Yii::$app->request; |
208 | 238 | $itemId = $request->post("data_id"); |
209 | 239 | $msg = array(); |
240 | + $user = Yii::$app->user->identity; | |
241 | + if (isset($user->is_manufacture) && $user->is_manufacture == 1) { | |
242 | + $manufacturer = ManufacturerRepository::findOne(["sys_user_id" => $user->id]); | |
243 | + $upgrade = UpgradeRepository::selectOne($itemId,true); | |
244 | + if (empty($upgrade) || empty($manufacturer) || $manufacturer->id != $request->post("manufacturer_id")) { | |
245 | + $msg['status'] = 0; | |
246 | + $msg['msg'] = "删除"; | |
247 | + return $this->renderJson($msg); | |
248 | + } | |
249 | + } | |
210 | 250 | |
211 | 251 | // 删除对应的版本 |
212 | 252 | if (Upgrade::delete($itemId)) { | ... | ... |
app-ht/modules/upgrade/views/upgrade/create.php
... | ... | @@ -50,7 +50,11 @@ $this->params['breadcrumbs'][] = $this->title; |
50 | 50 | <label for="skillName" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>请选择厂商名称:</label> |
51 | 51 | <div class="col-sm-4 text-left"> |
52 | 52 | <input type="hidden" id="manufacture_id" name="manufacture_id" value="<?= (isset($gets["manufacture_id"]) ? $gets["manufacture_id"] : "") ?>"/> |
53 | - <div class="form-control text-center" id="select_manufacture"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div> | |
53 | + <?php if (isset($gets["is_manufacture"]) && $gets["is_manufacture"] == 1) { ?> | |
54 | + <div class="form-control text-center"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div> | |
55 | + <?php } else { ?> | |
56 | + <div class="form-control text-center" id="select_manufacture"><span id="manufactureName"><?= (isset($gets["manufacture_name"]) && !empty($gets["manufacture_name"]) ? $gets["manufacture_name"] : "请选择厂商名称") ?></span> <span style="float: right;padding-right: 13px"> > </span></div> | |
57 | + <?php } ?> | |
54 | 58 | </div> |
55 | 59 | </div> |
56 | 60 | <div class="form-group col-sm-12"> |
... | ... | @@ -122,7 +126,7 @@ $this->params['breadcrumbs'][] = $this->title; |
122 | 126 | l.start(); |
123 | 127 | return false; |
124 | 128 | }); |
125 | - | |
129 | + <?php if (!isset($gets["is_manufacture"]) || $gets["is_manufacture"] != 1) { ?> | |
126 | 130 | $("#select_manufacture").bind("click", function () { |
127 | 131 | var getUrl = '<?=Url::toRoute("/upgrade/upgrade/select-manufacture")?>'; |
128 | 132 | var version = $("input[name='version']").val(); |
... | ... | @@ -142,7 +146,7 @@ $this->params['breadcrumbs'][] = $this->title; |
142 | 146 | getUrl = getUrl + "&isCreate=" + 1; |
143 | 147 | window.location.href = getUrl; |
144 | 148 | }); |
145 | - | |
149 | + <?php } ?> | |
146 | 150 | //上传文件函数 |
147 | 151 | //ids唯一ID |
148 | 152 | //folder文件保存目录 | ... | ... |
domain/manufacturer/Manufacturer.php
... | ... | @@ -124,11 +124,11 @@ class Manufacturer |
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | if (isset($manufacturerModel->sys_user_id)) { |
127 | - SysUserModel::deleteAll(["id" => $manufacturerModel->sys_user_id]); // 删除登录用户 | |
128 | - SysUserProfileModel::deleteAll(["sys_user_id" => $manufacturerModel->sys_user_id]); // 删除登录用户 | |
127 | + SysUserModel::updateAll(["is_enable" => 0], ["id" => $manufacturerModel->sys_user_id]); // 删除登录用户 | |
128 | + //SysUserProfileModel::deleteAll(["sys_user_id" => $manufacturerModel->sys_user_id]); // 删除登录用户 | |
129 | 129 | } |
130 | 130 | |
131 | - return ManufacturerModel::deleteAll(["id" => $id]); | |
131 | + return ManufacturerModel::updateAll(["is_delete" => 1], ["id" => $id]); | |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** | ... | ... |
domain/manufacturer/ManufacturerRepository.php
... | ... | @@ -39,7 +39,7 @@ class ManufacturerRepository |
39 | 39 | if ($limit) { |
40 | 40 | $manufacturerFind->limit($limit); |
41 | 41 | } |
42 | - | |
42 | + $manufacturerFind->andWhere(["is_delete" => 0]); | |
43 | 43 | $manufacturerFind->orderBy("m.id desc"); |
44 | 44 | $manufacturerFind->asArray(); |
45 | 45 | $dataList = $manufacturerFind->all(); |
... | ... | @@ -61,6 +61,7 @@ class ManufacturerRepository |
61 | 61 | if (!empty($map)) { |
62 | 62 | $manufacturerFind->where($map); |
63 | 63 | } |
64 | + $manufacturerFind->andWhere(["is_delete" => 0]); | |
64 | 65 | $pageCount = $manufacturerFind->count(); |
65 | 66 | |
66 | 67 | return $pageCount; | ... | ... |
domain/model/Model.php
domain/model/ModelRepository.php
... | ... | @@ -35,7 +35,7 @@ class ModelRepository |
35 | 35 | if ($limit) { |
36 | 36 | $modelFind->limit($limit); |
37 | 37 | } |
38 | - | |
38 | + $modelFind->andWhere(["is_delete" => 0]); | |
39 | 39 | $modelFind->orderBy("m.id desc"); |
40 | 40 | $modelFind->asArray(); |
41 | 41 | $dataList = $modelFind->all(); |
... | ... | @@ -53,6 +53,7 @@ class ModelRepository |
53 | 53 | if (!empty($map)) { |
54 | 54 | $modelFind->where($map); |
55 | 55 | } |
56 | + $modelFind->andWhere(["is_delete" => 0]); | |
56 | 57 | $pageCount = $modelFind->count(); |
57 | 58 | |
58 | 59 | return $pageCount; | ... | ... |
domain/production/Production.php
domain/production/ProductionRepository.php
... | ... | @@ -35,7 +35,7 @@ class ProductionRepository |
35 | 35 | if ($limit) { |
36 | 36 | $productionFind->limit($limit); |
37 | 37 | } |
38 | - | |
38 | + $productionFind->andWhere(["is_delete" => 0]); | |
39 | 39 | $productionFind->orderBy("p.id desc"); |
40 | 40 | $productionFind->asArray(); |
41 | 41 | $dataList = $productionFind->all(); |
... | ... | @@ -53,6 +53,7 @@ class ProductionRepository |
53 | 53 | if (!empty($map)) { |
54 | 54 | $productionFind->where($map); |
55 | 55 | } |
56 | + $productionFind->andWhere(["is_delete" => 0]); | |
56 | 57 | $pageCount = $productionFind->count(); |
57 | 58 | |
58 | 59 | return $pageCount; | ... | ... |
domain/project/Project.php
domain/project/ProjectRepository.php
... | ... | @@ -35,7 +35,7 @@ class ProjectRepository |
35 | 35 | if ($limit) { |
36 | 36 | $modelFind->limit($limit); |
37 | 37 | } |
38 | - | |
38 | + $modelFind->andWhere(["is_delete" => 0]); | |
39 | 39 | $modelFind->orderBy("p.id desc"); |
40 | 40 | $modelFind->asArray(); |
41 | 41 | $dataList = $modelFind->all(); |
... | ... | @@ -53,6 +53,7 @@ class ProjectRepository |
53 | 53 | if (!empty($map)) { |
54 | 54 | $modelFind->where($map); |
55 | 55 | } |
56 | + $modelFind->andWhere(["is_delete" => 0]); | |
56 | 57 | $pageCount = $modelFind->count(); |
57 | 58 | |
58 | 59 | return $pageCount; | ... | ... |