工单系统初始化数据
This commit is contained in:
@@ -128,7 +128,6 @@ public class MenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('sys:menu:update')")
|
@PreAuthorize("hasAuthority('sys:menu:update')")
|
||||||
@OperationLog
|
|
||||||
@ApiOperation("菜单克隆")
|
@ApiOperation("菜单克隆")
|
||||||
@PostMapping("/clone")
|
@PostMapping("/clone")
|
||||||
public ApiResult<?> onClone(@RequestBody MenuParam param){
|
public ApiResult<?> onClone(@RequestBody MenuParam param){
|
||||||
@@ -144,7 +143,6 @@ public class MenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('sys:menu:update')")
|
@PreAuthorize("hasAuthority('sys:menu:update')")
|
||||||
@OperationLog
|
|
||||||
@ApiOperation("安装插件")
|
@ApiOperation("安装插件")
|
||||||
@GetMapping("/install/{id}")
|
@GetMapping("/install/{id}")
|
||||||
public ApiResult<?> install(@PathVariable("id") Integer id){
|
public ApiResult<?> install(@PathVariable("id") Integer id){
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package com.gxwebsoft.common.system.mapper;
|
package com.gxwebsoft.common.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.gxwebsoft.common.system.entity.Role;
|
import com.gxwebsoft.common.system.entity.Role;
|
||||||
|
import com.gxwebsoft.common.system.param.RoleParam;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色Mapper
|
* 角色Mapper
|
||||||
@@ -11,4 +16,6 @@ import com.gxwebsoft.common.system.entity.Role;
|
|||||||
*/
|
*/
|
||||||
public interface RoleMapper extends BaseMapper<Role> {
|
public interface RoleMapper extends BaseMapper<Role> {
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
List<Role> selectListAll(@Param("param") RoleParam param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.gxwebsoft.common.system.mapper.RoleMapper">
|
<mapper namespace="com.gxwebsoft.common.system.mapper.RoleMapper">
|
||||||
|
<!-- 关联查询sql -->
|
||||||
|
<sql id="selectSql">
|
||||||
|
SELECT a.*
|
||||||
|
FROM sys_role a
|
||||||
|
<where>
|
||||||
|
<if test="param.roleCode != null">
|
||||||
|
AND a.role_code = #{param.roleCode}
|
||||||
|
</if>
|
||||||
|
<if test="param.tenantId != null">
|
||||||
|
AND a.tenant_id = #{param.tenantId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
<!-- 查询全部 -->
|
||||||
|
<select id="selectListAll" resultType="com.gxwebsoft.common.system.entity.Role">
|
||||||
|
<include refid="selectSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package com.gxwebsoft.common.system.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.gxwebsoft.common.system.entity.Menu;
|
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||||
import com.gxwebsoft.common.system.entity.Role;
|
import com.gxwebsoft.common.system.entity.*;
|
||||||
import com.gxwebsoft.common.system.entity.RoleMenu;
|
|
||||||
import com.gxwebsoft.common.system.mapper.MenuMapper;
|
import com.gxwebsoft.common.system.mapper.MenuMapper;
|
||||||
|
import com.gxwebsoft.common.system.mapper.RoleMapper;
|
||||||
import com.gxwebsoft.common.system.param.MenuParam;
|
import com.gxwebsoft.common.system.param.MenuParam;
|
||||||
import com.gxwebsoft.common.system.service.MenuService;
|
import com.gxwebsoft.common.system.param.RoleParam;
|
||||||
import com.gxwebsoft.common.system.service.RoleMenuService;
|
import com.gxwebsoft.common.system.service.*;
|
||||||
import com.gxwebsoft.common.system.service.RoleService;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,6 +30,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
@Resource
|
@Resource
|
||||||
private RoleMenuService roleMenuService;
|
private RoleMenuService roleMenuService;
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
@Resource
|
||||||
|
private UserRoleService userRoleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
@Transactional(rollbackFor = {Exception.class}, isolation = Isolation.SERIALIZABLE)
|
||||||
@@ -39,8 +43,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
baseMapper.delete(new LambdaQueryWrapper<Menu>().eq(Menu::getDeleted,0));
|
baseMapper.delete(new LambdaQueryWrapper<Menu>().eq(Menu::getDeleted,0));
|
||||||
// 顶级栏目
|
// 顶级栏目
|
||||||
param.setParentId(0);
|
param.setParentId(0);
|
||||||
// final List<Menu> list = baseMapper.getMenuByClone(param);
|
// 工单系统
|
||||||
//// final List<Integer> menuIds = list.stream().map(Menu::getMenuId).collect(Collectors.toList());
|
if (param.getTenantId().equals(10125)) {
|
||||||
|
// 初始化数据
|
||||||
|
initializedData();
|
||||||
|
}
|
||||||
|
// 开始克隆
|
||||||
doCloneMenu(baseMapper.getMenuByClone(param));
|
doCloneMenu(baseMapper.getMenuByClone(param));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -142,4 +150,66 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
private void initializedData(){
|
||||||
|
Role role = new Role();
|
||||||
|
User user = new User();
|
||||||
|
UserRole userRole = new UserRole();
|
||||||
|
if(roleService.count(new LambdaQueryWrapper<Role>().eq(Role::getRoleCode, "admin")) == 0){
|
||||||
|
role.setRoleCode("admin");
|
||||||
|
role.setRoleName("管理人员");
|
||||||
|
role.setComments("工单分派管理专员");
|
||||||
|
roleService.save(role);
|
||||||
|
if(userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, "管理人员")) == 0){
|
||||||
|
user.setUsername("刘备");
|
||||||
|
user.setNickname("刘备");
|
||||||
|
user.setPhone("13800138001");
|
||||||
|
user.setPassword(userService.encodePassword("123456"));
|
||||||
|
user.setSex("1");
|
||||||
|
userService.save(user);
|
||||||
|
// 添加用户角色
|
||||||
|
userRole.setRoleId(role.getRoleId());
|
||||||
|
userRole.setUserId(user.getUserId());
|
||||||
|
userRoleService.save(userRole);
|
||||||
|
// 添加统计表
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(roleService.count(new LambdaQueryWrapper<Role>().eq(Role::getRoleCode, "commander")) == 0){
|
||||||
|
role.setRoleCode("commander");
|
||||||
|
role.setRoleName("受理人员");
|
||||||
|
role.setComments("负责解决问题的处理人员");
|
||||||
|
roleService.save(role);
|
||||||
|
if(userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, "commander")) == 0){
|
||||||
|
user.setUsername("关羽");
|
||||||
|
user.setNickname("关羽");
|
||||||
|
user.setPhone("13800138002");
|
||||||
|
user.setPassword(userService.encodePassword("123456"));
|
||||||
|
user.setSex("1");
|
||||||
|
userService.save(user);
|
||||||
|
// 添加用户角色
|
||||||
|
userRole.setRoleId(role.getRoleId());
|
||||||
|
userRole.setUserId(user.getUserId());
|
||||||
|
userRoleService.save(userRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(roleService.count(new LambdaQueryWrapper<Role>().eq(Role::getRoleCode, "promoter")) == 0){
|
||||||
|
role.setRoleCode("promoter");
|
||||||
|
role.setRoleName("工单发起人");
|
||||||
|
role.setComments("问题及需求的发起人");
|
||||||
|
roleService.save(role);
|
||||||
|
if(userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, "promoter")) == 0){
|
||||||
|
user.setUsername("张飞");
|
||||||
|
user.setNickname("张飞");
|
||||||
|
user.setPassword(userService.encodePassword("123456"));
|
||||||
|
user.setSex("1");
|
||||||
|
userService.save(user);
|
||||||
|
// 添加用户角色
|
||||||
|
userRole.setRoleId(role.getRoleId());
|
||||||
|
userRole.setUserId(user.getUserId());
|
||||||
|
userRoleService.save(userRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user