refactor(system): 优化系统模块代码结构和功能
- 修改 MyMetaObjectHandler 中的时间处理方式,使用 Date 类型替代 Timestamp - 新增 AnyQueryTool 工具类,提供通用的 MyBatis Plus 查询方法 - 优化 YamlEdit 组件,增加只读模式和默认高度设置 -修复 CuteDeptTree 组件中的数据获取方法名称 - 调整系统菜单组件中的输入框宽度
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
<template>
|
||||
<div class="json-editor">
|
||||
<textarea ref="textarea" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -18,7 +16,13 @@ export default {
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
required: true
|
||||
required: false,
|
||||
default: '450px'
|
||||
},
|
||||
readOnly: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -33,8 +37,8 @@ export default {
|
||||
this.editor.setValue(this.value)
|
||||
}
|
||||
},
|
||||
height(value) {
|
||||
this.editor.setSize('auto', this.height)
|
||||
height(newHeight) {
|
||||
this.editor.setSize('auto', newHeight)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -49,7 +53,10 @@ export default {
|
||||
theme: 'idea'
|
||||
})
|
||||
this.editor.setSize('auto', this.height)
|
||||
if (this.value) {
|
||||
this.editor.setValue(this.value)
|
||||
}
|
||||
this.editor.setOption('readOnly', this.readOnly)
|
||||
this.editor.on('change', cm => {
|
||||
this.$emit('changed', cm.getValue())
|
||||
this.$emit('input', cm.getValue())
|
||||
@@ -62,20 +69,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.json-editor{
|
||||
height: 100%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.json-editor >>> .CodeMirror {
|
||||
font-size: 13px;
|
||||
overflow-y:auto;
|
||||
font-weight:normal
|
||||
}
|
||||
.json-editor >>> .CodeMirror-scroll{
|
||||
}
|
||||
.json-editor >>> .cm-s-rubyblue span.cm-string {
|
||||
color: #F08047;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
placeholder="输入部门名称搜索"
|
||||
prefix-icon="el-icon-search"
|
||||
class="filter-item"
|
||||
@input="getDeptDatas"
|
||||
@input="getDeptData"
|
||||
/>
|
||||
</div>
|
||||
<el-tree
|
||||
@@ -64,7 +64,7 @@ export default {
|
||||
if (resolve) {
|
||||
resolve(res.content)
|
||||
} else {
|
||||
this.deptDatas = res.content
|
||||
this.deptData = res.content
|
||||
}
|
||||
})
|
||||
}, 100)
|
||||
|
||||
@@ -68,10 +68,10 @@
|
||||
<el-input-number v-model.number="form.menuSort" :min="0" :max="999" controls-position="right" style="width: 178px;" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.iFrame.toString() !== 'true' && form.type.toString() === '1'" label="组件名称" prop="componentName">
|
||||
<el-input v-model="form.componentName" style="width: 178px;" placeholder="匹配组件内Name字段" />
|
||||
<el-input v-model="form.componentName" style="width: 450px;" placeholder="匹配组件内Name字段" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.iFrame.toString() !== 'true' && form.type.toString() === '1'" label="组件路径" prop="component">
|
||||
<el-input v-model="form.component" style="width: 178px;" placeholder="组件路径" />
|
||||
<el-input v-model="form.component" style="width: 450px;" placeholder="组件路径" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级类目" prop="pid">
|
||||
<treeselect
|
||||
|
||||
+5
-4
@@ -5,16 +5,17 @@ import cn.odboy.core.framework.permission.util.SecurityHelper;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
DateTime now = DateTime.now();
|
||||
/* 创建时间 */
|
||||
this.strictInsertFill(metaObject, "createTime", Timestamp.class, DateTime.now().toTimestamp());
|
||||
this.strictInsertFill(metaObject, "updateTime", Timestamp.class, DateTime.now().toTimestamp());
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, now);
|
||||
this.strictInsertFill(metaObject, "updateTime", Date.class, now);
|
||||
/* 操作人 */
|
||||
String username = "System";
|
||||
try {
|
||||
@@ -28,7 +29,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
/* 更新时间 */
|
||||
this.strictUpdateFill(metaObject, "updateTime", Timestamp.class, DateTime.now().toTimestamp());
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, DateTime.now());
|
||||
/* 操作人 */
|
||||
String username = "System";
|
||||
try {
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package cn.odboy.core.framework.mybatisplus.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义任意对象查询工具
|
||||
*
|
||||
* @author odboy
|
||||
* @date 2025-05-15
|
||||
*/
|
||||
@Component
|
||||
public class AnyQueryTool {
|
||||
public <T> T selectOne(BaseMapper<T> baseMapper, Object queryParams) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
public <T, M> M selectOne(BaseMapper<T> baseMapper, Object queryParams, Class<M> mapperClazz) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
T mapperTarget = baseMapper.selectOne(queryWrapper);
|
||||
if (mapperTarget == null) {
|
||||
return null;
|
||||
}
|
||||
return BeanUtil.copyProperties(mapperTarget, mapperClazz);
|
||||
}
|
||||
|
||||
public <T> List<T> selectList(BaseMapper<T> baseMapper, Object queryParams) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public <T, M> List<M> selectList(BaseMapper<T> baseMapper, Object queryParams, Class<M> mapperClazz) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
List<T> mapperTarget = baseMapper.selectList(queryWrapper);
|
||||
if (mapperTarget == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return BeanUtil.copyToList(mapperTarget, mapperClazz);
|
||||
}
|
||||
|
||||
public <T> Long selectCount(BaseMapper<T> baseMapper, Object queryParams) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
return baseMapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
public <T> Page<T> selectPage(BaseMapper<T> baseMapper, Page<T> page, Object queryParams) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
return baseMapper.selectPage(page, queryWrapper);
|
||||
}
|
||||
|
||||
public <T, M> Page<M> selectPage(BaseMapper<T> baseMapper, Page<T> page, Object queryParams, Class<M> mapperClazz) {
|
||||
QueryWrapper<T> queryWrapper = MybatisHelper.build(queryParams);
|
||||
Page<T> tPage = baseMapper.selectPage(page, queryWrapper);
|
||||
Page<M> mapperTarget = new Page<>();
|
||||
mapperTarget.setRecords(BeanUtil.copyToList(tPage.getRecords(), mapperClazz));
|
||||
mapperTarget.setTotal(tPage.getTotal());
|
||||
mapperTarget.setSize(tPage.getSize());
|
||||
mapperTarget.setCurrent(tPage.getCurrent());
|
||||
return mapperTarget;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user