提交 28d3953d 编写于 作者: 江南一点雨

个人中心修改个人信息

上级 2efd1be0
......@@ -60,4 +60,8 @@ public class HrService implements UserDetailsService {
public List<Hr> getAllHrsExceptCurrentHr() {
return hrMapper.getAllHrsExceptCurrentHr(HrUtils.getCurrentHr().getId());
}
public Integer updateHyById(Hr hr) {
return hrMapper.updateByPrimaryKeySelective(hr);
}
}
package org.javaboy.vhr.controller;
import org.javaboy.vhr.model.Hr;
import org.javaboy.vhr.model.RespBean;
import org.javaboy.vhr.service.HrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
......@@ -17,8 +22,19 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class HrInfoController {
@Autowired
HrService hrService;
@GetMapping("/hr/info")
public Hr getCurrentHr(Authentication authentication) {
return ((Hr) authentication.getPrincipal());
}
@PutMapping("/hr/info")
public RespBean updateHyById(@RequestBody Hr hr) {
if (hrService.updateHyById(hr) == 1) {
return RespBean.ok("更新成功!");
}
return RespBean.error("更新失败!");
}
}
......@@ -24,11 +24,40 @@
</el-tag>
</div>
<div style="display: flex;justify-content: space-around;margin-top: 10px">
<el-button type="primary">修改信息</el-button>
<el-button type="primary" @click="showUpdateHrInfoView">修改信息</el-button>
<el-button type="danger">修改密码</el-button>
</div>
</div>
</el-card>
<el-dialog
title="修改用户信息"
:visible.sync="dialogVisible"
width="30%">
<div>
<table>
<tr>
<td><el-tag>用户姓名:</el-tag></td>
<td><el-input v-model="hr2.name"></el-input></td>
</tr>
<tr>
<td><el-tag>电话号码:</el-tag></td>
<td><el-input v-model="hr2.telephone"></el-input></td>
</tr>
<tr>
<td><el-tag>手机号码:</el-tag></td>
<td><el-input v-model="hr2.phone"></el-input></td>
</tr>
<tr>
<td><el-tag>用户地址:</el-tag></td>
<td><el-input v-model="hr2.address"></el-input></td>
</tr>
</table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="updateHrInfo">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
......@@ -37,17 +66,33 @@
name: "HrInfo",
data() {
return {
hr: null
hr: null,
hr2: null,
dialogVisible:false
}
},
mounted() {
this.initHr();
},
methods: {
updateHrInfo() {
this.putRequest("/hr/info",this.hr2).then(resp=>{
if (resp) {
this.getRequest("/logout");
window.sessionStorage.removeItem("user")
this.$store.commit('initRoutes', []);
this.$router.replace("/");
}
})
},
showUpdateHrInfoView() {
this.dialogVisible = true;
},
initHr() {
this.getRequest('/hr/info').then(resp => {
if (resp) {
this.hr = resp;
this.hr2 = Object.assign({}, this.hr);
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册