first commit

This commit is contained in:
2026-05-07 16:37:25 +08:00
commit 822ed9a099
67 changed files with 1799 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace app\index\controller;
use app\BaseController;
use app\common\service\AuthService;
use think\facade\Session;
// 已完成
class Login extends BaseController
{
/*
处理登录请求(已完成)
*/
public function login(AuthService $authService)
{
$params = $this->request->only(['username', 'password'], 'post');
// 验证数据
if (empty($params['username']) || empty($params['password'])) {
return json(['code' => 400, 'message' => '用户名和密码不能为空']);
}
try {
$result = $authService->login($params['username'], $params['password']);
} catch (\Exception $e) {
return json(['code' => 400, 'message' => $e->getMessage(),'data' => []]);
}
return json(['code' => 200, 'message' => '登录成功', 'data' => $result]);
}
/*
退出登录(已完成)
*/
protected function logout()
{
Session::clear();
return json(['code' => 200, 'message' => '退出成功']);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace app\index\controller;
use app\BaseController;
use app\common\service\TicketService;
use think\facade\Session;
class Ticket extends BaseController
{
/**
* 更新工单(前台调用)
*/
public function updateTicket(TicketService $ticketService, $id)
{
$adminId = Session::get('id'); // 获取当前登录ID
$data = $this->request->post();
$allowFields = ['datanum', 'progress', 'status', 'remark', 'lock_time'];
try {
$result = $ticketService->updateTicket($id, $data, $allowFields, $adminId, false);
return json(['code' => 200, 'msg' => '更新成功', 'data' => $result]);
} catch (\Exception $e) {
return json(['code' => 400, 'msg' => $e->getMessage()]);
}
}
}