feat: add smt module

This commit is contained in:
nepiedg
2026-04-26 09:24:08 +08:00
parent 69eb3e5019
commit 613e4a58a9
78 changed files with 4629 additions and 5673 deletions
+164
View File
@@ -0,0 +1,164 @@
<?php
declare(strict_types=1);
namespace app\smt\controller\v1;
use app\smt\common\Response;
use app\smt\controller\BaseController;
use app\smt\service\QuitCheckinService;
use think\App;
class QuitCheckin extends BaseController
{
protected QuitCheckinService $service;
public function __construct(App $app)
{
parent::__construct($app);
$this->service = new QuitCheckinService();
}
public function profile()
{
try {
return Response::success($this->service->getProfile($this->getCurrentSmtUser()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function saveProfile()
{
try {
return Response::success($this->service->upsertProfile($this->getCurrentSmtUser(), $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function home()
{
try {
return Response::success($this->service->home($this->getCurrentSmtUserId()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function checkin()
{
try {
return Response::success($this->service->checkin($this->getCurrentSmtUserId(), $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function dreamPresets()
{
try {
return Response::success($this->service->listDreamPresets());
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function rewardGoals()
{
try {
return Response::success($this->service->listRewardGoals($this->getCurrentSmtUserId(), (string) $this->request->get('status', 'all')));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function createRewardGoal()
{
try {
return Response::success($this->service->createRewardGoal($this->getCurrentSmtUserId(), $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function updateRewardGoal(int $id)
{
try {
return Response::success($this->service->updateRewardGoal($this->getCurrentSmtUserId(), $id, $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function createSupervisorInvite()
{
try {
return Response::success($this->service->createSupervisorInvite($this->getCurrentSmtUserId(), (int) $this->request->post('days', 7)));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function bindSupervisorInvite()
{
try {
return Response::success($this->service->bindSupervisorInvite($this->getCurrentSmtUserId(), (string) $this->request->post('token', '')));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 400);
}
}
public function supervisorOverview()
{
try {
return Response::success($this->service->supervisorOverview($this->getCurrentSmtUserId()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function supervisorStatus()
{
try {
return Response::success($this->service->supervisorStatus($this->getCurrentSmtUserId()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function revokeSupervisorBinding()
{
try {
return Response::success($this->service->revokeSupervisorBinding($this->getCurrentSmtUserId(), $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 400);
}
}
public function reminderSettings()
{
try {
return Response::success($this->service->getReminderSettings($this->getCurrentSmtUserId()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
public function updateReminderSettings()
{
try {
return Response::success($this->service->updateReminderSettings($this->getCurrentSmtUserId(), $this->request->post()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 400);
}
}
public function runReminders()
{
try {
return Response::success($this->service->runReminders($this->getCurrentSmtUserId()));
} catch (\Throwable $e) {
return Response::error($e->getMessage(), $e->getCode() ?: 500);
}
}
}