Commit c397292b by 周海峰

优化

parent 7b318c8d
...@@ -10,6 +10,7 @@ import com.metro.auth.platform.domain.auth.PlatformPersonnel; ...@@ -10,6 +10,7 @@ import com.metro.auth.platform.domain.auth.PlatformPersonnel;
import com.metro.auth.platform.domain.auth.PlatformSysRole; import com.metro.auth.platform.domain.auth.PlatformSysRole;
import com.metro.auth.platform.domain.auth.User; import com.metro.auth.platform.domain.auth.User;
import com.metro.auth.platform.domain.dto.DepartmentPersonneDTO; import com.metro.auth.platform.domain.dto.DepartmentPersonneDTO;
import com.metro.auth.platform.domain.dto.PersonneDTO;
import com.metro.auth.platform.generallog.LogAnnotation; import com.metro.auth.platform.generallog.LogAnnotation;
import com.metro.auth.platform.service.PlatformPersonnelService; import com.metro.auth.platform.service.PlatformPersonnelService;
import com.metro.auth.platform.utils.DateUtil; import com.metro.auth.platform.utils.DateUtil;
...@@ -327,6 +328,35 @@ public class PlatformPersonnelController { ...@@ -327,6 +328,35 @@ public class PlatformPersonnelController {
return ResultJson.ok(entity); return ResultJson.ok(entity);
} }
@GetMapping("/dept_tree")
public ResultJson getDeptTree() {
DepartmentPersonneDTO tree = platformPersonnelService.getDeptTreeDTO();
return ResultJson.ok(tree);
}
@GetMapping("/search")
public ResultJson searchUsers(
@RequestParam String keyword,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "50") int pageSize) {
PageInfo<PlatformPersonnel> page = platformPersonnelService.searchUsers(keyword, pageNum, pageSize);
return ResultJson.ok(page);
}
@GetMapping("/dept_users/{deptId}")
public ResultJson getDeptUsers(@PathVariable String deptId,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(defaultValue = "100") int pageSize) {
PageInfo<PersonneDTO> page = platformPersonnelService.getDeptUsers(deptId, pageNum, pageSize);
return ResultJson.ok(page);
}
@PostMapping("/list_by_ids")
public ResultJson getUsersByIds(@RequestBody List<Integer> ids) {
List<PersonneDTO> list = platformPersonnelService.getUsersByIds(ids);
return ResultJson.ok(list);
}
/** /**
* @周海峰 * @周海峰
* 本地和微信比较 * 本地和微信比较
......
...@@ -96,9 +96,9 @@ public class PlatformRoleUserController { ...@@ -96,9 +96,9 @@ public class PlatformRoleUserController {
* @return * @return
*/ */
@GetMapping("/roleuserlist") @GetMapping("/roleuserlist")
public ResultJson roleuserpagedlist(PlatformPersonnel platformPersonnel) { public ResultJson roleuserlist(PlatformPersonnel platformPersonnel) {
List<PlatformSysUserRole> page = platformRoleUserService.roleuserlist(platformPersonnel); List<Integer> userIds = platformRoleUserService.getUserIdsByRole(platformPersonnel.getRole());
return ResultJson.ok(page); return ResultJson.ok(userIds);
} }
/** /**
......
...@@ -133,4 +133,19 @@ public interface PersonnelMapper { ...@@ -133,4 +133,19 @@ public interface PersonnelMapper {
List<PersonneDTO> getDepartmentPersonneDTOList(PersonnelExample example); List<PersonneDTO> getDepartmentPersonneDTOList(PersonnelExample example);
/**
* 根据部门ID查询该部门下的人员
*/
List<PersonneDTO> selectByDeptId(@Param("deptId") String deptId);
/**
* 关键词搜索用户(姓名或工号)
*/
List<PersonneDTO> searchByKeyword(@Param("keyword") String keyword);
/**
* 根据用户ID列表查询完整用户信息
*/
List<PersonneDTO> selectByIds(@Param("ids") List<Integer> ids);
} }
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
where account = #{account,jdbcType=VARCHAR} where account = #{account,jdbcType=VARCHAR}
</select> </select>
<!--获取所有员工以dto返回--> <!--获取所有员工以dto返回-->
<select id="getDepartmentPersonneDTOList" parameterType="com.metro.auth.platform.domain.entity.PersonnelExample" resultMap="PersonneldtoResultMap"> <select id="getDepartmentPersonneDTOList" parameterType="com.metro.auth.platform.domain.entity.PersonnelExample" resultMap="PersonneldtoResultMap">
select select
<if test="distinct"> <if test="distinct">
...@@ -250,6 +250,39 @@ ...@@ -250,6 +250,39 @@
</if> </if>
</select> </select>
<!--根据部门ID查询人员-->
<select id="selectByDeptId" resultMap="PersonneldtoResultMap">
select id, username, department, account
from platform_personnel
where department = #{deptId,jdbcType=VARCHAR}
and (delstatus = '0' or delstatus is null or delstatus = '')
and (status = '1' or status is null)
order by id asc
</select>
<!--关键词搜索用户(姓名或工号模糊匹配)-->
<select id="searchByKeyword" resultMap="PersonneldtoResultMap">
select id, username, department, account
from platform_personnel
where (username like concat('%', #{keyword,jdbcType=VARCHAR}, '%')
or account like concat('%', #{keyword,jdbcType=VARCHAR}, '%'))
and (delstatus = '0' or delstatus is null or delstatus = '')
and (status = '1' or status is null)
order by id asc
limit 100
</select>
<!--根据用户ID列表查询完整信息-->
<select id="selectByIds" resultMap="PersonneldtoResultMap">
select id, username, department, account
from platform_personnel
where id in
<foreach collection="ids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
order by id asc
</select>
......
...@@ -6,6 +6,7 @@ import com.metro.auth.platform.domain.auth.PlatformDepartment; ...@@ -6,6 +6,7 @@ import com.metro.auth.platform.domain.auth.PlatformDepartment;
import com.metro.auth.platform.domain.auth.PlatformPersonnel; import com.metro.auth.platform.domain.auth.PlatformPersonnel;
import com.metro.auth.platform.domain.auth.PlatformPersonnelExample; import com.metro.auth.platform.domain.auth.PlatformPersonnelExample;
import com.metro.auth.platform.domain.dto.DepartmentPersonneDTO; import com.metro.auth.platform.domain.dto.DepartmentPersonneDTO;
import com.metro.auth.platform.domain.dto.PersonneDTO;
import com.metro.auth.platform.viewformat.DataDictClass; import com.metro.auth.platform.viewformat.DataDictClass;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
...@@ -99,6 +100,14 @@ public interface PlatformPersonnelService { ...@@ -99,6 +100,14 @@ public interface PlatformPersonnelService {
DepartmentPersonneDTO getDepartmentPersonneDTO(); DepartmentPersonneDTO getDepartmentPersonneDTO();
DepartmentPersonneDTO getDeptTreeDTO();
PageInfo<PlatformPersonnel> searchUsers(String keyword, int pageNum, int pageSize);
PageInfo<PersonneDTO> getDeptUsers(String deptId, int pageNum, int pageSize);
List<PersonneDTO> getUsersByIds(List<Integer> ids);
/** /**
* zhf * zhf
* 20200402 * 20200402
......
...@@ -1803,6 +1803,60 @@ public class PlatformPersonnelServiceImpl implements PlatformPersonnelService { ...@@ -1803,6 +1803,60 @@ public class PlatformPersonnelServiceImpl implements PlatformPersonnelService {
} }
@Override @Override
public DepartmentPersonneDTO getDeptTreeDTO() {
DepartmentPersonneDTO dto = new DepartmentPersonneDTO();
DepartmentExample de = new DepartmentExample();
de.setOrderByClause(" id asc ");
List<DepartmentPersonneDTO> deptlist = departmentMapper.getDepartmentPersonneDTOList(de);
for (DepartmentPersonneDTO d : deptlist) {
if ("0".equals(d.getPid())) {
dto = d;
break;
}
}
dto = this.buildDeptTree(dto, deptlist);
return dto;
}
private DepartmentPersonneDTO buildDeptTree(DepartmentPersonneDTO parent, List<DepartmentPersonneDTO> allDepts) {
List<Object> children = new ArrayList<>();
for (DepartmentPersonneDTO d : allDepts) {
if (parent.getId().toString().equals(d.getPid())) {
children.add(this.buildDeptTree(d, allDepts));
}
}
parent.setChildren(children);
return parent;
}
@Override
public PageInfo<PlatformPersonnel> searchUsers(String keyword, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
PlatformPersonnelExample ex = new PlatformPersonnelExample();
PlatformPersonnelExample.Criteria c1 = ex.createCriteria();
c1.andUsernameLike("%" + keyword + "%");
PlatformPersonnelExample.Criteria c2 = ex.createCriteria();
c2.andAccountLike("%" + keyword + "%");
ex.or(c2);
List<PlatformPersonnel> list = platformPersonnelMapper.selectByExample(ex);
return new PageInfo<>(list);
}
@Override
public PageInfo<PersonneDTO> getDeptUsers(String deptId, int pageNum, int pageSize) {
List<PersonneDTO> list = personnelMapper.selectByDeptId(deptId);
return new PageInfo<>(list);
}
@Override
public List<PersonneDTO> getUsersByIds(List<Integer> ids) {
if (ids == null || ids.isEmpty()) {
return new ArrayList<>();
}
return personnelMapper.selectByIds(ids);
}
@Override
public void wixinAvatar2loaclFileBatch() { public void wixinAvatar2loaclFileBatch() {
//获取全部用户 //获取全部用户
PlatformPersonnelExample platformPersonnelExample = new PlatformPersonnelExample(); PlatformPersonnelExample platformPersonnelExample = new PlatformPersonnelExample();
......
...@@ -49,6 +49,8 @@ public interface PlatformRoleUserService { ...@@ -49,6 +49,8 @@ public interface PlatformRoleUserService {
List<PlatformSysUserRole> roleuserlist(PlatformPersonnel platformPersonnel); List<PlatformSysUserRole> roleuserlist(PlatformPersonnel platformPersonnel);
List<Integer> getUserIdsByRole(String roleId);
int addroleuser(PlatformSysUserRole platformSysUserRole); int addroleuser(PlatformSysUserRole platformSysUserRole);
/** /**
......
...@@ -43,6 +43,7 @@ import java.util.ArrayList; ...@@ -43,6 +43,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* @author zhouy * @author zhouy
...@@ -260,6 +261,14 @@ public class PlatformRoleUserServiceImpl implements PlatformRoleUserService { ...@@ -260,6 +261,14 @@ public class PlatformRoleUserServiceImpl implements PlatformRoleUserService {
return platformSysUserRoleMapper.selectByExample(example); return platformSysUserRoleMapper.selectByExample(example);
} }
@Override
public List<Integer> getUserIdsByRole(String roleId) {
PlatformSysUserRoleExample example = new PlatformSysUserRoleExample();
example.createCriteria().andRoleIdEqualTo(roleId);
List<PlatformSysUserRole> list = platformSysUserRoleMapper.selectByExample(example);
return list.stream().map(PlatformSysUserRole::getUserId).collect(Collectors.toList());
}
/** /**
* 功能描述: <b>用户角色信息 * 功能描述: <b>用户角色信息
* 〈〉 * 〈〉
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论