作者 朱兆平

用户搜索

... ... @@ -36,15 +36,24 @@ public class UserController {
public PageInfo<USERS> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
int pageNum,
@RequestParam(value = "pageSize",required = false,defaultValue = "5")
int pageSize){
return userService.selectAllUser(pageNum,pageSize);
int pageSize,
@RequestParam(value = "username",required = false) String username,
@RequestParam(value = "realname",required = false) String realname)
{
USERS user = new USERS();
//前端input传过来的为空,需要判断下
username = username.isEmpty()?null:username;
realname = realname.isEmpty()?null:realname;
user.setUsername(username);
user.setRealname(realname);
return userService.selectAllUser(pageNum,pageSize,user);
}
public String getusername(){
public String getCurrentUser(){
//通过session获取当前登录的用户信息
UserDetails userDetails =(UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return "欢迎回来:"+userDetails.getUsername();
return userDetails.getUsername();
}
@LogAnnotation(moduleName = "用户管理",operate = "用户编辑")
... ...
... ... @@ -19,5 +19,5 @@ public interface USERSMapper {
List<USERS> selectByUsername(String userName);
List<USERS> selectAllUser();
List<USERS> selectAllUser(USERS record);
}
\ No newline at end of file
... ...
... ... @@ -9,7 +9,7 @@ import java.util.List;
public interface UserService {
USERS loadByUsername(String username);
PageInfo<USERS> selectAllUser(int pageNum, int pageSize);
PageInfo<USERS> selectAllUser(int pageNum, int pageSize,USERS users);
int updateByPrimaryKeySelective(USERS record);
... ...
... ... @@ -56,9 +56,9 @@ public class UserServiceImpl implements UserService{
}
@Override
public PageInfo<USERS> selectAllUser(int pageNum, int pageSize){
public PageInfo<USERS> selectAllUser(int pageNum, int pageSize,USERS users){
Page<USERS> page = PageHelper.startPage(pageNum,pageSize);
List<USERS> list = usersMapper.selectAllUser();
List<USERS> list = usersMapper.selectAllUser(users);
for (USERS user: list) {
List<PERMISSION> permissionList = permissionMapper.findByUserId(user.getUserId());
user.setPermissions(permissionList);
... ...
... ... @@ -36,10 +36,17 @@
from USERS
where USERNAME = #{username,jdbcType=VARCHAR}
</select>
<select id="selectAllUser" resultMap="BaseResultMap" >
<select id="selectAllUser" resultMap="BaseResultMap" parameterType="com.tianbo.warehouse.model.USERS" >
select
<include refid="user_List" />
from USERS
WHERE 1=1
<if test="username != null" >
and username = #{username,jdbcType=VARCHAR}
</if>
<if test="realname != null" >
and realName = #{realname,jdbcType=VARCHAR}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from users
... ...