系统管理所属组织id
This commit is contained in:
parent
50f182f464
commit
248364786d
|
|
@ -115,4 +115,6 @@ public interface SysDeptMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeptById(Long deptId);
|
public int deleteDeptById(Long deptId);
|
||||||
|
|
||||||
|
List<SysDept> selectDeptByAncestors(String[] deptIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
package com.bonus.sgzb.system.service.impl;
|
package com.bonus.sgzb.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysDept;
|
||||||
|
import com.bonus.sgzb.system.mapper.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -22,11 +26,6 @@ import com.bonus.sgzb.system.api.domain.SysUser;
|
||||||
import com.bonus.sgzb.system.domain.SysPost;
|
import com.bonus.sgzb.system.domain.SysPost;
|
||||||
import com.bonus.sgzb.system.domain.SysUserPost;
|
import com.bonus.sgzb.system.domain.SysUserPost;
|
||||||
import com.bonus.sgzb.system.domain.SysUserRole;
|
import com.bonus.sgzb.system.domain.SysUserRole;
|
||||||
import com.bonus.sgzb.system.mapper.SysPostMapper;
|
|
||||||
import com.bonus.sgzb.system.mapper.SysRoleMapper;
|
|
||||||
import com.bonus.sgzb.system.mapper.SysUserMapper;
|
|
||||||
import com.bonus.sgzb.system.mapper.SysUserPostMapper;
|
|
||||||
import com.bonus.sgzb.system.mapper.SysUserRoleMapper;
|
|
||||||
import com.bonus.sgzb.system.service.ISysConfigService;
|
import com.bonus.sgzb.system.service.ISysConfigService;
|
||||||
import com.bonus.sgzb.system.service.ISysUserService;
|
import com.bonus.sgzb.system.service.ISysUserService;
|
||||||
|
|
||||||
|
|
@ -61,6 +60,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
@Autowired
|
@Autowired
|
||||||
protected Validator validator;
|
protected Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDeptMapper deptMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
|
|
@ -255,6 +257,21 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertUser(SysUser user)
|
public int insertUser(SysUser user)
|
||||||
{
|
{
|
||||||
|
// 暂时使用,需修改
|
||||||
|
Long deptId = user.getDeptId();
|
||||||
|
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||||
|
String ancestors = sysDept.getAncestors();
|
||||||
|
String[] split = ancestors.split(",");
|
||||||
|
List<SysDept> deptList = deptMapper.selectDeptByAncestors(split);
|
||||||
|
for (SysDept dept : deptList) {
|
||||||
|
String ancestors1 = dept.getAncestors();
|
||||||
|
String[] split1 = ancestors1.split(",");
|
||||||
|
List<String> list = Arrays.asList(split1);
|
||||||
|
if (list.size() == 2) {
|
||||||
|
user.setCompanyId(dept.getDeptId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 新增用户信息
|
// 新增用户信息
|
||||||
int rows = userMapper.insertUser(user);
|
int rows = userMapper.insertUser(user);
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
|
|
|
||||||
|
|
@ -154,4 +154,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
<select id="selectDeptByAncestors" resultMap="SysDeptResult">
|
||||||
|
select * from sys_dept where dept_id in
|
||||||
|
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||||
|
#{deptId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
|
<result property="companyId" column="company_id" />
|
||||||
<association property="dept" javaType="com.bonus.sgzb.system.api.domain.SysDept" resultMap="deptResult" />
|
<association property="dept" javaType="com.bonus.sgzb.system.api.domain.SysDept" resultMap="deptResult" />
|
||||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.company_id,
|
||||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||||
from sys_user u
|
from sys_user u
|
||||||
|
|
@ -158,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
<if test="companyId != null and companyId != ''">company_id,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="userId != null and userId != ''">#{userId},</if>
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
|
@ -172,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
<if test="companyId != null and companyId != ''">#{companyId},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue