This commit is contained in:
zhuokongming 2020-03-19 14:05:42 +08:00
parent 478b39d61a
commit a6d3ace808
13 changed files with 167 additions and 48 deletions

View File

@ -149,6 +149,10 @@ public class CodeGeneratorService {
int targetIndex = StringUtils.indexOf(projectPath, targetDir);
projectPath = projectPath.substring(0, targetIndex + targetDir.length() + 1);
projectPath = projectPath.replace("target/", "").replaceFirst("/", "");
Velocity.setProperty("input.encoding", "UTF-8");
Velocity.setProperty("output.encoding", "UTF-8");
for (Entry<String, String> entry : codeTemplates.entrySet()) {
String template = entry.getKey();
String filePath = projectPath + entry.getValue();

View File

@ -21,7 +21,7 @@ public enum IdGeneratorEnum {
ORDER(1, "order");
private int id;
private long id;
private String keyName;
IdGeneratorEnum(int id, String keyName) {
@ -34,7 +34,7 @@ public enum IdGeneratorEnum {
return "IdGeneratorEnum{" + "id=" + id + ", keyName='" + keyName + '\'' + '}';
}
public int getId() {
public long getId() {
return id;
}

View File

@ -115,16 +115,19 @@ public class PrivilegeEmployeeService {
* @return
*/
public List<PrivilegeEntity> getPrivilegesByEmployeeId(Long employeeId) {
List<PrivilegeEntity> privilegeEntities = null;
// 如果是超管的话
Boolean isSuperman = this.isSuperman(employeeId);
if (isSuperman) {
List<PrivilegeEntity> privilegeEntities = privilegeDao.selectAll();
if (privilegeEntities == null) {
return Lists.newArrayList();
}
return privilegeEntities;
privilegeEntities = privilegeDao.selectAll();
} else {
privilegeEntities = loadPrivilegeFromDb(employeeId);
}
List<PrivilegeEntity> privilegeEntities = loadPrivilegeFromDb(employeeId);
if (privilegeEntities == null) {
privilegeEntities = Lists.newArrayList();
}
this.updateCachePrivilege(employeeId, privilegeEntities);
return privilegeEntities;
}

View File

@ -8,6 +8,7 @@ import com.gangquan360.smartadmin.module.quartz.task.ITask;
import com.gangquan360.smartadmin.third.SmartApplicationContext;
import com.gangquan360.smartadmin.util.SmartIPUtil;
import com.gangquan360.smartadmin.util.SmartQuartzUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@ -28,6 +29,7 @@ import java.util.Date;
* @date
* @since JDK1.8
*/
@Slf4j
public class QuartzTask extends QuartzJobBean {
@Override
@ -59,7 +61,7 @@ public class QuartzTask extends QuartzJobBean {
ITask taskClass = (ITask) SmartApplicationContext.getBean(quartzTaskEntity.getTaskBean());
taskClass.execute(paramsStr);
taskLogEntity.setProcessStatus(TaskResultEnum.SUCCESS.getStatus());
} catch (Exception e) {
} catch (Throwable e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
e.printStackTrace(pw);
@ -67,6 +69,7 @@ public class QuartzTask extends QuartzJobBean {
sw.flush();
taskLogEntity.setProcessStatus(TaskResultEnum.FAIL.getStatus());
taskLogEntity.setProcessLog(sw.toString());
log.error("",e);
} finally {
long times = System.currentTimeMillis() - startTime;
taskLogEntity.setProcessDuration(times);

View File

@ -82,6 +82,9 @@ public class SystemConfigService {
* @return
*/
public ResponseDTO<PageResultDTO<SystemConfigVO>> getSystemConfigPage(SystemConfigQueryDTO queryDTO) {
if(queryDTO.getKey() != null){
queryDTO.setKey(queryDTO.getKey().toLowerCase());
}
Page page = SmartPaginationUtil.convert2PageQueryInfo(queryDTO);
List<SystemConfigEntity> entityList = systemConfigDao.selectSystemSettingList(page, queryDTO);
PageResultDTO<SystemConfigVO> pageResultDTO = SmartPaginationUtil.convert2PageResultDTO(page, entityList, SystemConfigVO.class);
@ -95,6 +98,9 @@ public class SystemConfigService {
* @return
*/
public ResponseDTO<SystemConfigVO> selectByKey(String configKey) {
if(configKey != null){
configKey = configKey.toLowerCase();
}
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
if (entity == null) {
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
@ -112,6 +118,9 @@ public class SystemConfigService {
* @return
*/
public <T> T selectByKey2Obj(String configKey, Class<T> clazz) {
if(configKey != null){
configKey = configKey.toLowerCase();
}
SystemConfigEntity entity = systemConfigDao.getByKey(configKey);
if (entity == null) {
return null;
@ -140,7 +149,7 @@ public class SystemConfigService {
* @return
*/
public ResponseDTO<String> addSystemConfig(SystemConfigAddDTO configAddDTO) {
SystemConfigEntity entity = systemConfigDao.getByKey(configAddDTO.getConfigKey());
SystemConfigEntity entity = systemConfigDao.getByKey(configAddDTO.getConfigKey().toLowerCase());
if (entity != null) {
return ResponseDTO.wrap(SystemConfigResponseCodeConst.ALREADY_EXIST);
}
@ -148,6 +157,7 @@ public class SystemConfigService {
if(!valueValid.isSuccess()){
return valueValid;
}
configAddDTO.setConfigKey(configAddDTO.getConfigKey().toLowerCase());
SystemConfigEntity addEntity = SmartBeanUtil.copy(configAddDTO, SystemConfigEntity.class);
addEntity.setIsUsing(JudgeEnum.YES.getValue());
systemConfigDao.insert(addEntity);
@ -168,7 +178,7 @@ public class SystemConfigService {
if (entity == null) {
return ResponseDTO.wrap(SystemConfigResponseCodeConst.NOT_EXIST);
}
SystemConfigEntity alreadyEntity = systemConfigDao.getByKeyExcludeId(updateDTO.getConfigKey(), updateDTO.getId());
SystemConfigEntity alreadyEntity = systemConfigDao.getByKeyExcludeId(updateDTO.getConfigKey().toLowerCase(), updateDTO.getId());
if (alreadyEntity != null) {
return ResponseDTO.wrap(SystemConfigResponseCodeConst.ALREADY_EXIST);
}
@ -177,6 +187,7 @@ public class SystemConfigService {
return valueValid;
}
entity = SmartBeanUtil.copy(updateDTO, SystemConfigEntity.class);
updateDTO.setConfigKey(updateDTO.getConfigKey().toLowerCase());
systemConfigDao.updateById(entity);
//刷新缓存

View File

@ -29,7 +29,7 @@ export const taskApi = {
return getAxios(`/quartz/task/resume/${taskId}`);
},
// 删除任务
deleteTasks: (taskId) => {
deleteTask: (taskId) => {
return getAxios(`/quartz/task/delete/${taskId}`);
}
};

View File

@ -9,7 +9,7 @@ export default {
return showTitle(item, this);
},
showChildren (item) {
return item.children && (item.children.length > 1 || (item.meta && item.meta.showAlways));
return item.children && (item.children.length > 0 || (item.meta && item.meta.showAlways));
},
getNameOrHref (item, children0) {
return item.href ? `isTurnByHref_${item.href}` : (children0 ? item.children[0].name : item.name);

View File

@ -11,9 +11,9 @@
v-show="!collapsed"
width="auto"
>
<template v-for="item in menuList">
<template v-for="item in menuList">
<template v-if="item.children && item.children.length === 1">
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="showChildren(item)"></side-menu-item>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item.children[0]" v-if="item.children[0].children && item.children[0].children.length > 0 "></side-menu-item>
<menu-item
:key="`menu-${item.children[0].name}`"
:name="getNameOrHref(item, true)"
@ -24,7 +24,7 @@
</menu-item>
</template>
<template v-else>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="showChildren(item)"></side-menu-item>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="item.children && item.children.length > 0"></side-menu-item>
<menu-item :key="`menu-${item.name}`" :name="getNameOrHref(item)" v-else>
<common-icon :type="item.icon || ''" />
<span>{{ showTitle(item) }}</span>
@ -81,6 +81,13 @@ export default {
CollapsedMenu
},
props: {
// path
menuNameMatchedMap:{
type: Map,
default() {
return new Map();
}
},
//
menuList: {
type: Array,
@ -161,6 +168,7 @@ export default {
},
methods: {
updateActiveName(name){
this.updateOpenName(name);
this.$nextTick(() => {
this.$refs.menu.updateOpened();
this.$refs.menu.updateActiveName(name);
@ -171,13 +179,15 @@ export default {
},
//
getOpenedNamesByActiveName(name) {
return this.$route.matched
.map(item => item.name)
.filter(item => item !== name);
let array = this.menuNameMatchedMap.get(name);
if(array){
return array;
}else{
return [];
}
},
updateOpenName(name) {
if (name === this.$config.homeName) this.openedNames = [];
else this.openedNames = this.getOpenedNamesByActiveName(name);
this.openedNames = this.menuNameMatchedMap.get(name);
}
}
};

View File

@ -10,6 +10,7 @@
v-model="collapsed"
>
<SideMenu
:menuNameMatchedMap="menuNameMatchedMap"
:active-name="$route.name"
:collapsed="collapsed"
:menu-list="menuList"
@ -123,7 +124,8 @@ export default {
searchKeyWord: '',
searchList: [],
searchListResult: [],
menuList: []
menuList: [],
menuNameMatchedMap:new Map()
};
},
computed: {
@ -284,6 +286,7 @@ export default {
icon: _.isUndefined(router.meta.icon) ? '' : router.meta.icon,
children: []
};
this.menuNameMatchedMap.set(menu.name,[menu.name]);
privilegeTree.push(menu);
//
if (router.children && router.children.length > 0) {
@ -292,11 +295,17 @@ export default {
}
}
}
console.log('privilegeTree',privilegeTree)
this.menuList = privilegeTree;
},
recursion(children, parentMenu) {
for (const router of children) {
//
if (this.$store.state.user.privilegeMenuKeyList.indexOf(router.name) ===-1) {
continue;
}
//
if (!router.meta.hideInMenu) {
let menu = {
@ -309,6 +318,10 @@ export default {
name: router.name,
title: router.meta.title
});
let menuNameArray = this.menuNameMatchedMap.get(parentMenu.name);
this.menuNameMatchedMap.set(menu.name,[...menuNameArray,menu.name]);
parentMenu.children.push(menu);
//
if (router.children && router.children.length > 0) {

View File

@ -12,7 +12,8 @@ const { homeName } = config;
Vue.use(Router);
const router = new Router({
routes: routers
// routes: routers,
routes: buildRouters(routers)
// mode: 'history'
});
const LOGIN_PAGE_NAME = 'login';
@ -107,6 +108,63 @@ let tempCheckObj = {
checkRouterPathMap: new Map()
};
function buildRouters (routerArray) {
let lineRouters = [];
for (let routerItem of routerArray) {
//如果是顶层菜单
if (routerItem.meta.topMenu) {
// for (let children of routerItem.children) {
let lineRouterArray = convertRouterTree2Line(routerItem.children);
lineRouters.push(...lineRouterArray);
// }
} else {
let lineRouterArray = convertRouterTree2Line([routerItem]);
lineRouters.push(...lineRouterArray);
}
}
return lineRouters;
}
function convertRouterTree2Line (routerArray) {
//一级,比如 人员管理
let topArray = [];
for (let router1Item of routerArray) {
let level2Array = [];
//二级,比如员工管理
if (router1Item.children) {
for (let level2Item of router1Item.children) {
let level2ItemCopy = {};
for (let property in level2Item) {
if ('children' !== property) {
level2ItemCopy[property] = level2Item[property];
}
}
//三级,
if (level2Item.children) {
level2Array.push(...level2Item.children)
}
level2ItemCopy.children = [];
level2Array.push(level2Item);
}
}
let newTopRouterItem = {};
for (let property in router1Item) {
if ('children' !== property) {
newTopRouterItem[property] = router1Item[property];
}
}
newTopRouterItem.children = level2Array;
topArray.push(newTopRouterItem);
}
return topArray;
}
function recursionRouter (routerArray) {
for (let routerItem of routerArray) {
if (!routerItem.name) {
@ -146,9 +204,12 @@ function recursionRouter (routerArray) {
}
}
recursionRouter(routers);
delete tempCheckObj.checkRouterNameMap;
delete tempCheckObj.checkRouterPathMap;
//如果是开发环境需要检测router的规范性
if (process.env.NODE_ENV === 'development') {
recursionRouter(routers);
delete tempCheckObj.checkRouterNameMap;
delete tempCheckObj.checkRouterPathMap;
}
export default router;

View File

@ -17,7 +17,6 @@ export const threeRouter = [
meta: {
title: '三级菜单'
},
component: () => import('@/views/home'),
children: [
{
path: '/three-router/level-two/level-three1',
@ -29,7 +28,7 @@ export const threeRouter = [
{ title: '删除', name: 'roleOneTwo-delete' }
]
},
component: () => import('@/views/home')
component: () => import('@/views/three-router/three-content')
},
{
path: '/three-router/level-two/level-three2',
@ -41,7 +40,7 @@ export const threeRouter = [
{ title: '删除', name: 'roleTwoTwo-delete' }
]
},
component: () => import('@/views/home')
component: () => import('@/views/three-router/three-content')
}
]
},
@ -55,7 +54,7 @@ export const threeRouter = [
{ title: '删除', name: 'roleOneOne-delete' }
]
},
component: () => import('@/views/home')
component: () => import('@/views/three-router/three-content')
}
]
}

View File

@ -80,19 +80,8 @@
<span>任务调度日志</span>
</Col>
</Row>
<Tables
:columns="logColumns"
:current="logPageNum"
:page-size="changeLogPageSize"
:pageShow="true"
:show-elevator="false"
:show-sizer="false"
:total="logPageTotal"
:value="logData"
@on-change="logChangePage"
style="height: 420px;"
v-if="hasLog"
></Tables>
<Table border :columns="logColumns" :data="logData"></Table>
<Page show-total @on-change="changeLogPageNum" :current="logPageNum" :total="logTotal" show-sizer />
<div slot="footer">
<Button @click="closeLog" type="primary">关闭</Button>
</div>
@ -125,8 +114,8 @@ export default {
pageSize: 10,
pageTotal: 0,
logPageNum: 1,
logPageSize: 6,
logPageTotal: 0,
logPageSize: 10,
logTotal: 0,
updateItem: {
taskBean: '',
taskCron: '',
@ -387,7 +376,7 @@ export default {
taskId: this.taskId
});
this.logData = result.data.list;
this.logPageTotal = result.data.total;
this.logTotal = result.data.total;
this.logPageNum = result.data.pageNum;
this.logPageSize = result.data.pageSize;
this.hasLog = true;
@ -405,7 +394,7 @@ export default {
this.getTaskList();
},
//
changeLogPageSize(pageNum) {
changeLogPageNum(pageNum) {
this.logPageNum = pageNum;
this.getTaskLog();
},

View File

@ -0,0 +1,26 @@
<template>
<Card class="warp-card" dis-hover>
<Alert>
<h3>三级路由页面</h3>
<pre>
这个是三级路由页面
</pre>
</Alert>
</Card>
</template>
<script>
export default {
name: 'ThreeContent',
components: {},
props: {},
data() {
return {
};
},
mounted() {
},
methods: {
}
};
</script>