【更新】更新移动端菜单管理(待完善)

pull/84/head
小诺 2023-01-31 01:47:08 +08:00 committed by 俞宝山
parent 647e7de72b
commit 61b969b2f1
18 changed files with 653 additions and 154 deletions

View File

@ -0,0 +1,40 @@
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/mobile/menu/` + url, ...arg)
/**
* 移动端菜单Api接口管理器
*
* @author yubaoshan
* @date 2023/01/28 22:42
**/
export default {
// 获取移动端菜单tree
mobileMenuTree(data) {
return request('tree', data, 'get')
},
// 获取移动端菜单列表
mobileMenuList(data) {
return request('list', data, 'get')
},
// 提交移动端菜单表单 edit为true时为编辑默认为新增
mobileMenuSubmitForm(data, edit = false) {
return request(edit ? 'add' : 'edit', data)
},
// 删除移动端菜单
mobileMenuDelete(data) {
return request('delete', data)
},
// 获取移动端菜单详情
mobileMenuDetail(data) {
return request('detail', data, 'get')
},
// 获取类别选择器
mobileMenuModuleSelector(data) {
return request('moduleSelector', data, 'get')
},
// 获取菜单树选择器
mobileMenuTreeSelector(data) {
return request('menuTreeSelector', data, 'get')
}
}

View File

@ -0,0 +1,37 @@
/**
* Copyright [2022] [https://www.xiaonuo.vip]
* Snowy采用APACHE LICENSE 2.0开源协议您在使用过程中需要注意以下几点
* 1.请不要删除和修改根目录下的LICENSE文件
* 2.请不要删除和修改Snowy源码头部的版权声明
* 3.本项目代码可免费商业使用商业使用请保留源码和相关描述文件的项目出处作者声明等
* 4.分发源码时候请注明软件出处 https://www.xiaonuo.vip
* 5.不可二次分发开源参与同类竞品如有想法可联系团队xiaonuobase@qq.com商议合作
* 6.若您的项目无法满足以上几点需要更多功能代码获取Snowy商业授权许可请在官网购买授权地址为 https://www.xiaonuo.vip
*/
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/mobile/module/${url}`, ...arg)
/**
* 类别
*
* @author yubaoshan
* @date 2022-09-22 22:33:20
*/
export default {
// 获取类别分页
modulePage(data) {
return request('page', data, 'get')
},
// 提交表单 edit为true时为编辑默认为新增
submitForm(data, edit = false) {
return request(edit ? 'add' : 'edit', data)
},
// 删除类别
moduleDelete(data) {
return request('delete', data)
},
// 获取类别详情
moduleDetail(data) {
return request('detail', data, 'get')
}
}

View File

@ -10,8 +10,25 @@
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="父ID" name="parentId">
<a-input v-model:value="formData.parentId" placeholder="请输入父ID" allow-clear />
<a-form-item label="上级菜单:" name="parentId">
<a-tree-select
v-model:value="formData.parentId"
v-model:treeExpandedKeys="defaultExpandedKeys"
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择上级菜单"
allow-clear
tree-default-expand-all
:tree-data="treeData"
:field-names="{
children: 'children',
label: 'title',
value: 'id'
}"
selectable="false"
tree-line
@change="parentChange(formData.parentId)"
></a-tree-select>
</a-form-item>
</a-col>
<a-col :span="12">
@ -24,24 +41,20 @@
<a-input v-model:value="formData.pages" placeholder="请输入界面路径" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="分类:" name="category">
<a-select v-model:value="formData.category" placeholder="请选择分类" :options="categoryOptions" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="图标:" name="icon">
<a-input v-model:value="formData.icon" placeholder="请输入图标" allow-clear />
<a-input v-model:value="formData.icon" style="width: calc(100% - 70px)" placeholder="请选择图标" allow-clear />
<a-button type="primary" @click="iconSelector.showIconModal(formData.icon)"></a-button>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="颜色:" name="color">
<a-input v-model:value="formData.color" placeholder="请输入颜色" allow-clear />
<color-picker v-model:value="formData.color" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="是否正规则:" name="isRegExp">
<a-radio-group v-model:value="formData.isRegExp" placeholder="请选择正规则" :options="isRegExpOptions" />
<a-form-item label="是否正规则:" name="regType">
<a-radio-group v-model:value="formData.regType" placeholder="请选择正规则" :options="regTypeOptions" />
</a-form-item>
</a-col>
<a-col :span="12">
@ -58,6 +71,7 @@
<a-button style="margin-right: 8px" @click="onClose"></a-button>
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
</template>
<Icon-selector ref="iconSelector" @iconCallBack="iconCallBack" />
</a-drawer>
</template>
@ -65,27 +79,53 @@
import tool from '@/utils/tool'
import { cloneDeep } from 'lodash-es'
import { required } from '@/utils/formRules'
import mobileMenuApi from '@/api/mobile/mobileMenuApi'
import mobileMenuApi from '@/api/mobile/resource/menuApi'
import ColorPicker from '@/components/ColorPicker/index.vue'
import IconSelector from '@/components/Selector/iconSelector.vue'
//
const visible = ref(false)
const emit = defineEmits({ successful: null })
const formRef = ref()
//
let iconSelector = ref()
// ()
const defaultExpandedKeys = ref([0])
const treeData = ref([])
const formData = ref({})
//
const moduleId = ref('')
const submitLoading = ref(false)
const categoryOptions = ref([])
const isRegExpOptions = ref([])
const regTypeOptions = ref([])
const statusOptions = ref([])
//
const onOpen = (record) => {
const onOpen = (record, module) => {
moduleId.value = module
visible.value = true
//
formData.value = {
regType: 'YES',
status: 'ENABLE',
category: 'MENU'
}
if (record) {
let recordData = cloneDeep(record)
formData.value = Object.assign({}, recordData)
}
categoryOptions.value = tool.dictList('MOBILE_CATEGORY')
isRegExpOptions.value = tool.dictList('MOBILE_IS_REG_EXP')
//
const treeParam = {
module: module
}
mobileMenuApi.mobileMenuTreeSelector(treeParam).then((res) => {
treeData.value = [
{
id: 0,
parentId: '-1',
title: '顶级',
children: res
}
]
})
regTypeOptions.value = tool.dictList('MOBILE_REG_TYPE')
statusOptions.value = tool.dictList('MOBILE_STATUS')
}
//
@ -94,16 +134,33 @@
formData.value = {}
visible.value = false
}
//
const parentChange = (value) => {
if (value > 0) {
//
const param = {
id: value
}
mobileMenuApi.mobileMenuDetail(param).then((res) => {
formData.value.module = res.module
})
} else {
formData.value.module = null
}
}
//
const iconCallBack = (value) => {
formData.value.icon = value
}
//
const formRules = {
parentId: [required('请输入父ID')],
parentId: [required('请选择上级')],
title: [required('请输入名称')],
pages: [required('请输入界面路径')],
category: [required('请输入分类')],
icon: [required('请输入图标')],
color: [required('请输入颜色')],
isRegExp: [required('请输入正规则')],
status: [required('请输入可用状态')],
icon: [required('请选择图标')],
color: [required('请选择颜色')],
regType: [required('请选择规则类型')],
status: [required('请选择可用状态')]
}
//
const onSubmit = () => {
@ -112,6 +169,7 @@
.then(() => {
submitLoading.value = true
const formDataParam = cloneDeep(formData.value)
formDataParam.module = moduleId.value
mobileMenuApi
.mobileMenuSubmitForm(formDataParam, !formDataParam.id)
.then(() => {

View File

@ -1,29 +1,27 @@
<template>
<a-card :bordered="false">
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form mb-4">
<a-row :gutter="24">
<a-col :span="6">
<a-form-item label="关键词" name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入关键词" />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="分类" name="category">
<a-select v-model:value="searchFormState.category" placeholder="请选择分类" :options="categoryOptions" />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="可用状态" name="status">
<a-select v-model:value="searchFormState.status" placeholder="请选择可用状态" :options="statusOptions" />
</a-form-item>
</a-col>
<a-col :span="6">
<a-button type="primary" @click="table.refresh(true)"></a-button>
<a-button style="margin: 0 8px" @click="() => searchFormRef.resetFields()">重置</a-button>
</a-col>
</a-row>
</a-form>
<s-table
<a-space class="mb-3">
<a-radio-group v-model:value="module" button-style="solid">
<a-radio-button
v-for="module in moduleList"
:key="module.id"
:value="module.id"
@click="moduleClock(module.id)"
>
<component :is="module.icon" />
{{ module.title }}</a-radio-button
>
</a-radio-group>
<a-input-search
v-model:value="searchFormState.searchKey"
placeholder="请输入菜单名称关键词"
enter-button
allowClear
@search="onSearch"
/>
</a-space>
<s-table
ref="table"
:columns="columns"
:data="loadData"
@ -36,7 +34,7 @@
>
<template #operator class="table-operator">
<a-space>
<a-button type="primary" @click="formRef.onOpen()">
<a-button type="primary" @click="formRef.onOpen(undefined, module)">
<template #icon><plus-outlined /></template>
新增
</a-button>
@ -44,18 +42,15 @@
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'category'">
{{ $TOOL.dictTypeData('MOBILE_CATEGORY', record.category) }}
</template>
<template v-if="column.dataIndex === 'isRegExp'">
{{ $TOOL.dictTypeData('MOBILE_IS_REG_EXP', record.isRegExp) }}
<template v-if="column.dataIndex === 'regType'">
{{ $TOOL.dictTypeData('MOBILE_REG_TYPE', record.regType) }}
</template>
<template v-if="column.dataIndex === 'status'">
{{ $TOOL.dictTypeData('MOBILE_STATUS', record.status) }}
</template>
<template v-if="column.dataIndex === 'action'">
<a-space>
<a @click="formRef.onOpen(record)"></a>
<a @click="formRef.onOpen(record, module)"></a>
<a-divider type="vertical" />
<a-popconfirm title="确定要删除吗?" @confirm="deleteMobileMenu(record)">
<a-button type="link" danger size="small">删除</a-button>
@ -70,10 +65,11 @@
<script setup name="mobileMenuIndex">
import { message } from 'ant-design-vue'
import tool from '@/utils/tool'
import Form from './form.vue'
import mobileMenuApi from '@/api/mobile/mobileMenuApi'
import mobileMenuApi from '@/api/mobile/resource/menuApi'
let searchFormState = reactive({})
let moduleList = ref([])
const module = ref()
const searchFormRef = ref()
const table = ref()
const formRef = ref()
@ -88,26 +84,18 @@
dataIndex: 'pages',
ellipsis: true
},
{
title: '分类',
dataIndex: 'category'
},
{
title: '图标',
dataIndex: 'icon'
},
{
title: '正规则',
dataIndex: 'isRegExp'
dataIndex: 'regType'
},
{
title: '可用状态',
dataIndex: 'status'
},
{
title: '排序码',
dataIndex: 'sortCode'
},
{
title: '创建时间',
dataIndex: 'createTime',
@ -136,14 +124,46 @@
}
}
const loadData = (parameter) => {
const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
if (!module.value) {
return mobileMenuApi.mobileMenuModuleSelector().then((data) => {
moduleList.value = data
module.value = data.length > 0 ? data[0].id : ''
searchFormState.module = module.value
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormState)).then((data) => {
if (data) {
return data
}
return []
})
})
} else {
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormState)).then((data) => {
if (data) {
return data
}
return []
})
}
/*const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
return mobileMenuApi.mobileMenuTree(Object.assign(parameter, searchFormParam)).then((data) => {
if (data) {
return data
}
return []
})
})*/
}
//
const moduleClock = (value) => {
searchFormState.module = value
table.value.refresh(true)
}
//
const onSearch = () => {
if (searchFormState.searchKey) {
table.value.refresh(true)
}
}
//
const deleteMobileMenu = (record) => {
let params = [
@ -170,6 +190,4 @@
table.value.clearRefreshSelected()
})
}
const categoryOptions = tool.dictList('MOBILE_CATEGORY')
const statusOptions = tool.dictList('MOBILE_STATUS')
</script>

View File

@ -0,0 +1,91 @@
<template>
<a-drawer
:title="formData.id ? '编辑菜单模块' : '增加菜单模块'"
:width="600"
:visible="visible"
:destroy-on-close="true"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
@close="onClose"
>
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-form-item label="模块名称:" name="title">
<a-input v-model:value="formData.title" placeholder="请输入模块名称" allow-clear />
</a-form-item>
<a-form-item label="图标:" name="icon">
<a-input v-model:value="formData.icon" style="width: calc(100% - 70px)" placeholder="请选择图标" allow-clear />
<a-button type="primary" @click="iconSelector.showIconModal(formData.icon)"></a-button>
</a-form-item>
<a-form-item label="颜色:" name="color">
<color-picker v-model:value="formData.color" />
</a-form-item>
<a-form-item label="排序:" name="sortCode">
<a-slider v-model:value="formData.sortCode" :max="100" />
</a-form-item>
</a-form>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose"></a-button>
<a-button type="primary" @click="onSubmit"></a-button>
</template>
<Icon-selector ref="iconSelector" @iconCallBack="iconCallBack" />
</a-drawer>
</template>
<script setup>
import ColorPicker from '@/components/ColorPicker/index.vue'
import { required } from '@/utils/formRules'
import moduleApi from '@/api/mobile/resource/moduleApi'
import IconSelector from '@/components/Selector/iconSelector.vue'
//
let visible = $ref(false)
const emit = defineEmits({ successful: null })
const formRef = ref()
const treeData = ref([])
let iconSelector = ref()
//
const formData = ref({})
//
const onOpen = (record) => {
visible = true
formData.value = {
sortCode: 99
}
if (record) {
formData.value = Object.assign({}, record)
}
}
//
const onClose = () => {
formRef.value.resetFields()
visible = false
}
//
const iconCallBack = (value) => {
formData.value.icon = value
}
//
const formRules = {
title: [required('请输入模块名称')],
icon: [required('请选择图标')],
color: [required('请选择颜色')]
}
//
const onSubmit = () => {
formRef.value
.validate()
.then(() => {
moduleApi.submitForm(formData.value, !formData.value.id).then(() => {
onClose()
emit('successful')
})
})
}
//
defineExpose({
onOpen
})
</script>

View File

@ -0,0 +1,139 @@
<template>
<a-card :bordered="false" :body-style="{ 'padding-bottom': '0px' }" class="mb-2">
<a-form ref="formRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
<a-row :gutter="24">
<a-col :span="8">
<a-form-item label="名称关键词" name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入模块名称关键词"></a-input>
</a-form-item>
</a-col>
<a-col :span="8">
<a-button type="primary" @click="table.refresh(true)"></a-button>
<a-button style="margin: 0 8px" @click="() => formRef.resetFields()">重置</a-button>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card :bordered="false">
<s-table
ref="table"
:columns="columns"
:data="loadData"
:alert="options.alert.show"
bordered
:row-key="(record) => record.id"
:tool-config="toolConfig"
:row-selection="options.rowSelection"
>
<template #operator class="table-operator">
<a-space>
<a-button type="primary" @click="form.onOpen()">
<template #icon><plus-outlined /></template>
新增模块
</a-button>
<a-button danger @click="deleteBatchModule()"></a-button>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'icon'">
<a-tag :color="record.color">
<component :is="record.icon" />
</a-tag>
</template>
<template v-if="column.dataIndex === 'action'">
<a-space>
<a @click="form.onOpen(record)"></a>
<a-divider type="vertical" />
<a-popconfirm title="确定要删除此模块吗?" @confirm="deleteModule(record)">
<a-button type="link" danger size="small">删除</a-button>
</a-popconfirm>
</a-space>
</template>
</template>
</s-table>
</a-card>
<Form ref="form" @successful="table.refresh(true)" />
</template>
<script setup name="mobileModule">
import { message } from 'ant-design-vue'
import Form from './form.vue'
import moduleApi from '@/api/mobile/resource/moduleApi'
let searchFormState = reactive({})
const formRef = ref()
const table = ref()
let form = ref()
const toolConfig = { refresh: true, height: true, columnSetting: false, striped: false }
const columns = [
{
title: '显示名称',
dataIndex: 'title'
},
{
title: '图标',
dataIndex: 'icon'
},
{
title: '排序',
dataIndex: 'sortCode',
sorter: true
},
{
title: '创建时间',
dataIndex: 'createTime',
sorter: true
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: '200px'
}
]
let selectedRowKeys = ref([])
//
const options = {
alert: {
show: false,
clear: () => {
selectedRowKeys = ref([])
}
},
rowSelection: {
onChange: (selectedRowKey, selectedRows) => {
selectedRowKeys.value = selectedRowKey
}
}
}
const loadData = (parameter) => {
return moduleApi.modulePage(Object.assign(parameter, searchFormState)).then((res) => {
return res
})
}
//
const deleteModule = (record) => {
let params = [
{
id: record.id
}
]
moduleApi.moduleDelete(params).then(() => {
table.value.refresh(true)
})
}
//
const deleteBatchModule = () => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
moduleApi.moduleDelete(params).then(() => {
table.value.clearRefreshSelected()
})
}
</script>

View File

@ -85,13 +85,13 @@ public class GenBasicServiceImpl extends ServiceImpl<GenBasicMapper, GenBasic> i
private static final String DB_PASSWORD_KEY = "spring.datasource.dynamic.datasource.master.password";
private static final String MODULE_KEY = "biz";
private static final String MODULE_KEY = "mobile";
private static final String GEN_PROJECT_FRONT_PLUGIN_KEY = "snowy-admin-web";
private static final String GEN_PROJECT_PLUGIN_KEY = "snowy-plugin";
private static final String GEN_PROJECT_PLUGIN_BIZ_KEY = GEN_PROJECT_PLUGIN_KEY + File.separator + "snowy-plugin-biz";
private static final String GEN_PROJECT_PLUGIN_BIZ_KEY = GEN_PROJECT_PLUGIN_KEY + File.separator + "snowy-plugin-mobile";
private static final List<JSONObject> GEN_SQL_FILE_LIST = CollectionUtil.newArrayList(
JSONUtil.createObj().set("name", "Mysql.sql.btl"),

View File

@ -26,10 +26,8 @@ import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.common.pojo.CommonValidList;
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
import javax.annotation.Resource;
@ -123,4 +121,32 @@ public class MobileMenuController {
public CommonResult<MobileMenu> detail(@Valid MobileMenuIdParam mobileMenuIdParam) {
return CommonResult.data(mobileMenuService.detail(mobileMenuIdParam));
}
/* ====菜单部分所需要用到的选择器==== */
/**
*
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 8)
@ApiOperation("获取模块选择器")
@GetMapping("/mobile/menu/moduleSelector")
public CommonResult<List<MobileModule>> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam) {
return CommonResult.data(mobileMenuService.moduleSelector(mobileMenuSelectorModuleParam));
}
/**
*
*
* @author xuyuxiang
* @date 2022/4/24 20:00
*/
@ApiOperationSupport(order = 9)
@ApiOperation("获取菜单树选择器")
@GetMapping("/mobile/menu/menuTreeSelector")
public CommonResult<List<Tree<String>>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam) {
return CommonResult.data(mobileMenuService.menuTreeSelector(mobileMenuSelectorMenuParam));
}
}

View File

@ -29,47 +29,52 @@ import javax.validation.constraints.NotBlank;
public class MobileMenuAddParam {
/** 父ID */
@ApiModelProperty(value = "父ID", required = true, position = 2)
@ApiModelProperty(value = "父ID", required = true, position = 1)
@NotBlank(message = "parentId不能为空")
private String parentId;
/** 名称 */
@ApiModelProperty(value = "名称", required = true, position = 3)
@ApiModelProperty(value = "名称", required = true, position = 2)
@NotBlank(message = "title不能为空")
private String title;
/** 界面路径 */
@ApiModelProperty(value = "界面路径", required = true, position = 5)
@ApiModelProperty(value = "界面路径", required = true, position = 3)
@NotBlank(message = "pages不能为空")
private String pages;
/** 分类 */
@ApiModelProperty(value = "分类", required = true, position = 6)
@ApiModelProperty(value = "分类", required = true, position = 4)
@NotBlank(message = "category不能为空")
private String category;
/** 模块 */
@ApiModelProperty(value = "模块", required = true, position = 5)
@NotBlank(message = "module不能为空")
private String module;
/** 图标 */
@ApiModelProperty(value = "图标", required = true, position = 7)
@ApiModelProperty(value = "图标", required = true, position = 6)
@NotBlank(message = "icon不能为空")
private String icon;
/** 颜色 */
@ApiModelProperty(value = "颜色", required = true, position = 8)
@ApiModelProperty(value = "颜色", required = true, position = 7)
@NotBlank(message = "color不能为空")
private String color;
/** 规则类型 */
@ApiModelProperty(value = "规则类型", required = true, position = 9)
@ApiModelProperty(value = "规则类型", required = true, position = 8)
@NotBlank(message = "regType不能为空")
private String regType;
/** 可用状态 */
@ApiModelProperty(value = "可用状态", required = true, position = 10)
@ApiModelProperty(value = "可用状态", required = true, position = 9)
@NotBlank(message = "status不能为空")
private String status;
/** 排序码 */
@ApiModelProperty(value = "排序码", position = 11)
@ApiModelProperty(value = "排序码", position = 10)
private Integer sortCode;
}

View File

@ -53,28 +53,33 @@ public class MobileMenuEditParam {
@NotBlank(message = "category不能为空")
private String category;
/** 模块 */
@ApiModelProperty(value = "模块", required = true, position = 7)
@NotBlank(message = "module不能为空")
private String module;
/** 图标 */
@ApiModelProperty(value = "图标", required = true, position = 7)
@ApiModelProperty(value = "图标", required = true, position = 8)
@NotBlank(message = "icon不能为空")
private String icon;
/** 颜色 */
@ApiModelProperty(value = "颜色", required = true, position = 8)
@ApiModelProperty(value = "颜色", required = true, position = 9)
@NotBlank(message = "color不能为空")
private String color;
/** 规则类型 */
@ApiModelProperty(value = "规则类型", required = true, position = 9)
@ApiModelProperty(value = "规则类型", required = true, position = 10)
@NotBlank(message = "regType不能为空")
private String regType;
/** 可用状态 */
@ApiModelProperty(value = "可用状态", required = true, position = 10)
@ApiModelProperty(value = "可用状态", required = true, position = 11)
@NotBlank(message = "status不能为空")
private String status;
/** 排序码 */
@ApiModelProperty(value = "排序码", position = 11)
@ApiModelProperty(value = "排序码", position = 12)
private Integer sortCode;
}

View File

@ -0,0 +1,32 @@
/*
* Copyright [2022] [https://www.xiaonuo.vip]
*
* SnowyAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Snowy
* 3.使使
* 4. https://www.xiaonuo.vip
* 5.xiaonuobase@qq.com
* 6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.mobile.modular.resource.param.menu;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
*
*
* @author xuyuxiang
* @date 2022/7/27 18:40
**/
@Getter
@Setter
public class MobileMenuSelectorMenuParam {
/** 模块 */
@ApiModelProperty(value = "模块")
private String module;
}

View File

@ -0,0 +1,32 @@
/*
* Copyright [2022] [https://www.xiaonuo.vip]
*
* SnowyAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Snowy
* 3.使使
* 4. https://www.xiaonuo.vip
* 5.xiaonuobase@qq.com
* 6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.mobile.modular.resource.param.menu;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
*
*
* @author xuyuxiang
* @date 2022/7/27 18:40
**/
@Getter
@Setter
public class MobileMenuSelectorModuleParam {
/** 名称关键词 */
@ApiModelProperty(value = "名称关键词")
private String searchKey;
}

View File

@ -30,12 +30,8 @@ public class MobileMenuTreeParam {
@ApiModelProperty(value = "关键词")
private String searchKey;
/** 分类 */
@ApiModelProperty(value = "分类")
private String category;
/** 可用状态 */
@ApiModelProperty(value = "可用状态")
private String status;
/** 模块 */
@ApiModelProperty(value = "模块")
private String module;
}

View File

@ -15,10 +15,8 @@ package vip.xiaonuo.mobile.modular.resource.service;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.service.IService;
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
import java.util.List;
@ -77,4 +75,20 @@ public interface MobileMenuService extends IService<MobileMenu> {
* @date 2023/01/28 22:42
**/
MobileMenu queryEntity(String id);
/**
*
*
* @author yubaoshan
* @date 2023/01/28 22:42
**/
List<MobileModule> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam);
/**
*
*
* @author yubaoshan
* @date 2023/01/28 22:42
**/
List<Tree<String>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam);
}

View File

@ -25,13 +25,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vip.xiaonuo.common.exception.CommonException;
import vip.xiaonuo.mobile.modular.resource.entity.MobileMenu;
import vip.xiaonuo.mobile.modular.resource.entity.MobileModule;
import vip.xiaonuo.mobile.modular.resource.enums.MobileResourceCategoryEnum;
import vip.xiaonuo.mobile.modular.resource.mapper.MobileMenuMapper;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuAddParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuEditParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuIdParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.MobileMenuTreeParam;
import vip.xiaonuo.mobile.modular.resource.param.menu.*;
import vip.xiaonuo.mobile.modular.resource.service.MobileMenuService;
import vip.xiaonuo.mobile.modular.resource.service.MobileModuleService;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@ -44,18 +45,19 @@ import java.util.stream.Collectors;
@Service
public class MobileMenuServiceImpl extends ServiceImpl<MobileMenuMapper, MobileMenu> implements MobileMenuService {
@Resource
private MobileModuleService mobileModuleService;
@Override
public List<Tree<String>> tree(MobileMenuTreeParam mobileMenuTreeParam) {
LambdaQueryWrapper<MobileMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getCategory())) {
lambdaQueryWrapper.eq(MobileMenu::getCategory, mobileMenuTreeParam.getCategory());
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getModule())) {
lambdaQueryWrapper.eq(MobileMenu::getModule, mobileMenuTreeParam.getModule());
}
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getSearchKey())) {
lambdaQueryWrapper.like(MobileMenu::getTitle, mobileMenuTreeParam.getSearchKey());
}
if(ObjectUtil.isNotEmpty(mobileMenuTreeParam.getStatus())) {
lambdaQueryWrapper.like(MobileMenu::getStatus, mobileMenuTreeParam.getStatus());
}
lambdaQueryWrapper.eq(MobileMenu::getCategory, MobileResourceCategoryEnum.MENU.getValue());
lambdaQueryWrapper.orderByDesc(MobileMenu::getSortCode);
List<MobileMenu> mobileMenuList = this.list(lambdaQueryWrapper);
List<TreeNode<String>> treeNodeList = mobileMenuList.stream().map(mobileMenu ->
@ -98,4 +100,30 @@ public class MobileMenuServiceImpl extends ServiceImpl<MobileMenuMapper, MobileM
}
return mobileMenu;
}
@Override
public List<MobileModule> moduleSelector(MobileMenuSelectorModuleParam mobileMenuSelectorModuleParam) {
LambdaQueryWrapper<MobileModule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(ObjectUtil.isNotEmpty(mobileMenuSelectorModuleParam.getSearchKey())) {
lambdaQueryWrapper.like(MobileModule::getTitle, mobileMenuSelectorModuleParam.getSearchKey());
}
lambdaQueryWrapper.eq(MobileModule::getCategory, MobileResourceCategoryEnum.MODULE.getValue());
return mobileModuleService.list(lambdaQueryWrapper);
}
@Override
public List<Tree<String>> menuTreeSelector(MobileMenuSelectorMenuParam mobileMenuSelectorMenuParam) {
LambdaQueryWrapper<MobileMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// 查询类型为菜单的
lambdaQueryWrapper.eq(MobileMenu::getCategory, MobileResourceCategoryEnum.MENU.getValue());
if(ObjectUtil.isNotEmpty(mobileMenuSelectorMenuParam.getModule())) {
lambdaQueryWrapper.eq(MobileMenu::getModule, mobileMenuSelectorMenuParam.getModule());
}
List<MobileMenu> resourceList = this.list(lambdaQueryWrapper);
List<TreeNode<String>> treeNodeList = resourceList.stream().map(sysMenu ->
new TreeNode<>(sysMenu.getId(), sysMenu.getParentId(),
sysMenu.getTitle(), sysMenu.getSortCode()).setExtra(JSONUtil.parseObj(sysMenu)))
.collect(Collectors.toList());
return TreeUtil.build(treeNodeList, "0");
}
}

View File

@ -49,8 +49,10 @@ public class MobileModuleServiceImpl extends ServiceImpl<MobileModuleMapper, Mob
@Resource
private MobileMenuService mobileMenuService;
/*
@Resource
/*private MobileRelationService mobileRelationService;*/
private MobileRelationService mobileRelationService;
*/
@Override
public Page<MobileModule> page(MobileModulePageParam mobileModulePageParam) {

View File

@ -1,26 +0,0 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Records of dev_dict
-- ----------------------------
INSERT INTO `dev_dict` VALUES ('1619343323218432002', '0', '移动菜单状态', 'MOBILE_STATUS', 'FRM', 93, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619343680636047362', '1619343323218432002', '可用', 'ENABLE', 'FRM', 94, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619343846382358529', '1619343323218432002', '不可用', 'DISABLED', 'FRM', 96, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344256295882753', '0', '移动菜单规则', 'MOBILE_IS_REG_EXP', 'FRM', 97, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344428111351809', '1619344256295882753', '正规则', 'YES', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344504456073218', '1619344256295882753', '反规则', 'NO', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
-- ----------------------------
-- Records of sys_relation
-- ----------------------------
INSERT INTO `sys_relation` VALUES ('1619345262266142721', '1570687866138206208', '1619345262001901569', 'SYS_ROLE_HAS_RESOURCE', '{\"menuId\":\"1619345262001901569\",\"buttonInfo\":[\"1619345262085787650\",\"1619345262131924994\",\"1619345262131924995\",\"1619345262131924996\"]}');
-- ----------------------------
-- Records of sys_resource
-- ----------------------------
INSERT INTO `sys_resource` VALUES ('1619345262001901569', '0', '移动管理', NULL, 'gsnnmdy8yi', 'MENU', '1548901111999770525', 'CATALOG', '/a0l7fxfq3m', NULL, 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `sys_resource` VALUES ('1619345262001901570', '1619345262001901569', '菜单类别', 'category', 'psf3uj3q90', 'MENU', '1548901111999770525', 'MENU', '/mobile/category', 'mobile/category/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `sys_resource` VALUES ('1619345262001901571', '1619345262001901569', '移动菜单', 'menu', '4a84jeju7l', 'MENU', '1548901111999770525', 'MENU', '/mobile/menu', 'mobile/menu/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -1,19 +1,3 @@
/*
Navicat Premium Data Transfer
Source Server : Mysql
Source Server Type : MySQL
Source Server Version : 80026
Source Host : localhost:3306
Source Schema : snowy
Target Server Type : MySQL
Target Server Version : 80026
File Encoding : 65001
Date: 30/01/2023 16:50:05
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
@ -44,7 +28,25 @@ CREATE TABLE `mobile_resource` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '移动资源' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of mobile_resource
-- Records of dev_dict
-- ----------------------------
INSERT INTO `dev_dict` VALUES ('1619343323218432002', '0', '移动菜单状态', 'MOBILE_STATUS', 'FRM', 93, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619343680636047362', '1619343323218432002', '可用', 'ENABLE', 'FRM', 94, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619343846382358529', '1619343323218432002', '不可用', 'DISABLED', 'FRM', 96, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344256295882753', '0', '移动菜单规则', 'MOBILE_REG_TYPE', 'FRM', 97, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344428111351809', '1619344256295882753', '正规则', 'YES', 'FRM', 98, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `dev_dict` VALUES ('1619344504456073218', '1619344256295882753', '反规则', 'NO', 'FRM', 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
-- ----------------------------
-- Records of sys_relation
-- ----------------------------
INSERT INTO `sys_relation` VALUES ('1619345262266142721', '1570687866138206208', '1619345262001901569', 'SYS_ROLE_HAS_RESOURCE', '{\"menuId\":\"1619345262001901569\",\"buttonInfo\":[\"1619345262085787650\",\"1619345262131924994\",\"1619345262131924995\",\"1619345262131924996\"]}');
-- ----------------------------
-- Records of sys_resource
-- ----------------------------
INSERT INTO `sys_resource` VALUES ('1619345262001901569', '0', '移动管理', NULL, 'gsnnmdy8yj', 'MENU', '1548901111999770525', 'CATALOG', '/a0l7fxfq3n', NULL, 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `sys_resource` VALUES ('1619345262001901570', '1619345262001901569', '菜单类别', 'module', 'psf3uj3q90', 'MENU', '1548901111999770525', 'MENU', '/mobile/module', 'mobile/resource/module/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
INSERT INTO `sys_resource` VALUES ('1619345262001901571', '1619345262001901569', '移动菜单', 'menu', '4a84jeju7l', 'MENU', '1548901111999770525', 'MENU', '/mobile/menu', 'mobile/resource/menu/index', 'appstore-outlined', NULL, 99, NULL, 'NOT_DELETE', NULL, NULL, NULL, NULL);
SET FOREIGN_KEY_CHECKS = 1;