active(); })->where('id', $userNo); return ApiResponse::response('first', $query); } /** * 내정보 확인 */ public static function getMyInfo($request, bool $debug = false) { $apiUser = app('api_user'); $user = User::find($apiUser); $data=[ 'member' => $member, 'company' => $company ]; return ApiResponse::response('result', $data, $debug); } /** * 회원 등록 또는 수정 */ public static function setMember(array $params) { if ($res = ApiResponse::validate(isset($params['user_id']), '아이디 없음')) return $res; if ($res = ApiResponse::validate(isset($params['user_ncnm']), '이름 없음')) return $res; $pwd1 = $params['user_pwd1'] ?? null; $pwd2 = $params['user_pwd2'] ?? null; if ($res = ApiResponse::validate( !$pwd1 || $pwd1 === $pwd2, '비밀번호가 일치하지 않음' )) return $res; $now = now(); $data = [ 'USER_EMAIL' => $params['user_email'] ?? null, 'USER_HP' => $params['user_hp'] ?? null, 'USER_IP' => $params['user_ip'] ?? null, 'ALT_DTTM' => $now, ]; if (!empty($params['user_start_dt'])) { $data['USER_START_DT'] = $params['user_start_dt']; } if (!empty($params['user_end_dt'])) { $data['USER_END_DT'] = $params['user_end_dt']; } // 신규 등록 if (empty($params['user_no'])) { // 초기 비빌번호 설정이 없으면 0000 으로 셋팅 $pwd = $pwd1 ?? '0000'; $data += [ 'USER_ID' => $params['user_id'], 'USER_PWD' => hash('sha256', $pwd), 'USER_NCNM' => $params['user_ncnm'] ?? null, 'USER_PART' => $params['user_part'] ?? null, 'USER_DEPT' => $params['user_dept'] ?? null, 'USER_ROLE' => $params['user_role'] ?? null, 'USER_STATUS' => $params['user_status'] ?? null, 'USER_MEMO' => $params['user_memo'] ?? null, 'REG_DTTM' => $now, 'ALT_DTTM' => $now, ]; DB::table('SITE_USER_INFO')->insert($data); } // 수정 else { if (!empty($pwd1)) { $data['USER_PWD'] = hash('sha256', $pwd1); } if (AdminPermissionService::hasPermission(session('Adm.token'), 'AC')) { $data += [ 'USER_ID' => $params['user_id'], 'USER_NCNM' => $params['user_ncnm'], 'USER_PART' => $params['user_part'], 'USER_DEPT' => $params['user_dept'], 'USER_ROLE' => $params['user_role'], 'USER_STATUS' => $params['user_status'], 'USER_MEMO' => $params['user_memo'], 'ALT_DTTM' => $now, ]; } DB::table('SITE_USER_INFO') ->where('USER_NO', $params['user_no']) ->update($data); } return ApiResponse::response('success'); } /** * 관리자 권한 삭제 */ public static function delAdmin(int $userNo) { DB::table('SITE_ADMIN')->where('UNO', $userNo)->delete(); DB::table('SITE_USER_INFO') ->where('USER_NO', $userNo) ->update(['USER_STATUS' => '02']); return ApiResponse::response('success'); } /** * 관리자 권한 등록 */ public static function setAdmin(int $userNo) { $mem = DB::table('SITE_USER_INFO') ->select('USER_ROLE', 'USER_PART') ->where('USER_NO', $userNo) ->first(); if (!$mem) { return ApiResponse::error('존재하지 않는 회원입니다.', 404); } DB::table('SITE_ADMIN')->updateOrInsert( ['UNO' => $userNo], ['LEVEL' => 'public', 'COMMENT' => '일반관리자'] ); DB::table('SITE_USER_INFO') ->where('USER_NO', $userNo) ->update(['USER_STATUS' => '01']); return ApiResponse::response('success'); } }