岗位用户查询

This commit is contained in:
piaobo 2025-12-18 08:46:54 +08:00
parent d0c4a6664f
commit 521bd25efd
13 changed files with 156 additions and 59 deletions

View File

@ -1,27 +0,0 @@
package com.zhyc.module.common.controller;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.module.common.domain.UserPost;
import com.zhyc.module.common.service.UserPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
//人员用户
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
UserPostService userPostService;
@GetMapping()
public AjaxResult getUserPost(String postCode){
List<UserPost> list = userPostService.getUserPostListByCode(postCode);
return AjaxResult.success(list);
}
}

View File

@ -0,0 +1,41 @@
package com.zhyc.module.common.controller;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.module.common.domain.Post;
import com.zhyc.module.common.domain.User;
import com.zhyc.module.common.service.PostService;
import com.zhyc.module.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
//人员用户
@RestController
@RequestMapping("/userPost")
public class UserPostController {
@Autowired
UserService userService;
@Autowired
PostService postService;
// 根据岗位编码获取用户
@GetMapping("/getUser")
public AjaxResult getUserPost(String postCode){
List<User> list = userService.getUserListByCode(postCode);
return AjaxResult.success(list);
}
// 获取岗位部门
@GetMapping("/getPost")
public AjaxResult getPost(){
List<Post> list = postService.selectPostList();
return AjaxResult.success(list);
}
}

View File

@ -0,0 +1,35 @@
package com.zhyc.module.common.domain;
import com.zhyc.common.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Post {
/** 岗位序号 */
@Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC)
private Long postId;
/** 岗位编码 */
@Excel(name = "岗位编码")
private String postCode;
/** 岗位名称 */
@Excel(name = "岗位名称")
private String postName;
/** 岗位排序 */
@Excel(name = "岗位排序")
private Integer postSort;
/** 状态0正常 1停用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 用户是否存在此岗位标识 默认不存在 */
private boolean flag = false;
}

View File

@ -1,9 +1,13 @@
package com.zhyc.module.common.domain; package com.zhyc.module.common.domain;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
public class UserPost { @NoArgsConstructor
@AllArgsConstructor
public class User {
// 用户id // 用户id
private String userId; private String userId;
// 用户名 // 用户名

View File

@ -0,0 +1,12 @@
package com.zhyc.module.common.mapper;
import com.zhyc.module.common.domain.Post;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface PostMapper {
@Select("select * from sys_post where status = '0' and post_name like '%部'")
List<Post> selectPostList();
}

View File

@ -0,0 +1,12 @@
package com.zhyc.module.common.mapper;
import com.zhyc.module.common.domain.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserMapper {
List<User> getUserListByCode(String postCode);
}

View File

@ -1,12 +0,0 @@
package com.zhyc.module.common.mapper;
import com.zhyc.module.common.domain.UserPost;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserPostMapper {
List<UserPost> getUserPostListByCode(String postCode);
}

View File

@ -0,0 +1,9 @@
package com.zhyc.module.common.service;
import com.zhyc.module.common.domain.Post;
import java.util.List;
public interface PostService {
List<Post> selectPostList();
}

View File

@ -1,9 +0,0 @@
package com.zhyc.module.common.service;
import com.zhyc.module.common.domain.UserPost;
import java.util.List;
public interface UserPostService {
List<UserPost> getUserPostListByCode(String postCode);
}

View File

@ -0,0 +1,9 @@
package com.zhyc.module.common.service;
import com.zhyc.module.common.domain.User;
import java.util.List;
public interface UserService {
List<User> getUserListByCode(String postCode);
}

View File

@ -0,0 +1,22 @@
package com.zhyc.module.common.service.impl;
import com.zhyc.module.common.domain.Post;
import com.zhyc.module.common.mapper.PostMapper;
import com.zhyc.module.common.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PostServiceImpl implements PostService {
@Autowired
PostMapper postMapper;
@Override
public List<Post> selectPostList() {
List<Post> list = postMapper.selectPostList();
return list;
}
}

View File

@ -1,19 +1,20 @@
package com.zhyc.module.common.service.impl; package com.zhyc.module.common.service.impl;
import com.zhyc.module.common.domain.UserPost; import com.zhyc.module.common.domain.User;
import com.zhyc.module.common.mapper.UserPostMapper; import com.zhyc.module.common.mapper.UserMapper;
import com.zhyc.module.common.service.UserPostService; import com.zhyc.module.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@Service @Service
public class UserPostServiceImpl implements UserPostService { public class UserPostServiceImpl implements UserService {
@Autowired @Autowired
UserPostMapper userPostMapper; UserMapper userMapper;
@Override @Override
public List<UserPost> getUserPostListByCode(String postCode) { public List<User> getUserListByCode(String postCode) {
return userPostMapper.getUserPostListByCode(postCode); return userMapper.getUserListByCode(postCode);
} }
} }

View File

@ -2,16 +2,16 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.common.mapper.UserPostMapper"> <mapper namespace="com.zhyc.module.common.mapper.UserMapper">
<resultMap type="UserPost" id="UserPostResult"> <resultMap type="User" id="UserResult">
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="nickName" column="nick_name" /> <result property="nickName" column="nick_name" />
<result property="postName" column="post_name"/> <result property="postName" column="post_name"/>
<result property="postCode" column="post_code" /> <result property="postCode" column="post_code" />
</resultMap> </resultMap>
<select id="getUserPostListByCode" resultMap="UserPostResult"> <select id="getUserPostListByCode" resultMap="UserResult">
SELECT u.user_id, nick_name , post_name , post_code SELECT u.user_id, nick_name , post_name , post_code
FROM sys_role r FROM sys_role r
JOIN sys_user_role ur ON r.role_id = ur.role_id JOIN sys_user_role ur ON r.role_id = ur.role_id