更新
This commit is contained in:
parent
7f633cceaf
commit
964ca18c53
@ -1 +1 @@
|
||||
VITE_BASE_API = 'http://localhost:8081/'
|
||||
VITE_BASE_API = 'http://localhost:8080/'
|
||||
@ -1 +1 @@
|
||||
VITE_BASE_API = 'http://localhost:8081/'
|
||||
VITE_BASE_API = 'http://localhost:8080/'
|
||||
@ -1,52 +1,59 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// token key
|
||||
const userKey:string = 'tansci_boot_user'
|
||||
const tokenKey:string = 'tansci_boot_token'
|
||||
|
||||
// 获取token
|
||||
// token信息
|
||||
export function getToken() {
|
||||
return sessionStorage.getItem(tokenKey);
|
||||
}
|
||||
|
||||
// 存储token
|
||||
export function setToken(token:string) {
|
||||
sessionStorage.setItem(tokenKey, token);
|
||||
}
|
||||
|
||||
// 删除token
|
||||
export function removeToken() {
|
||||
sessionStorage.removeItem(tokenKey);
|
||||
}
|
||||
|
||||
// 用户信息
|
||||
export function getUser() {
|
||||
return sessionStorage.getItem(userKey);
|
||||
}
|
||||
export function setUser(data:any) {
|
||||
return sessionStorage.setItem(userKey, JSON.stringify(data));
|
||||
}
|
||||
export function removeUser() {
|
||||
return sessionStorage.removeItem(userKey);
|
||||
}
|
||||
|
||||
// 登录
|
||||
export function login(data:any){
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: '/system/security/login',
|
||||
method: 'post',
|
||||
data: {
|
||||
username: data.username,
|
||||
password: data.password,
|
||||
code: data.code,
|
||||
uuid: data.uuid
|
||||
}
|
||||
}).then((res:any) => {
|
||||
var token = res.data
|
||||
setToken(token)
|
||||
resolve(token)
|
||||
}).catch((e:any) => {
|
||||
reject(e)
|
||||
})
|
||||
request({
|
||||
url: '/tansci/auth/login',
|
||||
method: 'post',
|
||||
data: {
|
||||
username: data.username,
|
||||
password: data.password,
|
||||
code: data.code
|
||||
}
|
||||
}).then((res:any) => {
|
||||
setToken(res.data.result.token)
|
||||
setUser(res.data.result)
|
||||
resolve(res.data.result.token)
|
||||
}).catch((e:any) => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 登出
|
||||
export function logout(){
|
||||
request({
|
||||
url: '/system/security/logout',
|
||||
url: '/tansci/auth/logout',
|
||||
method: 'get'
|
||||
}).then(() => {
|
||||
removeToken()
|
||||
removeUser()
|
||||
location.reload()
|
||||
})
|
||||
}
|
||||
3
tansci-boot-ui/src/components/layout/Empty.vue
Normal file
3
tansci-boot-ui/src/components/layout/Empty.vue
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
空页面
|
||||
</template>
|
||||
@ -23,6 +23,9 @@
|
||||
// 获取菜单
|
||||
let routers:any = [];
|
||||
let _routes = router.options.routes;
|
||||
|
||||
console.log("_routes:",_routes)
|
||||
|
||||
_routes.forEach((item:any)=>{
|
||||
if(item.children && item.type == 0){
|
||||
routers.push(item)
|
||||
@ -109,7 +112,7 @@
|
||||
}
|
||||
}
|
||||
.el-aside{
|
||||
::v-deep .el-menu{
|
||||
:deep(.el-menu) {
|
||||
margin: 0 0.6rem;
|
||||
padding: 0 0.2rem;
|
||||
border-right: none;
|
||||
|
||||
7
tansci-boot-ui/src/components/layout/None.vue
Normal file
7
tansci-boot-ui/src/components/layout/None.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component }">
|
||||
<keep-alive :include="$global.visitedViews.filter(it => it.meta.keepAlive).map(it => it.path.substr(it.path.lastIndexOf('/') + 1))">
|
||||
<component :is="Component" :key="$route.path" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</template>
|
||||
@ -20,5 +20,23 @@ export default[
|
||||
name: '500',
|
||||
meta: {title: "500"},
|
||||
component: () => import('@/views/common/500.vue')
|
||||
},
|
||||
{
|
||||
path: '/index',
|
||||
name: 'index',
|
||||
type: 0,
|
||||
icon: 'HomeFilled',
|
||||
meta: { title: "首页" },
|
||||
component: () => import("@/components/layout/Index.vue"),
|
||||
children: [
|
||||
{
|
||||
path: '/index',
|
||||
name: 'index',
|
||||
type: 0,
|
||||
icon: 'HomeFilled',
|
||||
meta: { title: "首页" },
|
||||
component: () => import('@/views/Index.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -1,14 +1,61 @@
|
||||
import { createRouter, createWebHistory } from "vue-router"
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getToken, removeToken, removeUser } from "@/api/auth"
|
||||
import { generateRoutes } from "./permission"
|
||||
|
||||
import routers from './routers'
|
||||
// import routers from './routers'
|
||||
|
||||
import common from './common'
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
...common,
|
||||
...routers
|
||||
// ...routers
|
||||
]
|
||||
})
|
||||
|
||||
const whiteList = ['/login']
|
||||
let load = false
|
||||
router.beforeEach(async (to:any, from:any, next) => {
|
||||
// 设置头部
|
||||
if(to.meta.title){
|
||||
document.title = to.meta.title
|
||||
} else {
|
||||
document.title = "Tansci Boot"
|
||||
}
|
||||
|
||||
if(getToken()){
|
||||
if(to.path === '/login'){
|
||||
next({ path: '/index' })
|
||||
} else {
|
||||
if(load){
|
||||
next()
|
||||
} else {
|
||||
load = true
|
||||
try {
|
||||
// 获取菜单
|
||||
await generateRoutes().then( (accessRoutes:any) => {
|
||||
accessRoutes.forEach( (item:any) => {
|
||||
router.addRoute(item)
|
||||
})
|
||||
})
|
||||
|
||||
next({ ...to, replace: true })
|
||||
} catch (error:any) {
|
||||
removeToken()
|
||||
removeUser()
|
||||
ElMessage.error(error.data || 'Has Error')
|
||||
next(`/login`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(whiteList.indexOf(to.path) !== -1){
|
||||
next()
|
||||
} else {
|
||||
next({ path: "/login" })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
97
tansci-boot-ui/src/router/permission.ts
Normal file
97
tansci-boot-ui/src/router/permission.ts
Normal file
@ -0,0 +1,97 @@
|
||||
import request from '@/utils/request'
|
||||
import common from '@/utils/common'
|
||||
|
||||
const viewModules = import.meta.glob("../views/**/**.vue")
|
||||
const layoutModules = import.meta.glob("../components/layout/**.vue")
|
||||
|
||||
// 根据菜单构建动态路由
|
||||
export const filterAsyncRouter = (routers:any, level:any) => {
|
||||
level = level || 0
|
||||
const accessedRouters = routers.filter( (router:any) => {
|
||||
if (router.isShow === 1) {
|
||||
var setIframe = () => {
|
||||
router.component = loadView(`/common/Iframe`)
|
||||
router.props = { url: router.url }
|
||||
router.path = "/" + router.url
|
||||
}
|
||||
|
||||
if(router.url && router.url.startsWith('http')){
|
||||
if(router.openMode == '0'){
|
||||
setIframe()
|
||||
}
|
||||
} else if(router.url && router.url.startsWith('/') && router.url.indexOf('.htm') != -1) {
|
||||
if(router.openMode == '0'){
|
||||
setIframe()
|
||||
}else{
|
||||
router.path = location.href.substring(0, location.href.indexOf('/', location.href.indexOf('/', location.href.indexOf('/') + 1) + 1)) + router.path
|
||||
}
|
||||
} else if (router.componentName) {
|
||||
router.props = {
|
||||
name: router.componentName,
|
||||
id :router.id
|
||||
}
|
||||
|
||||
// 根据组件类型渲染
|
||||
router.component = loadView(`/common/Component`)
|
||||
} else if (router.component) { // 如果是现成组件
|
||||
const component:any = router.component
|
||||
if (component === 'Layout') {
|
||||
router.path = "/" + common.uuid()
|
||||
router.component = level > 0 ? layoutModules[`../components/layout/None.vue`] : loadLayoutView()
|
||||
} else {
|
||||
router.path = router.path.startsWith('/') ? router.path : '/' + router.path
|
||||
router.component = loadView(component) || layoutModules[`../components/layout/Empty.vue`]
|
||||
}
|
||||
}
|
||||
if (router.children && router.children.length) {
|
||||
router.children = filterAsyncRouter(router.children, level + 1)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
return accessedRouters
|
||||
}
|
||||
|
||||
export const loadLayoutView = () => {
|
||||
return layoutModules[`../components/layout/Index.vue`]
|
||||
}
|
||||
|
||||
export const loadView = (view:any) => {
|
||||
view = view.substring(0, 1) === '/' ? view : '/' + view
|
||||
return viewModules[`../views${view}.vue`]
|
||||
}
|
||||
|
||||
// 获取当前用户的权限菜单
|
||||
export function generateRoutes(){
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: '/tansci/sysmenu/tree',
|
||||
method: 'get'
|
||||
}).then( (res:any) => {
|
||||
let data = recastData(res.data.result, [])
|
||||
console.log(data)
|
||||
const asyncRouter = filterAsyncRouter(data, 0)
|
||||
resolve(asyncRouter)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function recastData(data:any, arr:any){
|
||||
data.forEach( (item:any) => {
|
||||
arr.push({
|
||||
path: item.url,
|
||||
name: item.url,
|
||||
icon: item.icon,
|
||||
isShow: item.isShow,
|
||||
component: item.component,
|
||||
meta: {
|
||||
title: item.chineseName,
|
||||
keepAlive: item.keepAlive
|
||||
}
|
||||
})
|
||||
if (item.children && item.children.length) {
|
||||
recastData(item.children, arr);
|
||||
}
|
||||
});
|
||||
}
|
||||
16
tansci-boot-ui/src/utils/common.ts
Normal file
16
tansci-boot-ui/src/utils/common.ts
Normal file
@ -0,0 +1,16 @@
|
||||
const common:any = {}
|
||||
|
||||
// 生成UUID
|
||||
common.uuid = () => {
|
||||
function S4() {
|
||||
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
||||
}
|
||||
return (S4()+S4()+S4()+S4()+S4()+S4()+S4()+S4());
|
||||
}
|
||||
|
||||
// 是否包含逗号
|
||||
common.isComma = (value:any) => {
|
||||
return value.toString().indexOf(',') !== -1
|
||||
}
|
||||
|
||||
export default common
|
||||
@ -18,7 +18,7 @@ const axiosInstance: AxiosInstance = axios.create({
|
||||
axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => {
|
||||
// 设置token
|
||||
if (getToken()) {
|
||||
config.headers.Authorization = `Bearer ${getToken()}`
|
||||
config.headers.token = getToken()
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
||||
12
tansci-boot-ui/src/views/common/Component.vue
Normal file
12
tansci-boot-ui/src/views/common/Component.vue
Normal file
@ -0,0 +1,12 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component :is="props.name"></component>
|
||||
</template>
|
||||
23
tansci-boot-ui/src/views/common/Iframe.vue
Normal file
23
tansci-boot-ui/src/views/common/Iframe.vue
Normal file
@ -0,0 +1,23 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
url: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<iframe :src="url" width="100%" height="100%" frameborder="0"></iframe>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
iframe{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -78,8 +78,7 @@
|
||||
<el-input v-model="state.loginForm.username" prefix-icon="Avatar" placeholder="请输入账号" style="width:100%"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password" :rules="[
|
||||
{required: true,message: '请输入密码',trigger: 'blur'},
|
||||
{pattern: /^[a-zA-Z]\w{5,17}$/,message: '密码有误,请重新输入',trigger: 'blur'}]">
|
||||
{required: true,message: '请输入密码',trigger: 'blur'}]">
|
||||
<el-input type="password" v-model="state.loginForm.password" prefix-icon="Lock" show-password placeholder="请输入密码" style="width:100%"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
transformerVariantGroup,
|
||||
} from 'unocss'
|
||||
|
||||
const url = "http://127.0.0.1:8080"
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
@ -39,5 +40,16 @@ export default defineConfig({
|
||||
transformerVariantGroup(),
|
||||
]
|
||||
}),
|
||||
]
|
||||
],
|
||||
server: {
|
||||
proxy: {
|
||||
'/tansci': {
|
||||
target: url,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/tansci':'/tansci'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -23,7 +23,7 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
// 验证所有接口
|
||||
.addPathPatterns("/**")
|
||||
// 忽略校验
|
||||
.excludePathPatterns("/auth/**","/magic/**");
|
||||
.excludePathPatterns("/auth/**");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import cn.dev33.satoken.session.SaSessionCustomUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.tansci.common.WrapMapper;
|
||||
import com.tansci.common.Wrapper;
|
||||
import com.tansci.domain.SysUser;
|
||||
import com.tansci.domain.vo.SysUserVo;
|
||||
import com.tansci.service.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -29,13 +31,14 @@ public class AuthController {
|
||||
|
||||
@ApiOperation(value = "登录", notes = "登录")
|
||||
@PostMapping("/login")
|
||||
public Wrapper<SysUser> login(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.login(user.getUsername()));
|
||||
public Wrapper<SysUserVo> login(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.login(user));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登出", notes = "登出")
|
||||
@GetMapping("/logout")
|
||||
public Wrapper<Object> logout() {
|
||||
SaSessionCustomUtil.deleteSessionById(String.valueOf(StpUtil.getLoginId()));
|
||||
StpUtil.logout();
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, "登出成功!");
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import com.tansci.service.SysDicService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName: SysDicController.java
|
||||
* @ClassPath: com.tansci.controller.SysDicController.java
|
||||
* @Description: 字典管理
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:45
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sysdic")
|
||||
@Api(value = "sysdic", tags = "字典管理")
|
||||
public class SysDicController {
|
||||
|
||||
@Autowired
|
||||
private SysDicService sysDicService;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import com.tansci.service.SysLoginLogService;
|
||||
import com.tansci.service.SysOperLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName: SysLogController.java
|
||||
* @ClassPath: com.tansci.controller.SysLogController.java
|
||||
* @Description: 日志管理
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:45
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/syslog")
|
||||
@Api(value = "syslog", tags = "日志管理")
|
||||
public class SysLogController {
|
||||
|
||||
@Autowired
|
||||
private SysLoginLogService sysLoginLogService;
|
||||
@Autowired
|
||||
private SysOperLogService sysOperLogService;
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import com.tansci.common.WrapMapper;
|
||||
import com.tansci.common.Wrapper;
|
||||
import com.tansci.domain.SysMenu;
|
||||
import com.tansci.service.SysMenuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: SysMenuController.java
|
||||
* @ClassPath: com.tansci.controller.SysMenuController.java
|
||||
* @Description: 菜单管理
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:45
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sysmenu")
|
||||
@Api(value = "sysmenu", tags = "菜单管理")
|
||||
public class SysMenuController {
|
||||
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
@ApiOperation(value = "菜单树", notes = "菜单树")
|
||||
@GetMapping("/tree")
|
||||
public Wrapper<List<SysMenu>> tree(SysMenu menu) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysMenuService.tree(menu));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import com.tansci.service.SysOrgService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOrgController.java
|
||||
* @ClassPath: com.tansci.controller.SysOrgController.java
|
||||
* @Description: 组织管理
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:46
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sysrog")
|
||||
@Api(value = "sysrog", tags = "组织管理")
|
||||
public class SysOrgController {
|
||||
|
||||
@Autowired
|
||||
private SysOrgService sysOrgService;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.tansci.controller;
|
||||
|
||||
import com.tansci.service.SysRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleController.java
|
||||
* @ClassPath: com.tansci.controller.SysRoleController.java
|
||||
* @Description: 角色管理
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:46
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sysrole")
|
||||
@Api(value = "sysrole", tags = "角色管理")
|
||||
public class SysRoleController {
|
||||
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
|
||||
}
|
||||
@ -23,8 +23,8 @@ import java.util.List;
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Api(value = "user", tags = "用户管理")
|
||||
@RequestMapping("/sysuser")
|
||||
@Api(value = "sysuser", tags = "用户管理")
|
||||
public class SysUserController {
|
||||
|
||||
@Autowired
|
||||
@ -44,25 +44,25 @@ public class SysUserController {
|
||||
|
||||
@ApiOperation(value = "添加用户信息", notes = "添加用户信息")
|
||||
@PostMapping("/save")
|
||||
public Wrapper<Boolean> save(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.save(user));
|
||||
public Wrapper<Object> save(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.insert(user));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户信息", notes = "修改用户信息")
|
||||
@PostMapping("/update")
|
||||
public Wrapper<Boolean> update(@RequestBody SysUser user) {
|
||||
public Wrapper<Object> update(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.update(user));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户", notes = "删除用户")
|
||||
@GetMapping("/del")
|
||||
public Wrapper<Boolean> del(SysUser user) {
|
||||
public Wrapper<Object> del(SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.del(user));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码", notes = "修改密码")
|
||||
@PostMapping("/modifyPass")
|
||||
public Wrapper<Integer> modifyPass(@RequestBody SysUser user) {
|
||||
public Wrapper<Object> modifyPass(@RequestBody SysUser user) {
|
||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.modifyPass(user));
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.tansci.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@ -17,7 +16,7 @@ import java.time.LocalDateTime;
|
||||
/**
|
||||
* @ClassName: SysRole.java
|
||||
* @ClassPath: com.tansci.domain.SysRole.java
|
||||
* @Description: 权限
|
||||
* @Description: 角色
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/03/20 10:38
|
||||
**/
|
||||
@ -26,7 +25,7 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "sys_role")
|
||||
@ApiModel(value = "权限")
|
||||
@ApiModel(value = "角色")
|
||||
public class SysRole {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
|
||||
@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @path:com.tansci.domain.SysUser.java
|
||||
@ -48,8 +49,6 @@ public class SysUser {
|
||||
|
||||
@ApiModelProperty(value = "用户类型:1、管理员,2、普通用户")
|
||||
private Integer type;
|
||||
@TableField(exist = false)
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
@ -59,8 +58,6 @@ public class SysUser {
|
||||
|
||||
@ApiModelProperty(value = "性别:0、男,1、女")
|
||||
private Integer gender;
|
||||
@TableField(exist = false)
|
||||
private String genderName;
|
||||
|
||||
@ApiModelProperty(value = "出生日期")
|
||||
private LocalDate birthday;
|
||||
@ -98,11 +95,7 @@ public class SysUser {
|
||||
private String remarks;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private String roleId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "token")
|
||||
private String token;
|
||||
@ApiModelProperty(value = "权限IDS")
|
||||
private List<String> roleIds;
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.tansci.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserSession.java
|
||||
* @ClassPath: com.tansci.domain.vo.SysUserSession.java
|
||||
* @Description: 用户session信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 11:02
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "用户session信息")
|
||||
public class SysUserSessionVo {
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "用户名称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户类型:1、管理员,2、普通用户")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "权限IDS")
|
||||
private List<String> roleIds;
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.tansci.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserVo.java
|
||||
* @ClassPath: com.tansci.domain.vo.SysUserVo.java
|
||||
* @Description: 用户信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:13
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "用户信息")
|
||||
public class SysUserVo {
|
||||
|
||||
@ApiModelProperty(value = "用户名称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户类型:1、管理员,2、普通用户")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "token")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty(value = "登录时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
|
||||
private LocalDateTime loginTime;
|
||||
|
||||
}
|
||||
@ -37,7 +37,7 @@ public class GlobalExceptionHandler {
|
||||
return WrapMapper.wrap(Wrapper.ILLEGAL_ARGUMENT_CODE_, "参数有误:" + ex.getBindingResult().getFieldError().getDefaultMessage(), null);
|
||||
} else {
|
||||
log.error("统一系统异常:{}", e);
|
||||
return WrapMapper.wrap(Wrapper.ERROR_CODE, Wrapper.ERROR_MESSAGE, null);
|
||||
return WrapMapper.wrap(Wrapper.ERROR_CODE, e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysDic;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysDicMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysDicMapper.java
|
||||
* @Description: 字典信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:28
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysDicMapper extends BaseMapper<SysDic> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysLoginLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysLoginLogMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysLoginLogMapper.java
|
||||
* @Description: 登录日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:29
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysLoginLogMapper extends BaseMapper<SysLoginLog> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysMenuMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysMenuMapper.java
|
||||
* @Description: 菜单信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:26
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysOperLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOperLogMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysOperLogMapper.java
|
||||
* @Description: 操作日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:29
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysOperLogMapper extends BaseMapper<SysOperLog> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysOrg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOrgMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysOrgMapper.java
|
||||
* @Description: 组织机构
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:27
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysOrgMapper extends BaseMapper<SysOrg> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysRoleMapper.java
|
||||
* @Description: 角色信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:25
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysRoleMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleMenuMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysRoleMenuMapper.java
|
||||
* @Description: 菜单角色
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:30
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysRoleOrg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleOrgMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysRoleOrgMapper.java
|
||||
* @Description: 组织角色
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:30
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysRoleOrgMapper extends BaseMapper<SysRoleOrg> {
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tansci.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tansci.domain.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserRoleMapper.java
|
||||
* @ClassPath: com.tansci.mapper.SysUserRoleMapper.java
|
||||
* @Description: 用户权限
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:30
|
||||
**/
|
||||
@Mapper
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysDic;
|
||||
|
||||
/**
|
||||
* @ClassName: SysDicService.java
|
||||
* @ClassPath: com.tansci.service.SysDicService.java
|
||||
* @Description: 字典信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:33
|
||||
**/
|
||||
public interface SysDicService extends IService<SysDic> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysLoginLog;
|
||||
|
||||
/**
|
||||
* @ClassName: SysLoginLogService.java
|
||||
* @ClassPath: com.tansci.service.SysLoginLogService.java
|
||||
* @Description: 登录日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:34
|
||||
**/
|
||||
public interface SysLoginLogService extends IService<SysLoginLog> {
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: SysMenuService.java
|
||||
* @ClassPath: com.tansci.service.SysMenuService.java
|
||||
* @Description: 菜单信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:35
|
||||
**/
|
||||
public interface SysMenuService extends IService<SysMenu> {
|
||||
|
||||
List<SysMenu> tree(SysMenu menu);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysOperLog;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOperLogService.java
|
||||
* @ClassPath: com.tansci.service.SysOperLogService.java
|
||||
* @Description: 操作日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:35
|
||||
**/
|
||||
public interface SysOperLogService extends IService<SysOperLog> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysOrg;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOrgService.java
|
||||
* @ClassPath: com.tansci.service.SysOrgService.java
|
||||
* @Description: 组织信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:36
|
||||
**/
|
||||
public interface SysOrgService extends IService<SysOrg> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysRoleMenu;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleMenuService.java
|
||||
* @ClassPath: com.tansci.service.SysRoleMenuService.java
|
||||
* @Description: 菜单角色
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 10:26
|
||||
**/
|
||||
public interface SysRoleMenuService extends IService<SysRoleMenu> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysRole;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleService.java
|
||||
* @ClassPath: com.tansci.service.SysRoleService.java
|
||||
* @Description: 角色信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:37
|
||||
**/
|
||||
public interface SysRoleService extends IService<SysRole> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tansci.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysUserRole;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserRoleService.java
|
||||
* @ClassPath: com.tansci.service.SysUserRoleService.java
|
||||
* @Description: 用户角色
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 10:04
|
||||
**/
|
||||
public interface SysUserRoleService extends IService<SysUserRole> {
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.tansci.domain.SysUser;
|
||||
import com.tansci.domain.vo.SysUserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,14 +21,14 @@ public interface SysUserService extends IService<SysUser> {
|
||||
|
||||
List<SysUser> list(SysUser user);
|
||||
|
||||
Integer modifyPass(SysUser user);
|
||||
Object insert(SysUser user);
|
||||
|
||||
boolean save(SysUser user);
|
||||
Object update(SysUser user);
|
||||
|
||||
boolean update(SysUser user);
|
||||
Object del(SysUser user);
|
||||
|
||||
boolean del(SysUser user);
|
||||
SysUserVo login(SysUser user);
|
||||
|
||||
SysUser login(String username);
|
||||
Object modifyPass(SysUser user);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysDic;
|
||||
import com.tansci.mapper.SysDicMapper;
|
||||
import com.tansci.service.SysDicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysDicServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysDicServiceImpl.java
|
||||
* @Description: 字典信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:39
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysDicServiceImpl extends ServiceImpl<SysDicMapper, SysDic> implements SysDicService {
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysLoginLog;
|
||||
import com.tansci.mapper.SysLoginLogMapper;
|
||||
import com.tansci.service.SysLoginLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysLoginLogServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysLoginLogServiceImpl.java
|
||||
* @Description: 登录日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:40
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLog> implements SysLoginLogService {
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tansci.common.constant.Constants;
|
||||
import com.tansci.domain.SysMenu;
|
||||
import com.tansci.domain.SysRoleMenu;
|
||||
import com.tansci.domain.vo.SysUserSessionVo;
|
||||
import com.tansci.mapper.SysMenuMapper;
|
||||
import com.tansci.service.SysMenuService;
|
||||
import com.tansci.service.SysRoleMenuService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName: SysMenuServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysMenuServiceImpl.java
|
||||
* @Description: 菜单信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:41
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuService sysRoleMenuService;
|
||||
|
||||
@Override
|
||||
public List<SysMenu> tree(SysMenu menu) {
|
||||
// 菜单权限
|
||||
String userId = String.valueOf(StpUtil.getLoginId());
|
||||
SysUserSessionVo sessionVo = (SysUserSessionVo) StpUtil.getSession().get(userId);
|
||||
List<String> menuIds = Lists.newArrayList();
|
||||
if (Objects.nonNull(sessionVo) && Objects.nonNull(sessionVo.getRoleIds()) && sessionVo.getRoleIds().size() > 0) {
|
||||
List<SysRoleMenu> menus = sysRoleMenuService.list(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, sessionVo.getRoleIds()));
|
||||
menuIds.addAll(menus.stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
List<SysMenu> list = this.baseMapper.selectList(
|
||||
Wrappers.<SysMenu>lambdaQuery()
|
||||
.eq(SysMenu::getIsDel, Constants.NOT_DEL_FALG)
|
||||
.eq(Objects.nonNull(menuIds) && menuIds.size() > 0, SysMenu::getId, menuIds)
|
||||
.eq(Objects.nonNull(menu.getParentId()), SysMenu::getParentId, menu.getParentId())
|
||||
.like(Objects.nonNull(menu.getName()), SysMenu::getName, menu.getName())
|
||||
.like(Objects.nonNull(menu.getChineseName()), SysMenu::getChineseName, menu.getChineseName())
|
||||
.orderByDesc(SysMenu::getUpdateTime)
|
||||
);
|
||||
list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SysMenu::getId))), ArrayList::new));
|
||||
Map<String, List<SysMenu>> map = list.stream().collect(Collectors.groupingBy(SysMenu::getParentId, Collectors.toList()));
|
||||
list.stream().forEach(item -> item.setChildren(map.get(item.getId())));
|
||||
|
||||
List<SysMenu> menuList = map.get("0").stream().sorted(Comparator.comparing(SysMenu::getSort)).collect(Collectors.toList());
|
||||
return menuList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysOperLog;
|
||||
import com.tansci.mapper.SysOperLogMapper;
|
||||
import com.tansci.service.SysOperLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOperLogServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysOperLogServiceImpl.java
|
||||
* @Description: 操作日志
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:42
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements SysOperLogService {
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysOrg;
|
||||
import com.tansci.mapper.SysOrgMapper;
|
||||
import com.tansci.service.SysOrgService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysOrgServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysOrgServiceImpl.java
|
||||
* @Description: 组织信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:43
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> implements SysOrgService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysRoleMenu;
|
||||
import com.tansci.mapper.SysRoleMenuMapper;
|
||||
import com.tansci.service.SysRoleMenuService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleMenuServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysRoleMenuServiceImpl.java
|
||||
* @Description: 菜单权限
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 10:26
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysRole;
|
||||
import com.tansci.mapper.SysRoleMapper;
|
||||
import com.tansci.service.SysRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysRoleServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysRoleServiceImpl.java
|
||||
* @Description: 权限信息
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 9:44
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.tansci.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tansci.domain.SysUserRole;
|
||||
import com.tansci.mapper.SysUserRoleMapper;
|
||||
import com.tansci.service.SysUserRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserRoleServiceImpl.java
|
||||
* @ClassPath: com.tansci.service.impl.SysUserRoleServiceImpl.java
|
||||
* @Description: 用户权限
|
||||
* @Author: tanyp
|
||||
* @Date: 2023/3/29 10:05
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
|
||||
}
|
||||
@ -5,18 +5,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tansci.common.constant.Constants;
|
||||
import com.tansci.domain.SysUser;
|
||||
import com.tansci.common.exception.BusinessException;
|
||||
import com.tansci.domain.SysUser;
|
||||
import com.tansci.domain.SysUserRole;
|
||||
import com.tansci.domain.vo.SysUserSessionVo;
|
||||
import com.tansci.domain.vo.SysUserVo;
|
||||
import com.tansci.mapper.SysUserMapper;
|
||||
import com.tansci.service.SysUserRoleService;
|
||||
import com.tansci.service.SysUserService;
|
||||
import com.tansci.utils.Sha256Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName: SysUserServiceImpl.java
|
||||
@ -29,6 +36,9 @@ import java.util.Objects;
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> page(Page page, SysUser user) {
|
||||
return this.baseMapper.selectPage(page,
|
||||
@ -51,7 +61,77 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer modifyPass(SysUser user) {
|
||||
public Object insert(SysUser user) {
|
||||
Integer count = this.baseMapper.selectCount(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, user.getUsername()));
|
||||
if (Objects.nonNull(count) && count > 0) {
|
||||
throw new BusinessException("用户名称已存在!");
|
||||
}
|
||||
user.setIsDel(Constants.NOT_DEL_FALG);
|
||||
user.setCreateTime(LocalDateTime.now());
|
||||
user.setPassword(Sha256Util.getSHA256(user.getPassword()));
|
||||
int rows = this.baseMapper.insert(user);
|
||||
if (rows > 0) {
|
||||
// 添加权限
|
||||
List<SysUserRole> userRoles = Lists.newArrayList();
|
||||
user.getRoleIds().forEach(item -> {
|
||||
userRoles.add(SysUserRole.builder().userId(user.getId()).roleId(item).build());
|
||||
});
|
||||
sysUserRoleService.saveBatch(userRoles);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object update(SysUser user) {
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
return this.baseMapper.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object del(SysUser user) {
|
||||
user.setIsDel(Constants.IS_DEL_FALG);
|
||||
int rows = this.baseMapper.updateById(user);
|
||||
if (rows > 0) {
|
||||
sysUserRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserVo login(SysUser user) {
|
||||
SysUser sysUser = this.baseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, user.getUsername()));
|
||||
if (Objects.nonNull(sysUser) && Objects.equals(sysUser.getPassword(), Sha256Util.getSHA256(user.getPassword()))) {
|
||||
// 生成token
|
||||
StpUtil.login(sysUser.getId());
|
||||
|
||||
// 用户角色到session
|
||||
List<SysUserRole> roles = sysUserRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, sysUser.getId()));
|
||||
if (Objects.nonNull(roles) && roles.size() > 0) {
|
||||
StpUtil.getSession().set(sysUser.getId(),
|
||||
SysUserSessionVo.builder()
|
||||
.id(sysUser.getId())
|
||||
.username(sysUser.getUsername())
|
||||
.nickname(sysUser.getNickname())
|
||||
.type(sysUser.getType())
|
||||
.roleIds(roles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
return SysUserVo.builder()
|
||||
.username(sysUser.getUsername())
|
||||
.nickname(sysUser.getNickname())
|
||||
.type(sysUser.getType())
|
||||
.avatar(sysUser.getAvatar())
|
||||
.loginTime(LocalDateTime.now())
|
||||
.token(StpUtil.getTokenInfo().getTokenValue())
|
||||
.build();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object modifyPass(SysUser user) {
|
||||
SysUser sysUser = this.baseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, user.getUsername()));
|
||||
|
||||
if (Objects.isNull(sysUser) || !Objects.equals(Sha256Util.getSHA256(sysUser.getPassword()), Sha256Util.getSHA256(user.getPassword()))) {
|
||||
@ -63,48 +143,4 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return this.baseMapper.updateById(sysUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(SysUser user) {
|
||||
Integer count = this.baseMapper.selectCount(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, user.getUsername()));
|
||||
if (Objects.nonNull(count) && count > 0) {
|
||||
throw new BusinessException("用户名称已存在!");
|
||||
}
|
||||
user.setIsDel(Constants.NOT_DEL_FALG);
|
||||
user.setCreateTime(LocalDateTime.now());
|
||||
user.setPassword(Sha256Util.getSHA256(user.getPassword()));
|
||||
int row = this.baseMapper.insert(user);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(SysUser user) {
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
int row = this.baseMapper.updateById(user);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean del(SysUser user) {
|
||||
user.setIsDel(Constants.IS_DEL_FALG);
|
||||
this.baseMapper.updateById(user);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser login(String username) {
|
||||
SysUser user = this.baseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||
if (Objects.nonNull(user)) {
|
||||
// 生成token
|
||||
StpUtil.login(user.getId());
|
||||
// 获取token信息
|
||||
return SysUser.builder()
|
||||
.username(user.getUsername())
|
||||
.nickname(user.getNickname())
|
||||
.type(user.getType())
|
||||
.token(StpUtil.getTokenInfo().getTokenValue())
|
||||
.build();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
server:
|
||||
port: 8081
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /tansci/
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user