紧急修复无法修改个人信息的错误,以及无法设置密保问题的错误
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.fjy</groupId>
|
<groupId>com.fjy</groupId>
|
||||||
<artifactId>spring</artifactId>
|
<artifactId>spring</artifactId>
|
||||||
<version>V2.9.2</version>
|
<version>V2.9.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>spring</name>
|
<name>spring</name>
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class DataController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/home/adduserque")
|
@PostMapping("/home/adduserque")
|
||||||
public boolean adduserque(TbUserque userque) throws Exception {
|
public boolean adduserque(TbUserque userque) throws Exception {
|
||||||
|
System.out.println("【问题】"+userque.toString());
|
||||||
//对密保问题加密存储
|
//对密保问题加密存储
|
||||||
userque.setAnswer(new BigInteger(CodingUtil.encryptSHA(userque.getAnswer().getBytes())).toString(32));
|
userque.setAnswer(new BigInteger(CodingUtil.encryptSHA(userque.getAnswer().getBytes())).toString(32));
|
||||||
return userService.addUserQue(userque);
|
return userService.addUserQue(userque);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class RegisterController {
|
|||||||
tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32));
|
tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32));
|
||||||
if (userService.doRegisterService(tbUser)){
|
if (userService.doRegisterService(tbUser)){
|
||||||
//更新用户列表是否注册的标记
|
//更新用户列表是否注册的标记
|
||||||
studentService.UpdateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(),RegisteredEnum.REGISTERED.getCode());
|
studentService.updateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(),RegisteredEnum.REGISTERED.getCode());
|
||||||
return true;
|
return true;
|
||||||
/*return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":"
|
/*return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":"
|
||||||
+ serverProperties.getPortNum() + request.getContextPath() + "/index";*/
|
+ serverProperties.getPortNum() + request.getContextPath() + "/index";*/
|
||||||
@@ -75,9 +75,9 @@ public class RegisterController {
|
|||||||
@RequestParam(value = "realname") String realname){
|
@RequestParam(value = "realname") String realname){
|
||||||
TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname);
|
TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname);
|
||||||
if (studentlist!=null&&studentlist.getRegistered().equals(RegisteredEnum.REGISTERED.getCode()) ) {
|
if (studentlist!=null&&studentlist.getRegistered().equals(RegisteredEnum.REGISTERED.getCode()) ) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,18 +43,25 @@ public class UpdateController {
|
|||||||
@PostMapping(value = "/home/userUpdate")
|
@PostMapping(value = "/home/userUpdate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean doUserUpdate(TbUser tbUser)throws Exception{
|
public boolean doUserUpdate(TbUser tbUser)throws Exception{
|
||||||
|
System.out.println("【tbUser】"+tbUser.toString());
|
||||||
if (tbUser.getColuserid()==null){
|
if (tbUser.getColuserid()==null){
|
||||||
throw new UserException(ResultEnum.ID_NULLPOINT);
|
throw new UserException(ResultEnum.ID_NULLPOINT);
|
||||||
}
|
}
|
||||||
if (tbUser.getColpassword()!=null){
|
if (tbUser.getColpassword()!=null){
|
||||||
userService.updateColpasswordByColname(tbUser.getColpassword(),tbUser.getColname());
|
userService.updateColpasswordByColname(tbUser.getColpassword(),tbUser.getColname());
|
||||||
}
|
}
|
||||||
|
|
||||||
//注销原本的注册标记
|
//注销原本的注册标记
|
||||||
VUserinfo tempUser = userService.findUserInfo(tbUser.getColuserid());
|
VUserinfo tempUser = userService.findUserInfo(tbUser.getColuserid());
|
||||||
studentService.UpdateStudentListRegistered(tempUser.getColrealname(),tempUser.getColstudentno(),
|
|
||||||
|
System.out.println("【VUserinfo】"+tempUser.toString());
|
||||||
|
|
||||||
|
studentService.updateStudentListRegistered(tempUser.getColrealname(),tempUser.getColstudentno(),
|
||||||
RegisteredEnum.UNREGISTERED.getCode());
|
RegisteredEnum.UNREGISTERED.getCode());
|
||||||
|
|
||||||
|
|
||||||
if (userService.doRegisterService(tbUser)){
|
if (userService.doRegisterService(tbUser)){
|
||||||
studentService.UpdateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(),
|
studentService.updateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(),
|
||||||
RegisteredEnum.REGISTERED.getCode());
|
RegisteredEnum.REGISTERED.getCode());
|
||||||
log.info(tbUser.getColname()+" 信息更新成功");
|
log.info(tbUser.getColname()+" 信息更新成功");
|
||||||
//写入数据库日志
|
//写入数据库日志
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -12,7 +13,7 @@ public class TbUserque {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "coluserid")
|
@Column(name = "coluserid")
|
||||||
private Integer userid;
|
private Integer coluserid;
|
||||||
|
|
||||||
@Column(name = "colquestion")
|
@Column(name = "colquestion")
|
||||||
private String question;
|
private String question;
|
||||||
|
|||||||
@@ -27,9 +27,8 @@ public class StudentService {
|
|||||||
return tbStudentListRepository.findByColstudentnoAndColrealname(studentno,realname);
|
return tbStudentListRepository.findByColstudentnoAndColrealname(studentno,realname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TbStudentlist UpdateStudentListRegistered(String realname,String studentno,Integer code){
|
public TbStudentlist updateStudentListRegistered(String realname,String studentno,Integer code){
|
||||||
TbStudentlist studentlist = new TbStudentlist();
|
TbStudentlist studentlist = findByColstudentnoAndColrealname(studentno,realname);
|
||||||
studentlist = findByColstudentnoAndColrealname(studentno,realname);
|
|
||||||
studentlist.setRegistered(code);
|
studentlist.setRegistered(code);
|
||||||
return tbStudentListRepository.save(studentlist);
|
return tbStudentListRepository.save(studentlist);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class UserService {
|
|||||||
|
|
||||||
public boolean addUserQue(TbUserque userque) {
|
public boolean addUserQue(TbUserque userque) {
|
||||||
TbUserque tbUserque = userqueRepository.save(userque);
|
TbUserque tbUserque = userqueRepository.save(userque);
|
||||||
if (tbUserque != null) {
|
if (!tbUserque.equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://localhost:3306/db_imis2?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
url: jdbc:mysql://localhost:3306/db_imis2?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
||||||
username:
|
username: imis2
|
||||||
password:
|
password: 2015imis2
|
||||||
|
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://127.0.0.1:3306/db_imis2?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
url: jdbc:mysql://127.0.0.1:3306/db_imis2?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
||||||
username: xxx
|
username: imis2
|
||||||
password: xxx
|
password: 2015imis2
|
||||||
|
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
var dt = new Date();
|
var dt = new Date();
|
||||||
let th = this;
|
let th = this;
|
||||||
|
let username = "";
|
||||||
/*let username = this.ruleForm2.colname.value;*/
|
/*let username = this.ruleForm2.colname.value;*/
|
||||||
var month = dt.getMonth() + 1;
|
var month = dt.getMonth() + 1;
|
||||||
var day = dt.getDate();
|
var day = dt.getDate();
|
||||||
@@ -47,7 +48,7 @@ var Main = {
|
|||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
if (response.data === true) {
|
if (response.data === true) {
|
||||||
callback();
|
callback();
|
||||||
} else if (value !== that.ruleForm2.colname) {
|
} else if (value !== username) {
|
||||||
return callback(new Error('用户名已存在'));
|
return callback(new Error('用户名已存在'));
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
@@ -138,9 +139,12 @@ var Main = {
|
|||||||
colemail: '',
|
colemail: '',
|
||||||
colpassword: '',
|
colpassword: '',
|
||||||
checkPass: '',
|
checkPass: '',
|
||||||
|
question: '',
|
||||||
|
answer: ''
|
||||||
},
|
},
|
||||||
ruleForm3: {
|
ruleForm3: {
|
||||||
coluserid: '',
|
coluserid: '',
|
||||||
|
colname: '',
|
||||||
question: '',
|
question: '',
|
||||||
answer: ''
|
answer: ''
|
||||||
},
|
},
|
||||||
@@ -243,7 +247,7 @@ var Main = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
axios({
|
axios({
|
||||||
url: getRootPath_web() + '/home/userUpdate',
|
url: getRootPath_web() + url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: that.ruleForm2
|
data: that.ruleForm2
|
||||||
,
|
,
|
||||||
@@ -352,7 +356,9 @@ var Main = {
|
|||||||
axios.get(getRootPath_web() + '/home/userinfo')
|
axios.get(getRootPath_web() + '/home/userinfo')
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
//console.log(response.data);
|
//console.log(response.data);
|
||||||
that.ruleForm2 = response.data;
|
// 注意此处赋值为引用赋值
|
||||||
|
that.ruleForm3 = that.ruleForm2 = response.data;
|
||||||
|
username=response.data.colname;
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
//console.log(error);
|
//console.log(error);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title th:text="${title}"></title>
|
<title th:text="${title}"></title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.3.3/lib/theme-chalk/index.css">
|
||||||
<link th:href="@{/css/style.css}" rel="stylesheet">
|
<link th:href="@{/css/style.css}" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<script src="https://unpkg.com/vue@2.5.15/dist/vue.js"></script>
|
<script src="https://unpkg.com/vue@2.5.15/dist/vue.js"></script>
|
||||||
<!-- 引入组件库 -->
|
<!-- 引入组件库 -->
|
||||||
<script src="https://unpkg.com/element-ui@2.3.3/lib/index.js"></script>
|
<script src="https://unpkg.com/element-ui@2.3.3/lib/index.js"></script>
|
||||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
<script src="https://unpkg.com/axios@0.18.0/dist/axios.min.js"></script>
|
||||||
<script th:src="@{/js/common.js}"></script>
|
<script th:src="@{/js/common.js}"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary"
|
<el-button type="primary"
|
||||||
@click="submitForm('ruleForm2')">提交
|
@click="submitForm('ruleForm2','/home/userUpdate')">提交
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="resetForm('ruleForm2')">重置</el-button>
|
<el-button @click="resetForm('ruleForm2')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -71,11 +71,10 @@
|
|||||||
<el-form
|
<el-form
|
||||||
:model="ruleForm3" status-icon :rules="rules3" ref="ruleForm3"
|
:model="ruleForm3" status-icon :rules="rules3" ref="ruleForm3"
|
||||||
label-width="100px" class="demo-ruleForm"
|
label-width="100px" class="demo-ruleForm"
|
||||||
action="/cms/home/adduserque"
|
|
||||||
method="POST" name="ruleForm3">
|
method="POST" name="ruleForm3">
|
||||||
<el-form-item label="ID"
|
<el-form-item label="ID"
|
||||||
prop="coluserid">
|
prop="coluserid">
|
||||||
<el-input :readonly="true" v-model="ruleForm2.coluserid"
|
<el-input :readonly="true" v-model="ruleForm3.coluserid"
|
||||||
name="userid" readonly></el-input>
|
name="userid" readonly></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="问题"
|
<el-form-item label="问题"
|
||||||
@@ -98,7 +97,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary"
|
<el-button type="primary"
|
||||||
@click="submitForm('ruleForm3','home/adduserque')">提交
|
@click="submitForm('ruleForm3','/home/adduserque')">提交
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="resetForm('ruleForm3')">重置</el-button>
|
<el-button @click="resetForm('ruleForm3')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ public class LoginControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doLogin() throws Exception {
|
public void doLogin() throws Exception {
|
||||||
//测试正常登录
|
//测试正常登录
|
||||||
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "root"))
|
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "admin"))
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
.andExpect(MockMvcResultMatchers.status().is3xxRedirection());
|
||||||
//测试密码错误
|
//测试密码错误
|
||||||
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "123"))
|
mvc.perform(MockMvcRequestBuilders.post("/login/dologin").param("colname", "root").param("colpassword", "123"))
|
||||||
.andExpect(MockMvcResultMatchers.content().json("{\n" +
|
.andExpect(MockMvcResultMatchers.content().json("{\n" +
|
||||||
" \"code\": 105,\n" +
|
" \"code\": 605,\n" +
|
||||||
" \"message\": \"用户名或密码错误\",\n" +
|
" \"message\": \"用户名或密码错误\",\n" +
|
||||||
" \"data\": null\n" +
|
" \"data\": null\n" +
|
||||||
"}"));
|
"}"));
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
@@ -22,29 +24,26 @@ public class RegisterControllerTest {
|
|||||||
private MockMvc mvc;
|
private MockMvc mvc;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Transactional
|
||||||
public void doRegister()throws Exception {
|
public void doRegister()throws Exception {
|
||||||
//测试正常注册,abc每次调试必须改,因为唯一约束
|
//测试正常注册,abc每次调试必须改,因为唯一约束
|
||||||
mvc.perform(MockMvcRequestBuilders.post("/register/doregister")
|
mvc.perform(MockMvcRequestBuilders.post("/register/doregister")
|
||||||
.param("colname", "abc")
|
.param("colname", "abc")
|
||||||
.param("colpassword", "123456")
|
.param("colpassword", "123456")
|
||||||
.param("colemail","test@gmail.com")
|
.param("colemail","test@gmail.com")
|
||||||
.param("colstudentno","0003")
|
.param("colstudentno","15251101209")
|
||||||
.param("colrealname","TestRegister"))
|
.param("colrealname","徐杜鑫"))
|
||||||
.andExpect(MockMvcResultMatchers.content().json("{\n" +
|
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||||
" \"code\": 0,\n" +
|
|
||||||
" \"message\": \"请求成功\",\n" +
|
|
||||||
" \"data\": null\n" +
|
|
||||||
"}"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doCheckStudentNo()throws Exception {
|
public void doCheckStudentNo()throws Exception {
|
||||||
//测试非法学号检查
|
//测试非法学号检查
|
||||||
mvc.perform(MockMvcRequestBuilders.post("/CheckStudentNo")
|
mvc.perform(MockMvcRequestBuilders.get("/CheckStudentNo")
|
||||||
.param("studentno","0003"))
|
.param("studentno","0003"))
|
||||||
.andExpect(MockMvcResultMatchers.content().string("false"));
|
.andExpect(MockMvcResultMatchers.content().string("false"));
|
||||||
//测试合法学号检查
|
//测试合法学号检查
|
||||||
mvc.perform(MockMvcRequestBuilders.post("/CheckStudentNo")
|
mvc.perform(MockMvcRequestBuilders.get("/CheckStudentNo")
|
||||||
.param("studentno","15251101238"))
|
.param("studentno","15251101238"))
|
||||||
.andExpect(MockMvcResultMatchers.content().string("true"));
|
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||||
}
|
}
|
||||||
@@ -55,12 +54,12 @@ public class RegisterControllerTest {
|
|||||||
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
||||||
.param("studentno","15251101238")
|
.param("studentno","15251101238")
|
||||||
.param("realname","符嘉"))
|
.param("realname","符嘉"))
|
||||||
.andExpect(MockMvcResultMatchers.content().string("false"));
|
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||||
//测试学号与姓名匹配
|
//测试学号与姓名匹配
|
||||||
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
mvc.perform(MockMvcRequestBuilders.get("/CheckStudent")
|
||||||
.param("studentno","15251101238")
|
.param("studentno","15251101238")
|
||||||
.param("realname","符嘉阳"))
|
.param("realname","符嘉阳"))
|
||||||
.andExpect(MockMvcResultMatchers.content().string("true"));
|
.andExpect(MockMvcResultMatchers.content().string("false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user