diff --git a/src/main/java/com/cm/inspection/controller/apis/gridpersonnel/GridPersonnelController.java b/src/main/java/com/cm/inspection/controller/apis/gridpersonnel/GridPersonnelController.java index deaa822..3ca582e 100644 --- a/src/main/java/com/cm/inspection/controller/apis/gridpersonnel/GridPersonnelController.java +++ b/src/main/java/com/cm/inspection/controller/apis/gridpersonnel/GridPersonnelController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -114,7 +115,7 @@ public class GridPersonnelController extends AbstractController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpagegridpersonnel") - public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException, UnsupportedEncodingException { Map params = requestParams(); page.setParams(params); return gridPersonnelService.listPageGridPersonnel(page); @@ -137,7 +138,7 @@ public class GridPersonnelController extends AbstractController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpagegridpersonnelofmine") - public SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException, UnsupportedEncodingException { Map params = requestParams(); page.setParams(params); return gridPersonnelService.listPageGridPersonnelOfMine(page); diff --git a/src/main/java/com/cm/inspection/controller/app/apis/gridpersonnel/GridPersonnelAppController.java b/src/main/java/com/cm/inspection/controller/app/apis/gridpersonnel/GridPersonnelAppController.java index 4e709d8..485bdb3 100644 --- a/src/main/java/com/cm/inspection/controller/app/apis/gridpersonnel/GridPersonnelAppController.java +++ b/src/main/java/com/cm/inspection/controller/app/apis/gridpersonnel/GridPersonnelAppController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -102,7 +103,7 @@ public class GridPersonnelAppController extends AbstractController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpagegridpersonnel") - public SuccessResultList> listPageGridPersonnel(@RequestHeader("token") String token, ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnel(@RequestHeader("token") String token, ListPage page) throws SearchException, UnsupportedEncodingException { Map params = requestParams(); page.setParams(params); return gridPersonnelService.listPageGridPersonnel(page); diff --git a/src/main/java/com/cm/inspection/controller/resources/gridpersonnel/GridPersonnelResourceController.java b/src/main/java/com/cm/inspection/controller/resources/gridpersonnel/GridPersonnelResourceController.java index 98d1e57..21cf975 100644 --- a/src/main/java/com/cm/inspection/controller/resources/gridpersonnel/GridPersonnelResourceController.java +++ b/src/main/java/com/cm/inspection/controller/resources/gridpersonnel/GridPersonnelResourceController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -102,7 +103,7 @@ public class GridPersonnelResourceController extends AbstractController { }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpagegridpersonnel") - public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException, UnsupportedEncodingException { Map params = requestParams(); page.setParams(params); return gridPersonnelService.listPageGridPersonnel(page); diff --git a/src/main/java/com/cm/inspection/service/gridpersonnel/IGridPersonnelService.java b/src/main/java/com/cm/inspection/service/gridpersonnel/IGridPersonnelService.java index c6eca2a..e7872e9 100644 --- a/src/main/java/com/cm/inspection/service/gridpersonnel/IGridPersonnelService.java +++ b/src/main/java/com/cm/inspection/service/gridpersonnel/IGridPersonnelService.java @@ -11,6 +11,7 @@ import com.cm.common.result.SuccessResultList; import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO; import com.cm.inspection.pojo.vos.gridpersonnel.GridPersonnelVO; +import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Map; @@ -116,7 +117,7 @@ public interface IGridPersonnelService { * @return * @throws SearchException */ - SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException; + SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException, UnsupportedEncodingException; /** * 网格人员列表(通过用户名和是否是网格员) @@ -173,7 +174,7 @@ public interface IGridPersonnelService { * @return * @throws SearchException */ - SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException; + SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException, UnsupportedEncodingException; /** * 获取我的网格员身份 diff --git a/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java b/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java index 42963e1..1e857bd 100644 --- a/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java @@ -8,6 +8,7 @@ import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.plugin.oauth.service.user.IUserService; +import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; @@ -24,9 +25,12 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.oauth2.client.resource.UserRedirectRequiredException; import org.springframework.stereotype.Service; import javax.swing.text.ParagraphView; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Array; import java.util.*; /** @@ -202,8 +206,21 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson } @Override - public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnel(ListPage page) throws SearchException, UnsupportedEncodingException { PageHelper.startPage(page.getPage(), page.getRows()); + Object keywords = page.getParams().get("keywords"); + if(keywords != null && !StringUtils.isBlank(keywords.toString())) { + page.getParams().remove("keywords"); + List userIds = new ArrayList<>(); + List userResourceBOs = userService.listResourceByKeywords(keywords.toString()); + for(UserResourceBO userResourceBO : userResourceBOs) { + userIds.add(userResourceBO.getUserId()); + } + if(userIds.isEmpty()) { + return new SuccessResultList<>(new ArrayList<>(), page.getPage(), 0L); + } + page.getParams().put("userIds", userIds); + } List gridPersonnelDTOs = gridPersonnelDao.listGridPersonnel(page.getParams()); PageInfo pageInfo = new PageInfo<>(gridPersonnelDTOs); setGridPersonnelUserInfo(gridPersonnelDTOs); @@ -252,7 +269,7 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson } @Override - public SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException { + public SuccessResultList> listPageGridPersonnelOfMine(ListPage page) throws SearchException, UnsupportedEncodingException { page.getParams().put("leaderUserId", securityComponent.getCurrentUser().getUserId()); return listPageGridPersonnel(page); }