Commit a71518cb authored by 廖旭伟's avatar 廖旭伟

用户列表查询以及站点授权bug修改

parent b4c25cc3
package com.mortals.xhx.module.user.service.impl; package com.mortals.xhx.module.user.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.SysConstains; import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.code.UserType; import com.mortals.framework.common.code.UserType;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -9,6 +11,8 @@ import com.mortals.framework.model.Result; ...@@ -9,6 +11,8 @@ import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.SecurityUtil; import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.feign.rsp.ApiResp;
import com.mortals.xhx.module.area.model.AreaQuery; import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.service.AreaService; import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.menu.service.MenuService; import com.mortals.xhx.module.menu.service.MenuService;
...@@ -80,7 +84,12 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -80,7 +84,12 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
} }
if(StringUtils.isNotEmpty(entity.getAreaCodes())){ if(StringUtils.isNotEmpty(entity.getAreaCodes())){
List<String> areaCodeList = Arrays.asList(entity.getAreaCodes().split(",")); List<String> areaCodeList = Arrays.asList(entity.getAreaCodes().split(","));
String siteIds = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null); String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
JSONObject apiResp = JSON.parseObject(resp);
if (apiResp.getInteger("code") != YesNoEnum.YES.getValue()) {
throw new AppException("获取用户站点列表树数据失败:" + apiResp.getString("msg"));
}
String siteIds = apiResp.getString("data");
entity.setSiteIds(siteIds); entity.setSiteIds(siteIds);
} }
...@@ -206,10 +215,15 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -206,10 +215,15 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override @Override
public void siteAuth(UserEntityExt entityExt, Context context) { public void siteAuth(UserEntityExt entityExt, Context context) {
if (!ObjectUtils.isEmpty(entityExt.getUserId())) { if (ObjectUtils.isEmpty(entityExt.getUserId())) {
throw new AppException("用户ID不能为空!"); throw new AppException("用户ID不能为空!");
} }
String siteIds = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(entityExt.getAreaCodeList()), context); String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(entityExt.getAreaCodeList()), context);
JSONObject apiResp = JSON.parseObject(resp);
if (apiResp.getInteger("code") != YesNoEnum.YES.getValue()) {
throw new AppException("获取用户站点列表树数据失败:" + apiResp.getString("msg"));
}
String siteIds = apiResp.getString("data");
UserEntity userEntity = this.get(entityExt.getUserId(), context); UserEntity userEntity = this.get(entityExt.getUserId(), context);
userEntity.setAreaCodes(entityExt.getAreaCodeList().stream().collect(Collectors.joining(","))); userEntity.setAreaCodes(entityExt.getAreaCodeList().stream().collect(Collectors.joining(",")));
userEntity.setSiteIds(siteIds); userEntity.setSiteIds(siteIds);
......
...@@ -100,7 +100,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -100,7 +100,7 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Override @Override
@UnAuth @UnAuth
public Rest<Object> list(UserEntity query) { public Rest<Object> list(@RequestBody UserEntity query) {
Map<String, Object> model = new HashMap(); Map<String, Object> model = new HashMap();
Rest<Object> ret = new Rest<>(); Rest<Object> ret = new Rest<>();
Context context = this.getContext(); Context context = this.getContext();
......
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