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