Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cxt104926
Stusystem
提交
6c61a954
S
Stusystem
项目概览
cxt104926
/
Stusystem
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Stusystem
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6c61a954
编写于
3月 30, 2021
作者:
cxt104926
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
菜单管理
上级
02b671ed
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
351 addition
and
37 deletion
+351
-37
doc/createDatabase.sql
doc/createDatabase.sql
+49
-0
src/main/java/com/stu/stusystem/controller/system/MenuController.java
...a/com/stu/stusystem/controller/system/MenuController.java
+53
-2
src/main/java/com/stu/stusystem/mapper/system/MenuMapper.java
...main/java/com/stu/stusystem/mapper/system/MenuMapper.java
+17
-0
src/main/java/com/stu/stusystem/mapper/system/StuMapper.java
src/main/java/com/stu/stusystem/mapper/system/StuMapper.java
+1
-0
src/main/java/com/stu/stusystem/model/system/Menu.java
src/main/java/com/stu/stusystem/model/system/Menu.java
+40
-0
src/main/java/com/stu/stusystem/service/system/MenuService.java
...in/java/com/stu/stusystem/service/system/MenuService.java
+107
-0
src/main/java/com/stu/stusystem/service/system/dto/MenuDTO.java
...in/java/com/stu/stusystem/service/system/dto/MenuDTO.java
+38
-0
src/main/java/com/stu/stusystem/service/system/vo/MenuVO.java
...main/java/com/stu/stusystem/service/system/vo/MenuVO.java
+38
-0
src/main/resources/config/liquibase/20210329_creat_table_menu.xml
.../resources/config/liquibase/20210329_creat_table_menu.xml
+7
-35
src/main/resources/config/master.xml
src/main/resources/config/master.xml
+1
-0
未找到文件。
doc/createDatabase.sql
0 → 100644
浏览文件 @
6c61a954
-- stu_class 班级表
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'100000000000'
,
'信息技术学院'
,
''
,
1
,
'SE45yZijRbqGr6XzP0FC2Q'
,
''
,
'11:07:29'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'100010000000'
,
'网络工程系'
,
'100000000000'
,
2
,
'INIT20200908'
,
''
,
'13:44:47'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'100020000000'
,
'物联网工程系'
,
'100000000000'
,
2
,
'INIT20200908'
,
''
,
'13:44:29'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'200000000000'
,
'经济管理学院'
,
''
,
1
,
'INIT20200908'
,
''
,
'13:25:32'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'200010000000'
,
'金融系'
,
'200000000000'
,
2
,
'INIT20200908'
,
''
,
'13:45:58'
,
'巴扎黑'
,
'16:21:18'
,
'巴扎黑'
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'200020000000'
,
'会计学系'
,
'200000000000'
,
2
,
'INIT20200908'
,
''
,
'13:46:10'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'300000000000'
,
'外国语学院'
,
''
,
1
,
'INIT20200908'
,
''
,
'13:25:45'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'300010000000'
,
'外语翻译系'
,
'300000000000'
,
2
,
'INIT20200908'
,
''
,
'13:46:38'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'4ISr5_0PSfSx-otmhznqZQ'
,
'网络一班'
,
'100010000000'
,
2
,
'INIT20200908'
,
'2020'
,
'16:14:54'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'9cfYz55YRhm--Tr1qEmSuQ'
,
'物联网二班'
,
'100020000000'
,
3
,
'INIT20200908'
,
'2020'
,
'16:15:52'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'BwFS2b-3Q--VnW08L0Tqww'
,
'会计学二班'
,
'200020000000'
,
2
,
'INIT20200908'
,
'2020'
,
'16:14:01'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'i4VORBYQR6GKKW6uVa7GkA'
,
'金融班'
,
'200010000000'
,
3
,
'INIT20200908'
,
'2020'
,
'16:18:55'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'IPIFC_9nTqOJZfHOTmZnzw'
,
'翻译班'
,
'300010000000'
,
3
,
'INIT20200908'
,
'2020'
,
'16:16:27'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'wFd6crq-RVeu8_ilZrGQHA'
,
'会计学一班'
,
'200020000000'
,
2
,
'INIT20200908'
,
'2020'
,
'16:08:31'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'xpRlKZcqSr-fV84gwguipg'
,
'物联网一班'
,
'100020000000'
,
3
,
'INIT20200908'
,
'2020'
,
'16:15:48'
,
'巴扎黑'
,
NULL
,
NULL
);
INSERT
INTO
stusystem
.
stu_class
(
id
,
name
,
pid
,
sign
,
user_id
,
grade
,
create_time
,
create_by
,
update_time
,
update_by
)
VALUES
(
'_dkvCK7LS0K65tPx-jLliQ'
,
'网络二班'
,
'100010000000'
,
3
,
'INIT20200908'
,
'2020'
,
'16:15:23'
,
'巴扎黑'
,
NULL
,
NULL
);
src/main/java/com/stu/stusystem/controller/system/MenuController.java
浏览文件 @
6c61a954
package
com.stu.stusystem.controller.system
;
import
com.github.pagehelper.PageInfo
;
import
com.stu.stusystem.common.ApiResult
;
import
com.stu.stusystem.common.OffsetPage
;
import
com.stu.stusystem.model.system.Menu
;
import
com.stu.stusystem.service.system.MenuService
;
import
com.stu.stusystem.service.system.dto.MenuDTO
;
import
com.stu.stusystem.service.system.dto.StuClassDTO
;
import
com.stu.stusystem.service.system.dto.StuClassQuery
;
import
com.stu.stusystem.service.system.vo.MenuVO
;
import
com.stu.stusystem.service.system.vo.StuClassVO
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* @author: cxt
...
...
@@ -13,5 +26,43 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/menu"
)
public
class
MenuController
{
private
MenuService
menuService
;
@ApiOperation
(
"分页查询"
)
@GetMapping
(
"/get"
)
public
PageInfo
<
MenuVO
>
getMenuPage
(
OffsetPage
query
,
String
name
)
{
return
this
.
menuService
.
getMenuPage
(
query
,
name
);
}
@ApiOperation
(
"修改菜单"
)
@PutMapping
(
"/update"
)
public
ApiResult
<
String
>
updateMenu
(
@RequestBody
MenuDTO
dto
)
{
this
.
menuService
.
updateMenu
(
dto
);
return
ApiResult
.
success
();
}
@ApiOperation
(
"删除菜单"
)
@DeleteMapping
(
"/delete"
)
public
ApiResult
<
String
>
deleteMenu
(
@RequestParam
(
"id"
)
String
id
)
{
this
.
menuService
.
deleteMenu
(
id
);
return
ApiResult
.
success
();
}
@ApiOperation
(
"新增菜单"
)
@PostMapping
(
"/add"
)
public
ApiResult
<
String
>
saveMenu
(
@RequestBody
MenuDTO
dto
)
{
this
.
menuService
.
saveMenu
(
dto
);
return
ApiResult
.
success
();
}
@ApiOperation
(
"查询树形菜单"
)
@GetMapping
(
"/get/treeMenu"
)
public
List
<
Object
>
getTreeMenu
(){
return
this
.
menuService
.
getTreeMenu
();
}
@Autowired
public
void
setMenuService
(
MenuService
menuService
)
{
this
.
menuService
=
menuService
;
}
}
src/main/java/com/stu/stusystem/mapper/system/MenuMapper.java
0 → 100644
浏览文件 @
6c61a954
package
com.stu.stusystem.mapper.system
;
import
com.stu.stusystem.common.CommonMapper
;
import
com.stu.stusystem.model.em.TreeModel
;
import
com.stu.stusystem.model.system.Menu
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* @author cxt
* @date 2021/3/29
*/
public
interface
MenuMapper
extends
CommonMapper
<
Menu
>
{
@Select
(
"select id,name,pid from menu"
)
List
<
TreeModel
>
getTreeMenu
();
}
src/main/java/com/stu/stusystem/mapper/system/StuMapper.java
浏览文件 @
6c61a954
...
...
@@ -6,6 +6,7 @@ import com.stu.stusystem.service.system.dto.UserManagerQuery;
import
com.stu.stusystem.service.system.vo.StuUserVO
;
import
org.apache.ibatis.annotations.Param
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
...
...
src/main/java/com/stu/stusystem/model/system/Menu.java
0 → 100644
浏览文件 @
6c61a954
package
com.stu.stusystem.model.system
;
import
com.stu.stusystem.common.BaseModel
;
import
com.stu.stusystem.common.OffsetPage
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author cxt
* @date 2021/3/29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
Menu
extends
BaseModel
{
private
String
id
;
// 图标
private
String
iconImg
;
// 名称
private
String
name
;
// 页面url
private
String
url
;
// 父级id
private
String
pid
;
// 菜单类型(M:目录,C:菜单,B:按钮)
private
String
menuType
;
// 是否启用
private
Boolean
isVisible
;
// 排序
private
Integer
orderNum
;
}
src/main/java/com/stu/stusystem/service/system/MenuService.java
0 → 100644
浏览文件 @
6c61a954
package
com.stu.stusystem.service.system
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.stu.stusystem.common.ApiException
;
import
com.stu.stusystem.common.OffsetPage
;
import
com.stu.stusystem.mapper.system.MenuMapper
;
import
com.stu.stusystem.model.em.TreeModel
;
import
com.stu.stusystem.model.system.Menu
;
import
com.stu.stusystem.model.system.StuUser
;
import
com.stu.stusystem.service.system.dto.MenuDTO
;
import
com.stu.stusystem.service.system.vo.MenuVO
;
import
com.stu.stusystem.util.CopyBeanUtil
;
import
com.stu.stusystem.util.TreeModelUtil
;
import
org.apache.shiro.SecurityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.weekend.WeekendSqls
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author cxt
* @date 2021/3/29
*/
@Service
public
class
MenuService
{
private
MenuMapper
menuMapper
;
/**
* 分页查询
*/
public
PageInfo
<
MenuVO
>
getMenuPage
(
OffsetPage
query
,
String
name
)
{
PageHelper
.
startPage
(
query
.
getPage
(),
query
.
getLimit
());
Example
example
=
new
Example
(
Menu
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
name
!=
null
)
{
criteria
.
andEqualTo
(
"name"
,
name
);
}
example
.
orderBy
(
"create_time"
).
desc
();
List
<
Menu
>
menus
=
this
.
menuMapper
.
selectByExample
(
example
);
List
<
MenuVO
>
menuVOS
=
CopyBeanUtil
.
copyList
(
menus
,
new
MenuVO
());
return
new
PageInfo
<>(
menuVOS
);
}
/**
* 更新菜单
*/
public
void
updateMenu
(
MenuDTO
dto
)
{
Menu
menu
=
this
.
menuMapper
.
selectByPrimaryKey
(
dto
.
getId
());
if
(
menu
==
null
)
{
throw
new
ApiException
(
"没有找到更新资源"
);
}
CopyBeanUtil
.
copy
(
dto
,
menu
);
StuUser
user
=
(
StuUser
)
SecurityUtils
.
getSubject
().
getPrincipal
();
menu
.
setUpdateBy
(
user
.
getName
());
menu
.
setCreateTime
(
new
Date
());
int
i
=
this
.
menuMapper
.
updateByExample
(
menu
,
new
Example
.
Builder
(
Menu
.
class
)
.
where
(
WeekendSqls
.<
Menu
>
custom
().
andEqualTo
(
Menu:
:
getId
,
dto
.
getId
())).
build
());
if
(
i
!=
1
)
{
throw
new
ApiException
(
ApiException
.
UPDATE_FAIL
);
}
}
/**
* 删除菜单
*/
public
void
deleteMenu
(
String
id
)
{
int
i
=
this
.
menuMapper
.
deleteByPrimaryKey
(
id
);
if
(
i
!=
1
)
{
throw
new
ApiException
(
ApiException
.
DELETE_FAIL
);
}
}
/**
* 新增菜单
*/
public
void
saveMenu
(
MenuDTO
dto
)
{
List
<
Menu
>
menus
=
this
.
menuMapper
.
selectByExample
(
new
Example
.
Builder
(
Menu
.
class
)
.
where
(
WeekendSqls
.<
Menu
>
custom
().
andEqualTo
(
Menu:
:
getName
,
dto
.
getName
())).
build
());
if
(
menus
.
size
()
!=
0
)
{
throw
new
ApiException
(
"您添加的菜单已存在"
);
}
Menu
menu
=
new
Menu
();
CopyBeanUtil
.
copy
(
dto
,
menu
);
StuUser
user
=
(
StuUser
)
SecurityUtils
.
getSubject
().
getPrincipal
();
menu
.
setCreateBy
(
user
.
getName
());
menu
.
setCreateTime
(
new
Date
());
this
.
menuMapper
.
insert
(
menu
);
}
/**
* 查询树形菜单
*/
public
List
<
Object
>
getTreeMenu
()
{
List
<
TreeModel
>
treeMenu
=
this
.
menuMapper
.
getTreeMenu
();
return
TreeModelUtil
.
buildTreeList
(
treeMenu
);
}
@Autowired
public
void
setMenuMapper
(
MenuMapper
menuMapper
)
{
this
.
menuMapper
=
menuMapper
;
}
}
src/main/java/com/stu/stusystem/service/system/dto/MenuDTO.java
0 → 100644
浏览文件 @
6c61a954
package
com.stu.stusystem.service.system.dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author cxt
* @date 2021/3/29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
MenuDTO
{
private
String
id
;
@ApiModelProperty
(
"图标"
)
private
String
iconImg
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"页面url"
)
private
String
url
;
@ApiModelProperty
(
"父级id"
)
private
String
pid
;
@ApiModelProperty
(
"菜单类型(M:目录,C:菜单,B:按钮)"
)
private
String
menuType
;
@ApiModelProperty
(
"是否启用"
)
private
Boolean
isVisible
;
@ApiModelProperty
(
"排序"
)
private
Integer
orderNum
;
}
src/main/java/com/stu/stusystem/service/system/vo/MenuVO.java
0 → 100644
浏览文件 @
6c61a954
package
com.stu.stusystem.service.system.vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author cxt
* @date 2021/3/29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
MenuVO
{
private
String
id
;
@ApiModelProperty
(
"图标"
)
private
String
iconImg
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"页面url"
)
private
String
url
;
@ApiModelProperty
(
"父级id"
)
private
String
pid
;
@ApiModelProperty
(
"菜单类型(M:目录,C:菜单,B:按钮)"
)
private
String
menuType
;
@ApiModelProperty
(
"是否启用"
)
private
Boolean
isVisible
;
@ApiModelProperty
(
"排序"
)
private
Integer
orderNum
;
}
src/main/resources/config/liquibase/20210329_creat_table_menu.xml
浏览文件 @
6c61a954
...
...
@@ -12,12 +12,12 @@
Added the entity menu.
-->
<changeSet
id=
"2021-03"
author=
"cxt"
>
<createTable
tableName=
"
stu_class
"
remarks=
"菜单表"
>
<createTable
tableName=
"
menu
"
remarks=
"菜单表"
>
<column
name=
"id"
type=
"varchar(22)"
>
<constraints
primaryKey=
"true"
nullable=
"false"
/>
</column>
<column
name=
"icon_img"
type=
"
tinyint(1
)"
remarks=
"图标"
>
<column
name=
"icon_img"
type=
"
varchar(50
)"
remarks=
"图标"
>
<constraints
nullable=
"true"
/>
</column>
...
...
@@ -33,45 +33,17 @@
<constraints
nullable=
"true"
/>
</column>
<column
name=
"menu_type"
type=
"
tinyint
(1)"
remarks=
"菜单类型(M:目录,C:菜单,B:按钮)"
>
<column
name=
"menu_type"
type=
"
varchar
(1)"
remarks=
"菜单类型(M:目录,C:菜单,B:按钮)"
>
<constraints
nullable=
"false"
/>
</column>
<column
name=
"is_
us
e"
type=
"tinyint(1)"
remarks=
"是否启用"
>
<column
name=
"is_
visibl
e"
type=
"tinyint(1)"
remarks=
"是否启用"
>
<constraints
nullable=
"false"
/>
</column>
/** 显示顺序 */
private String orderNum;
/** 菜单URL */
private String url;
/** 打开方式(menuItem页签 menuBlank新窗口) */
private String target;
/** 类型(M目录 C菜单 F按钮) */
private String menuType;
/** 菜单状态(0显示 1隐藏) */
private String visible;
/** 是否刷新(0刷新 1不刷新) */
private String isRefresh;
/** 权限字符串 */
private String perms;
/** 菜单图标 */
private String icon;
<column
name=
"order_num"
type=
"int(11)"
remarks=
"排序"
>
<constraints
nullable=
"false"
/>
</column>
<column
name=
"create_time"
type=
"time"
remarks=
"创建时间"
>
<constraints
nullable=
"false"
/>
...
...
src/main/resources/config/master.xml
浏览文件 @
6c61a954
...
...
@@ -7,5 +7,6 @@
<include
file=
"classpath:config/liquibase/20200907_creat_table_StuUser.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/20200914_creat_table_log.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/20210323_creat_table_stuClass.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/20210329_creat_table_menu.xml"
relativeToChangelogFile=
"false"
/>
</databaseChangeLog>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录