新增公司
This commit is contained in:
parent
79bf7f5f4a
commit
8920722356
|
|
@ -117,6 +117,11 @@ public class SysDept extends BaseEntity {
|
|||
|
||||
private SysUser sysUser;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
*角色名称
|
||||
*/
|
||||
|
|
@ -209,6 +214,14 @@ public class SysDept extends BaseEntity {
|
|||
this.sysUser = sysUser;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
|
@ -63,6 +64,9 @@ public class SysDeptController extends BaseController
|
|||
@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();
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ 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);
|
||||
}
|
||||
|
||||
|
|
@ -302,11 +303,11 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
dept.setStatus("0");//默认启用
|
||||
dept.setMenuTemplateId(1L);//TODO 将来用前端传的模版ID
|
||||
dept.setInitPassword(SecurityUtils.encryptPassword(dept.getSysUser().getPassword()));
|
||||
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() + "'失败,登录账号已存在");
|
||||
}
|
||||
int result = deptMapper.insertDept(dept);
|
||||
if (result > 0) {
|
||||
SysUser user = createCompanyAdminUser(dept);
|
||||
createCompanyAdminRole(dept, user);
|
||||
}
|
||||
|
|
@ -347,8 +348,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatusNormal(dept);
|
||||
}
|
||||
//判断是否是修改公司信息并判断是否关联用户信息
|
||||
if (Objects.nonNull(dept.getParentId()) && dept.getParentId().equals(0L)){
|
||||
//判断是否需要修改公司管理员用户信息
|
||||
if (systemConfig.isAddRootCompany() && Objects.nonNull(dept.getParentId()) && dept.getParentId().equals(0L)){
|
||||
updateCompanyAdminUserAndRole(dept);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<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>
|
||||
|
|
@ -77,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getDeptList" resultType="com.bonus.system.api.domain.SysDept">
|
||||
select * from sys_dept sd where parent_id='0'
|
||||
select * from sys_dept sd where parent_id='0' and del_flag='0'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and sd.dept_name like concat('%', #{keyWord}, '%')
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue