forked from MarkerHub/vueblog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
470 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
**/.idea/** | ||
**/target/** | ||
|
||
**/node_modules/** | ||
|
||
**/*.iml | ||
|
||
*.iml | ||
|
||
# Package Files # | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
vueblog-java/src/main/java/com/markerhub/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.markerhub.controller; | ||
|
||
import com.markerhub.entity.User; | ||
import com.markerhub.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/user") | ||
public class UserController { | ||
|
||
@Autowired | ||
UserService userService; | ||
|
||
@GetMapping("/{id}") | ||
public Object test(@PathVariable("id") Long id) { | ||
return userService.getById(id); | ||
} | ||
|
||
|
||
/** | ||
* 测试实体校验 | ||
* @param user | ||
* @return | ||
*/ | ||
@PostMapping("/save") | ||
public Object testUser(@Validated @RequestBody User user) { | ||
return user.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
vueblog-java/src/main/java/com/markerhub/shiro/JwtFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
vueblog-java/src/main/java/com/markerhub/util/ShiroUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.markerhub.util; | ||
|
||
import com.markerhub.shiro.AccountProfile; | ||
import org.apache.shiro.SecurityUtils; | ||
|
||
public class ShiroUtil { | ||
|
||
public static AccountProfile getProfile() { | ||
return (AccountProfile)SecurityUtils.getSubject().getPrincipal(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<div class="m-content"> | ||
|
||
<h3>欢迎来到MarkerHub的博客</h3> | ||
<div class="block"> | ||
<el-avatar :size="50" :src="user.avatar"></el-avatar> | ||
<div>{{ user.username }}</div> | ||
</div> | ||
<div class="maction"> | ||
<el-link href="/blogs">主页</el-link> | ||
<el-divider direction="vertical"></el-divider> | ||
<span> | ||
<el-link type="success" href="/blog/add" :disabled="!hasLogin">发表文章</el-link> | ||
</span> | ||
<el-divider direction="vertical"></el-divider> | ||
|
||
<span v-show="!hasLogin"> | ||
<el-link type="primary" href="/login">登陆</el-link> | ||
</span> | ||
<span v-show="hasLogin"> | ||
<el-link type="danger" @click="logout">退出</el-link> | ||
</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Header", | ||
data() { | ||
return { | ||
hasLogin: false, | ||
user: { | ||
username: '请先登录', | ||
avatar: "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" | ||
}, | ||
blogs: {}, | ||
currentPage: 1, | ||
total: 0 | ||
} | ||
}, | ||
methods: { | ||
logout() { | ||
const _this = this | ||
this.$axios.get('http://localhost:8081/logout', { | ||
headers: { | ||
"Authorization": localStorage.getItem("token") | ||
} | ||
}).then((res) => { | ||
_this.$store.commit('REMOVE_INFO') | ||
_this.$router.push('/login') | ||
}); | ||
} | ||
}, | ||
created() { | ||
if(this.$store.getters.getUser.username) { | ||
this.user.username = this.$store.getters.getUser.username | ||
this.user.avatar = this.$store.getters.getUser.avatar | ||
this.hasLogin = true | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.m-container { | ||
width: 960px; | ||
margin: 0 auto; | ||
} | ||
.m-content { | ||
text-align: center; | ||
} | ||
.maction { | ||
margin: 10px 0; | ||
} | ||
</style> |
Oops, something went wrong.