Commit 8bb8dda6 by guojuxing

用户列表接口

parent a73ed3ce
......@@ -2,6 +2,7 @@ package com.gic.auth.dao.mapper;
import java.util.List;
import com.gic.auth.qo.UserListQO;
import org.apache.ibatis.annotations.Param;
import com.gic.auth.entity.TabSysUser;
......@@ -70,4 +71,14 @@ public interface TabSysUserMapper {
TabSysUser login(@Param("phoneNumber") String phoneNumber,
@Param("password") String password,
@Param("enterpriseId") Integer enterpriseId);
/**
* 列表查询
* @Title: listUser

* @Description:

 * @author guojuxing
* @param params

* @return java.util.List<com.gic.auth.entity.TabSysUser>


 */
List<TabSysUser> listUser(UserListQO params);
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import java.util.List;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.qo.UserListQO;
import com.github.pagehelper.Page;
/**
* @author guojx
......@@ -40,4 +42,14 @@ public interface UserService {
List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber);
TabSysUser login(String phoneNumber, Integer enterpriseId, String password);
/**
* 查询管理员列表数据
* @Title: pageUser

* @Description:

 * @author guojuxing
* @param params

* @return com.github.pagehelper.Page


 */
Page pageUser(UserListQO params);
}
......@@ -4,13 +4,16 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gic.auth.dao.mapper.TabSysUserMapper;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.qo.UserListQO;
import com.gic.auth.service.UserService;
import com.gic.commons.util.EntityUtil;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
/**
* @author guojx
......@@ -64,4 +67,11 @@ public class UserServiceImpl implements UserService {
public TabSysUser login(String phoneNumber, Integer enterpriseId, String password) {
return this.tabSysUserMapper.login(phoneNumber, password, enterpriseId);
}
@Override
public Page pageUser(UserListQO params) {
PageHelper.startPage(params.getCurrentPage(), params.getPageSize());
List<TabSysUser> list = tabSysUserMapper.listUser(params);
return (Page) list;
}
}
......@@ -10,13 +10,16 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.qo.UserListQO;
import com.gic.auth.service.*;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode;
import com.gic.store.utils.valid.ValidUtil;
......@@ -151,6 +154,13 @@ public class UserApiServiceImpl implements UserApiService {
return ServiceResponse.success(EntityUtil.changeEntityByJSON(UserDTO.class, user));
}
@Override
public ServiceResponse<Page<UserDTO>> pageUser(UserListQO params) {
com.github.pagehelper.Page page = userService.pageUser(params);
Page<UserDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, UserDTO.class);
return ServiceResponse.success(resultPage);
}
/**
* 保存关联数据,角色关联、资源关联
* @Title: saveRole

......
......@@ -211,4 +211,25 @@
and enterprise_id = #{enterpriseId}
and password = #{password}
</select>
<select id="listUser" resultType="com.gic.auth.dto.UserListDTO" parameterType="com.gic.auth.qo.UserListQO">
select
a.user_id userId,
a.user_name userName,
a.phone_number phoneNumber,
a.phone_area_code phoneAreaCode,
GROUP_CONCAT(b.role_id) userRoleIds,
GROUP_CONCAT(c.resource_id) userResourceIds
from tab_sys_user a
left join tab_sys_user_role b on a.user_id = b.user_id
left join tab_sys_user_resource c on a.user_id = c.user_id
where a.enterprise_id = #{enterpriseId}
and a.status = 1
and b.status = 1
and c.status = 1
<if test="search != null and search != '' ">
and ( a.user_name like concat('%', #{search}, '%') or a.phone_number like concat('%', #{search}, '%') )
</if>
</select>
</mapper>
\ No newline at end of file
package com.gic.auth.web.controller;
import com.gic.auth.web.vo.UserDetailVO;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,12 +9,14 @@ import org.springframework.web.bind.annotation.RestController;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.qo.UserListQO;
import com.gic.auth.service.UserApiService;
import com.gic.auth.web.utils.UserPasswordUtils;
import com.gic.auth.web.vo.UserDetailVO;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.response.EnterpriseRestResponse;
import com.gic.store.constant.StoreGroupConstant;
import com.gic.store.utils.CommonResultControllerUtils;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
@RestController
@RequestMapping("/user")
......@@ -62,10 +61,9 @@ public class UserController {
return ResultControllerUtils.commonResultOne(userApiService.getUserById(userId), UserDetailVO.class);
}
@RequestMapping("/get-user")
public RestResponse getUser() {
return RestResponse.success(CommonResultControllerUtils
.commonResult(userApiService.getUserByEnterpriseId(StoreGroupConstant.TEST_ENTERPRISE_ID)));
@RequestMapping("/list-user")
public RestResponse listUser(UserListQO params) {
return ResultControllerUtils.commonResult(userApiService.pageUser(params));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment