fangxiaoting_branch
“fangxiaoting” 1 year ago
parent 1b382b341f
commit 0bd73e8716

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

@ -0,0 +1,2 @@
[LocalizedFileNames]
ÐèÇóÆ¥Åä (1).png=@ÐèÇóÆ¥Åä (1),0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 217 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/walktofree" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,117 +0,0 @@
<template>
<div class="home-container">
<h1>首页</h1>
<div class="search-container">
<input type="text" class="search-input" placeholder="世界这么大出去看看吧">
<button class="search-button" @click="gotoSearchPage()"></button>
</div>
<div class="image-container">
<img src="../../photos/background.png" alt="图片描述" class="search-image">
</div>
<div class="footer-nav">
<button>首页</button>
<button @click="gotomessage()"></button>
<button @click="gotomine()"></button>
</div>
</div>
</template>
<style scoped>
/* 添加样式以定义图片的大小和位置 */
.image-container {
text-align: center; /* 或者根据你的需求来设置 */
margin-top: 20px; /* 你可以根据需要调整这个值 */
}
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.search-container {
/* 定义搜索框容器的样式 */
text-align: center;
margin-bottom: 20px; /* 根据需要添加一些底部间距 */
display: flex;
align-items: center; /* 垂直居中 */
justify-content: center; /* 水平居中(如果不需要完全居中,可以去掉这个)*/
}
.search-input {
/* 定义搜索框的样式 */
flex: 1; /* 占据剩余空间 */
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
.search-button {
/* 定义搜索按钮的样式 */
margin-left: 10px; /* 与搜索框之间的间距 */
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.search-button:hover {
/* 搜索按钮点击时的样式 */
background-color: #bbb;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
export default {
name: 'Home',
methods: {
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
gotomine() {
this.$router.push('/mine');
},
gotoSearchPage() {
this.$router.push('/searchPage');
},
}
}
</script>

@ -0,0 +1,16 @@
<template>
<div>
<label for="user-input"></label>
<input type="text" id="user-input" v-model="userInput" placeholder="请输入">
</div>
</template>
<script>
export default {
data() {
return {
userInput: '', //
};
},
};
</script>

@ -1,110 +0,0 @@
<template>
<div class="login-container">
<h1>登录页面</h1>
<form @submit.prevent="login" class="login-form">
<label for="username">用户名</label>
<input type="text" id="username" v-model="username" class="input-field">
<br>
<label for="password">密码</label>
<input type="password" id="password" v-model="password" class="input-field">
<br>
<button type="submit" class="submit-button">登录</button>
<button @click="goToRegister" class="register-button">注册</button>
</form>
</div>
</template>
<style scoped>
.login-container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
border: 1px solid #28a7a3;
border-radius: 5px;
text-align: center;
}
.input-field {
margin: 10px 0;
padding: 5px;
width: 100%;
}
.submit-button {
padding: 10px 20px;
background-color: #007bff;
color: #003f3f;
border: none;
border-radius: 5px;
cursor: pointer;
}
.register-button {
padding: 10px 20px;
background-color: #ff6347;
color: #003f3f;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
<script>
import { login } from '../api/auth'
import axios from "axios";
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
login() {
console.log("用户名:", this.username);
console.log("密码:", this.password);
axios.post('http://192.168.254.35:8080/Login/login', {
//
username: this.username,
password: this.password
}, {
// cookie
withCredentials: true,
// JSON
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
// status
if (response.data == 1) {
//
this.$router.push('/home');
}
else if (response.data == 2) {
alert('登录失败:账号或密码错误' );
}
else if(response.data == 3){
alert('登录失败:账号未注册');
}
else if(response.data == 0) {
alert('登录失败:未知原因');
}
else {
alert('登录失败:未知原因');
}
})
.catch(error => {
console.error(error);
//
alert('登录失败:网络错误或服务器错误');
});
},
goToRegister() {
this.$router.push('/register'); //
}
}
}
</script>

@ -0,0 +1,68 @@
<template>
<div class="footer-nav">
<div class="button-with-icon" @click="gotohome()">
<el-icon><House /></el-icon>
<span>首页</span>
</div>
<div class="button-with-icon" @click="gotomessage()()">
<el-icon><ChatDotSquare /></el-icon>
<span>消息</span>
</div>
<div class="button-with-icon" @click="gotomine()">
<el-icon><User /></el-icon>
<span>我的</span>
</div>
</div>
</template>
<script>
export default {
name: 'Home',
methods: {
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
gotomine() {
this.$router.push('/mine');
},
gotoSearchPage() {
this.$router.push('/searchPage');
},
gotoAddDemandPage() {
this.$router.push('/addDemandPage');
},
}
}
</script>
<style>
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.button-with-icon {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>

@ -1,97 +0,0 @@
<template>
<div class="register-container">
<h1>注册页面</h1>
<form @submit.prevent="register" class="register-form">
<label for="username">用户名</label>
<input type="text" id="username" v-model="username" class="input-field">
<br>
<label for="password">密码</label>
<input type="password" id="password" v-model="password" class="input-field">
<br>
<button type="submit" class="submit-button">注册</button>
<button class="return-button" @click="gotoLogin()"></button>
</form>
</div>
</template>
<style scoped>
.register-container {
max-width: 400px;
margin: 0 auto;
padding: 30px;
border: 1px solid #cccc7b;
border-radius: 5px;
text-align: center;
}
.input-field {
margin: 10px 0;
padding: 5px;
width: 100%;
}
.submit-button {
padding: 10px 20px;
background-color: #28a7a3;
color: #abd4ee;
border: none;
border-radius: 5px;
cursor: pointer;
}
.return-button {
padding: 10px 20px;
background-color: #ff6347; /* 例如,设置为红色 */
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px; /* 可以添加一些上边距来分隔按钮 */
}
</style>
<script>
import { register } from '../api/auth'
import axios from "axios";
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
register() {
console.log("用户名:", this.username);
console.log("密码:", this.password);
axios.post('http://192.168.254.35:8080/Login/register', {
//
username: this.username,
password: this.password
}, {
// cookie
withCredentials: true,
// JSON
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data)
//
alert(response.data);
})
.catch(error => {
console.error(error)
//
alert(response.data);
})
},
gotoLogin(){
this.$router.push('/login');
},
}
}
</script>

@ -1,11 +0,0 @@
<script setup>
</script>
<template>
</template>
<style scoped>
</style>

@ -1,67 +0,0 @@
<template>
<div class="home-container">
<h1>消息页面</h1>
<!-- 在这里添加你的主页内容 -->
<div class="footer-nav">
<button @click="gotohome()"></button>
<button @click="gotomessage()"></button>
<button @click="gotomine()"></button>
</div>
</div>
</template>
<style scoped>
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
export default {
name: 'Message',
methods: {
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
gotomine() {
this.$router.push('/mine');
},
}
}
</script>

@ -1,189 +0,0 @@
<template>
<div class="profile">
<h2>个人主页</h2>
<div v-if="showNicknameInput">
<label for="nickname">昵称</label>
<input type="nickname" id="nickname" v-model="nickname" class="input-field">
<button @click="updateNickname"></button>
</div>
<div v-else>
<p>昵称{{ user.nickname }}</p>
<button @click="toggleNicknameInput"></button>
</div>
<h1>{{ user.name }}</h1>
<p>身份证号{{user.IDCard}}</p>
<div v-if="showEmailInput">
<label for="email">邮箱</label>
<input type="email" id="email" v-model="email" class="input-field">
<button @click="updateEmail"></button>
</div>
<div v-else>
<p>邮箱{{ user.email }}</p>
<button @click="toggleEmailInput"></button>
</div>
<div v-if="showPhoneInput">
<label for="PhoneNumber">手机号</label>
<input type="phone" id="phone" v-model="phone" class="input-field">
<button @click="updatePhone"></button>
</div>
<div v-else>
<p>手机号{{ user.phone }}</p>
<button @click="togglePhoneInput"></button>
</div>
<div class="footer-nav">
<button @click="gotohome()"></button>
<button @click="gotomessage()"></button>
<button>我的</button>
</div>
</div>
</template>
<style scoped>
/* 在这里添加样式 */
.profile {
max-width: 400px;
margin: 0 auto;
padding: 20px;
}
.input-field {
margin-bottom: 10px;
}
button {
margin-top: 10px;
}
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
import axios from 'axios';
export default {
props: ['phone'],
data() {
return {
user: {},
nickname:'',
showNicknameInput: false,
email: '',
showEmailInput: false,
phone: '',
showPhoneInput: false,
IDCard: '',
createtime: '',
status: 0,
};
},
created() {
//
this.fetchUser(this.phone);
},
methods: {
fetchUser(phone) {
// API
axios.get(`http://192.168.254.35:8080/users/getByPhone?phone=15616168609`)
.then(response => {
alert(response.data);
this.user = response.data;
})
.catch(error => {
console.error('Error fetching user:', error);
});
},
toggleNicknameInput(){
this.showNicknameInput = !this.showNicknameInput;
this.nickname = this.user.nickname;
},
updateNickname(){
axios.get(`http://192.168.254.35:8080/users/getByPhone?phone=15616168609`, { nickname: this.nickname })
.then(response => {
this.user.nickname = this.nickname;
this.toggleNicknameInput(); //
})
.catch(error => {
console.error('Error updating nickname:', error);
});
},
toggleEmailInput() {
this.showEmailInput = !this.showEmailInput;
this.email = this.user.email;//
},
updateEmail() {
//
axios.get(`http://192.168.254.35:8080/users/getByPhone?phone=15616168609`, { email: this.email })
.then(response => {
this.user.email = this.email;
this.toggleEmailInput(); //
})
.catch(error => {
console.error('Error updating email:', error);
});
},
togglePhoneInput(){
this.showPhoneInput = !this.showPhoneInput;
this.phone = this.user.phone;
},
updatePhone(){
axios.get(`http://192.168.254.35:8080/users/getByPhone?phone=15616168609`, { phone: this.phone })
.then(response => {
alert(this.phone);
this.user.phone = this.phone;
this.togglePhoneInput(); //
})
.catch(error => {
console.error('Error updating phone:', error);
});
},
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
}
};
</script>

@ -1,339 +1,45 @@
<template>
<div class="mine">
<h2>个人主页</h2>
<h1>{{ user.name }}</h1>
<!-- <h1>用户姓名</h1>-->
<p>创建时间{{user.createtime}}</p>
<p>账号: {{ username }}</p>
<p>身份证号{{user.IDCard}}</p>
<div v-if="showEmailInput">
<label for="email">邮箱</label>
<input type="email" id="email" v-model="email" class="input-field">
<button @click="updateEmail"></button>
</div>
<div v-else>
<p>邮箱{{ user.email }}</p>
<button @click="toggleEmailInput"></button>
</div>
<div v-if="showPhoneInput">
<label for="PhoneNumber">手机号</label>
<input type="phone" id="phone" v-model="phone" class="input-field">
<button @click="updatePhone"></button>
</div>
<div v-else>
<p>手机号{{ user.phone }}</p>
<button @click="togglePhoneInput"></button>
</div>
<div class="footer-nav">
<button @click="gotohome()"></button>
<button @click="gotomessage()"></button>
<button>我的</button>
</div>
</div>
</template>
<style scoped>
.profile {
max-width: 400px;
margin: 0 auto;
padding: 20px;
}
.input-field {
margin-bottom: 10px;
}
button {
margin-top: 10px;
}
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
import { ref, onMounted } from 'vue';
// 使AxiosHTTP
import axios from 'axios';
export default {
name: 'Mine',
props: ['username'],
setup(props) {
const user = ref({}); // 使refdata
const email = ref('');
const showEmailInput = ref(false);
const phone = ref('');
const showPhoneInput = ref(false);
// 使onMountedcreated
onMounted(() => {
fetchUser(props.username);
});
// fetchUser使Axios
async function fetchUser(username) {
try {
const response = await axios.get(`/api/users/${username}`);
user.value = response.data; // user
} catch (error) {
console.error('Error fetching user:', error);
}
}
//
function gotohome() {
router.push('/home');
}
function gotomessage() {
router.push('/message');
}
fetchUser(username) {
// API
axios.post(`http://192.168.254.35:8080/user/${username}`)
.then(response => {
this.user = response.data;
})
.catch(error => {
console.error('Error fetching user:', error);
});
},
toggleEmailInput() {
this.showEmailInput = !this.showEmailInput;
this.email = this.user.email;//
},
updateEmail() {
//
axios.put(`http://192.168.254.35:8080/user/${this.username}/email`, { email: this.email })
.then(response => {
alert(this.email);
this.user.email = this.email;
this.toggleEmailInput(); //
})
.catch(error => {
console.error('Error updating email:', error);
});
},
togglePhoneInput(){
this.showPhoneInput = !this.showPhoneInput;
this.phone = this.user.phone;
},
updatePhone(){
axios.put(`http://192.168.254.35:8080/user/${this.username}/phone`, { phone: this.phone })
.then(response => {
this.user.phone = this.phone;
this.togglePhoneInput(); //
})
.catch(error => {
console.error('Error updating phone:', error);
});
}
return {
user,
email,
showEmailInput,
phone,
showPhoneInput,
gotohome,
gotomessage,
};
},
};
</script>
<script setup lang="ts">
import { ref, watchEffect } from 'vue'
import { format } from 'date-fns'
const startDateValue = ref(format(new Date(), 'yyyy-MM-dd'))
const endDateValue = ref(format(new Date(), 'yyyy-MM-dd'))
watchEffect(() => {
console.log('startDateValue:', startDateValue.value)
console.log('endDateValue:', endDateValue.value)
})
</script>
<template>
<div class="mine">
<h2>个人主页</h2>
<h1>{{ user.name }}</h1>
<!-- <h1>用户姓名</h1>-->
<p>创建时间{{user.createtime}}</p>
<p>账号: {{ username }}</p>
<p>身份证号{{user.IDCard}}</p>
<div v-if="showEmailInput">
<label for="email">邮箱</label>
<input type="email" id="email" v-model="email" class="input-field">
<button @click="updateEmail"></button>
</div>
<div v-else>
<p>邮箱{{ user.email }}</p>
<button @click="toggleEmailInput"></button>
</div>
<div v-if="showPhoneInput">
<label for="PhoneNumber">手机号</label>
<input type="phone" id="phone" v-model="phone" class="input-field">
<button @click="updatePhone"></button>
</div>
<div v-else>
<p>手机号{{ user.phone }}</p>
<button @click="togglePhoneInput"></button>
</div>
<div class="footer-nav">
<button @click="gotohome()"></button>
<button @click="gotomessage()"></button>
<button>我的</button>
</div>
</div>
<VueDatePicker
placeholder="请选择预计出发日期"
:min-date="new Date()"
format="yyyy-MM-dd"
v-model="startDateValue" />
<VueDatePicker
placeholder="请选择预计返回日期"
:min-date="new Date()"
format="yyyy-MM-dd"
v-model="endDateValue" />
</template>
<style scoped>
.profile {
max-width: 400px;
margin: 0 auto;
padding: 20px;
}
.input-field {
margin-bottom: 10px;
}
button {
margin-top: 10px;
}
.home-container {
/* 添加你的样式 */
text-align: center;
padding: 20px;
/* 可能需要为内容添加一些底部空间以容纳底部导航 */
padding-bottom: 50px;
}
.footer-nav {
/* 定义底部导航的样式 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: #f5f5f5; /* 示例背景色 */
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
export default {
name: 'Mine',
props: ['username'],
data() {
return {
user: {}, //
email: '',
showEmailInput: false,
phone: '',
showPhoneInput: false,
};
},
created() {
this.fetchUser(this.username);
},
methods: {
gotohome() {
this.$router.push('/home');
},
gotomessage() {
this.$router.push('/message');
},
fetchUser(username) {
// API
axios.post(`http://192.168.254.35:8080/user/${username}`)
.then(response => {
this.user = response.data;
})
.catch(error => {
console.error('Error fetching user:', error);
});
},
toggleEmailInput() {
this.showEmailInput = !this.showEmailInput;
this.email = this.user.email;//
},
updateEmail() {
//
axios.put(`http://192.168.254.35:8080/user/${this.username}/email`, { email: this.email })
.then(response => {
this.user.email = this.email;
this.toggleEmailInput(); //
})
.catch(error => {
console.error('Error updating email:', error);
});
},
togglePhoneInput(){
this.showPhoneInput = !this.showPhoneInput;
this.phone = this.user.phone;
},
updatePhone(){
axios.put(`http://192.168.254.35:8080/user/${this.username}/phone`, { phone: this.phone })
.then(response => {
this.user.phone = this.phone;
this.togglePhoneInput(); //
})
.catch(error => {
console.error('Error updating phone:', error);
});
}
}
}
</script>
<script setup lang="ts">
import { ref, watchEffect } from 'vue'
import { format } from 'date-fns'
const startDateValue = ref(format(new Date(), 'yyyy-MM-dd'))
const endDateValue = ref(format(new Date(), 'yyyy-MM-dd'))
watchEffect(() => {
console.log('startDateValue:', startDateValue.value)
console.log('endDateValue:', endDateValue.value)
})
</script>
<template>
<VueDatePicker
placeholder="请选择预计出发日期"
:min-date="new Date()"
format="yyyy-MM-dd"
v-model="startDateValue" />
<VueDatePicker
placeholder="请选择预计返回日期"
:min-date="new Date()"
format="yyyy-MM-dd"
v-model="endDateValue" />
</template>

@ -0,0 +1,28 @@
<script>
export default {
name: 'return',
methods: {
gotohome() {
this.$router.push('/home');
},
}
}
</script>
<template>
<div class="return">
<button class="return-button" @click="gotohome()"></button>
</div>
</template>
<style>.return-button {
/* 定义返回按钮的样式 */
position: fixed; /* 使按钮位置固定 */
top: 10px;
left: 10px;
margin: 0;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #ccc;
color: #333;
cursor: pointer;
} </style>

@ -1,91 +0,0 @@
<template>
<div class="home-container">
<div class="return">
<button class="return-button" @click="gotohome()"></button>
</div>
<div class="search-container">
<input type="text" class="search-input" placeholder="世界这么大出去看看吧">
<button class="search-button" @click="search"></button>
</div>
</div>
</template>
<style scoped>
.search-container {
/* 定义搜索框容器的样式 */
text-align: center;
/* 使用margin-top来确保搜索框在返回按钮下方20px */
margin-top: 50px; /* 假设返回按钮的高度是30px10px padding * 2 + 10px height再加上20px的间距 */
margin-bottom: 20px; /* 根据需要添加一些底部间距 */
display: flex;
align-items: center; /* 垂直居中 */
justify-content: center; /* 水平居中(如果不需要完全居中,可以去掉这个)*/
}
.search-input {
/* 定义搜索框的样式 */
flex: 1; /* 占据剩余空间 */
padding: 15px;
border-radius: 5px;
border: 1px solid #ccc;
}
.search-button {
margin-left: 10px; /* 与搜索框之间的间距 */
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.search-button:hover {
/* 搜索按钮点击时的样式 */
background-color: #bbb;
}
.return-button {
/* 定义返回按钮的样式 */
position: fixed; /* 使按钮位置固定 */
top: 10px;
left: 10px;
margin: 0;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button {
/* 定义按钮的样式 */
flex: 1;
border: none;
padding: 10px;
background-color: #ccc;
color: #333;
cursor: pointer;
}
.footer-nav button:hover {
/* 按钮点击时的样式 */
background-color: #bbb;
}
</style>
<script>
export default {
name: 'SearchPage',
methods: {
gotohome() {
this.$router.push('/home');
},
}
}
</script>

@ -0,0 +1,6 @@
export type AreaList = {
code: string;
level: number;
name: string;
areaList: AreaList[];
};

@ -0,0 +1,25 @@
package com.softegg.freetogo;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @description:http使
* @author:zhanglinhao
* @date:2024/5/9 15:20
*/
@Configuration
public class Configurer implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
//是否发送Cookie
.allowCredentials(true)
//放行哪些原始域
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.exposedHeaders("*");
}
}

@ -0,0 +1,13 @@
package com.softegg.freetogo.Demand.Dao;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @description:Jpa
* @author:wuyifan
* @date:2024/5/10 19:50
*/
public interface DemandsRepository extends JpaRepository<Demands, Integer> {
}

@ -0,0 +1,47 @@
package com.softegg.freetogo.Demand.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @description:demand
* @author:wuyifan
* @date:2024/5/10 11:36
*/
@Entity
@Table(name="demands")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Demands {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer uid;
@Column
private String phone;//游客手机号码
@Column
private boolean touristGender;//游客性别 ture:male, false:female
@Column
private String nickname;//发布需求的游客昵称信息
@Column
private String createTime;//需求发布时间
@Column
private String departureDate;//游客需求起始日期
@Column
private String endDate;//游客需求结束日期
@Column
private String sumDay;//游客旅游总天数
@Column
private String city;//发布需求的目的城市
@Column
private String message;//需求备注内容
// @Column
// private boolean guideGender;//希望导游性别
// @Column
// private int status;
}

@ -0,0 +1,85 @@
package com.softegg.freetogo.Demand.controller;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description:Demand
* @author:wuyifan
* @date:2024/5/10 11:40
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/demands")
public class DemandsController {
@Autowired
private DemandsService demandsService;
@GetMapping("findAll")
public List<Demands> findAll() {
return demandsService.findAll();
}
@GetMapping("add")
public String add(String phone,
boolean tGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String city,
String message) {
Demands demand = new Demands();
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
demandsService.add(demand);
return "添加成功";
}
@GetMapping("delbyid")
public String delById(int id) {
demandsService.deleteById(id);
return "删除成功";
}
@GetMapping("findbyid")
public Demands getUserById(int id) {
return demandsService.getDemandById(id);
}
@GetMapping("update")
public String update(int id,
String phone,
boolean tGender,
String nkn,
String ct,
String dDate,
String eDate,
String sDay,
String city,
String message) {
Demands demand = demandsService.getDemandById(id);
setDemands(phone, tGender, nkn, ct, dDate, eDate, sDay, city, message, demand);
demandsService.update(demand);
return "更新成功";
}
private void setDemands(String phone, boolean tGender, String nkn, String ct, String dDate, String eDate, String sDay, String city, String message, Demands demand) {
demand.setPhone(phone);
demand.setTouristGender(tGender);
demand.setNickname(nkn);
demand.setCreateTime(ct);
demand.setDepartureDate(dDate);
demand.setEndDate(eDate);
demand.setSumDay(sDay);
demand.setCity(city);
demand.setMessage(message);
// demand.setGuideGender(gGender);
}
}

@ -0,0 +1,23 @@
package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 2059
*/
public interface DemandsService {
List<Demands> findAll();//查找所有需求
void add(Demands demand);//以demand为用户入库
void deleteById(int id);//删除对应id需求
Demands getDemandById(int id);//获得对应id需求
void update(Demands demand);//更新需求信息
}

@ -0,0 +1,92 @@
package com.softegg.freetogo.Demand.service;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 19:50
*/
@Component
public class DemandsServiceImpl implements DemandsService {
@Autowired
private DemandsRepository DemandsRepository;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.Demand.Bean.Demands>
* @author: wuyifan
* @date: 2024/5/10 19:53
*/
public List<Demands> findAll() {
System.out.println("查询成功");
return DemandsRepository.findAll();
}
/**
* @description: demand
* @param: demand
* @return: void
* @author: wuyifan
* @date: 2024/5/10 19:55
*/
public void add(Demands demand) {
DemandsRepository.save(demand);
System.out.println("添加成功");
}
/**
* @description: id
* @param: id
* @return: void
* @author: wuyifan
* @date: 2024/5/10 19:59
*/
public void deleteById(int id) {
DemandsRepository.deleteById(id);
System.out.println("删除成功");
}
/**
* @description: id
* @param: id
* @return: com.softegg.freetogo.Demand.Bean.Demands
* @author: wuyifan
* @date: 2024/5/10 20:02
*/
public Demands getDemandById(int id) {
return DemandsRepository.findById(id).orElse(null);
}
/**
* @description:
* @param: demand
* @return: void
* @author: wuyifan
* @date: 2024/5/10 20:05
*/
public void update(Demands demand) {
DemandsRepository.save(demand);
System.out.println("更新成功");
}
// /**
// * @description: 判断相同需求是否已经入库
// * @param: id
// * @return: boolean
// * @author: wuyifan
// * @date: 2024/5/10 20:05
// */
// public boolean isRegister(int id) {
// Demands demand = DemandsRepository.findById(id);
// System.out.println(demand);
// return users != null;
// }
}

@ -0,0 +1,15 @@
package com.softegg.freetogo.Evaluate.Dao;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @description: Jpa
* @author: zhanglinhao
* @date: 2024/5/10 9:27
*/
public interface EvaluateRepository extends JpaRepository<Evaluations, Integer> {
List<Evaluations> findByEditorPhone(String phone);
}

@ -0,0 +1,38 @@
package com.softegg.freetogo.Evaluate.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 9:07
*/
@Entity
@Table(name = "evaluation")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Evaluations {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int eid;
@Column(name = "etorname")
private String editorName;
@Column(name = "etorphone")
private String editorPhone;
@Column(name = "etedname")
private String editedName;
@Column(name = "etedphone")
private String editedPhone;
@Column(name = "createtime")
private String ct;
@Column(name = "modifytime")
private String mt;
@Column
private String ebody;
}

@ -0,0 +1,58 @@
package com.softegg.freetogo.Evaluate.controller;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import com.softegg.freetogo.Evaluate.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/11 17:33
*/
@RestController
@RequestMapping("/evaluate")
public class EvaluationController {
@Autowired
EvaluateService evaluateService;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:11
*/
@GetMapping("findAllEvaluation")
public List<Evaluations> findAllEvaluation() {
return evaluateService.evaluationList();
}
/**
* @description:
* @param: ebody
* @return: void
* @author: zhanglinhao
* @date: 2024/5/12 0:28
*/
@PostMapping("addEvaluation")
public void addEvaluation(@RequestBody Map<String, Evaluations> ebody) {
Evaluations evaluation = ebody.get("evaluation");
evaluateService.addEvaluation(evaluation);
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:30
*/
@GetMapping("evaluationByPhone")
public List<Evaluations> evaluationByPhone(String phone) {
return evaluateService.getEListByPhone(phone);
}
}

@ -0,0 +1,30 @@
package com.softegg.freetogo.Evaluate.service;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 8:52
*/
@Service
public interface EvaluateService {
List<Evaluations> evaluationList();//获取所有评论
<<<<<<< HEAD
List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
void addEvaluation(Evaluations evaluation);//添加评论
=======
List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
void addEvaluation(Evaluations evaluation);//添加评论
void editEvaluation(int eid, String ebody);//编辑评论
void deleteEvaluation(int eid);//删除评论
>>>>>>> zhanglinhao_branch
}

@ -0,0 +1,109 @@
package com.softegg.freetogo.Evaluate.service;
import com.softegg.freetogo.Evaluate.Dao.EvaluateRepository;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/10 9:25
*/
@Component
public class EvaluateServiceImpl implements EvaluateService {
@Autowired
EvaluateRepository evaluateRepository;
/**
* @description:
* @param: null
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 9:25
*/
@Override
public List<Evaluations> evaluationList() {
System.out.println("查询评论");
return evaluateRepository.findAll();
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/11 16:28
*/
@Override
public List<Evaluations> getEListByPhone(String phone) {
System.out.println("查询"+phone+"的评论");
return evaluateRepository.findByEditorPhone(phone);
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/11 16:28
*/
@Override
public List<Evaluations> getEListByPhone(String phone) {
System.out.println("查询" + phone + "的评论");
return evaluateRepository.findByEditorPhone(phone);
}
/**
* @description:
* @param: evaluation
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 21:20
*/
@Override
public void addEvaluation(Evaluations evaluation) {
evaluateRepository.save(evaluation);
System.out.println("添加评论" + evaluation.getEbody());
}
<<<<<<< HEAD
=======
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:10
*/
@Override
public void editEvaluation(int eid, String ebody) {
System.out.println("编辑评论:" + eid);
Optional<Evaluations> opt = evaluateRepository.findById(eid);
if (opt.isPresent()) {
Evaluations evaluation = opt.get();
evaluation.setEbody(ebody);
evaluateRepository.save(evaluation);
System.out.println("编辑成功:" + eid);
}
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:28
*/
@Override
public void deleteEvaluation(int eid) {
evaluateRepository.deleteById(eid);
System.out.println("删除评论:" + eid);
}
>>>>>>> zhanglinhao_branch
}

@ -0,0 +1,13 @@
package com.softegg.freetogo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FreeToGoApplication {
public static void main(String[] args) {
SpringApplication.run(FreeToGoApplication.class, args);
}
}

@ -0,0 +1,81 @@
package com.softegg.freetogo.Login.controller;
import com.softegg.freetogo.Login.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 9:35
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/Login")
public class LoginController {
@Autowired
LoginService loginService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:44
*/
@PostMapping("login")
public int Login(@RequestBody Map<String, Object> map) {
System.out.println(map);
<<<<<<< HEAD
System.out.println("phone:"+map.get("phone").toString());
System.out.println("password"+map.get("password").toString());
int tag = loginService.loginAccount(map.get("name").toString(), map.get("password").toString());
System.out.println("LoginTag:"+tag);
=======
System.out.println("phone:" + map.get("phone").toString());
System.out.println("password" + map.get("password").toString());
int tag = loginService.loginAccount(map.get("name").toString(), map.get("password").toString());
System.out.println("LoginTag:" + tag);
>>>>>>> zhanglinhao_branch
return switch (tag) {
case 1000 -> 1;//登陆成功
case 1001 -> 2;//密码或账号错误
case 1002 -> 3;//该账户未注册
case 1005 -> 6;//未输入账号密码
case 1006 -> 7;//未输入账号
case 1007 -> 8;//未输入密码
case 1008 -> 9;//身份证输入错误
default -> 0;
};
}
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:45
*/
@PostMapping("register")
public int Register(@RequestBody Map<String, Object> map) {
System.out.println(map);
<<<<<<< HEAD
int tag = loginService.registerAccount((String)map.get("name"), (String)map.get("password"),(String)map.get("phone"),(String)map.get("nickname"),(String)map.get("IDCard"));
System.out.println("RegisterTag:"+tag);
=======
int tag = loginService.registerAccount((String) map.get("name"), (String) map.get("password"), (String) map.get("phone"), (String) map.get("nickname"), (String) map.get("IDCard"));
System.out.println("RegisterTag:" + tag);
>>>>>>> zhanglinhao_branch
return switch (tag) {
case 1003 -> 4;//该账户已经注册
case 1004 -> 5;//注册成功
default -> 0;
};
}
}

@ -0,0 +1,20 @@
package com.softegg.freetogo.Login.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 8:37
*/
@Service
public interface LoginService {
int loginAccount(String phone, String password);//登录
// int registerAccount(String phone, String password);
int registerAccount(String name,
String password,
String phone,
String nickname,
String IDCard);//注册
}

@ -0,0 +1,108 @@
package com.softegg.freetogo.Login.service;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
<<<<<<< HEAD
import java.util.Objects;
=======
>>>>>>> zhanglinhao_branch
/**
* @description:
* @author:zhanglinhao
* @date:2024/5/9 9:33
*/
@Component
public class LoginServiceImpl implements LoginService {
@Autowired
UsersService usersService;
/**
* @description:
* @param: phone
* @param: password
* @return: int
* @author: zhanglinhao
* @date: 2024/5/9 22:46
*/
@Override
public int loginAccount(String phone, String password) {
if (phone.isEmpty() && password.isEmpty())
return 1005;//未输入账号密码
else if (phone.isEmpty())
return 1006;//未输入账号
else if (password.isEmpty())
return 1007;//未输入密码
if (usersService.isRegister(phone)) {
if (usersService.getUserByPhone(phone).getPassword().equals(password))
return 1000;//登录成功
else
return 1001;//密码或账号错误
} else
return 1002;//该账户未注册
}
/**
* @description:
* @param: name
* @param: password
* @param: phone
* @param: nickname
* @param: IDCard
* @return: int
* @author: zhanglinhao
* @date: 2024/5/11 15:57
*/
@Override
public int registerAccount(String name,
String password,
String phone,
String nickname,
String IDCard) {
if (usersService.isRegister(phone))
return 1003;//该账户已经注册
<<<<<<< HEAD
else if(IDCard.length()!=18)
return 1008;//身份证输入错误
else {
LocalDateTime currentTime = LocalDateTime.now();
System.out.println("注册信息:姓名:"+name+"密码:"+password+"电话:"+phone+"昵称:"+nickname+"身份证:"+IDCard);
=======
else if (IDCard.length() != 18)
return 1008;//身份证输入错误
else {
LocalDateTime currentTime = LocalDateTime.now();
System.out.println("注册信息:姓名:" + name + "密码:" + password + "电话:" + phone + "昵称:" + nickname + "身份证:" + IDCard);
>>>>>>> zhanglinhao_branch
Users user = new Users();
user.setPhone(phone);
user.setPassword(password);
user.setNickname(nickname);
user.setIDCard(IDCard);
user.setName(name);
<<<<<<< HEAD
user.setCreatetime((currentTime.getYear()+"-"+currentTime.getMonthValue()+"-"+currentTime.getDayOfMonth()));
=======
user.setCreatetime((currentTime.getYear() + "-" + currentTime.getMonthValue() + "-" + currentTime.getDayOfMonth()));
>>>>>>> zhanglinhao_branch
user.setGender(isMale(IDCard));
usersService.add(user);
return 1004;//注册成功
}
}
<<<<<<< HEAD
boolean isMale(String IDCard){
System.out.println("根据身份证判断性别:"+IDCard+" 第17位:"+IDCard.charAt(16));
return (int)IDCard.charAt(16) % 2 != 0;
=======
boolean isMale(String IDCard) {
System.out.println("根据身份证判断性别:" + IDCard + " 第17位:" + IDCard.charAt(16));
return (int) IDCard.charAt(16) % 2 != 0;
>>>>>>> zhanglinhao_branch
}
}

@ -0,0 +1,9 @@
1000->1 登录成功
1001->2 密码或账号错误
1002->3 该账户未注册
1003->4 该账户已经注册
1004->5 注册成功
1005->6 未输入账号密码
1006->7 未输入账号
1007->8 身份证输入错误
1008->9

@ -0,0 +1,41 @@
package com.softegg.freetogo.SendDemand.controller;
import com.softegg.freetogo.SendDemand.service.SendDemandService;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:09
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/SendDemand")
public class SendDemandController {
@Autowired
SendDemandService sendDemandService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:45
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString())){
case 1005 -> 1;//需求发送成功
default -> 0;
};
}
}

@ -0,0 +1,13 @@
package com.softegg.freetogo.SendDemand.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:31
*/
@Service
public interface SendDemandService {
int sendnewDemandAccount(String city, String phone);
}

@ -0,0 +1,39 @@
package com.softegg.freetogo.SendDemand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:10
*/
@Component
public class SendDemandServiceImpl implements SendDemandService {
@Autowired
DemandsService demandsService;
UsersService usersService;
/**
* @description:
* @param: city
* @return: int
* @author: wuyifan
* @date: 2024/5/10 23:25
*/
@Override
public int sendnewDemandAccount(String city, String phone) {
Demands demand = new Demands();
Users user = usersService.getUserByPhone(phone);
demand.setPhone(phone);
demand.setCity(city);
demand.setTouristGender(user.isGender());
demand.setNickname(user.getNickname());
demandsService.add(demand);
return 1005;//添加需求成功
}
}

@ -0,0 +1,13 @@
package com.softegg.freetogo.User.Dao;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @description:Jpa
* @author:zhanglinhao
* @date:2024/5/8 8:50
*/
public interface UsersRepository extends JpaRepository<Users, Integer> {
Users findByPhone(String phone);//自定义函数,根据手机号进行查找返回对应对象
}

@ -0,0 +1,60 @@
package com.softegg.freetogo.User.bean;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @description:users
* @author:zhanglinhao
* @date:2024/5/7 15:36
*/
@Entity
@Table(name = "users")
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Users {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer uid;
@Column
private String name;
@Column
private String email;
@Column
private String password;
@Column
private String createtime;
@Column
private String IDCard;
@Column
private int reputation;
@Column
private boolean gender;//ture:male, false:female
@Column
private boolean membertype;//true:guide, false:visitor
@Column
private String phone;
@Column
private String nickname;
@Column
private int status;
public Users(String name, String email, String psw, String ct, int rpt, String phone, String nkn, String idc, boolean gender, boolean type, int status) {
this.name = name;
this.email = email;
this.password = psw;
this.createtime = ct;
this.reputation = rpt;
this.phone = phone;
this.nickname = nkn;
this.IDCard = idc;
this.gender = gender;
this.membertype = type;
this.status = status;
}
}

@ -0,0 +1,217 @@
package com.softegg.freetogo.User.controller;
import com.softegg.freetogo.User.bean.Users;
import com.softegg.freetogo.User.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:Users
* @author:zhanglinhao
* @date:2024/5/8 8:28
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/Users")
public class UsersController {
@Autowired
private UsersService usersService;
/**
* @description: users
* @param: null
* @return: java.util.List<com.softegg.freetogo.User.bean.Users>
* @author: zhanglinhao
* @date: 2024/5/10 8:16
*/
@GetMapping("findAll")
public List<Users> findAll() {
System.out.println("响应查找所有数据");
return usersService.findAll();
}
/**
* @description:
* @param: name
* @param: email
* @param: psw
* @param: ct
* @param: rpt
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@GetMapping("add")
public String add(String name,
String email,
String password,
String createtime,
int reputation,
String phone,
String nickname,
String IDCard,
boolean gender,
boolean type,
int status) {
Users user = new Users(name, email, password, createtime, reputation, phone, nickname, IDCard, gender, type, status);
usersService.add(user);
System.out.println("添加用户");
return "添加成功";
}
/**
* @description: id
* @param: id
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@GetMapping("delbyid")
public String delById(int id) {
usersService.deleteById(id);
System.out.println("通过id删除用户");
return "删除成功";
}
/**
* @description: id
* @param: id
* @return: com.softegg.freetogo.User.bean.Users
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@GetMapping("findbyid")
public Users getUserById(int id) {
System.out.println("通过id获取用户数据");
return usersService.getUserById(id);
}
/**
* @description: 使GET
* @param: name
* @param: email
* @param: password
* @param: ct
* @param: rpt
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@GetMapping("update")
public String update(String name,
String email,
String password,
String createtime,
int reputation,
String phone,
String nickname,
String IDCard,
boolean gender,
boolean type,
int status) {
Users User = usersService.getUserByPhone(phone);
System.out.println(User);
setUsers(name, email, password, createtime, reputation, phone, nickname, IDCard, gender, type, status, User);
usersService.update(User);
System.out.println("更新用户信息:" + User);
return "更新成功";
}
/**
* @description: 使POST
* @param: user
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 19:45
*/
@PostMapping("pupdate")
public boolean pupdate(@RequestBody Map<String, Map<String, Object>> user) {
Map<String, Object> ubody = user.get("user");
// System.out.println(ubody);
// System.out.println(ubody.get("uid"));
Users User = new Users((int) ubody.get("uid"), (String) ubody.get("name"), (String) ubody.get("email"), (String) ubody.get("password"), (String) ubody.get("createtime"), (String) ubody.get("IDCard"), (int) ubody.get("reputation"), (boolean) ubody.get("gender"), (boolean) ubody.get("membertype"), (String) ubody.get("phone"), (String) ubody.get("nickname"), (int) ubody.get("status"));
usersService.update(User);
return true;
}
@PostMapping("Pupdate")
public boolean Pupdate(@RequestBody Map<String, Users> user) {
Users ubody = user.get("user");
System.out.println(ubody);
// System.out.println(ubody.get("uid"));
Users User = new Users(ubody.getUid(), ubody.getName(), ubody.getEmail(), ubody.getPassword(), ubody.getCreatetime(), ubody.getIDCard(), ubody.getReputation(), ubody.isGender(), ubody.isMembertype(), ubody.getPhone(), ubody.getNickname(), ubody.getStatus());
usersService.update(User);
return true;
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.User.bean.Users
* @author: zhanglinhao
* @date: 2024/5/10 8:17
*/
@GetMapping("getByPhone")
public Users getByPhone(String phone) {
System.out.println("根据手机号获取用户信息:" + phone);
return usersService.getUserByPhone(phone);
}
/**
* @description: user
* @param: name
* @param: email
* @param: psw
* @param: ct
* @param: rpt
* @param: phone
* @param: nkn
* @param: idc
* @param: gender
* @param: type
* @param: status
* @param: user
* @return: void
* @author: zhanglinhao
* @date: 2024/5/10 8:18
*/
private void setUsers(String name,
String email,
String psw,
String ct,
int rpt,
String phone,
String nkn,
String idc,
boolean gender,
boolean type,
int status,
Users user) {
user.setName(name);
user.setGender(gender);
user.setPassword(psw);
user.setEmail(email);
user.setReputation(rpt);
user.setMembertype(type);
user.setCreatetime(ct);
user.setPhone(phone);
user.setNickname(nkn);
user.setIDCard(idc);
user.setStatus(status);
}
}

@ -0,0 +1,103 @@
package com.softegg.freetogo.User.service;
import com.softegg.freetogo.User.Dao.UsersRepository;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/8 8:50
*/
@Component
public class UserServiceImpl implements UsersService {
@Autowired
private UsersRepository usersRepository;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.User.Bean.Users>
* @author: zhanglinhao
* @date: 2024/5/9 22:52
*/
public List<Users> findAll() {
System.out.println("查询成功");
return usersRepository.findAll();
}
/**
* @description: user
* @param: user
* @return: void
* @author: zhanglinhao
* @date: 2024/5/9 22:53
*/
public void add(Users user) {
usersRepository.save(user);
System.out.println("添加成功:" + user);
}
/**
* @description: id
* @param: id
* @return: void
* @author: zhanglinhao
* @date: 2024/5/9 22:53
*/
public void deleteById(int id) {
usersRepository.deleteById(id);
System.out.println("删除成功:" + id);
}
/**
* @description: id
* @param: id
* @return: com.softegg.freetogo.User.Bean.Users
* @author: zhanglinhao
* @date: 2024/5/9 22:54
*/
public Users getUserById(int id) {
return usersRepository.findById(id).orElse(null);
}
/**
* @description:
* @param: user
* @return: void
* @author: zhanglinhao
* @date: 2024/5/9 22:54
*/
public void update(Users user) {
usersRepository.save(user);
System.out.println("更新成功:" + user);
}
/**
* @description:
* @param: phone
* @return: boolean
* @author: zhanglinhao
* @date: 2024/5/9 22:54
*/
public boolean isRegister(String phone) {
Users users = usersRepository.findByPhone(phone);
System.out.println("正在验证用户是否注册:" + users);
return users != null;
}
/**
* @description:
* @param: phone
* @return: com.softegg.freetogo.User.Bean.Users
* @author: zhanglinhao
* @date: 2024/5/9 22:55
*/
public Users getUserByPhone(String phone) {
System.out.println("通过手机号查找用户:" + phone);
return usersRepository.findByPhone(phone);
}
}

@ -0,0 +1,28 @@
package com.softegg.freetogo.User.service;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author:zhanglinhaon
* @date:2024/5/7 16:06
*/
@Service
public interface UsersService {
List<Users> findAll();//查找所有用户
void add(Users user);//以user为用户入库
void deleteById(int id);//删除对应id用户
Users getUserById(int id);//获得对应id用户
void update(Users user);//更新用户信息
boolean isRegister(String phone);//判断该手机号(账号)是否已经入库
Users getUserByPhone(String phone);//根据手机号获得用户
}

@ -0,0 +1,17 @@
package com.softegg.freetogo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description
* @author:zhanglinhao
* @date:2024/5/7 23:40
*/
@RestController
public class helloController {
@GetMapping("/hello")
public String hello() {
return "hello world!";
}
}

@ -0,0 +1,5 @@
spring.application.name=FreeToGo
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/freetogo?useSSL=false&useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=zlh1260788704

@ -0,0 +1,10 @@
spring:
jpa:
hibernate:
ddl-auto: none
show-sql: true
datasource:
username: root
password: zlh1260788704
url: dbc:mysql://localhost:3306/freetogo?useSSL=false&useUnicode=true&characterEncoding=utf-8
driverClassName: com.mysql.jdbc.Driver
Loading…
Cancel
Save