feat: Add SHZ log inspection and HighGo database querying capabilities

- Introduced `inspect-shz-logs` skill for inspecting local and production logs with bounded read-only commands.
- Added `view.sh` script for log viewing with options for following logs and filtering by keywords.
- Created `query-shz-highgo` skill for querying the SHZ HighGo database through an SSH gateway.
- Implemented read-only SQL execution with strict controls on allowed statements and query structure.
- Added new domain and mapper classes for managing outdoor fair job associations.
- Enhanced `OutdoorFairController` to support job listing and management for outdoor fairs.
- Created SQL scripts for initializing outdoor fair job data and managing menu visibility.
This commit is contained in:
2026-06-25 23:13:35 +08:00
parent c24f5e6621
commit 82d3264c72
18 changed files with 781 additions and 4 deletions

View File

@@ -0,0 +1,56 @@
---
name: inspect-shz-logs
description: Inspect and follow the SHZ backend's local and production logs through bounded, read-only commands. Use when Claude Code is working in the shz-backend project and needs to diagnose startup failures, exceptions, request behavior, scheduled jobs, or runtime incidents from local backend.log or the production backend, error, info, and user logs on the shz server.
---
# Inspect SHZ Logs
Use the bundled script instead of assembling SSH commands manually. Keep every initial read bounded; follow logs only when the user explicitly asks to monitor live activity.
## Inspect local logs
Read the last 200 lines:
```bash
.claude/skills/inspect-shz-logs/scripts/view.sh local 200
```
Follow the local log interactively:
```bash
.claude/skills/inspect-shz-logs/scripts/view.sh local 200 --follow
```
## Inspect production logs
Read the main application log:
```bash
.claude/skills/inspect-shz-logs/scripts/view.sh online backend 200
```
Read the current error log:
```bash
.claude/skills/inspect-shz-logs/scripts/view.sh online error 200
```
Choose only one production log type: `backend`, `error`, `info`, or `user`. Add `--follow` as the final argument only for an explicit live-monitoring request.
For keyword analysis, fetch a bounded window and filter locally, for example:
```bash
.claude/skills/inspect-shz-logs/scripts/view.sh online error 1000 | rg -i 'exception|error|failed'
```
## Diagnose from logs
1. Establish whether the request concerns local or production behavior.
2. Read 100300 recent lines from the relevant log.
3. Expand up to the script's 5,000-line cap only when timestamps or stack traces require more context.
4. Correlate timestamps, thread names, exception causes, and nearby requests.
5. Report the evidence and likely cause without exposing tokens, passwords, personal data, or unrelated log content.
Treat production access as read-only. Never restart services, edit files, deploy code, truncate logs, or run arbitrary remote commands through this skill.
Read [references/log-locations.md](references/log-locations.md) only when checking server identity, paths, or supported log types.

View File

@@ -0,0 +1,19 @@
# Log locations
## Local
- Main log: `<project>/.local/logs/backend.log`
- Producer: `<project>/local.sh`
## Production: shz
- SSH: `root@39.98.44.136:6022`
- Application: `/opt/service/project/shz-backend/ruoyi-admin/target/ruoyi-admin.jar`
- Profile: `dev`
- HTTP port: `9091`
- Main process log: `/opt/service/project/shz-backend/logs/backend.log`
- Current error log: `/opt/service/project/shz-backend/logs/sys-error.log`
- Current info log: `/opt/service/project/shz-backend/logs/sys-info.log`
- Current user log: `/opt/service/project/shz-backend/logs/sys-user.log`
Use only the bundled read-only viewer. Rotated files use date suffixes but are intentionally not exposed by the default script.

View File

@@ -0,0 +1,109 @@
#!/usr/bin/env bash
set -euo pipefail
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
project_dir="$(cd "${skill_dir}/../../.." && pwd)"
local_log="${project_dir}/.local/logs/backend.log"
ssh_host="root@39.98.44.136"
ssh_port="6022"
remote_log_dir="/opt/service/project/shz-backend/logs"
usage() {
cat <<'EOF'
Usage:
view.sh local [lines] [--follow]
view.sh online [backend|error|info|user] [lines] [--follow]
Examples:
view.sh local 200
view.sh local 100 --follow
view.sh online backend 200
view.sh online error 500 --follow
EOF
}
validate_lines() {
local lines="$1"
if [[ ! "${lines}" =~ ^[0-9]+$ ]] || (( lines < 1 || lines > 5000 )); then
echo "Lines must be an integer between 1 and 5000: ${lines}" >&2
exit 2
fi
}
validate_follow() {
local follow="${1:-}"
if [[ -n "${follow}" && "${follow}" != "--follow" ]]; then
echo "Unknown option: ${follow}" >&2
usage >&2
exit 2
fi
}
view_local() {
local lines="${1:-200}"
local follow="${2:-}"
validate_lines "${lines}"
validate_follow "${follow}"
if [[ ! -f "${local_log}" ]]; then
echo "Local log does not exist: ${local_log}" >&2
echo "Start the project first with: ./local.sh start" >&2
exit 1
fi
if [[ "${follow}" == "--follow" ]]; then
tail -n "${lines}" -F -- "${local_log}"
else
tail -n "${lines}" -- "${local_log}"
fi
}
view_online() {
local kind="${1:-backend}"
local lines="${2:-200}"
local follow="${3:-}"
local remote_file
case "${kind}" in
backend) remote_file="${remote_log_dir}/backend.log" ;;
error) remote_file="${remote_log_dir}/sys-error.log" ;;
info) remote_file="${remote_log_dir}/sys-info.log" ;;
user) remote_file="${remote_log_dir}/sys-user.log" ;;
*)
echo "Unknown online log type: ${kind}" >&2
usage >&2
exit 2
;;
esac
validate_lines "${lines}"
validate_follow "${follow}"
if [[ "${follow}" == "--follow" ]]; then
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
tail -n "${lines}" -F -- "${remote_file}"
else
ssh -p "${ssh_port}" -o BatchMode=yes -o ConnectTimeout=10 "${ssh_host}" \
tail -n "${lines}" -- "${remote_file}"
fi
}
target="${1:-}"
case "${target}" in
local)
[[ $# -le 3 ]] || { usage >&2; exit 2; }
view_local "${2:-200}" "${3:-}"
;;
online)
[[ $# -le 4 ]] || { usage >&2; exit 2; }
view_online "${2:-backend}" "${3:-200}" "${4:-}"
;;
help|-h|--help)
usage
;;
*)
usage >&2
exit 2
;;
esac