|
@@ -389,4 +389,109 @@ class NoticeController extends Controller
|
|
|
}
|
|
}
|
|
|
return view('admin.notice.horse_race_lamp_update', compact('info', 'id'));
|
|
return view('admin.notice.horse_race_lamp_update', compact('info', 'id'));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function routeMailList()
|
|
|
|
|
+ {
|
|
|
|
|
+ $list = DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')
|
|
|
|
|
+ ->orderBy('ID', 'desc')
|
|
|
|
|
+ ->paginate(20);
|
|
|
|
|
+
|
|
|
|
|
+ return view('admin.notice.route_mail', compact('list'));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function routeMailAdd(Request $request)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($request->isMethod('post')) {
|
|
|
|
|
+ $mark = trim((string) $request->input('MailMark', ''));
|
|
|
|
|
+ $title = trim((string) $request->input('TitleString', ''));
|
|
|
|
|
+ $text = trim((string) $request->input('TextString', ''));
|
|
|
|
|
+ $status = (int) $request->input('Status', 1);
|
|
|
|
|
+
|
|
|
|
|
+ if ($mark === '' || $title === '' || $text === '') {
|
|
|
|
|
+ return $this->json(500, 'Mail mark, title and content are required');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!preg_match('/^[A-Za-z0-9_\-]{1,100}$/', $mark)) {
|
|
|
|
|
+ return $this->json(500, 'Mail mark only allows letters, numbers, underscore and dash, max length 100');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $now = date('Y-m-d H:i:s');
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')->insert([
|
|
|
|
|
+ 'MailMark' => $mark,
|
|
|
|
|
+ 'TitleString' => $title,
|
|
|
|
|
+ 'TextString' => mb_strlen($text) > 500 ? mb_substr($text, 0, 500) : $text,
|
|
|
|
|
+ 'Status' => $status ? 1 : 0,
|
|
|
|
|
+ 'CreatedAt' => $now,
|
|
|
|
|
+ 'UpdatedAt' => $now,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ } catch (\Throwable $exception) {
|
|
|
|
|
+ return $this->json(500, 'Save failed, mail mark may already exist');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return apiReturnSuc();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return view('admin.notice.route_mail_form', ['info' => null]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function routeMailUpdate(Request $request, $id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($request->isMethod('post')) {
|
|
|
|
|
+ $title = trim((string) $request->input('TitleString', ''));
|
|
|
|
|
+ $text = trim((string) $request->input('TextString', ''));
|
|
|
|
|
+ $status = (int) $request->input('Status', 1);
|
|
|
|
|
+
|
|
|
|
|
+ if ($title === '' || $text === '') {
|
|
|
|
|
+ return $this->json(500, 'Title and content are required');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')
|
|
|
|
|
+ ->where('ID', $id)
|
|
|
|
|
+ ->update([
|
|
|
|
|
+ 'TitleString' => $title,
|
|
|
|
|
+ 'TextString' => mb_strlen($text) > 500 ? mb_substr($text, 0, 500) : $text,
|
|
|
|
|
+ 'Status' => $status ? 1 : 0,
|
|
|
|
|
+ 'UpdatedAt' => date('Y-m-d H:i:s'),
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ return apiReturnSuc();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $info = DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')->where('ID', $id)->first();
|
|
|
|
|
+ return view('admin.notice.route_mail_form', compact('info'));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function routeMailSwitch($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $info = DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')->where('ID', $id)->first();
|
|
|
|
|
+ if (!$info) {
|
|
|
|
|
+ return $this->json(500, 'Config not found');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')
|
|
|
|
|
+ ->where('ID', $id)
|
|
|
|
|
+ ->update([
|
|
|
|
|
+ 'Status' => $info->Status ? 0 : 1,
|
|
|
|
|
+ 'UpdatedAt' => date('Y-m-d H:i:s'),
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ return apiReturnSuc();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function routeMailDelete($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $info = DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')->where('ID', $id)->first();
|
|
|
|
|
+ if (!$info) {
|
|
|
|
|
+ return $this->json(500, 'Config not found');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DB::connection('write')->transaction(function () use ($id, $info) {
|
|
|
|
|
+ DB::connection('write')->table('QPAccountsDB.dbo.RouteMailConfig')->where('ID', $id)->delete();
|
|
|
|
|
+ DB::connection('write')->table('QPAccountsDB.dbo.RouteMailSendLog')->where('MailMark', $info->MailMark)->delete();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return apiReturnSuc();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|