Compare commits

...

30 Commits

Author SHA1 Message Date
sxu c01eeb505d 新增公司 2025-01-05 21:09:00 +08:00
sxu c802aa082e 新增公司 2025-01-05 20:22:10 +08:00
sxu 5021c02115 新增公司 2025-01-05 20:00:45 +08:00
sxu 4dfc5570cb 新增公司 2025-01-05 19:44:58 +08:00
sxu 3e5b0245af 新增公司 2025-01-05 16:34:14 +08:00
sxu 093093e650 新增公司 2025-01-05 12:32:37 +08:00
sxu 6004d6ab3b 新增公司 2025-01-05 12:17:44 +08:00
sxu 8c6494baef 新增公司 2025-01-05 12:13:36 +08:00
sxu 66cf195033 新增公司 2025-01-05 12:05:03 +08:00
sxu b29ee64423 新增公司 2025-01-05 11:12:45 +08:00
sxu 53f6e98185 新增公司 2025-01-05 11:02:05 +08:00
sxu 8920722356 新增公司 2025-01-05 10:38:18 +08:00
sxu 79bf7f5f4a 新增公司 2025-01-05 10:19:04 +08:00
sxu fa3016819b 新增公司 2025-01-05 09:55:58 +08:00
sxu e3a6759569 新增公司 2025-01-05 09:47:30 +08:00
sxu 7251823161 新增公司 2025-01-05 09:43:26 +08:00
sxu e36d04ec40 新增公司 2025-01-05 09:26:54 +08:00
sxu 3796dd92ef 新增公司 2025-01-05 00:39:26 +08:00
sxu 340a724dfc 新增公司 2025-01-05 00:04:24 +08:00
sxu f5ae2fb1a2 新增公司 2025-01-04 23:59:03 +08:00
sxu 9847f0b275 新增公司 2025-01-04 23:56:54 +08:00
sxu 366bb2fc8a 新增公司 2025-01-04 23:42:10 +08:00
sxu a7aadb246f 新增公司 2025-01-04 23:38:51 +08:00
sxu 0a1498e973 新增公司 2025-01-04 23:31:15 +08:00
sxu c8f8231ec8 新增公司 2025-01-04 23:05:13 +08:00
sxu 508a4bd302 新增公司 2025-01-04 22:54:32 +08:00
sxu 1566d127ec 新增公司 2025-01-04 22:31:36 +08:00
sxu 8494438c24 新增公司 2025-01-04 22:00:45 +08:00
sxu 4ce1078a1b 新增公司 2025-01-04 11:20:56 +08:00
sxu 49996f6530 新增公司 2025-01-04 11:08:07 +08:00
34 changed files with 1000 additions and 65 deletions

View File

@ -73,6 +73,10 @@ public class SysDept extends BaseEntity {
* 父部门名称
*/
private String parentName;
//权限模版ID
private Long menuTemplateId;
/**
*
*/
@ -91,6 +95,50 @@ public class SysDept extends BaseEntity {
*/
private String address;
/**
* 公司简称
*/
private String deptAbbreviation;
/**
* 公司概述
*/
private String remark;
/**
* logo
*/
private String logo;
//公司管理员用户ID
private Long adminUserId;
/**
* 公司用户初始密码
*/
private String initPassword;
private SysUser sysUser;
/**
* 所属公司ID
*/
private Long companyId;
/**
*角色名称
*/
private String roleName;
private String keyWord;
public Long getMenuTemplateId() {
return menuTemplateId;
}
public void setMenuTemplateId(Long menuTemplateId) {
this.menuTemplateId = menuTemplateId;
}
public void setCity(String city) {
this.city = city;
@ -127,6 +175,79 @@ public class SysDept extends BaseEntity {
this.province = province;
}
public String getDeptAbbreviation() {
return deptAbbreviation;
}
public void setDeptAbbreviation(String deptAbbreviation) {
this.deptAbbreviation = deptAbbreviation;
}
@Override
public String getRemark() {
return remark;
}
@Override
public void setRemark(String remark) {
this.remark = remark;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public Long getAdminUserId() {
return adminUserId;
}
public void setAdminUserId(Long adminUserId) {
this.adminUserId = adminUserId;
}
public String getInitPassword() {
return initPassword;
}
public void setInitPassword(String initPassword) {
this.initPassword = initPassword;
}
public SysUser getSysUser() {
return sysUser;
}
public void setSysUser(SysUser sysUser) {
this.sysUser = sysUser;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getKeyWord() {
return keyWord;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}
/**
* 子部门

View File

@ -72,6 +72,8 @@ public class SysMenu extends BaseEntity
/** 系统类型 */
private String systemType;
private Long templateId;
public Long getMenuId()
{
return menuId;
@ -247,6 +249,14 @@ public class SysMenu extends BaseEntity
this.systemType = systemType;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -35,6 +35,9 @@ public class SysPost extends BaseEntity
@Excel(name = "岗位名称")
private String postName;
/** 所属公司ID */
private Long companyId;
/** 岗位排序 */
@Excel(name = "岗位排序")
private Integer postSort;
@ -80,6 +83,14 @@ public class SysPost extends BaseEntity
this.postName = postName;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
@NotNull(message = "显示顺序不能为空")
public Integer getPostSort()
{

View File

@ -65,6 +65,11 @@ public class SysRole extends BaseEntity
/** 部门组(数据权限) */
private Long[] deptIds;
/**
* 所属公司ID
*/
private Long companyId;
/** 角色菜单权限 */
private Set<String> permissions;
@ -216,6 +221,14 @@ public class SysRole extends BaseEntity
this.deptIds = deptIds;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public Set<String> getPermissions()
{
return permissions;

View File

@ -0,0 +1,28 @@
package com.bonus.system.api.domain;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* 权限模板对象 sys_template
*
* @author bonus
* @date 2020-07-09
*/
@Data
public class SysTemplate extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private String id;
/** 模板名称 */
@Excel(name = "模板名称")
private String name;
private List<Integer> menuIds;
}

View File

@ -0,0 +1,38 @@
package com.bonus.system.api.domain;
import java.io.Serializable;
/**
* 系统模板菜单表(SysTempMenu)实体类
*
* @author bonus
* @since 2020-07-09 13:38:36
*/
public class SysTemplateMenu implements Serializable {
private static final long serialVersionUID = 904598953972609708L;
/**
* 模板ID
*/
private Long tempId;
/**
* 菜单ID
*/
private Long menuId;
public Long getTempId() {
return tempId;
}
public void setTempId(Long tempId) {
this.tempId = tempId;
}
public Long getMenuId() {
return menuId;
}
public void setMenuId(Long menuId) {
this.menuId = menuId;
}
}

View File

@ -63,9 +63,9 @@ public class SafeUtil {
* @return 如果包含特殊脚本字符返回true否则返回false
*/
public static boolean checkScript(String mark) {
if (mark != null && !"".equals(mark)) {
return match(SAFE_SCRIPT_PATTERN, mark.toLowerCase().trim());
}
// if (mark != null && !"".equals(mark)) {
// return match(SAFE_SCRIPT_PATTERN, mark.toLowerCase().trim());
// }
return false;
}

View File

@ -28,7 +28,7 @@ public class MimeTypeUtils
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
// 图片
"bmp", "gif", "jpg", "jpeg", "png",
"bmp", "gif", "jpg", "jpeg", "png", "svg",
// word excel powerpoint
"doc", "docx", "xls", "xlsx","csv", "ppt", "pptx", "html", "htm", "txt",
// 压缩文件

View File

@ -1,7 +1,10 @@
package com.bonus.system.controller;
import java.util.ArrayList;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
@ -155,4 +158,37 @@ public class SysDeptController extends BaseController
}
return error("系统异常");
}
/**
* 根据登录用户获取公司详细信息
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:dept:query"))
@GetMapping(value = "/company_info")
public AjaxResult getCompanyInfo() {
try{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
return success(deptService.selectDeptById(companyId));
} catch (Exception e){
log.error(e.toString(),e);
}
return error("系统异常");
}
@GetMapping("/deptList")
@SysLog(title = "获取公司列表", businessType = OperaType.QUERY,logType = 0,module = "系统管理->部门管理")
public TableDataInfo deptList(SysDept dept) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
throw new ServiceException("抱歉,您无权查看公司列表!");
}
List<SysDept> deptList = new ArrayList<>();
try{
startPage();
dept.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
deptList = deptService.getDeptList(dept);
return getDataTable(deptList);
}catch (Exception e){
log.error(e.toString(),e);
}
return getDataTableError(deptList);
}
}

View File

@ -6,8 +6,10 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.system.api.domain.SysDept;
import com.bonus.system.api.domain.SysMenu;
import com.bonus.system.domain.UserMenuParams;
import com.bonus.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -40,6 +42,9 @@ public class SysMenuController extends BaseController
@Autowired
private ISysMenuService menuService;
@Autowired
private ISysDeptService deptService;
/**
* 获取当前用户的菜单列表
*/
@ -199,7 +204,8 @@ public class SysMenuController extends BaseController
try{
Long userId = SecurityUtils.getUserId();
UserMenuParams userMenuParams = new UserMenuParams(userId, systemType);
SysDept sysDept = deptService.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
UserMenuParams userMenuParams = new UserMenuParams(userId, systemType, sysDept.getMenuTemplateId());
List<SysMenu> menus = menuService.selectMenuTreeByUserIdAndSystemType(userMenuParams);
return success(menuService.buildMenus(menus));
}catch (Exception e){

View File

@ -8,6 +8,7 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.config.SystemConfig;
import com.bonus.system.api.domain.SysPost;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,6 +41,9 @@ public class SysPostController extends BaseController {
@Autowired
private ISysPostService postService;
@Autowired
SystemConfig systemConfig;
/**
* 获取岗位列表
*/

View File

@ -1,22 +1,22 @@
package com.bonus.system.domain;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
/**
* @author wangvivi
*/
@Setter
@Getter
@Data
public class UserMenuParams {
private Long userId;
private Long systemType;
private Long templateId;
UserMenuParams(){}
public UserMenuParams(Long userId, Long systemType){
public UserMenuParams(Long userId, Long systemType, Long templateId){
this.userId = userId;
this.systemType = systemType;
this.templateId = templateId;
}
}

View File

@ -1,6 +1,8 @@
package com.bonus.system.mapper;
import java.util.List;
import com.bonus.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Param;
import com.bonus.system.api.domain.SysDept;
@ -19,6 +21,8 @@ public interface SysDeptMapper
*/
public List<SysDept> selectDeptList(SysDept dept);
List<SysDept> getDeptList(SysDept dept);
/**
* 查询部门人员树列表
*
@ -123,4 +127,11 @@ public interface SysDeptMapper
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 获取公司管理员详情
* @param deptId
* @return
*/
public SysUser selectCompanyAdminByDept(@Param("deptId") Long deptId);
}

View File

@ -63,9 +63,10 @@ public interface SysMenuMapper
* 根据用户ID查询菜单
*
* @param userId 用户ID
* @param templateId 权限模板ID
* @return 菜单列表
*/
public List<SysMenu> selectMenuTreeByUserId(Long userId);
public List<SysMenu> selectMenuTreeByUserId(@Param("userId") Long userId, @Param("templateId")Long templateId);
/**
* 根据用户ID查询菜单

View File

@ -24,7 +24,7 @@ public interface SysPostMapper
*
* @return 岗位列表
*/
public List<SysPost> selectPostAll();
public List<SysPost> selectPostAll(SysPost sysPost);
/**
* 通过岗位ID查询岗位信息
@ -85,16 +85,16 @@ public interface SysPostMapper
/**
* 校验岗位名称
*
* @param postName 岗位名称
* @param post
* @return 结果
*/
public SysPost checkPostNameUnique(String postName);
public SysPost checkPostNameUnique(SysPost post);
/**
* 校验岗位编码
*
* @param postCode 岗位编码
* @param post
* @return 结果
*/
public SysPost checkPostCodeUnique(String postCode);
public SysPost checkPostCodeUnique(SysPost post);
}

View File

@ -60,18 +60,18 @@ public interface SysRoleMapper
/**
* 校验角色名称是否唯一
*
* @param roleName 角色名称
* @param role 角色名称
* @return 角色信息
*/
public SysRole checkRoleNameUnique(String roleName);
public SysRole checkRoleNameUnique(SysRole role);
/**
* 校验角色权限是否唯一
*
* @param roleKey 角色权限
* @param role 角色权限
* @return 角色信息
*/
public SysRole checkRoleKeyUnique(String roleKey);
public SysRole checkRoleKeyUnique(SysRole role);
/**
* 修改角色信息

View File

@ -0,0 +1,61 @@
package com.bonus.system.mapper;
import com.bonus.system.api.domain.SysTemplate;
import java.util.List;
/**
* 权限模板Mapper接口
*
* @author bonus
* @date 2025-01-05
*/
public interface SysTemplateMapper
{
/**
* 查询权限模板
*
* @param id 权限模板ID
* @return 权限模板
*/
public SysTemplate selectSysTemplateById(String id);
/**
* 查询权限模板列表
*
* @param sysTemplate 权限模板
* @return 权限模板集合
*/
public List<SysTemplate> selectSysTemplateList(SysTemplate sysTemplate);
/**
* 新增权限模板
*
* @param sysTemplate 权限模板
* @return 结果
*/
public int insertSysTemplate(SysTemplate sysTemplate);
/**
* 修改权限模板
*
* @param sysTemplate 权限模板
* @return 结果
*/
public int updateSysTemplate(SysTemplate sysTemplate);
/**
* 删除权限模板
*
* @param id 权限模板ID
* @return 结果
*/
public int deleteSysTemplateById(String id);
/**
* 批量删除权限模板
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysTemplateByIds(String[] ids);
}

View File

@ -0,0 +1,59 @@
package com.bonus.system.mapper;
import com.bonus.system.api.domain.SysTemplateMenu;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 系统模板菜单表(SysTempMenu)表数据库访问层
*
* @author bonus
* @since 2025-01-05
*/
public interface SysTemplateMenuMapper {
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<SysTemplateMenu> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
/**
* 通过实体作为筛选条件查询
*
* @param sysTempMenu 实例对象
* @return 对象列表
*/
List<SysTemplateMenu> queryAll(SysTemplateMenu sysTempMenu);
/**
* 新增数据
*
* @param sysTempMenu 实例对象
* @return 影响行数
*/
int insert(SysTemplateMenu sysTempMenu);
/**
* 修改数据
*
* @param sysTempMenu 实例对象
* @return 影响行数
*/
int update(SysTemplateMenu sysTempMenu);
/**
* 根据模板删除菜单信息
*
* @param tempId
* @return
*/
int deleteByTempId(@Param("tempId") String tempId);
}

View File

@ -20,6 +20,8 @@ public interface ISysDeptService
*/
public List<SysDept> selectDeptList(SysDept dept);
public List<SysDept> getDeptList(SysDept dept);
/**
* 查询部门树结构信息
*

View File

@ -0,0 +1,39 @@
package com.bonus.system.service;
import com.bonus.system.api.domain.SysTemplateMenu;
import java.util.List;
/**
* 系统模板菜单表(SysTemplateMenu)表服务接口
*
* @author bonus
* @since 2025-01-05
*/
public interface SysTemplateMenuService {
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<SysTemplateMenu> queryAllByLimit(int offset, int limit);
/**
* 新增数据
*
* @param sysTemplateMenu 实例对象
* @return 实例对象
*/
SysTemplateMenu insert(SysTemplateMenu sysTemplateMenu);
/**
* 修改数据
*
* @param sysTemplateMenu 实例对象
* @return 实例对象
*/
SysTemplateMenu update(SysTemplateMenu sysTemplateMenu);
}

View File

@ -1,16 +1,22 @@
package com.bonus.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.system.mapper.SysUserMapper;
import com.bonus.config.SystemConfig;
import com.bonus.system.api.domain.*;
import com.bonus.system.domain.SysRoleDept;
import com.bonus.system.domain.SysRoleMenu;
import com.bonus.system.mapper.*;
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
import com.bonus.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.bonus.common.core.constant.UserConstants;
import com.bonus.common.core.exception.ServiceException;
@ -19,20 +25,18 @@ import com.bonus.common.core.utils.SpringUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.datascope.annotation.DataScope;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysDept;
import com.bonus.system.api.domain.SysRole;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.domain.vo.TreeSelect;
import com.bonus.system.mapper.SysDeptMapper;
import com.bonus.system.mapper.SysRoleMapper;
import com.bonus.system.service.ISysDeptService;
import javax.annotation.Resource;
/**
* 部门管理 服务实现
*
* @author bonus
*/
@Service
@Slf4j
public class SysDeptServiceImpl implements ISysDeptService
{
@Autowired
@ -44,6 +48,25 @@ public class SysDeptServiceImpl implements ISysDeptService
@Autowired
private SysRoleMapper roleMapper;
@Resource
private SysUserRoleMapper userRoleMapper;
@Resource
private SysRoleMenuMapper roleMenuMapper;
@Resource
SysTemplateMenuMapper sysTemplateMenuMapper;
@Resource
private SysRoleDeptMapper roleDeptMapper;
@Lazy
@Autowired
ISysUserService userService;
@Resource
private SystemConfig systemConfig;
/**
* 查询部门管理数据
*
@ -64,9 +87,15 @@ public class SysDeptServiceImpl implements ISysDeptService
String str = dept.getDeptName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
dept.setDeptName(str);
}
dept.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return deptMapper.selectDeptList(dept);
}
@Override
public List<SysDept> getDeptList(SysDept dept) {
return deptMapper.getDeptList(dept);
}
/**
* 查询部门树结构信息
*
@ -170,7 +199,12 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override
public SysDept selectDeptById(Long deptId)
{
return deptMapper.selectDeptById(deptId);
SysDept sysDept = deptMapper.selectDeptById(deptId);
if (systemConfig.isAddRootCompany() && Objects.nonNull(sysDept.getParentId()) && sysDept.getParentId().equals(0L)) {
SysUser sysUser = deptMapper.selectCompanyAdminByDept(deptId);
sysDept.setSysUser(sysUser);
}
return sysDept;
}
/**
@ -265,16 +299,26 @@ public class SysDeptServiceImpl implements ISysDeptService
if (dept.getParentId() == null){
dept.setParentId(0L);
dept.setAncestors("0");
}
else {
dept.setStatus("0");//默认启用
dept.setMenuTemplateId(1L);//TODO 将来用前端传的模版ID
int result = deptMapper.insertDept(dept);
if (systemConfig.isAddRootCompany() && result > 0) {
if (StringUtils.isNotNull(dept.getSysUser()) && !userService.checkUserNameUnique(dept.getSysUser())) {
throw new ServiceException("新增公司管理员用户'" + dept.getSysUser().getUserName() + "'失败,登录账号已存在");
}
SysUser user = createCompanyAdminUser(dept);
createCompanyAdminRole(dept, user);
}
return result;
} else {
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
return deptMapper.insertDept(dept);
}
/**
@ -302,6 +346,10 @@ public class SysDeptServiceImpl implements ISysDeptService
// 如果该部门是启用状态则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
//判断是否需要修改公司管理员用户信息
if (systemConfig.isAddRootCompany() && Objects.nonNull(dept.getParentId()) && dept.getParentId().equals(0L)){
updateCompanyAdminUserAndRole(dept);
}
return result;
}
@ -391,5 +439,83 @@ public class SysDeptServiceImpl implements ISysDeptService
{
return getChildList(list, t).size() > 0 ? true : false;
}
/**
* 创建公司管理员用户
* @param dept
*/
private SysUser createCompanyAdminUser(SysDept dept) {
log.info("创建公司管理员用户:{}",dept);
SysUser user = dept.getSysUser();
user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(dept.getInitPassword()));
user.setDeptId(dept.getDeptId());
user.setLoginType("0"); //后台
userMapper.insertUser(user);
dept.setAdminUserId(user.getUserId());
deptMapper.updateDept(dept);
return user;
}
/**
* 创建公司管理员并分配角色菜单等
*/
private void createCompanyAdminRole(SysDept sysDept, SysUser user) {
log.info("部门信息{},公司管理员用户{}",sysDept,user);
SysRole role = new SysRole();
role.setRoleKey("company_admin");
role.setRoleName("公司管理员");
role.setRemark("公司管理员");
role.setCompanyId(sysDept.getDeptId());
role.setRoleSort(0);
role.setStatus("0");
role.setCreateBy(SecurityUtils.getUsername());
roleMapper.insertRole(role);
log.info("创建的角色id为{}",role.getRoleId());
//绑定管理员角色和公司关系
List<SysRoleDept> roleDeptList = new ArrayList<>();
SysRoleDept rd = new SysRoleDept();
rd.setRoleId(Long.valueOf(role.getRoleId()));
rd.setDeptId(sysDept.getDeptId());
roleDeptList.add(rd);
roleDeptMapper.batchRoleDept(roleDeptList);
//用户绑定角色
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(user.getUserId());
sysUserRole.setRoleId(role.getRoleId());
List<SysUserRole> sysUserRoleList = new ArrayList<SysUserRole>();
sysUserRoleList.add(sysUserRole);
userRoleMapper.batchUserRole(sysUserRoleList);
//对初始化管理员赋值菜单权限
List<SysRoleMenu> sysRoleMenulist = new ArrayList<>();
SysTemplateMenu sysTemplateMenu = new SysTemplateMenu();
sysTemplateMenu.setTempId(sysDept.getMenuTemplateId());
List<SysTemplateMenu> sysTemplateMenus = sysTemplateMenuMapper.queryAll(sysTemplateMenu);
SysRoleMenu sysRoleMenu = null;
for (SysTemplateMenu stm : sysTemplateMenus) {
sysRoleMenu = new SysRoleMenu();
sysRoleMenu.setRoleId(role.getRoleId());
sysRoleMenu.setMenuId(stm.getMenuId());
sysRoleMenulist.add(sysRoleMenu);
}
roleMenuMapper.batchRoleMenu(sysRoleMenulist);
}
/**
* 修改公司管理员用户和角色信息
* @param dept
*/
private void updateCompanyAdminUserAndRole(SysDept dept) {
SysUser oldCompanyAdmin = deptMapper.selectCompanyAdminByDept(dept.getDeptId());
SysUser user = dept.getSysUser();
user.setUpdateBy(SecurityUtils.getUsername());
user.setUpdateTime(DateUtils.getNowDate());
user.setDeptId(dept.getDeptId());
user.setUserId(oldCompanyAdmin.getUserId());
userMapper.updateUser(user);
}
}

View File

@ -9,8 +9,10 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.bonus.system.api.domain.SysDept;
import com.bonus.system.api.domain.SysMenu;
import com.bonus.system.domain.UserMenuParams;
import com.bonus.system.mapper.SysDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.common.core.constant.Constants;
@ -45,6 +47,9 @@ public class SysMenuServiceImpl implements ISysMenuService
@Autowired
private SysRoleMenuMapper roleMenuMapper;
@Autowired
private SysDeptMapper deptMapper;
/**
* 根据用户查询系统菜单列表
*
@ -70,6 +75,8 @@ public class SysMenuServiceImpl implements ISysMenuService
String str = menu.getMenuName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
menu.setMenuName(str);
}
SysDept sysDept = deptMapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
menu.setTemplateId(sysDept.getMenuTemplateId());
List<SysMenu> menuList = menuMapper.selectMenuList(menu);
return menuList;
}
@ -132,7 +139,8 @@ public class SysMenuServiceImpl implements ISysMenuService
}
else
{
menus = menuMapper.selectMenuTreeByUserId(userId);
SysDept sysDept = deptMapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
menus = menuMapper.selectMenuTreeByUserId(userId, sysDept.getMenuTemplateId());
}
return getChildPerms(menus, 0);
}

View File

@ -2,6 +2,7 @@ package com.bonus.system.service.impl;
import java.util.List;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,7 +44,7 @@ public class SysPostServiceImpl implements ISysPostService
String str = post.getPostName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
post.setPostName(str);
}
post.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return postMapper.selectPostList(post);
}
@ -55,7 +56,9 @@ public class SysPostServiceImpl implements ISysPostService
@Override
public List<SysPost> selectPostAll()
{
return postMapper.selectPostAll();
SysPost sysPost = new SysPost();
sysPost.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return postMapper.selectPostAll(sysPost);
}
/**
@ -91,8 +94,10 @@ public class SysPostServiceImpl implements ISysPostService
@Override
public boolean checkPostNameUnique(SysPost post)
{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
post.setCompanyId(companyId);
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
SysPost info = postMapper.checkPostNameUnique(post);
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.NOT_UNIQUE;
@ -109,8 +114,10 @@ public class SysPostServiceImpl implements ISysPostService
@Override
public boolean checkPostCodeUnique(SysPost post)
{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
post.setCompanyId(companyId);
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
SysPost info = postMapper.checkPostCodeUnique(post);
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.NOT_UNIQUE;

View File

@ -73,6 +73,7 @@ public class SysRoleServiceImpl implements ISysRoleService
String str = role.getRoleKey().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
role.setRoleKey(str);
}
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return roleMapper.selectRoleList(role);
}
@ -166,8 +167,10 @@ public class SysRoleServiceImpl implements ISysRoleService
@Override
public boolean checkRoleNameUnique(SysRole role)
{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
role.setCompanyId(companyId);
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
SysRole info = roleMapper.checkRoleNameUnique(role);
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.NOT_UNIQUE;
@ -184,8 +187,10 @@ public class SysRoleServiceImpl implements ISysRoleService
@Override
public boolean checkRoleKeyUnique(SysRole role)
{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
role.setCompanyId(companyId);
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
SysRole info = roleMapper.checkRoleKeyUnique(role);
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.NOT_UNIQUE;
@ -253,6 +258,7 @@ public class SysRoleServiceImpl implements ISysRoleService
public int insertRole(SysRole role)
{
// 新增角色信息
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
roleMapper.insertRole(role);
return insertRoleMenu(role);
}

View File

@ -0,0 +1,57 @@
package com.bonus.system.service.impl;
import com.bonus.system.api.domain.SysTemplateMenu;
import com.bonus.system.mapper.SysTemplateMenuMapper;
import com.bonus.system.service.SysTemplateMenuService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 系统模板菜单表(SysTempMenu)表服务实现类
*
* @author bonus
* @since 2025-01-05
*/
@Service("sysTempMenuService")
public class SysTemplateMenuServiceImpl implements SysTemplateMenuService {
@Resource
private SysTemplateMenuMapper sysTempMenuMapper;
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
@Override
public List<SysTemplateMenu> queryAllByLimit(int offset, int limit) {
return this.sysTempMenuMapper.queryAllByLimit(offset, limit);
}
/**
* 新增数据
*
* @param sysTemplateMenu 实例对象
* @return 实例对象
*/
@Override
public SysTemplateMenu insert(SysTemplateMenu sysTemplateMenu) {
this.sysTempMenuMapper.insert(sysTemplateMenu);
return sysTemplateMenu;
}
/**
* 修改数据
*
* @param sysTemplateMenu 实例对象
* @return 实例对象
*/
@Override
public SysTemplateMenu update(SysTemplateMenu sysTemplateMenu) {
this.sysTempMenuMapper.update(sysTemplateMenu);
return null;
}
}

View File

@ -109,6 +109,7 @@ public class SysUserServiceImpl implements ISysUserService {
String phone =user.getPhonenumber().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
user.setPhonenumber(phone);
}
user.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
List<SysUser> sysUsers = userMapper.selectUserList(user);
return sysUsers;
}

View File

@ -20,11 +20,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="menuTemplateId" column="menu_template_id" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="district" column="district" />
<result property="address" column="address" />
<result property="deptAbbreviation" column="dept_abbreviation" />
<result property="remark" column="remark" />
<result property="logo" column="logo" />
<result property="adminUserId" column="admin_user_id" />
<result property="initPassword" column="init_password" />
</resultMap>
<sql id="selectDeptVo">
@ -40,16 +45,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.del_flag,
d.create_by,
d.create_time,
d.menu_template_id,
d.province,
d.city,
d.district,
d.address
d.address,
d.dept_abbreviation,
d.remark,
d.logo,
d.admin_user_id,
d.init_password
from sys_dept d
</sql>
<select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND (find_in_set(#{companyId}, ancestors) or dept_id = #{companyId})
</if>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
@ -67,6 +81,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by d.parent_id, d.order_num
</select>
<select id="getDeptList" resultType="com.bonus.system.api.domain.SysDept">
select * from sys_dept sd where parent_id='0' and del_flag='0'
<if test="companyId != null and companyId != 0">
AND dept_id != #{companyId}
</if>
<if test="keyWord != null and keyWord != ''">
and sd.dept_name like concat('%', #{keyWord}, '%')
</if>
</select>
<select id="selectDeptUserList" resultType="com.bonus.system.api.domain.SysDept">
SELECT
d.dept_id AS deptId,
@ -141,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<insert id="insertDept" parameterType="com.bonus.system.api.domain.SysDept">
<insert id="insertDept" parameterType="com.bonus.system.api.domain.SysDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
@ -155,7 +179,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="city != null and city != ''">city,</if>
<if test="district != null and district != ''">district,</if>
<if test="address != null and address != ''">address,</if>
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="logo != null and logo != ''">logo,</if>
<if test="initPassword != null and initPassword != ''">init_password,</if>
<if test="status != null">status,</if>
<if test="menuTemplateId != null">menu_template_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
@ -171,7 +200,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="city != null and city != ''">#{city},</if>
<if test="district != null and district != ''">#{district},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="deptAbbreviation != null and deptAbbreviation != ''">#{deptAbbreviation},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="logo != null and logo != ''">#{logo},</if>
<if test="initPassword != null and initPassword != ''">#{initPassword},</if>
<if test="status != null">#{status},</if>
<if test="menuTemplateId != null">#{menuTemplateId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
@ -191,6 +225,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="city != null">city = #{city},</if>
<if test="district != null">district = #{district},</if>
<if test="address != null">address = #{address},</if>
<if test="deptAbbreviation != null and deptAbbreviation != ''">dept_abbreviation = #{deptAbbreviation},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="logo != null and logo != ''">logo = #{logo},</if>
<if test="adminUserId != null and adminUserId != 0">admin_user_id = #{adminUserId},</if>
<if test="initPassword != null and initPassword != ''">init_password = #{initPassword},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
@ -222,4 +261,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
<select id="selectCompanyAdminByDept" resultType="com.bonus.system.api.domain.SysUser">
select su.nick_name as nickName, su.user_name as userName, su.phonenumber as phonenumber,
su.user_id as userId, sd.dept_id as deptId
from sys_dept sd
left join sys_user su on su.user_id = sd.admin_user_id
where sd.dept_id = #{deptId}
</select>
</mapper>

View File

@ -29,21 +29,27 @@
</resultMap>
<sql id="selectMenuVo">
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time, system_type
from sys_menu
select sm.menu_id, sm.menu_name, sm.parent_id, sm.order_num, sm.path, sm.component, sm.`query`, sm.is_frame,
sm.is_cache, sm.menu_type, sm.visible, sm.status, ifnull(sm.perms,'') as perms, sm.icon, sm.create_time, sm.system_type
from sys_menu sm
</sql>
<select id="selectMenuList" parameterType="com.bonus.system.api.domain.SysMenu" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
<where>
<if test="menuName != null and menuName != ''">
AND menu_name like concat('%', #{menuName}, '%')
AND sm.menu_name like concat('%', #{menuName}, '%')
</if>
<if test="visible != null and visible != ''">
AND visible = #{visible}
AND sm.visible = #{visible}
</if>
<if test="status != null and status != ''">
AND status = #{status}
AND sm.status = #{status}
</if>
<if test="templateId != null">
and exists (
select 0 from sys_template_menu stm where stm.temp_id = #{templateId} and stm.menu_id = sm.menu_id
)
</if>
</where>
order by parent_id, order_num
@ -71,10 +77,15 @@
<if test="status != null and status != ''">
AND m.status = #{status}
</if>
<if test="templateId != null">
and exists (
select 0 from sys_template_menu stm where stm.temp_id = #{templateId} and stm.menu_id = m.menu_id
)
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
<select id="selectMenuTreeByUserId" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
@ -82,6 +93,11 @@
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
<if test="templateId != null">
AND exists (
select 0 from sys_template_menu stm where stm.temp_id = #{templateId} and stm.menu_id = m.menu_id
)
</if>
order by m.parent_id, m.order_num
</select>
@ -93,6 +109,11 @@
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0 AND FIND_IN_SET(#{systemType}, m.system_type)
<if test="templateId != null">
AND exists (
select 0 from sys_template_menu stm where stm.temp_id = #{templateId} and stm.menu_id = m.menu_id
)
</if>
order by m.parent_id, m.order_num
</select>
@ -132,7 +153,7 @@
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_id = #{menuId}
where sm.menu_id = #{menuId}
</select>
<select id="hasChildByMenuId" resultType="Integer">
@ -141,7 +162,7 @@
<select id="checkMenuNameUnique" parameterType="com.bonus.system.api.domain.SysMenu" resultMap="SysMenuResult">
<include refid="selectMenuVo"/>
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
where sm.menu_name=#{menuName} and sm.parent_id = #{parentId} limit 1
</select>
<update id="updateMenu" parameterType="com.bonus.system.api.domain.SysMenu">

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="postCode" column="post_code" />
<result property="postName" column="post_name" />
<result property="postSort" column="post_sort" />
<result property="companyId" column="company_id" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -18,13 +19,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
select post_id, post_code, post_name, post_sort, company_id, status, create_by, create_time, remark
from sys_post
</sql>
<select id="selectPostList" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
<where>
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
<if test="postCode != null and postCode != ''">
AND post_code like concat('%', #{postCode}, '%')
</if>
@ -38,8 +42,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by post_sort
</select>
<select id="selectPostAll" resultMap="SysPostResult">
<select id="selectPostAll" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where 1=1
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
</select>
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
@ -56,21 +64,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
select p.post_id, p.post_name, p.post_code
select p.post_id, p.post_name, p.post_code, p.company_id
from sys_post p
left join sys_user_post up on up.post_id = p.post_id
left join sys_user u on u.user_id = up.user_id
where u.user_name = #{userName}
</select>
<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
<select id="checkPostNameUnique" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_name=#{postName} limit 1
where post_name=#{postName}
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
<select id="checkPostCodeUnique" parameterType="com.bonus.system.api.domain.SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_code=#{postCode} limit 1
where post_code=#{postCode}
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<update id="updatePost" parameterType="com.bonus.system.api.domain.SysPost">
@ -79,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
<if test="postName != null and postName != ''">post_name = #{postName},</if>
<if test="postSort != null">post_sort = #{postSort},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@ -93,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">post_code,</if>
<if test="postName != null and postName != ''">post_name,</if>
<if test="postSort != null">post_sort,</if>
<if test="companyId != null">company_id,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -102,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="postCode != null and postCode != ''">#{postCode},</if>
<if test="postName != null and postName != ''">#{postName},</if>
<if test="postSort != null">#{postSort},</if>
<if test="companyId != null">#{companyId},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>

View File

@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="dataScope" column="data_scope" />
<result property="menuCheckStrictly" column="menu_check_strictly" />
<result property="deptCheckStrictly" column="dept_check_strictly" />
<result property="companyId" column="company_id" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
@ -24,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark, r.is_built_in
r.company_id, r.status, r.del_flag, r.create_time, r.remark, r.is_built_in
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
@ -40,6 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleName != null and roleName != ''">
AND r.role_name like concat('%', #{roleName}, '%')
</if>
<if test="companyId != null">
AND r.company_id = #{companyId}
</if>
<if test="status != null and status != ''">
AND r.status = #{status}
</if>
@ -84,14 +88,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE r.del_flag = '0' and u.user_name = #{userName}
</select>
<select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult">
<select id="checkRoleNameUnique" parameterType="com.bonus.system.api.domain.SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
where r.role_name=#{roleName} and r.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
<select id="checkRoleKeyUnique" parameterType="com.bonus.system.api.domain.SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
where r.role_key=#{roleKey} and r.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND company_id = #{companyId}
</if>
limit 1
</select>
<insert id="insertRole" parameterType="com.bonus.system.api.domain.SysRole" useGeneratedKeys="true" keyProperty="roleId">
@ -103,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataScope != null and dataScope != ''">data_scope,</if>
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
<if test="companyId != null">company_id,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -116,6 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
<if test="companyId != null">#{companyId},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
@ -133,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>

View File

@ -0,0 +1,63 @@
<?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">
<mapper namespace="com.bonus.system.mapper.SysTemplateMapper">
<resultMap type="com.bonus.system.api.domain.SysTemplate" id="SysTemplateResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSysTemplateVo">
select id, name, remark from sys_template
</sql>
<select id="selectSysTemplateList" parameterType="com.bonus.system.api.domain.SysTemplate" resultMap="SysTemplateResult">
<include refid="selectSysTemplateVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
</where>
</select>
<select id="selectSysTemplateById" parameterType="java.lang.String" resultMap="SysTemplateResult">
<include refid="selectSysTemplateVo"/>
where id = #{id}
</select>
<insert id="insertSysTemplate" parameterType="com.bonus.system.api.domain.SysTemplate">
insert into sys_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null and name != ''">name,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSysTemplate" parameterType="com.bonus.system.api.domain.SysTemplate">
update sys_template
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysTemplateById" parameterType="java.lang.String">
delete from sys_template where id = #{id}
</delete>
<delete id="deleteSysTemplateByIds" parameterType="java.lang.String">
delete from sys_template where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,57 @@
<?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">
<mapper namespace="com.bonus.system.mapper.SysTemplateMenuMapper">
<resultMap type="com.bonus.system.api.domain.SysTemplateMenu" id="SysTemplateMenuMap">
<result property="tempId" column="temp_id" />
<result property="menuId" column="menu_id" />
</resultMap>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SysTemplateMenuMap">
select
temp_id, menu_id
from sys_template_menu
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="SysTemplateMenuMap">
select
temp_id, menu_id
from sys_template_menu
<where>
<if test="tempId != null">
and temp_id = #{tempId}
</if>
<if test="menuId != null">
and menu_id = #{menuId}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="" useGeneratedKeys="true">
insert into sys_template_menu(temp_id, menu_id)
values (#{tempId}, #{menuId})
</insert>
<!--通过主键修改数据-->
<update id="update">
update sys_template_menu
<set>
<if test="tempId != null">
temp_id = #{tempId},
</if>
<if test="menuId != null">
menu_id = #{menuId},
</if>
</set>
where = #{}
</update>
<delete id="deleteByTempId" parameterType="Long">
delete from sys_template_menu where temp_id = #{tempId}
</delete>
</mapper>

View File

@ -130,6 +130,9 @@
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="companyId != null and companyId != 0">
AND (find_in_set(#{companyId}, ancestors) or u.dept_id = #{companyId})
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
ancestors) ))

View File

@ -1,5 +1,11 @@
SET NAMES utf8mb4;
-- 菜单模版ID
alter table sys_dept add menu_template_id bigint(20) null comment '菜单模版ID';
-- 公司管理员用户ID
alter table sys_dept add admin_user_id bigint(20) null comment '公司管理员用户ID';
-- 公司用户初始密码
alter table sys_dept add init_password varchar(255) null comment '公司用户初始密码';
-- 省
alter table sys_dept add province varchar(50) null comment '';
-- 市
@ -13,4 +19,64 @@ alter table sys_dept add dept_abbreviation varchar(255) null comment '公司简
-- 公司概述
alter table sys_dept add remark varchar(255) null comment '公司概述';
-- 公司logo
alter table sys_dept add logo varchar(255) null comment '公司logo';
alter table sys_dept add logo varchar(255) null comment '公司logo';
-- 所属公司ID
alter table sys_role add company_id bigint null comment '所属公司ID';
-- 所属公司ID
alter table sys_post
add company_id bigint null comment '所属公司ID';
-- 系统模板表
create table sys_template
(
id bigint auto_increment
primary key,
name varchar(50) not null comment '模板名称',
remark varchar(200) null comment '备注'
)
comment '权限模板表' charset = utf8
row_format = DYNAMIC;
-- 插入菜单默认模板
INSERT INTO sys_template (id, name, remark) VALUES (1, 'default_menu_template', '默认公司菜单模板');
-- 系统模板菜单表
create table sys_template_menu
(
temp_id bigint not null comment '模板ID',
menu_id bigint not null comment '菜单ID'
)
comment '系统模板菜单表' charset = utf8
row_format = DYNAMIC;
-- 插入菜单模板数据
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 100);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 101);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 103);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1007);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1008);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1009);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1010);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1011);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1016);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1017);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1018);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1019);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1000);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1001);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1002);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1003);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1004);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1005);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1006);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 104);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1020);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1021);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1022);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1023);
INSERT INTO bns_cloud_smart_site.sys_template_menu (temp_id, menu_id) VALUES (1, 1024);