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

修改admin账号登陆时在无站点情况下无法进入基础设置的bug

parent 7867872e
...@@ -18,4 +18,7 @@ public class ModelVo extends BaseEntityLong { ...@@ -18,4 +18,7 @@ public class ModelVo extends BaseEntityLong {
private Long siteId; private Long siteId;
/** 模块下包含的数据统计 */ /** 模块下包含的数据统计 */
private List<ModelCensusEntity> censusList; private List<ModelCensusEntity> censusList;
/** 是否admin 0否,1是*/
private Integer isAdmin;
} }
\ No newline at end of file
...@@ -32,5 +32,5 @@ public interface ModelService extends ICRUDService<ModelEntity,Long>{ ...@@ -32,5 +32,5 @@ public interface ModelService extends ICRUDService<ModelEntity,Long>{
* @return * @return
* @throws AppException * @throws AppException
*/ */
List<ModelEntity> getListBySiteId(Long siteId) throws AppException; List<ModelEntity> getListBySiteId(Long siteId,Integer isAdmin) throws AppException;
} }
\ No newline at end of file
...@@ -50,7 +50,17 @@ public class ModelServiceImpl extends AbstractCRUDServiceImpl<ModelDao, ModelEnt ...@@ -50,7 +50,17 @@ public class ModelServiceImpl extends AbstractCRUDServiceImpl<ModelDao, ModelEnt
} }
@Override @Override
public List<ModelEntity> getListBySiteId(Long siteId) throws AppException { public List<ModelEntity> getListBySiteId(Long siteId,Integer isAdmin) throws AppException {
if(isAdmin!=null&&isAdmin==1){
ModelQuery modelQuery = new ModelQuery();
modelQuery.setOrderColList(new ArrayList<OrderCol>() {
{
add(new OrderCol("a.sort", OrderCol.ASCENDING));
}
});
List<ModelEntity> modelEntityList = this.find(modelQuery);
return modelEntityList;
}
if(siteId==null || siteId==0){ if(siteId==null || siteId==0){
return Collections.emptyList(); return Collections.emptyList();
} }
......
...@@ -135,7 +135,7 @@ public class ModelController extends BaseCRUDJsonBodyMappingController<ModelServ ...@@ -135,7 +135,7 @@ public class ModelController extends BaseCRUDJsonBodyMappingController<ModelServ
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code=1; int code=1;
try { try {
List<ModelEntity> result = this.getService().getListBySiteId(query.getSiteId()); List<ModelEntity> result = this.getService().getListBySiteId(query.getSiteId(),query.getIsAdmin());
model.put("data", result); model.put("data", result);
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
......
...@@ -8,4 +8,6 @@ import java.util.List; ...@@ -8,4 +8,6 @@ import java.util.List;
public class ModelPdu { public class ModelPdu {
private List<Long> idList; private List<Long> idList;
private Long siteId; private Long siteId;
/** 是否admin 0否,1是*/
private Integer isAdmin;
} }
...@@ -76,21 +76,30 @@ public class ModelController extends BaseJsonBodyController { ...@@ -76,21 +76,30 @@ public class ModelController extends BaseJsonBodyController {
String busiDesc = "查询站点编排" ; String busiDesc = "查询站点编排" ;
int code=1; int code=1;
try { try {
if(this.getCurUser()==null){
throw new AppException("未登录或者登录过期");
}
ModelPdu modelPdu = new ModelPdu(); ModelPdu modelPdu = new ModelPdu();
modelPdu.setSiteId(query.getSiteId()); modelPdu.setSiteId(query.getSiteId());
if(this.getCurUser().getId()==1){
modelPdu.setIsAdmin(1);
}else {
modelPdu.setIsAdmin(0);
}
//ApiResp<List<ModelFeignVO>> apiResp = apiModelFeign.getModelBySiteId(modelPdu); //ApiResp<List<ModelFeignVO>> apiResp = apiModelFeign.getModelBySiteId(modelPdu);
String resp = apiModelFeign.getModelBySiteId(modelPdu); String resp = apiModelFeign.getModelBySiteId(modelPdu);
ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class); ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class);
if (apiResp.getCode() != YesNoEnum.YES.getValue()) { if (apiResp.getCode() != YesNoEnum.YES.getValue()) {
throw new AppException("获取站点列表信息失败:" + apiResp.getMsg()); throw new AppException("获取站点列表信息失败:" + apiResp.getMsg());
} }
if(this.getCurUser()==null){
throw new AppException("未登录或者登录过期");
}
Map<Long,Long> map = roleModelService.getModelIdsUserId(this.getCurUser().getId()); Map<Long,Long> map = roleModelService.getModelIdsUserId(this.getCurUser().getId());
List<ModelFeignVO> modelFeignVOList = JSONObject.parseArray(apiResp.getData().get("data").toString(),ModelFeignVO.class); List<ModelFeignVO> modelFeignVOList = JSONObject.parseArray(apiResp.getData().get("data").toString(),ModelFeignVO.class);
List<ModelFeignVO> list = modelFeignVOList.stream().filter(item->map.containsKey(item.getId())).collect(Collectors.toList()); List<ModelFeignVO> list = modelFeignVOList.stream().filter(item->map.containsKey(item.getId())).collect(Collectors.toList());
if(this.getCurUser().getId()==1){
model.put("data", modelFeignVOList);
}else {
model.put("data", list); model.put("data", list);
}
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) { } catch (Exception var9) {
......
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