xhf_branch
于慕涵 2 years ago
parent 8ef76af6a5
commit 3d61809102

@ -1,32 +0,0 @@
package com.example.hosdata.controller;
import com.example.hosdata.pojo.Information;
import com.example.hosdata.pojo.RegisterRecord;
import com.example.hosdata.service.DocyzService;
import com.example.hosdata.service.InService;
import com.example.hosdata.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.HtmlUtils;
import java.util.List;
@RestController
public class InController {
@Autowired
InService inService;
@CrossOrigin
@GetMapping("/api/setting")
public List<Information> listuser() throws Exception {
return inService.listbyuser();
}
@CrossOrigin
@PostMapping("/api/setting")
public Information Update(@RequestBody Information information) throws Exception {
inService.update(information);
return information;
}
}

@ -1,12 +0,0 @@
package com.example.hosdata.dao;
import com.example.hosdata.pojo.Information;
import com.example.hosdata.pojo.RegisterRecord;
import com.example.hosdata.pojo.User;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface InDAO extends JpaRepository<Information,Integer>{
List<Information> findByUsername(String username);
}

@ -1,26 +0,0 @@
package com.example.hosdata.service;
import com.example.hosdata.dao.InDAO;
import com.example.hosdata.dao.RegisterDAO;
import com.example.hosdata.pojo.Information;
import com.example.hosdata.pojo.RegisterRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class InService {
@Autowired
InDAO inDAO;
static public String userna;
public List<Information> listbyuser() {
return inDAO.findByUsername(userna);
}
public void update(Information information) {
inDAO.save(information);
}
}

@ -1,52 +0,0 @@
package com.example.hosdata.pojo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.persistence.*;
@Entity
@Table(name = "user")
@JsonIgnoreProperties({"handler","hibernateLazyInitializer"})
public class Information {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
String id;
String username;
String password;
String realname;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
}

@ -1,180 +0,0 @@
<template>
<el-table
:data="serecords"
style="width: 50%"
:model="ruleForm"
class="se">
<el-table-column
prop="id"
label="登录身份"
v-model="ruleForm.id"
width="180">
</el-table-column>
<el-table-column
prop="username"
v-model="ruleForm.username"
label="账号"
width="180">
</el-table-column>
<el-table-column
prop="password"
label="密码"
width="180">
</el-table-column>
<el-table-column
prop="realname"
v-model="ruleForm.realname"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="sex"
v-model="ruleForm.sex"
label="性别"
width="180">
</el-table-column>
<el-table-column
prop="age"
v-model="ruleForm.age"
label="年龄"
width="180">
</el-table-column>
<el-table-column
prop="contact"
v-model="ruleForm.contact"
label="联系方式"
width="180">
</el-table-column>
<el-table-column
label="操作"
width="180">
<el-button type="text" @click="dialogVisible = true">修改</el-button>
<el-dialog title="修改密码" :visible.sync="dialogVisible" append-to-body>
<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm">
<el-form-item label="身份" prop="id">
<el-input v-model="ruleForm.id" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="账号" prop="username">
<el-input v-model="ruleForm.username" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="密码" prop="pass">
<el-input type="password" v-model="ruleForm.pass" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="checkPass">
<el-input type="password" v-model="ruleForm.checkPass" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="姓名" prop="realname">
<el-input v-model="ruleForm.realname" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="性别" prop="sex">
<el-input v-model="ruleForm.sex" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="年龄" prop="age">
<el-input v-model="ruleForm.age" autocomplete="off" clearable></el-input>
</el-form-item>
<el-form-item label="联系方式" prop="contact">
<el-input v-model="ruleForm.contact" autocomplete="off" clearable></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submitForm('ruleForm')"> </el-button>
</div>
</el-dialog>
</el-table-column>
</el-table>
</template>
<script>
export default {
name: 'SettingIndex',
data () {
var validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'))
} else {
if (this.ruleForm.checkPass !== '') {
this.$refs.ruleForm.validateField('checkPass')
}
callback()
}
}
var validatePass2 = (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'))
} else if (value !== this.ruleForm.pass) {
callback(new Error('两次输入密码不一致!'))
} else {
callback()
}
}
return {
serecords: [],
dialogVisible: false,
formLabelWidth: '100px',
ruleForm: {
id: '',
username: '',
realname: '',
pass: '',
checkPass: '',
sex: '未填写',
age: '未填写',
contact: '未填写'
},
rules: {
pass: [
{ validator: validatePass, trigger: 'blur' }
],
checkPass: [
{ validator: validatePass2, trigger: 'blur' }
]
}
}
},
mounted: function () {
this.loadSerecords()
},
methods: {
loadSerecords () {
var _this = this
this.$axios.get('/setting').then(resp => {
if (resp && resp.status === 200) {
_this.serecords = resp.data
}
})
},
submitForm (formName) {
this.$axios
.post('/setting', {
id: this.ruleForm.id,
username: this.ruleForm.username,
realname: this.ruleForm.realname,
password: this.ruleForm.checkPass,
sex: this.ruleForm.sex,
age: this.ruleForm.age,
contact: this.ruleForm.contact
}).then(resp => {
if (resp && resp.status === 200) {
this.$emit('submitForm')
}
})
this.$message({
message: '修改成功',
type: 'success'
})
this.$router.replace({path: '/login'})
}
}
}
</script>
<style scoped>
.se {
position: fixed;
margin-left: 50%;
left: -400px;
top: 140px;
width: 700px;
}
</style>
Loading…
Cancel
Save