This commit is contained in:
王子琦
2026-01-09 15:48:50 +08:00
commit ea34c396dd
106 changed files with 60207 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead

17
mobile-h5/.eslintrc.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
parserOptions: {
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}

23
mobile-h5/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

24
mobile-h5/README.md Normal file
View File

@@ -0,0 +1,24 @@
# mobile-h5
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

19
mobile-h5/jsconfig.json Normal file
View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

12206
mobile-h5/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
mobile-h5/package.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "mobile-h5",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"lib-flexible": "^0.3.2",
"vant": "^2.13.9",
"vue": "^2.6.14",
"vue-router": "^3.5.1"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"postcss-pxtorem": "^6.1.0",
"vue-template-compiler": "^2.6.14"
}
}

View File

@@ -0,0 +1,11 @@
module.exports = {
plugins: {
autoprefixer: {},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
selectorBlackList: ['.ignore-px'],
minPixelValue: 2
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"
>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

12
mobile-h5/src/App.vue Normal file
View File

@@ -0,0 +1,12 @@
<template>
<div id="app">
<router-view />
</div>
</template>
<style>
#app {
min-height: 100vh;
background-color: #f7f8fa;
}
</style>

View File

@@ -0,0 +1,72 @@
const BASE_URL = '/api/registrations'
/**
* 获取所有注册记录
*/
export async function getRegistrations() {
const response = await fetch(BASE_URL)
if (!response.ok) {
throw new Error('获取注册列表失败')
}
return response.json()
}
/**
* 根据ID获取单条注册记录
* @param {number} id
*/
export async function getRegistrationById(id) {
const response = await fetch(`${BASE_URL}/${id}`)
if (response.status === 404) {
return null
}
if (!response.ok) {
throw new Error('获取注册记录失败')
}
return response.json()
}
/**
* 创建注册记录
* @param {object} registration
*/
export async function createRegistration(registration) {
const response = await fetch(BASE_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(registration)
})
if (!response.ok) {
throw new Error('创建注册记录失败')
}
return response.json()
}
/**
* 更新注册记录
* @param {number} id
* @param {object} registration
*/
export async function updateRegistration(id, registration) {
const response = await fetch(`${BASE_URL}/${id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(registration)
})
return response.ok
}
/**
* 删除注册记录
* @param {number} id
*/
export async function deleteRegistration(id) {
const response = await fetch(`${BASE_URL}/${id}`, {
method: 'DELETE'
})
return response.ok
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,59 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

16
mobile-h5/src/main.js Normal file
View File

@@ -0,0 +1,16 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Vant from 'vant'
import 'vant/lib/index.css'
import 'lib-flexible/flexible'
import './styles/global.css'
Vue.config.productionTip = false
Vue.use(Vant)
new Vue({
router,
render: h => h(App)
}).$mount('#app')

View File

@@ -0,0 +1,25 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import RegistrationList from '../views/RegistrationList.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/registrations',
name: 'registrations',
component: RegistrationList
}
]
const router = new VueRouter({
routes
})
export default router

View File

@@ -0,0 +1,27 @@
html,
body {
height: 100%;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
background-color: #f7f8fa;
color: #323233;
}
a {
color: inherit;
text-decoration: none;
}
.page-container {
min-height: 100vh;
background-color: #f7f8fa;
/* padding: 12px 12px 64px; */
box-sizing: border-box;
}
.van-cell-group--inset{
padding: 0;
}

View File

@@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

View File

@@ -0,0 +1,94 @@
<template>
<div class="home page-container">
<van-nav-bar
title="Vant H5 模板"
left-text="返回"
left-arrow
fixed
placeholder
@click-left="onBack"
/>
<div class="hero-card">
<div class="hero-title">Vue 2 + Vant</div>
<div class="hero-subtitle">移动端开箱即用的 UI 模板</div>
<van-button type="primary" block round @click="onAction">立即体验</van-button>
</div>
<van-grid :border="false" column-num="3" clickable>
<van-grid-item icon="fire-o" text="高质量组件" />
<van-grid-item icon="guide-o" text="移动端导航" />
<van-grid-item icon="balance-o" text="主题可定制" />
</van-grid>
<van-cell-group inset title="快速入口">
<van-cell title="登记列表" icon="orders-o" is-link to="/registrations" />
<van-cell title="表单示例" icon="todo-list-o" is-link @click="onNav('表单示例')" />
</van-cell-group>
<van-divider>更多组件请查看 Vant 文档</van-divider>
<van-tabbar v-model="activeTab" fixed>
<van-tabbar-item icon="home-o">首页</van-tabbar-item>
<van-tabbar-item icon="friends-o">社区</van-tabbar-item>
<van-tabbar-item icon="setting-o">我的</van-tabbar-item>
</van-tabbar>
</div>
</template>
<script>
export default {
name: 'HomeView',
data () {
return {
activeTab: 0
}
},
methods: {
onBack () {
if (window.history.length > 1) {
this.$router.back()
}
},
onAction () {
this.$toast('Vant 已就绪')
},
onNav (name) {
this.$dialog.alert({
title: '示例入口',
message: `${name} 可在此扩展`
})
}
}
}
</script>
<style scoped>
.home {
padding-top: 16px;
}
.hero-card {
background: linear-gradient(135deg, #3f8cff, #65c5ff);
color: #fff;
border-radius: 12px;
padding: 20px 16px;
box-shadow: 0 10px 30px rgba(63, 140, 255, 0.16);
margin-bottom: 16px;
}
.hero-title {
font-size: 20px;
font-weight: 700;
margin-bottom: 6px;
}
.hero-subtitle {
opacity: 0.9;
margin-bottom: 14px;
}
.van-grid {
margin-bottom: 12px;
}
</style>

View File

@@ -0,0 +1,353 @@
<template>
<div class="registration-list page-container">
<van-nav-bar
title="登记列表"
left-text=""
fixed
placeholder
@click-left="onBack"
/>
<van-pull-refresh
v-model="refreshing"
class="list-wrapper"
@refresh="onRefresh"
>
<template #loading><div style="height:0"/></template>
<van-list
v-model="loading"
:finished="finished"
:loading-text="refreshing ? '' : '加载中...'"
finished-text="没有更多了"
@load="loadData"
>
<div v-for="item in list" :key="item.id" class="card-item">
<div class="card-header">
<div class="card-title">
<div class="name">{{ item.customerName }}</div>
<div class="time">{{ item.registerTime }}</div>
</div>
<van-tag :type="getStatusType(item.status)" class="status-tag">
{{ item.status }}
</van-tag>
</div>
<div class="card-body">
<div class="info-row">
<span class="label">联系方式</span>
<span class="value">{{ item.contact || '-' }}</span>
</div>
<template v-if="isLocked(item)">
<div class="info-row">
<span class="label">服务类型</span>
<span class="value">{{ item.serviceType || '-' }}</span>
</div>
<div class="info-row">
<span class="label">电源类型</span>
<span class="value">{{ item.powerType || '-' }}</span>
</div>
<div class="info-row">
<span class="label">备注</span>
<span class="value">{{ item.note || '-' }}</span>
</div>
</template>
<template v-else>
<van-field
v-model.trim="item.serviceType"
label="服务类型"
placeholder="请选择服务类型"
input-align="right"
is-link
border
class="editable-field"
@click="openPicker(item, 'serviceType')"
/>
<van-field
v-model.trim="item.powerType"
label="电源类型"
placeholder="请选择电源类型"
input-align="right"
is-link
border
class="editable-field"
@click="openPicker(item, 'powerType')"
/>
<van-field
v-model.trim="item.note"
type="textarea"
label="备注"
placeholder="请输入备注"
autosize
border
class="editable-field"
/>
</template>
</div>
<div class="card-actions" v-if="!isLocked(item)">
<van-button
type="primary"
size="small"
round
class="submit-btn"
@click="submitItem(item)"
>
登记完成
</van-button>
</div>
</div>
<van-empty v-if="!loading && list.length === 0" description="暂无登记记录" />
</van-list>
</van-pull-refresh>
<van-popup v-model="showPicker" position="bottom" round>
<van-picker
show-toolbar
:columns="pickerColumns"
@confirm="onPickerConfirm"
@cancel="showPicker = false"
/>
</van-popup>
</div>
</template>
<script>
import { getRegistrations, updateRegistration } from '@/api/registration'
import { Toast,Dialog } from 'vant';
export default {
name: 'RegistrationList',
data() {
return {
list: [],
loading: false,
finished: false,
refreshing: true,
showPicker: false,
pickerColumns: [],
currentItem: null,
currentField: '',
serviceOptions: ['安装', '维修', '咨询'],
powerOptions: ['市电', '锂电', '其他']
}
},
methods: {
onBack() {
if (window.history.length > 1) {
this.$router.back()
} else {
this.$router.push('/')
}
},
async loadData() {
try {
const data = await getRegistrations()
this.list = data
setTimeout(()=>{
this.finished = true
},500)
} catch (error) {
this.$toast.fail('加载失败')
console.error(error)
} finally {
this.loading = false
this.refreshing = false
}
},
async onRefresh() {
this.finished = false
this.list = []
await this.loadData()
},
getStatusType(status) {
const map = {
'已登记': 'success',
'待登记': 'primary',
'处理中': 'primary',
'已完成': 'success',
'已取消': 'default'
}
return map[status] || 'warning'
},
isLocked(item = {}) {
return item.status === '已登记'
},
async submitItem(item) {
try {
const confirmed = await Dialog.confirm({
title: '确认提交',
message: '提交后将锁定该记录,是否继续?'
}).then(() => true).catch(() => false)
if (!confirmed) return
Toast.loading()
item.status = '已登记'
const success = await updateRegistration(item.id, item)
Toast.clear()
if (success) {
this.$toast.success('提交成功')
} else {
this.$toast.fail('提交失败')
}
} catch (error) {
this.$toast.fail('提交失败')
console.error(error)
}
},
openPicker(item, field) {
if (this.isLocked(item)) return
this.currentItem = item
this.currentField = field
this.pickerColumns = field === 'serviceType' ? this.serviceOptions : this.powerOptions
this.showPicker = true
},
onPickerConfirm(value) {
if (this.isLocked(this.currentItem)) {
this.showPicker = false
return
}
if (this.currentItem && this.currentField) {
this.$set(this.currentItem, this.currentField, value)
}
this.showPicker = false
}
}
}
</script>
<style scoped>
.registration-list {
background: #f7f8fa;
min-height: 100vh;
padding-top: 16px;
padding-bottom: 20px;
display: flex;
flex-direction: column;
}
.list-wrapper {
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
padding: 0 12px;
box-sizing: border-box;
}
.card-item {
margin-top: 12px;
padding: 14px 14px 10px;
border-radius: 14px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
background: #fff;
}
.card-item:first-of-type {
margin-top: 0;
}
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.card-title {
flex: 1;
}
.name {
font-size: 16px;
font-weight: 700;
color: #303133;
line-height: 1.3;
}
.time {
margin-top: 4px;
font-size: 12px;
color: #909399;
}
.status-tag {
border-radius: 12px;
padding: 3px 12px;
font-size: 12px;
}
.card-body {
margin-top: 12px;
padding-top: 10px;
border-top: 1px solid #f0f0f0;
display: grid;
gap: 6px;
}
.card-actions {
margin-top: 12px;
display: flex;
justify-content: flex-end;
}
.submit-btn {
padding: 0 18px;
width: 100%;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 14px;
color: #303133;
}
.label {
color: #909399;
}
.value {
max-width: 70%;
text-align: right;
word-break: break-all;
}
.info-row{
padding: 6px 0;
}
:deep(.editable-field){
padding: 6px 0;
}
:deep(.editable-field .van-field__control) {
font-size: 14px;
color: #303133;
padding: 0 !important;
}
:deep(.editable-field .van-field__control--textarea) {
min-height: 80px;
line-height: 1.6;
padding: 10px 12px !important;
background: #f2f3f5;
border: 1px solid #e6e8eb;
border-radius: 10px;
}
:deep(.editable-field .van-field__body) {
align-items: flex-start;
}
:deep(.editable-field .van-field__control::placeholder) {
color: #c0c4cc;
}
:deep(.editable-field .van-field__label) {
color: #909399;
}
:deep(.editable-field .van-field__right-icon) {
color: #c0c4cc;
}
</style>

12
mobile-h5/vue.config.js Normal file
View File

@@ -0,0 +1,12 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8088',
changeOrigin: true
}
}
}
})

BIN
pc-web.zip Normal file

Binary file not shown.

3
pc-web/.browserslistrc Normal file
View File

@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead

2
pc-web/.env.development Normal file
View File

@@ -0,0 +1,2 @@
VUE_APP_API_BASE_URL=/api

2
pc-web/.env.production Normal file
View File

@@ -0,0 +1,2 @@
VUE_APP_API_BASE_URL=/api

17
pc-web/.eslintrc.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}

23
pc-web/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

24
pc-web/README.md Normal file
View File

@@ -0,0 +1,24 @@
# pc-web
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

5
pc-web/babel.config.js Normal file
View File

@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

258
pc-web/index.html Normal file
View File

@@ -0,0 +1,258 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>信息登记</title>
<style>
:root {
color-scheme: light dark;
--bg: #f5f5f5;
--card: #ffffff;
--text: #222222;
--primary: #2b7cff;
--muted: #666666;
--success: #16a34a;
--danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--muted: #9ca3af;
--success: #22c55e;
--danger: #f87171;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
background: var(--bg);
color: var(--text);
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
}
.card {
width: min(520px, 92vw);
background: var(--card);
border-radius: 18px;
padding: 28px 24px;
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}
h1 {
margin: 0 0 10px;
font-size: 24px;
}
p {
margin: 0 0 22px;
color: var(--muted);
font-size: 14px;
}
label {
display: block;
font-weight: 600;
margin-bottom: 6px;
}
input {
width: 100%;
padding: 12px 14px;
border: 1px solid #d1d5db;
border-radius: 10px;
font-size: 16px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
background: transparent;
color: inherit;
}
input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(43, 124, 255, 0.2);
}
.field {
margin-bottom: 18px;
}
button {
width: 100%;
padding: 14px 16px;
border: none;
border-radius: 12px;
background: var(--primary);
color: #fff;
font-size: 16px;
font-weight: 700;
letter-spacing: 0.5px;
cursor: pointer;
transition: transform 0.08s ease, box-shadow 0.2s ease;
box-shadow: 0 12px 24px rgba(43, 124, 255, 0.25);
}
button:active {
transform: scale(0.99);
box-shadow: 0 8px 18px rgba(43, 124, 255, 0.22);
}
button[disabled] {
opacity: 0.75;
cursor: not-allowed;
box-shadow: none;
}
.success {
text-align: center;
padding: 10px 4px 0;
}
.success-icon {
width: 72px;
height: 72px;
margin: 6px auto 14px;
border-radius: 999px;
background: rgba(22, 163, 74, 0.14);
border: 1px solid rgba(22, 163, 74, 0.25);
display: grid;
place-items: center;
color: var(--success);
}
.success-title {
font-size: 20px;
font-weight: 800;
margin: 0 0 6px;
}
.success-desc {
margin: 0 0 18px;
color: var(--muted);
font-size: 14px;
}
.success-btn {
background: var(--success);
box-shadow: 0 12px 24px rgba(22, 163, 74, 0.22);
}
.toast {
position: fixed;
left: 50%;
bottom: 36px;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.82);
color: #fff;
padding: 12px 16px;
border-radius: 999px;
font-size: 14px;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
}
.toast.error {
background: rgba(220, 38, 38, 0.92);
}
.toast.show {
opacity: 1;
}
</style>
</head>
<body>
<div class="card">
<h1>信息登记</h1>
<p>请填写您的姓名和联系电话,点击“确定”提交。</p>
<div id="success" class="success" hidden>
<div class="success-icon" aria-hidden="true">
<svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 6 9 17l-5-5"></path>
</svg>
</div>
<div class="success-title">提交成功</div>
<div class="success-desc">我们已收到您的信息。</div>
<button id="success-again" style="display: none" class="success-btn" type="button">继续登记</button>
</div>
<form id="reg-form" novalidate>
<div class="field">
<label for="name">姓名</label>
<input id="name" name="name" type="text" placeholder="请输入姓名" required>
</div>
<div class="field">
<label for="phone">联系电话</label>
<input id="phone" name="phone" type="tel" placeholder="请输入手机号" inputmode="numeric" pattern="^\\d{6,}$" required>
</div>
<button type="submit">确定</button>
</form>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script>
const form = document.getElementById('reg-form');
const toast = document.getElementById('toast');
const success = document.getElementById('success');
const successAgain = document.getElementById('success-again');
const submitButton = form.querySelector('button[type="submit"]');
function showToast(message, variant = 'default') {
toast.textContent = message;
toast.classList.toggle('error', variant === 'error');
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 1800);
}
function showSuccess() {
form.hidden = true;
success.hidden = false;
successAgain.focus();
}
function resetToForm() {
success.hidden = true;
form.hidden = false;
form.reset();
form.name.focus();
}
successAgain.addEventListener('click', resetToForm);
form.addEventListener('submit', async (event) => {
event.preventDefault();
const name = form.name.value.trim();
const phone = form.phone.value.trim();
if (!name) {
showToast('请填写姓名', 'error');
return;
}
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
showToast('请填写有效联系电话', 'error');
return;
}
submitButton.disabled = true;
const originalButtonText = submitButton.textContent;
submitButton.textContent = '提交中...';
try {
// 调用后端接口提交数据
const response = await fetch('http://118.195.205.71:8888/api/registrations', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
customerName: name,
contact: phone
})
});
if (response.ok) {
showToast('提交成功');
showSuccess();
} else {
showToast('提交失败,请重试', 'error');
}
} catch {
showToast('网络错误,请检查连接', 'error');
} finally {
submitButton.disabled = false;
submitButton.textContent = originalButtonText;
}
});
</script>
</body>
</html>

18422
pc-web/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

30
pc-web/package.json Normal file
View File

@@ -0,0 +1,30 @@
{
"name": "pc-web",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.13.2",
"core-js": "^3.6.5",
"element-ui": "^2.15.14",
"fastclick": "^1.0.6",
"qrcode": "^1.5.4",
"vue": "^2.6.11",
"vue-loading-overlay": "3.0",
"vue-router": "^3.2.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.19",
"@vue/cli-plugin-eslint": "~4.5.19",
"@vue/cli-plugin-router": "~4.5.19",
"@vue/cli-service": "~4.5.19",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
}
}

BIN
pc-web/pc-web.zip Normal file

Binary file not shown.

BIN
pc-web/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

26
pc-web/public/index.html Normal file
View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>业务登记系统</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<style>
.el-main{
padding: 0;
}
</style>
</html>

67
pc-web/src/App.vue Normal file
View File

@@ -0,0 +1,67 @@
<template>
<el-container class="layout">
<!-- <el-header class="layout__header" height="64px">
<div class="logo">业务登记系统</div>
</el-header> -->
<el-container>
<el-aside width="200px" v-if="false" class="layout__aside">
<el-menu router :default-active="$route.path" class="layout__menu">
<el-menu-item index="/">
<i class="el-icon-house"></i>
<span>首页</span>
</el-menu-item>
<!-- <el-menu-item index="/about">
<i class="el-icon-info"></i>
<span>关于</span>
</el-menu-item> -->
</el-menu>
</el-aside>
<el-main class="layout__main">
<router-view />
</el-main>
</el-container>
</el-container>
</template>
<style>
body {
margin: 0;
background: #f5f7fa;
}
.layout {
min-height: 100vh;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.layout__header {
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.logo {
font-size: 18px;
color: #409eff;
font-weight: 600;
letter-spacing: 0.5px;
}
.layout__aside {
border-right: 1px solid #ebeef5;
}
.layout__menu {
border: none;
}
.layout__main {
padding: 24px;
}
.layout__header-links {
display: flex;
align-items: center;
}
</style>

47
pc-web/src/api/client.js Normal file
View File

@@ -0,0 +1,47 @@
import axios from 'axios'
function normalizeApiBaseUrl(configuredBaseUrl) {
if (!configuredBaseUrl) return '/api'
if (/^https?:\/\//i.test(configuredBaseUrl)) {
try {
const url = new URL(configuredBaseUrl)
if (
process.env.NODE_ENV === 'production' &&
(url.hostname === 'localhost' || url.hostname === '127.0.0.1')
) {
return '/api'
}
return configuredBaseUrl
} catch (e) {
return '/api'
}
}
return configuredBaseUrl
}
const baseURL = normalizeApiBaseUrl(process.env.VUE_APP_API_BASE_URL)
export const apiClient = axios.create({
baseURL
})
export function buildPdfUrl(fileName) {
if (!fileName) return ''
const name = String(fileName)
if (/^https?:\/\//i.test(name)) return name
const encodedName = encodeURIComponent(name)
const configuredBaseUrl = normalizeApiBaseUrl(process.env.VUE_APP_API_BASE_URL)
if (configuredBaseUrl && /^https?:\/\//i.test(configuredBaseUrl)) {
try {
const url = new URL(configuredBaseUrl)
return `${url.origin}/pdf/${encodedName}`
} catch (e) {
return `/pdf/${encodedName}`
}
}
return `/pdf/${encodedName}`
}

5
pc-web/src/api/pdfs.js Normal file
View File

@@ -0,0 +1,5 @@
import { apiClient as client } from './client'
export function fetchPdfs() {
return client.get('/pdfs').then(res => res.data)
}

View File

@@ -0,0 +1,49 @@
import { apiClient as client } from './client'
export function fetchRegistrations() {
return client.get('/registrations').then(res => res.data)
}
export function fetchRegistration(id) {
return client.get(`/registrations/${id}`).then(res => res.data)
}
export function createRegistration(payload) {
return client.post('/registrations', payload).then(res => res.data)
}
export function updateRegistration(id, payload) {
return client.put(`/registrations/${id}`, payload).then(res => res.data)
}
export function deleteRegistration(id) {
return client.delete(`/registrations/${id}`).then(res => res.data)
}
export function sendSmsToUserPhone(id) {
return client.get(`/registrations/sendSms/${id}`).then(res => res.data)
}
export function searchRegistrations(params = {}) {
return client
.get('/registrations/search', {
params: {
customerName: params.customerName,
contact: params.contact,
serviceType: params.serviceType,
powerType: params.powerType,
status: params.status,
urlPath: params.urlPath
}
})
.then(res => res.data)
}
export function searchByPhone(phoneNumber) {
return searchRegistrations({ contact: phoneNumber, status: '已登记' })
}
export function serchUrlPath(urlPath) {
return client.get(`/registrations/getPdfPath/${urlPath}`).then(res => res.data)
}

BIN
pc-web/src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,59 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

14
pc-web/src/main.js Normal file
View File

@@ -0,0 +1,14 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import FastClick from 'fastclick'
FastClick.attach(document.body);
Vue.config.productionTip = false
Vue.use(ElementUI)
new Vue({
router,
render: h => h(App)
}).$mount('#app')

View File

@@ -0,0 +1,42 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/register',
name: 'Register',
component: () => import('../views/Register.vue')
},
{
path: '/phone-query',
name: 'PhoneQuery',
component: () => import('../views/PhoneQuery.vue')
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
},
{
path: '/getfile/:urlPath',
name: 'GetFile',
component: () => import('../views/GetFile.vue')
}
]
const router = new VueRouter({
routes
})
export default router

View File

@@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

View File

@@ -0,0 +1,27 @@
<template>
<div class="catch-all">
<h1>URL 后缀捕获页面</h1>
<p>当前 URL 参数: <strong>{{ $route.params.pathMatch }}</strong></p>
<p>完整路径: <strong>{{ fullPath }}</strong></p>
</div>
</template>
<script>
export default {
name: 'CatchAll',
computed: {
fullPath() {
return this.$route.fullPath
}
},
mounted() {
console.log('URL 后缀参数:', this.$route.params.pathMatch)
}
}
</script>
<style scoped>
.catch-all {
padding: 20px;
}
</style>

View File

@@ -0,0 +1,51 @@
<template>
<div class="get-file">
<loading :active="isLoading" :is-full-page="true" />
</div>
</template>
<script>
import Loading from "vue-loading-overlay";
import "vue-loading-overlay/dist/vue-loading.css";
import { serchUrlPath } from "../api/registrations";
import { buildPdfUrl } from "../api/client";
export default {
name: "GetFile",
components: {
Loading,
},
data() {
return {
isLoading: false,
};
},
computed: {
fileSuffix() {
return this.$route.params.urlPath;
},
fullPath() {
return this.$route.fullPath;
},
},
mounted() {
this.isLoading = true;
serchUrlPath(this.fileSuffix).then((res) => {
if (res != null && res.length > 1) {
window.location.href = buildPdfUrl(res);
} else {
this.isLoading = false;
alert("请访问短信提供的链接!");
}
}).catch(() => {
this.isLoading = false;
});
},
};
</script>
<style scoped>
.get-file {
padding: 20px;
}
</style>

761
pc-web/src/views/Home.vue Normal file
View File

@@ -0,0 +1,761 @@
<template>
<div class="home">
<!-- <el-row :gutter="16" class="home__summary">
<el-col :md="6" :sm="12" :xs="24" v-for="item in summaryCards" :key="item.label">
<el-card shadow="hover" class="home__card">
<div class="home__card-title">{{ item.label }}</div>
<div class="home__card-value">{{ item.value }}</div>
<div class="home__card-footer">
<i :class="item.icon"></i>
<span>{{ item.sub }}</span>
</div>
</el-card>
</el-col>
</el-row> -->
<el-dialog
:visible.sync="qrDialogVisible"
title="登记信息二维码"
width="320px"
center
>
<div style="text-align: center;">
<canvas ref="qrCanvas"></canvas>
<p style="margin-top: 12px; color: #909399; font-size: 12px;">扫描二维码查看登记信息</p>
</div>
</el-dialog>
<el-dialog
:visible.sync="showDialog"
title="文件列表"
:fullscreen="isMobile"
:width="isMobile ? '100%' : '1000px'"
:top="isMobile ? '0' : '15vh'"
>
<div v-loading="pdfLoading" style="min-height: 120px;">
<el-empty v-if="!pdfLoading && pdfFiles.length === 0" description="暂无PDF文件" />
<div v-else>
<div class="home__pdf-search">
<el-input v-model="pdfSearchKeyword" size="large" placeholder="搜索文件名" />
</div>
<el-empty v-if="!pdfLoading && filteredPdfFiles.length === 0" description="无匹配文件" />
<el-table
:height="isMobile ? null : 500"
v-else
:data="filteredPdfFiles"
size="mini"
border
style="width: 100%;"
@row-click="handlePdfRowClick"
>
<el-table-column label="选择" width="60" align="center">
<template slot-scope="scope">
<el-radio v-model="selectedFileName" :label="scope.row.name">&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column prop="name" label="文件名" min-width="420">
<template slot-scope="scope">
<el-link
:href="pdfHref(scope.row)"
type="primary"
@click.native.prevent="openPdf(scope.row)"
>
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<!-- <el-table-column label="操作" width="120" align="center">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="openPdf(scope.row)">打开</el-button>
</template>
</el-table-column> -->
</el-table>
</div>
</div>
<template #footer>
<el-button type="primary" @click="confirmSaveData">确认登记</el-button>
</template>
</el-dialog>
<el-card class="home__card home__table-card">
<div slot="header" class="home__card-header">
<span class="home__card-header-title">登记列表</span>
<div class="home__header-actions">
<!-- <el-button size="mini" class="home__header-action home__header-action--pdf" @click="openPdfDialog">文件列表</el-button> -->
<el-button size="small" type="primary" class="home__header-action" @click="loadData" :loading="loading">刷新</el-button>
</div>
</div>
<div v-loading="loading">
<el-table v-if="!isMobile" height="650px" border align="center" :data="tableData" stripe size="medium">
<!-- <el-table-column prop="id" label="ID" width="80" /> -->
<el-table-column align="center" prop="registerTime" label="登记时间" min-width="180" />
<el-table-column align="center" prop="customerName" label="客户名称*" min-width="140">
<template slot-scope="scope">
<template v-if="isEditable(scope.row)">
<el-input v-model="scope.row.customerNameDraft" size="mini" />
</template>
<template v-else>{{ scope.row.customerName }}</template>
</template>
</el-table-column>
<el-table-column align="center" prop="contact" label="联系方式*" min-width="140">
<template slot-scope="scope">
<template v-if="isEditable(scope.row)">
<el-input v-model="scope.row.contactDraft" size="mini" />
</template>
<template v-else><div >{{ scope.row.contact }}</div></template>
</template>
</el-table-column>
<el-table-column align="center" prop="serviceType" label="服务类型*" min-width="120">
<template slot-scope="scope">
<template v-if="isEditable(scope.row)">
<el-select
v-model="scope.row.serviceTypeDraft"
size="mini"
placeholder="请选择"
clearable
style="width: 100%;"
>
<el-option
v-for="opt in serviceTypeOptions"
:key="opt"
:label="opt"
:value="opt"
/>
</el-select>
</template>
<template v-else>{{ scope.row.serviceType }}</template>
</template>
</el-table-column>
<el-table-column align="center" prop="powerType" label="办电类型*" min-width="120">
<template slot-scope="scope">
<template v-if="isEditable(scope.row)">
<el-select
v-model="scope.row.powerTypeDraft"
size="mini"
placeholder="请选择"
clearable
style="width: 100%;"
>
<el-option
v-for="opt in powerTypeOptions"
:key="opt"
:label="opt"
:value="opt"
/>
</el-select>
</template>
<template v-else>{{ scope.row.powerType }}</template>
</template>
</el-table-column>
<el-table-column align="center" prop="status" label="状态" width="120">
<template slot-scope="scope">
<el-tag :type="statusType(scope.row.status)" disable-transitions>
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="note" label="备注" min-width="160">
<template slot-scope="scope">
<template v-if="isEditable(scope.row)">
<el-input v-model="scope.row.noteDraft" size="mini" />
</template>
<template v-else>{{ scope.row.note }}</template>
</template>
</el-table-column>
<!-- <el-table-column align="center" label="二维码" width="80">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="showQrCode(scope.row)">
查看
</el-button>
</template>
</el-table-column> -->
<el-table-column align="center" label="操作" width="180">
<template slot-scope="scope">
<el-button
type="text"
size="mini"
v-if="isEditable(scope.row)"
:loading="isSaving(scope.row)"
:disabled="isSaving(scope.row) || !canSave(scope.row)"
@click="openFileDialog(scope.row)"
>
登记
</el-button>
<el-popconfirm
title="确定要删除这条记录吗?"
confirm-button-text="确定"
cancel-button-text="取消"
style="flex: 1;"
@confirm="deleteRow(scope.row)"
>
<el-button
slot="reference"
class="home__danger-text"
type="text"
size="mini"
:loading="isDeleting(scope.row)"
:disabled="isSaving(scope.row) || isDeleting(scope.row)"
>
删除
</el-button>
</el-popconfirm>
<!-- <el-button
type="text"
size="mini"
v-if="!isEditable(scope.row)"
@click="sendSms(scope.row.id)"
>
发送文件通知
</el-button> -->
</template>
</el-table-column>
</el-table>
<div v-else class="home__mobile-list">
<el-empty v-if="!loading && tableData.length === 0" description="暂无数据" />
<el-card v-else v-for="row in tableData" :key="row.id" class="home__mobile-card">
<div class="home__mobile-card-header">
<div class="home__mobile-card-time">{{ row.registerTime }}</div>
<el-tag size="mini" :type="statusType(row.status)" disable-transitions>{{ row.status }}</el-tag>
</div>
<div class="home__mobile-field">
<div class="home__mobile-label">客户名称*</div>
<div class="home__mobile-value">
<el-input v-if="isEditable(row)" v-model="row.customerNameDraft" size="small" />
<span v-else>{{ row.customerName }}</span>
</div>
</div>
<div class="home__mobile-field">
<div class="home__mobile-label">联系方式*</div>
<div class="home__mobile-value">
<el-input v-if="isEditable(row)" v-model="row.contactDraft" size="small" />
<span v-else>{{ row.contact }}</span>
</div>
</div>
<div class="home__mobile-field">
<div class="home__mobile-label">服务类型*</div>
<div class="home__mobile-value">
<el-select
v-if="isEditable(row)"
v-model="row.serviceTypeDraft"
size="small"
placeholder="请选择"
clearable
style="width: 100%;"
>
<el-option v-for="opt in serviceTypeOptions" :key="opt" :label="opt" :value="opt" />
</el-select>
<span v-else>{{ row.serviceType }}</span>
</div>
</div>
<div class="home__mobile-field">
<div class="home__mobile-label">办电类型*</div>
<div class="home__mobile-value">
<el-select
v-if="isEditable(row)"
v-model="row.powerTypeDraft"
size="small"
placeholder="请选择"
clearable
style="width: 100%;"
>
<el-option v-for="opt in powerTypeOptions" :key="opt" :label="opt" :value="opt" />
</el-select>
<span v-else>{{ row.powerType }}</span>
</div>
</div>
<div class="home__mobile-field">
<div class="home__mobile-label">备注</div>
<div class="home__mobile-value">
<el-input v-if="isEditable(row)" v-model="row.noteDraft" size="small" />
<span v-else>{{ row.note }}</span>
</div>
</div>
<div class="home__mobile-actions">
<el-button
v-if="isEditable(row)"
type="primary"
size="medium "
:loading="isSaving(row)"
style="flex: 1;"
:disabled="isSaving(row) || !canSave(row)"
@click="openFileDialog(row)"
>
登记
</el-button>
<el-popconfirm
title="确定要删除这条记录吗?"
confirm-button-text="确定"
cancel-button-text="取消"
@confirm="deleteRow(row)"
>
<el-button
slot="reference"
type="danger"
size="medium "
style="flex: 1;"
:loading="isDeleting(row)"
:disabled="isSaving(row) || isDeleting(row)"
>
删除
</el-button>
</el-popconfirm>
</div>
<!-- <div v-else class="home__mobile-actions">
<el-button type="primary" size="mini" plain @click="showQrCode(row)">
查看二维码
</el-button>
</div> -->
</el-card>
</div>
</div>
</el-card>
</div>
</template>
<script>
import { buildPdfUrl } from '@/api/client'
import Qrcode from'qrcode'
export default {
name: 'Home',
data() {
return {
showDialog:false,
qrDialogVisible: false,
pdfLoading: false,
pdfFiles: [],
pdfSearchKeyword: '',
loading: false,
savingId: null,
deletingId: null,
windowWidth: typeof window !== 'undefined' ? window.innerWidth : 1024,
serviceTypeOptions: ['办电类','咨询类'],
powerTypeOptions: ['高压新装、增容', '低压居民新装、增容', '低压非居民新装、增容','低压分布式电源新装、增容','个人电动汽车充电桩','新户通电','电能表校验','低压公共汽车充电桩业务','改压','小区配套新装'],
summaryCards: [
],
tableData: [],
savedData:undefined,
selectedFileName: ''
}
},
computed: {
isMobile() {
return this.windowWidth <= 768
},
filteredPdfFiles() {
const keyword = (this.pdfSearchKeyword || '').trim().toLowerCase()
if (!keyword) return this.pdfFiles || []
return (this.pdfFiles || []).filter(item => String(item.name || '').toLowerCase().includes(keyword))
}
},
created() {
this.loadData()
},
mounted() {
this._onResize = () => {
this.windowWidth = window.innerWidth
}
window.addEventListener('resize', this._onResize, { passive: true })
},
beforeDestroy() {
window.removeEventListener('resize', this._onResize)
},
methods: {
async confirmSaveData(){
const data = this.savedData;
await this.saveRow(data)
this.showDialog = false
},
handlePdfRowClick(row) {
if (!row) return
this.selectedFileName = row.name || ''
},
openFileDialog(data){
this.savedData = data;
this.selectedFileName = '';
this.pdfSearchKeyword = ''
this.openPdfDialog();
},
async sendSms(id){
const { sendSmsToUserPhone } = await import('@/api/registrations')
this.$confirm('是否确认发送文件通知', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
customClass: this.isMobile ? 'home__message-box--mobile-center' : undefined
}).then(async() => {
await sendSmsToUserPhone(id)
this.$message({
type: 'success',
message: '发送成功!'
});
}).catch(() => {
});
},
async openPdfDialog() {
this.showDialog = true
this.pdfSearchKeyword = ''
await this.loadPdfFiles()
},
async loadPdfFiles() {
this.pdfLoading = true
try {
const { fetchPdfs } = await import('@/api/pdfs')
const list = await fetchPdfs()
this.pdfFiles = (list || []).map(item => ({
name: item.name,
url: item.url
}))
} catch (err) {
this.$message.error('加载PDF列表失败')
// eslint-disable-next-line no-console
console.error(err)
} finally {
this.pdfLoading = false
}
},
openPdf(file) {
const url = this.pdfHref(file)
if (url && url !== '#') window.location.href = url
},
pdfHref(row) {
return buildPdfUrl(row && row.name) || (row && row.url) || '#'
},
async loadData() {
this.loading = true
try {
const { fetchRegistrations } = await import('@/api/registrations')
const list = await fetchRegistrations()
this.tableData = (list || []).map(item => ({
id: item.id,
customerName: item.customerName,
customerNameDraft: item.customerName,
contact: item.contact,
contactDraft: item.contact,
serviceType: item.serviceType,
serviceTypeDraft: item.serviceType,
powerType: item.powerType,
powerTypeDraft: item.powerType,
registerTime: item.registerTime,
note: item.note,
noteDraft: item.note,
status: item.status
}))
} catch (err) {
this.$message.error('加载登记数据失败')
// eslint-disable-next-line no-console
console.error(err)
} finally {
this.loading = false
}
},
isEditable(row) {
return row.status === '待登记'
},
isSaving(row) {
return this.savingId === row.id
},
isDeleting(row) {
return this.deletingId === row.id
},
canSave(row) {
const customerName = (row.customerNameDraft || '').trim()
const contact = (row.contactDraft || '').trim()
const serviceType = (row.serviceTypeDraft || '').trim()
const powerType = (row.powerTypeDraft || '').trim()
return Boolean(customerName && contact && serviceType && powerType)
},
async deleteRow(row) {
const id = row && row.id
if (!id) return
this.deletingId = id
try {
const { deleteRegistration } = await import('@/api/registrations')
await deleteRegistration(id)
this.tableData = (this.tableData || []).filter(item => item.id !== id)
if (this.savedData && this.savedData.id === id) {
this.showDialog = false
this.savedData = undefined
this.selectedFileName = ''
}
this.$message.success('已删除')
} catch (err) {
this.$message.error('删除失败')
// eslint-disable-next-line no-console
console.error(err)
} finally {
this.deletingId = null
}
},
async saveRow(row) {
const customerName = (row.customerNameDraft || '').trim()
const contact = (row.contactDraft || '').trim()
const serviceType = (row.serviceTypeDraft || '').trim()
const powerType = (row.powerTypeDraft || '').trim()
if (!customerName) {
this.$message.warning('客户名称为必填')
return
}
if (!contact) {
this.$message.warning('联系方式为必填')
return
}
if (!serviceType) {
this.$message.warning('服务类型为必填')
return
}
if (!powerType) {
this.$message.warning('办电类型为必填')
return
}
this.savingId = row.id
try {
const { updateRegistration } = await import('@/api/registrations')
const payload = {
id: row.id,
customerName,
contact,
serviceType,
powerType,
registerTime: row.registerTime,
note: row.noteDraft,
status: '已登记',
fileName: this.selectedFileName
}
await updateRegistration(row.id, payload)
row.customerNameDraft = customerName
row.contactDraft = contact
row.serviceTypeDraft = serviceType
row.powerTypeDraft = powerType
row.customerName = customerName
row.contact = contact
row.serviceType = serviceType
row.powerType = powerType
row.note = row.noteDraft
row.status = '已登记'
this.$message.success('已登记')
} catch (err) {
this.$message.error('保存失败')
// eslint-disable-next-line no-console
console.error(err)
} finally {
this.savingId = null
}
},
statusType(status) {
const map = {
待登记: 'warning',
已登记: 'success',
已完成: 'success',
已关闭: 'info'
}
return map[status] || 'default'
},
async showQrCode(row) {
this.qrDialogVisible = true
await this.$nextTick()
const canvas = this.$refs.qrCanvas
if (!canvas) return
const qrContent = [
`客户名称: ${row.customerName || ''}`,
`联系方式: ${row.contact || ''}`,
`服务类型: ${row.serviceType || ''}`,
`办电类型: ${row.powerType || ''}`,
`登记时间: ${row.registerTime || ''}`,
`状态: ${row.status || ''}`,
`备注: ${row.note || ''}`
].join('\n')
try {
await Qrcode.toCanvas(canvas, qrContent, {
width: 240,
margin: 2,
color: {
dark: '#000000',
light: '#ffffff'
}
})
} catch (err) {
this.$message.error('生成二维码失败')
// eslint-disable-next-line no-console
console.error(err)
}
}
}
}
</script>
<style scoped>
.home {
display: flex;
flex-direction: column;
gap: 16px;
padding: 20px;
}
.home__danger-text {
color: #f56c6c;
}
:global(.home__message-box--mobile-center) {
margin-top: 0 !important;
width: calc(100% - 32px);
max-width: 420px;
}
.home__pdf-search {
margin-bottom: 10px;
}
.home__card-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.home__card-header-title {
line-height: 1.2;
}
.home__header-actions {
display: flex;
gap: 8px;
margin-left: auto;
}
.home__summary {
margin: 0;
}
.home__card {
min-height: 200px;
}
.home__card-title {
color: #909399;
font-size: 13px;
}
.home__card-value {
margin-top: 12px;
font-size: 28px;
font-weight: 600;
color: #303133;
}
.home__card-footer {
margin-top: 8px;
color: #67c23a;
display: flex;
align-items: center;
gap: 6px;
}
.home__table-card {
margin-top: 8px;
}
.home__header-action {
margin-left: 0;
}
.home__header-action--pdf {
background: #fff;
}
.home__mobile-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.home__mobile-card {
border-radius: 8px;
}
.home__mobile-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.home__mobile-card-time {
color: #909399;
font-size: 12px;
line-height: 1.2;
}
.home__mobile-field {
display: grid;
grid-template-columns: 86px 1fr;
gap: 10px;
padding: 6px 0;
}
.home__mobile-label {
color: black;
font-size: 14px;
line-height: 28px;
}
.home__mobile-value {
min-width: 0;
font-size: 14px;
color: #303133;
line-height: 28px;
word-break: break-word;
}
.home__mobile-link {
color: #409eff;
}
.home__mobile-actions {
display: flex;
justify-content: flex-end;
margin-top: 12px;
gap: 8px;
}
@media (max-width: 768px) {
.home {
gap: 12px;
}
.home__card {
min-height: auto;
}
.home__header-actions {
width: 100%;
}
.home__header-actions ::v-deep .el-button {
flex: 1;
}
.home__table-card {
margin-top: 0;
}
}
</style>

View File

@@ -0,0 +1,200 @@
<template>
<div class="phone-query">
<div class="phone-query__container">
<div class="phone-query__icon">
<i class="el-icon-search"></i>
</div>
<h2 class="phone-query__title">业务办理告知</h2>
<!-- <p class="phone-query__subtitle">输入手机号查询相关文件</p> -->
<el-card class="phone-query__card" shadow="hover">
<el-form :model="form" ref="formRef">
<el-form-item prop="phone">
<el-input
v-model="form.phone"
placeholder="请输入手机号"
maxlength="11"
size="large"
prefix-icon="el-icon-mobile-phone"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
:loading="loading"
@click="handleQuery"
class="phone-query__btn"
>
<i v-if="!loading" class="el-icon-search"></i>
查询
</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</div>
</template>
<script>
import { buildPdfUrl } from '@/api/client'
export default {
name: "PhoneQuery",
data() {
return {
form: {
phone: "",
},
loading: false,
};
},
methods: {
async handleQuery() {
const phone = (this.form.phone || "").trim();
if (!phone) {
this.$message.warning("请输入手机号");
return;
}
if (!/^1[3-9]\d{9}$/.test(phone)) {
this.$message.warning("请输入正确的手机号");
return;
}
this.loading = true;
try {
const { searchByPhone } = await import("@/api/registrations");
let data = await searchByPhone(phone);
if (data != null && data.length > 0) {
data = data[0]
if (data.status == "待登记") {
this.$message.warning("暂未查询到相关信息");
} else if (data.status == "已登记") {
const { fileName } = data;
if (fileName == null) {
this.$message.warning("未查询到相关信息");
}else{
window.location.href = buildPdfUrl(fileName)
}
}
}else{
this.$message.warning("暂未查询到相关信息");
}
// TODO: 调用查询接口
// window.location.href = "/pdf/1.pdf";
} catch (err) {
this.$message.error("查询失败");
// eslint-disable-next-line no-console
console.error(err);
} finally {
this.loading = false;
}
},
},
};
</script>
<style scoped>
.phone-query {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.phone-query__container {
text-align: center;
}
.phone-query__icon {
width: 80px;
height: 80px;
margin: 0 auto 20px;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.phone-query__icon i {
font-size: 36px;
color: #fff;
}
.phone-query__title {
color: #fff;
font-size: 28px;
font-weight: 600;
margin: 0 0 8px;
}
.phone-query__subtitle {
color: rgba(255, 255, 255, 0.8);
font-size: 14px;
margin: 0 0 30px;
}
.phone-query__card {
width: 360px;
border-radius: 12px;
border: none;
}
.phone-query__card ::v-deep .el-card__body {
padding: 30px;
}
.phone-query__card ::v-deep .el-input__inner {
height: 48px;
line-height: 48px;
font-size: 16px;
border-radius: 8px;
}
.phone-query__card ::v-deep .el-input__prefix {
left: 12px;
font-size: 18px;
color: #909399;
}
.phone-query__card ::v-deep .el-input--prefix .el-input__inner {
padding-left: 40px;
}
.phone-query__btn {
width: 100%;
height: 48px;
font-size: 16px;
border-radius: 8px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
}
.phone-query__btn:hover {
opacity: 0.9;
}
.phone-query__btn i {
margin-right: 6px;
}
@media (max-width: 480px) {
.phone-query__card {
width: 100%;
max-width: 360px;
}
.phone-query__title {
font-size: 24px;
}
.phone-query__icon {
width: 64px;
height: 64px;
}
.phone-query__icon i {
font-size: 28px;
}
}
</style>

View File

@@ -0,0 +1,252 @@
<template>
<div class="register">
<div class="register__container">
<div class="register__icon">
<i :class="submitted ? 'el-icon-check' : 'el-icon-edit-outline'"></i>
</div>
<h2 class="register__title">{{ submitted ? '提交成功' : '咨询信息登记' }}</h2>
<p class="register__subtitle">{{ submitted ? '我们已收到您的信息' : '请填写您的姓名和联系电话' }}</p>
<el-card v-if="!submitted" class="register__card" shadow="hover">
<!-- 成功状态 -->
<div v-if="submitted" class="register__success">
<div class="register__success-icon">
<i class="el-icon-circle-check"></i>
</div>
<el-button
type="primary"
class="register__btn register__btn--success"
@click="resetForm"
>
继续登记
</el-button>
</div>
<!-- 表单 -->
<el-form v-if="!submitted" :model="form" ref="formRef">
<el-form-item prop="name">
<el-input
v-model="form.name"
placeholder="请输入姓名"
size="large"
prefix-icon="el-icon-user"
/>
</el-form-item>
<el-form-item prop="phone">
<el-input
v-model="form.phone"
placeholder="请输入手机号"
maxlength="11"
size="large"
prefix-icon="el-icon-mobile-phone"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
:loading="loading"
@click="handleSubmit"
class="register__btn"
>
<i v-if="!loading" class="el-icon-check"></i>
确定
</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</div>
</template>
<script>
export default {
name: 'Register',
data() {
return {
form: {
name: '',
phone: ''
},
loading: false,
submitted: false
}
},
methods: {
async handleSubmit() {
const name = (this.form.name || '').trim()
const phone = (this.form.phone || '').trim()
if (!name) {
this.$message.warning('请填写姓名')
return
}
if (!phone) {
this.$message.warning('请填写联系电话')
return
}
if (!/^1[3-9]\d{9}$/.test(phone)) {
this.$message.warning('请填写有效联系电话')
return
}
this.loading = true
try {
const { createRegistration } = await import('@/api/registrations')
await createRegistration({
customerName: name,
contact: phone
})
this.$message.success('提交成功')
this.submitted = true
} catch (err) {
this.$message.error('网络错误,请检查连接')
// eslint-disable-next-line no-console
console.error(err)
} finally {
this.loading = false
}
},
resetForm() {
this.form.name = ''
this.form.phone = ''
this.submitted = false
}
}
}
</script>
<style scoped>
.register {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
}
.register__container {
text-align: center;
}
.register__icon {
width: 80px;
height: 80px;
margin: 0 auto 20px;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.register__icon i {
font-size: 36px;
color: #fff;
}
.register__title {
color: #fff;
font-size: 28px;
font-weight: 600;
margin: 0 0 8px;
}
.register__subtitle {
color: rgba(255, 255, 255, 0.8);
font-size: 14px;
margin: 0 0 30px;
}
.register__card {
width: 360px;
border-radius: 12px;
border: none;
}
.register__card ::v-deep .el-card__body {
padding: 30px;
}
.register__card ::v-deep .el-input__inner {
height: 48px;
line-height: 48px;
font-size: 16px;
border-radius: 8px;
}
.register__card ::v-deep .el-input__prefix {
left: 12px;
font-size: 18px;
color: #909399;
}
.register__card ::v-deep .el-input--prefix .el-input__inner {
padding-left: 40px;
}
.register__btn {
width: 100%;
height: 48px;
font-size: 16px;
border-radius: 8px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
}
.register__btn:hover {
opacity: 0.9;
}
.register__btn i {
margin-right: 6px;
}
.register__btn--success {
background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}
.register__success {
text-align: center;
padding: 20px 0;
}
.register__success-icon {
width: 72px;
height: 72px;
margin: 0 auto 24px;
background: rgba(22, 163, 74, 0.1);
border: 2px solid rgba(22, 163, 74, 0.3);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.register__success-icon i {
font-size: 36px;
color: #22c55e;
}
@media (max-width: 480px) {
.register__card {
width: 100%;
max-width: 360px;
}
.register__title {
font-size: 24px;
}
.register__icon {
width: 64px;
height: 64px;
}
.register__icon i {
font-size: 28px;
}
}
</style>

14
pc-web/vue.config.js Normal file
View File

@@ -0,0 +1,14 @@
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://127.0.0.1:7946',
changeOrigin: true
},
'/pdf': {
target: 'http://127.0.0.1:7946',
changeOrigin: true
}
}
}
}

14
preset-vue2.json Normal file
View File

@@ -0,0 +1,14 @@
{
"useConfigFiles": true,
"plugins": {
"@vue/cli-plugin-babel": {},
"@vue/cli-plugin-eslint": {
"config": "eslint:recommended",
"lintOn": ["save"]
},
"@vue/cli-plugin-router": {
"historyMode": false
}
},
"vueVersion": "2"
}

258
reg_front/index.html Normal file
View File

@@ -0,0 +1,258 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>信息登记</title>
<style>
:root {
color-scheme: light dark;
--bg: #f5f5f5;
--card: #ffffff;
--text: #222222;
--primary: #2b7cff;
--muted: #666666;
--success: #16a34a;
--danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--muted: #9ca3af;
--success: #22c55e;
--danger: #f87171;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
background: var(--bg);
color: var(--text);
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
}
.card {
width: min(520px, 92vw);
background: var(--card);
border-radius: 18px;
padding: 28px 24px;
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}
h1 {
margin: 0 0 10px;
font-size: 24px;
}
p {
margin: 0 0 22px;
color: var(--muted);
font-size: 14px;
}
label {
display: block;
font-weight: 600;
margin-bottom: 6px;
}
input {
width: 100%;
padding: 12px 14px;
border: 1px solid #d1d5db;
border-radius: 10px;
font-size: 16px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
background: transparent;
color: inherit;
}
input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(43, 124, 255, 0.2);
}
.field {
margin-bottom: 18px;
}
button {
width: 100%;
padding: 14px 16px;
border: none;
border-radius: 12px;
background: var(--primary);
color: #fff;
font-size: 16px;
font-weight: 700;
letter-spacing: 0.5px;
cursor: pointer;
transition: transform 0.08s ease, box-shadow 0.2s ease;
box-shadow: 0 12px 24px rgba(43, 124, 255, 0.25);
}
button:active {
transform: scale(0.99);
box-shadow: 0 8px 18px rgba(43, 124, 255, 0.22);
}
button[disabled] {
opacity: 0.75;
cursor: not-allowed;
box-shadow: none;
}
.success {
text-align: center;
padding: 10px 4px 0;
}
.success-icon {
width: 72px;
height: 72px;
margin: 6px auto 14px;
border-radius: 999px;
background: rgba(22, 163, 74, 0.14);
border: 1px solid rgba(22, 163, 74, 0.25);
display: grid;
place-items: center;
color: var(--success);
}
.success-title {
font-size: 20px;
font-weight: 800;
margin: 0 0 6px;
}
.success-desc {
margin: 0 0 18px;
color: var(--muted);
font-size: 14px;
}
.success-btn {
background: var(--success);
box-shadow: 0 12px 24px rgba(22, 163, 74, 0.22);
}
.toast {
position: fixed;
left: 50%;
bottom: 36px;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.82);
color: #fff;
padding: 12px 16px;
border-radius: 999px;
font-size: 14px;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
}
.toast.error {
background: rgba(220, 38, 38, 0.92);
}
.toast.show {
opacity: 1;
}
</style>
</head>
<body>
<div class="card">
<h1>信息登记</h1>
<p>请填写您的姓名和联系电话,点击“确定”提交。</p>
<div id="success" class="success" hidden>
<div class="success-icon" aria-hidden="true">
<svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 6 9 17l-5-5"></path>
</svg>
</div>
<div class="success-title">提交成功</div>
<div class="success-desc">我们已收到您的信息。</div>
<button id="success-again" style="display: none" class="success-btn" type="button">继续登记</button>
</div>
<form id="reg-form" novalidate>
<div class="field">
<label for="name">姓名</label>
<input id="name" name="name" type="text" placeholder="请输入姓名" required>
</div>
<div class="field">
<label for="phone">联系电话</label>
<input id="phone" name="phone" type="tel" placeholder="请输入手机号" inputmode="numeric" pattern="^\\d{6,}$" required>
</div>
<button type="submit">确定</button>
</form>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script>
const form = document.getElementById('reg-form');
const toast = document.getElementById('toast');
const success = document.getElementById('success');
const successAgain = document.getElementById('success-again');
const submitButton = form.querySelector('button[type="submit"]');
function showToast(message, variant = 'default') {
toast.textContent = message;
toast.classList.toggle('error', variant === 'error');
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 1800);
}
function showSuccess() {
form.hidden = true;
success.hidden = false;
successAgain.focus();
}
function resetToForm() {
success.hidden = true;
form.hidden = false;
form.reset();
form.name.focus();
}
successAgain.addEventListener('click', resetToForm);
form.addEventListener('submit', async (event) => {
event.preventDefault();
const name = form.name.value.trim();
const phone = form.phone.value.trim();
if (!name) {
showToast('请填写姓名', 'error');
return;
}
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
showToast('请填写有效联系电话', 'error');
return;
}
submitButton.disabled = true;
const originalButtonText = submitButton.textContent;
submitButton.textContent = '提交中...';
try {
// 调用后端接口提交数据
const response = await fetch('http://118.195.205.71:8888/api/registrations', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
customerName: name,
contact: phone
})
});
if (response.ok) {
showToast('提交成功');
showSuccess();
} else {
showToast('提交失败,请重试', 'error');
}
} catch {
showToast('网络错误,请检查连接', 'error');
} finally {
submitButton.disabled = false;
submitButton.textContent = originalButtonText;
}
});
</script>
</body>
</html>

BIN
server.zip Normal file

Binary file not shown.

2
server/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf

33
server/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip

BIN
server/data/app.db Normal file

Binary file not shown.

295
server/mvnw vendored Normal file
View File

@@ -0,0 +1,295 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.4
#
# Optional ENV vars
# -----------------
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
# MVNW_REPOURL - repo url base for downloading maven distribution
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
# ----------------------------------------------------------------------------
set -euf
[ "${MVNW_VERBOSE-}" != debug ] || set -x
# OS specific support.
native_path() { printf %s\\n "$1"; }
case "$(uname)" in
CYGWIN* | MINGW*)
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
native_path() { cygpath --path --windows "$1"; }
;;
esac
# set JAVACMD and JAVACCMD
set_java_home() {
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
if [ -n "${JAVA_HOME-}" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACCMD="$JAVA_HOME/jre/sh/javac"
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
return 1
fi
fi
else
JAVACMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v java
)" || :
JAVACCMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
return 1
fi
fi
}
# hash string like Java String::hashCode
hash_string() {
str="${1:-}" h=0
while [ -n "$str" ]; do
char="${str%"${str#?}"}"
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
str="${str#?}"
done
printf %x\\n $h
}
verbose() { :; }
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
die() {
printf %s\\n "$1" >&2
exit 1
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
scriptDir="$(dirname "$0")"
scriptName="$(basename "$0")"
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
esac
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
case "${distributionUrl##*/}" in
maven-mvnd-*bin.*)
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
*)
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
distributionPlatform=linux-amd64
;;
esac
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
;;
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
esac
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
distributionUrlName="${distributionUrl##*/}"
distributionUrlNameMain="${distributionUrlName%.*}"
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
exec_maven() {
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
}
if [ -d "$MAVEN_HOME" ]; then
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
exec_maven "$@"
fi
case "${distributionUrl-}" in
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
esac
# prepare tmp dir
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
trap clean HUP INT TERM EXIT
else
die "cannot create temp dir"
fi
mkdir -p -- "${MAVEN_HOME%/*}"
# Download and Install Apache Maven
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
verbose "Downloading from: $distributionUrl"
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
distributionUrl="${distributionUrl%.zip}.tar.gz"
distributionUrlName="${distributionUrl##*/}"
fi
# verbose opt
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
# normalize http auth
case "${MVNW_PASSWORD:+has-password}" in
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
esac
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
verbose "Found wget ... using wget"
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
cat >"$javaSource" <<-END
public class Downloader extends java.net.Authenticator
{
protected java.net.PasswordAuthentication getPasswordAuthentication()
{
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
}
public static void main( String[] args ) throws Exception
{
setDefault( new Downloader() );
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
}
}
END
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
verbose " - Compiling Downloader.java ..."
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
verbose " - Running Downloader.java ..."
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
fi
# If specified, validate the SHA-256 sum of the Maven distribution zip file
if [ -n "${distributionSha256Sum-}" ]; then
distributionSha256Result=false
if [ "$MVN_CMD" = mvnd.sh ]; then
echo "Checksum validation is not supported for maven-mvnd." >&2
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
elif command -v sha256sum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
distributionSha256Result=true
fi
elif command -v shasum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
fi
if [ $distributionSha256Result = false ]; then
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
exit 1
fi
fi
# unzip and move
if command -v unzip >/dev/null; then
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
else
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
fi
# Find the actual extracted directory name (handles snapshots where filename != directory name)
actualDistributionDir=""
# First try the expected directory name (for regular distributions)
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
actualDistributionDir="$distributionUrlNameMain"
fi
fi
# If not found, search for any directory with the Maven executable (for snapshots)
if [ -z "$actualDistributionDir" ]; then
# enable globbing to iterate over items
set +f
for dir in "$TMP_DOWNLOAD_DIR"/*; do
if [ -d "$dir" ]; then
if [ -f "$dir/bin/$MVN_CMD" ]; then
actualDistributionDir="$(basename "$dir")"
break
fi
fi
done
set -f
fi
if [ -z "$actualDistributionDir" ]; then
verbose "Contents of $TMP_DOWNLOAD_DIR:"
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
die "Could not find Maven distribution directory in extracted archive"
fi
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
clean || :
exec_maven "$@"

189
server/mvnw.cmd vendored Normal file
View File

@@ -0,0 +1,189 @@
<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.3.4
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_M2_PATH = "$HOME/.m2"
if ($env:MAVEN_USER_HOME) {
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
}
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
}
$MAVEN_WRAPPER_DISTS = $null
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
} else {
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
}
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
# Find the actual extracted directory name (handles snapshots where filename != directory name)
$actualDistributionDir = ""
# First try the expected directory name (for regular distributions)
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
$actualDistributionDir = $distributionUrlNameMain
}
# If not found, search for any directory with the Maven executable (for snapshots)
if (!$actualDistributionDir) {
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
if (Test-Path -Path $testPath -PathType Leaf) {
$actualDistributionDir = $_.Name
}
}
}
if (!$actualDistributionDir) {
Write-Error "Could not find Maven distribution directory in extracted archive"
}
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"

86
server/pom.xml Normal file
View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.reg</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>server</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.46.1.3</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.42</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,16 @@
package com.reg.server;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.reg.server.registration")
public class ServerApplication {
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
System.out.println("启动成功");
}
}

View File

@@ -0,0 +1,73 @@
package com.reg.server.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.sqlite.SQLiteDataSource;
import javax.sql.DataSource;
import java.io.File;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Configuration
public class DatabaseConfig {
@Bean
public DataSource dataSource() {
Path baseDir = resolveBaseDir();
Path dataDir = baseDir.resolve("data");
Path dbFile = dataDir.resolve("app.db");
try {
Files.createDirectories(dataDir);
} catch (Exception ignored) {
// rely on SQLite to fail loudly if directory is not writable
}
SQLiteDataSource ds = new SQLiteDataSource();
ds.setUrl("jdbc:sqlite:" + dbFile.toString());
return ds;
}
private Path resolveBaseDir() {
try {
// When running from JAR, location points to the JAR file; from IDE, to classes directory.
java.net.URL location = DatabaseConfig.class.getProtectionDomain()
.getCodeSource()
.getLocation();
String path = location.getPath();
// Handle JAR path: jar:file:/path/to/app.jar!/BOOT-INF/classes!/
if (path.contains(".jar")) {
// Extract the JAR file path
int jarIndex = path.indexOf(".jar");
path = path.substring(0, jarIndex + 4);
// Remove "file:" prefix if present
if (path.startsWith("file:")) {
path = path.substring(5);
}
// On Windows, remove leading slash before drive letter (e.g., /D:/...)
if (path.length() > 2 && path.charAt(0) == '/' && path.charAt(2) == ':') {
path = path.substring(1);
}
// Decode URL encoding
path = java.net.URLDecoder.decode(path, "UTF-8");
Path jarPath = Paths.get(path);
Path parent = jarPath.getParent();
if (parent != null) {
return parent;
}
} else {
// Running from IDE/classes directory
Path classesPath = Paths.get(location.toURI());
Path parent = classesPath.getParent();
if (parent != null) {
return parent;
}
}
} catch (Exception ignored) {
// fall back
}
return Paths.get(System.getProperty("user.dir", "."));
}
}

View File

@@ -0,0 +1,42 @@
package com.reg.server.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
import java.nio.file.Path;
import java.nio.file.Paths;
@Configuration
public class PdfResourceConfig implements WebMvcConfigurer {
@Value("${app.pdf.external-dir:}")
private String externalDir;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String[] locations = resolveLocations();
registry.addResourceHandler("/pdf/**")
.addResourceLocations(locations)
.resourceChain(true)
.addResolver(new PathResourceResolver());
}
private String[] resolveLocations() {
if (!StringUtils.hasText(externalDir)) {
return new String[]{"classpath:/pdf/"};
}
String externalLocation = toExternalLocation(externalDir);
return new String[]{externalLocation, "classpath:/pdf/"};
}
private static String toExternalLocation(String directory) {
Path path = Paths.get(directory).toAbsolutePath().normalize();
String uri = path.toUri().toString();
return uri.endsWith("/") ? uri : (uri + "/");
}
}

View File

@@ -0,0 +1,120 @@
package com.reg.server.pdf;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RestController
@CrossOrigin
public class PdfController {
private final ResourcePatternResolver resolver;
@Value("${app.pdf.external-dir:}")
private String externalDir;
public PdfController(ResourcePatternResolver resolver) {
this.resolver = resolver;
}
@GetMapping("/api/pdfs")
public List<PdfFile> listPdfs() throws IOException {
Map<String, PdfFile> filesByName = new LinkedHashMap<>();
for (String name : listClasspathPdfs()) {
filesByName.putIfAbsent(name, toPdfFile(name));
}
for (String name : listExternalPdfs()) {
filesByName.putIfAbsent(name, toPdfFile(name));
}
return filesByName.values().stream()
.sorted(Comparator.comparing(PdfFile::getName, String.CASE_INSENSITIVE_ORDER))
.collect(Collectors.toList());
}
private List<String> listClasspathPdfs() throws IOException {
Resource[] resources = resolver.getResources("classpath*:/pdf/*.pdf");
List<String> names = new ArrayList<>();
for (Resource resource : resources) {
String filename = resource.getFilename();
if (filename != null && filename.toLowerCase().endsWith(".pdf")) {
names.add(filename);
}
}
return names;
}
private List<String> listExternalPdfs() {
if (!StringUtils.hasText(externalDir)) {
return Collections.emptyList();
}
Path dir = Paths.get(externalDir).toAbsolutePath().normalize();
if (!Files.isDirectory(dir)) {
return Collections.emptyList();
}
try (Stream<Path> stream = Files.list(dir)) {
return stream
.filter(Files::isRegularFile)
.map(path -> path.getFileName().toString())
.filter(name -> name.toLowerCase().endsWith(".pdf"))
.sorted(String.CASE_INSENSITIVE_ORDER)
.collect(Collectors.toList());
} catch (Exception ignored) {
return Collections.emptyList();
}
}
private static PdfFile toPdfFile(String name) {
String encoded = UriUtils.encodePathSegment(name, StandardCharsets.UTF_8);
return new PdfFile(name, "/pdf/" + encoded);
}
public static class PdfFile {
private String name;
private String url;
public PdfFile() {
}
public PdfFile(String name, String url) {
this.name = name;
this.url = url;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}

View File

@@ -0,0 +1,98 @@
package com.reg.server.registration;
public class Registration {
private Long id;
private String registerTime;
private String customerName;
private String contact;
private String serviceType;
private String powerType;
private String note;
private String status;
/**
* 文件访问链接
*/
private String urlPath;
public String getUrlPath() {
return urlPath;
}
public void setUrlPath(String urlPath) {
this.urlPath = urlPath;
}
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRegisterTime() {
return registerTime;
}
public void setRegisterTime(String registerTime) {
this.registerTime = registerTime;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getPowerType() {
return powerType;
}
public void setPowerType(String powerType) {
this.powerType = powerType;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}

View File

@@ -0,0 +1,130 @@
package com.reg.server.registration;
import cn.hutool.core.util.RandomUtil;
import com.aliyun.tea.TeaException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("/api/registrations")
@CrossOrigin
public class RegistrationController {
private final RegistrationService service;
/**
* <b>description</b> :
* <p>使用凭据初始化账号Client</p>
*
* @return Client
* @throws Exception
*/
public static com.aliyun.dysmsapi20170525.Client createClient() throws Exception {
// 工程代码建议使用更安全的无AK方式凭据配置方式请参见https://help.aliyun.com/document_detail/378657.html。
com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setCredential(credential);
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
config.endpoint = "dysmsapi.aliyuncs.com";
config.setAccessKeyId("LTAI5tSqZrdsoC54tgWTrdYB");
config.setAccessKeySecret("I1nu7T6DJuvhribphaWh53RRw8TdC7");
return new com.aliyun.dysmsapi20170525.Client(config);
}
public RegistrationController(RegistrationService service) {
this.service = service;
}
@GetMapping
public List<Registration> list() {
return service.list();
}
@GetMapping("/search")
public List<Registration> search(
@RequestParam(required = false) String customerName,
@RequestParam(required = false) String contact,
@RequestParam(required = false) String serviceType,
@RequestParam(required = false) String powerType,
@RequestParam(required = false) String status) {
Registration condition = new Registration();
condition.setCustomerName(customerName);
condition.setContact(contact);
condition.setServiceType(serviceType);
condition.setPowerType(powerType);
condition.setStatus(status);
RandomUtil.randomString(8);
return service.search(condition);
}
@GetMapping("/{id}")
public ResponseEntity<Registration> get(@PathVariable Long id) {
return service.get(id)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
}
@PostMapping
public ResponseEntity<Registration> create(@RequestBody Registration registration) {
Registration saved = service.create(registration);
return ResponseEntity.status(HttpStatus.CREATED).body(saved);
}
@PutMapping("/{id}")
public ResponseEntity<Void> update(@PathVariable Long id, @RequestBody Registration registration) {
String urlPath = null;
if ("已登记".equals(registration.getStatus().trim()) && registration.getFileName() != null) {
urlPath = RandomUtil.randomString(5);
registration.setUrlPath(urlPath);
}
boolean updated = service.update(id, registration);
return updated ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> delete(@PathVariable Long id) {
boolean deleted = service.delete(id);
return deleted ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
}
@GetMapping("/getPdfPath/{urlPath}")
public ResponseEntity<String> getPdfPath(@PathVariable String urlPath) {
List<Registration> search = service.search(new Registration() {{
setUrlPath(urlPath);
}});
if (search == null || search.isEmpty()) {
return ResponseEntity.ok("");
}
return ResponseEntity.ok(search.get(0).getFileName());
}
// @GetMapping("sendSms/{id}")
// public ResponseEntity sendSms (@PathVariable Long id) throws Exception {
// com.aliyun.dysmsapi20170525.Client client = this.createClient();
// com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
// Registration registration = service.get(id)
// .orElseThrow(() -> new IllegalStateException("数据不可能为空id=" + id));
// sendSmsRequest.setPhoneNumbers(registration.getContact());
// sendSmsRequest.setSignName("顷琦");
// sendSmsRequest.setTemplateCode("SMS_499300449");
// com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
// try {
// com.aliyun.dysmsapi20170525.models.SendSmsResponse resp = client.sendSmsWithOptions(sendSmsRequest, runtime);
// System.out.println(new com.google.gson.Gson().toJson(resp));
// } catch (TeaException error) {
// System.out.println(error.getMessage());
// System.out.println(error.getData().get("Recommend"));
// } catch (Exception _error) {
// TeaException error = new TeaException(_error.getMessage(), _error);
// System.out.println(error.getMessage());
// System.out.println(error.getData().get("Recommend"));
//
// }
// return ResponseEntity.status(HttpStatus.OK).body("发送短信成功");
// }
}

View File

@@ -0,0 +1,22 @@
package com.reg.server.registration;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Optional;
@Mapper
public interface RegistrationMapper {
int insert(Registration registration);
Optional<Registration> findById(Long id);
List<Registration> findAll();
int update(Registration registration);
int delete(Long id);
List<Registration> findByCondition(Registration condition);
}

View File

@@ -0,0 +1,53 @@
package com.reg.server.registration;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Optional;
@Service
public class RegistrationService {
private final RegistrationMapper mapper;
public RegistrationService(RegistrationMapper mapper) {
this.mapper = mapper;
}
public List<Registration> list() {
return mapper.findAll();
}
public Optional<Registration> get(Long id) {
return mapper.findById(id);
}
public Registration create(Registration registration) {
registration.setRegisterTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
defaultStatus(registration);
mapper.insert(registration);
return registration;
}
public boolean update(Long id, Registration registration) {
registration.setId(id);
defaultStatus(registration);
return mapper.update(registration) > 0;
}
public boolean delete(Long id) {
return mapper.delete(id) > 0;
}
public List<Registration> search(Registration condition) {
return mapper.findByCondition(condition);
}
private void defaultStatus(Registration registration) {
if (!StringUtils.hasText(registration.getStatus())) {
registration.setStatus("待登记");
}
}
}

View File

@@ -0,0 +1,19 @@
spring:
application:
name: server
sql:
init:
platform: sqlite
mode: never
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
server:
port: 7946
app:
pdf:
# Optional: serve PDFs from a local folder (preferred first), e.g. ./resources/pdf
external-dir: ""

View File

@@ -0,0 +1,11 @@
DELETE FROM registrations;
INSERT INTO registrations (register_time, customer_name, contact, service_type, power_type, note, status) VALUES
('2025-12-16 09:30:00', '张三', '13800138001', '新装', '单相', '住宅用电申请', '已完成'),
('2025-12-16 10:15:00', '李四', '13900139002', '增容', '三相', '工厂扩产需增加容量', '处理中'),
('2025-12-15 14:20:00', '王五', '13700137003', '过户', '单相', '', '已完成'),
('2025-12-15 16:45:00', '赵六', '13600136004', '新装', '三相', '商铺开业用电', '待处理'),
('2025-12-14 11:00:00', '钱七', '13500135005', '改类', '单相', '居民改为商业用电', '处理中'),
('2025-12-14 08:30:00', '孙八', '13400134006', '新装', '单相', '', '已完成'),
('2025-12-13 15:10:00', '周九', '13300133007', '增容', '三相', '设备升级需要更大功率', '待处理'),
('2025-12-13 09:00:00', '吴十', '13200132008', '过户', '单相', '房屋买卖过户', '已取消');

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.reg.server.registration.RegistrationMapper">
<resultMap id="registrationResultMap" type="com.reg.server.registration.Registration">
<id property="id" column="id"/>
<result property="registerTime" column="register_time"/>
<result property="customerName" column="customer_name"/>
<result property="contact" column="contact"/>
<result property="serviceType" column="service_type"/>
<result property="powerType" column="power_type"/>
<result property="note" column="note"/>
<result property="status" column="status"/>
<result property="fileName" column="file_name"/>
<result property="urlPath" column="url_path" />
</resultMap>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO registrations (register_time, customer_name, contact, service_type, power_type, note, status)
VALUES (#{registerTime}, #{customerName}, #{contact}, #{serviceType}, #{powerType}, #{note}, #{status})
</insert>
<select id="findById" resultMap="registrationResultMap">
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
FROM registrations WHERE id = #{id}
</select>
<select id="findAll" resultMap="registrationResultMap">
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
FROM registrations ORDER BY register_time DESC
</select>
<update id="update">
UPDATE registrations
SET register_time = #{registerTime},
customer_name = #{customerName},
contact = #{contact},
service_type = #{serviceType},
power_type = #{powerType},
note = #{note},
status = #{status},
file_name = #{fileName},
url_path = #{urlPath}
WHERE id = #{id}
</update>
<delete id="delete">
DELETE FROM registrations WHERE id = #{id}
</delete>
<select id="findByCondition" resultMap="registrationResultMap">
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name
FROM registrations
<where>
<if test="customerName != null and customerName != ''">
AND customer_name LIKE CONCAT('%', #{customerName}, '%')
</if>
<if test="contact != null and contact != ''">
AND contact LIKE CONCAT('%', #{contact}, '%')
</if>
<if test="serviceType != null and serviceType != ''">
AND service_type = #{serviceType}
</if>
<if test="powerType != null and powerType != ''">
AND power_type = #{powerType}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="urlPath != null and urlPath != ''">
AND url_path = #{urlPath}
</if>
</where>
ORDER BY register_time DESC
</select>
</mapper>

Some files were not shown because too many files have changed in this diff Show More