Commit 19b7bb54 by zhanghj

V1.0.0--获取服务商下的技工列表增加分页

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@18087 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b1ed39ba
package com.glsx.usercenter.controller;
import java.io.ByteArrayOutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.groups.Default;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.utils.*;
import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.dto.MerchantInfo;
import com.glsx.usercenter.mapper.DictionaryTypeMapper;
import com.glsx.usercenter.mapper.SysRoleMapper;
import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.pojo.dictionary.DictionaryData;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.utils.AccountValidatorUtil;
import com.glsx.usercenter.utils.QRCodeUtil;
import com.glsx.usercenter.utils.RedisCacheUtil;
import com.glsx.usercenter.utils.ShiroUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.ExcessiveAttemptsException;
......@@ -34,25 +19,43 @@ import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.*;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.util.StringUtil;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.Page;
import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.dto.MerchantInfo;
import com.glsx.usercenter.mapper.SysRoleMapper;
import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.pojo.Test;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysMechanic;
import com.glsx.usercenter.pojo.user.SysMerchant;
import com.glsx.usercenter.pojo.user.SysResourceMatching;
import com.glsx.usercenter.pojo.user.SysUser;
import com.glsx.usercenter.pojo.user.SysUserImage;
import com.glsx.usercenter.pojo.user.SysUserImageExample;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.service.SysUserService;
import org.springframework.web.multipart.MultipartFile;
import com.glsx.usercenter.utils.AccountValidatorUtil;
import com.glsx.usercenter.utils.QRCodeUtil;
import com.glsx.usercenter.utils.RedisCacheUtil;
import com.glsx.usercenter.utils.ShiroUtil;
/**
* @author duanht
......@@ -685,10 +688,16 @@ public class UserController extends BaseController {
*
*/
@RequestMapping(value = "/getServiceMechanicList", method = {RequestMethod.GET})
public ResultObject getServiceMechanicList(HttpServletRequest request) {
public ResultObject getServiceMechanicList(HttpServletRequest request, @RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize) {
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
Integer userId = ShiroUtil.getUserId();
List<SysMechanic> list = sysUserService.getServiceMechanicList(userId);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), list);
List<SysMechanic> list = sysUserService.getServiceMechanicList(userId, page);
com.github.pagehelper.Page<SysMechanic> pages = (com.github.pagehelper.Page<SysMechanic>) list;
page.setTotalCount((int)pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
}
......@@ -237,9 +237,10 @@ public interface SysUserService {
* @Title: getServiceMechanicList
* @Description: TODO 获取服务商下面的技工列表
* @param userId
* @param page
* @return
* List<SysMechanic>
*
*/
List<SysMechanic> getServiceMechanicList(Integer userId);
List<SysMechanic> getServiceMechanicList(Integer userId, Page page);
}
......@@ -3,10 +3,6 @@ package com.glsx.usercenter.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.github.pagehelper.PageHelper;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.service.IAreaService;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.LockedAccountException;
......@@ -19,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.dto.ServiceInfo;
import com.glsx.usercenter.mapper.SysOrganizationMapper;
......@@ -43,6 +41,7 @@ import com.glsx.usercenter.pojo.user.SysUserOrg;
import com.glsx.usercenter.pojo.user.SysUserRole;
import com.glsx.usercenter.pojo.user.SysUserServices;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.service.SysUserService;
......@@ -625,8 +624,9 @@ public class SysUserServiceImpl implements SysUserService {
}
@Override
public List<SysMechanic> getServiceMechanicList(Integer userId) {
public List<SysMechanic> getServiceMechanicList(Integer userId, Page page) {
// TODO Auto-generated method stub
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
List<SysMechanic> list = sysUserMapper.getServiceMechanicList(userId);
for (SysMechanic sysMechanic : list) {
if (StringUtils.isNotEmpty(sysMechanic.getDistrict())) {
......
......@@ -955,7 +955,7 @@
<select id="getServiceMechanicList" resultType="com.glsx.usercenter.pojo.user.SysMechanic">
select
u.id, u.username, u.name, u.phone_number,
m.district,
m.district, m.address,
GROUP_CONCAT(sdd.data_value SEPARATOR '、') serviceItems
FROM sys_service_mechanic sm
LEFT JOIN sys_user u on sm.mechanic_id = u.id
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!