|
@@ -35,22 +35,26 @@ class UserGroupController extends CatchController
|
|
|
*/
|
|
|
public function detail(Request $request) {
|
|
|
$this->validate($request, ['id' => 'required']);
|
|
|
+ $uid = $this->getLoginUserId();
|
|
|
$obj = DB::table('user_groups')
|
|
|
->where([
|
|
|
- 'uid' => $this->getLoginUserId(), 'is_enabled' => 1,
|
|
|
+ 'uid' => $uid, 'is_enabled' => 1,
|
|
|
'id' => $request->input('id')
|
|
|
])->first();
|
|
|
if($obj) {
|
|
|
// ToDo:完善
|
|
|
$obj->user_num = '-1';
|
|
|
$obj->tags_arr = \json_decode($obj->tags, true);
|
|
|
- $obj->gzh_nams = DB::table('gzh_ug_maps as a')
|
|
|
- ->leftJoin('wechat_authorization_infos as b', function($query) {
|
|
|
+ $obj->gzh_names = DB::table('gzh_ug_maps as a')
|
|
|
+ ->join('wechat_authorization_infos as b', function($query) use ($uid) {
|
|
|
$query->on('a.gzh_id', '=', 'b.id')
|
|
|
- ->where('b.is_enabled', 1);
|
|
|
+ ->where([
|
|
|
+ 'b.is_enabled' => 1,
|
|
|
+ 'b.user_id' => $uid
|
|
|
+ ]);
|
|
|
})->where([
|
|
|
- 'ug_id' => $request->input('id')
|
|
|
- ])->select('b.name')->get()->pluck('name')->toArray();
|
|
|
+ 'a.ug_id' => $request->input('id')
|
|
|
+ ])->select('b.nick_name')->get()->pluck('nick_name')->toArray();
|
|
|
}
|
|
|
|
|
|
return $obj;
|
|
@@ -85,29 +89,32 @@ class UserGroupController extends CatchController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除
|
|
|
+ * 批量删除
|
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
|
|
*/
|
|
|
public function delete(Request $request) {
|
|
|
- $this->validate($request, ['id' => 'required']);
|
|
|
+ $this->validate($request, ['ids' => 'required|array']);
|
|
|
|
|
|
- $model = UserGroupModel::where([
|
|
|
- 'uid' => $this->getLoginUserId(), 'id' => $request->input('id'),
|
|
|
- 'is_enabled' => 1,
|
|
|
- ])->first();
|
|
|
- if($model) {
|
|
|
- $model->is_enabled = 0;
|
|
|
- $model->save();
|
|
|
- GzhUgMapModel::where([
|
|
|
- 'ug_id' => $model->id,
|
|
|
- 'is_enabled' => 1
|
|
|
- ])->update([
|
|
|
- 'is_enabled' => 0
|
|
|
- ]);
|
|
|
+ foreach ($request->input('ids') as $id) {
|
|
|
+ $model = UserGroupModel::where([
|
|
|
+ 'uid' => $this->getLoginUserId(), 'id' => $id,
|
|
|
+ 'is_enabled' => 1,
|
|
|
+ ])->first();
|
|
|
+ if($model) {
|
|
|
+ $model->is_enabled = 0;
|
|
|
+ $model->save();
|
|
|
+ GzhUgMapModel::where([
|
|
|
+ 'ug_id' => $model->id,
|
|
|
+ 'is_enabled' => 1
|
|
|
+ ])->update([
|
|
|
+ 'is_enabled' => 0
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return 'ok';
|
|
|
}
|
|
|
}
|