Commit c207f06e authored by tangwei's avatar tangwei

增加权限

parent 5710fb1c
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.UserOrgTreeModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/4/25
*/
@RestController
@Api(tags = "平台单位部门树")
@RequestMapping(value = "/companyClient")
public class PrivilegeController extends BaseController{
@Autowired
private RedisUtils redisUtils;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/queryOrgTree")
@ApiOperation(httpMethod = "GET",value = "查询单位、子单位、部门树", notes = "查询单位、子单位、部门树")
public FeignClientResult<Collection<UserOrgTreeModel>> queryOrgTree() {
//获取当前登录人单位
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
Long companyId=reginParams.getCompany().getSequenceNbr();
FeignClientResult<Collection<UserOrgTreeModel>> de =Privilege.companyClient.queryOrgTree(companyId);
return de;
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/subcompany")
@ApiOperation(httpMethod = "GET",value = "查询单位、子单位、部门树", notes = "查询单位、子单位、部门树")
public ResponseModel< List<CompanyModel >> subcompany() {
//获取当前登录人单位
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
Long companyId=reginParams.getCompany().getSequenceNbr();
FeignClientResult<Collection<CompanyModel>> de =Privilege.companyClient.querySubAgencyTree(companyId);
CompanyModel companyModel=new CompanyModel();
companyModel.setSequenceNbr(companyId);
companyModel.setCompanyName(reginParams.getCompany().getCompanyName());
companyModel.setChildren(de.getResult());
List<CompanyModel > date=new ArrayList();
date.add(companyModel);
return ResponseHelper.buildResponse(date);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.excel.DataSources; import com.yeejoin.amos.boot.biz.common.excel.DataSources;
import com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptorContext;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.UserOrgTreeModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import org.springframework.web.bind.annotation.PathVariable;
import java.util.Collection; import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.LinkedHashMap;
import java.util.List; import java.util.*;
/** /**
* @description: * @description:
...@@ -23,6 +31,10 @@ import java.util.List; ...@@ -23,6 +31,10 @@ import java.util.List;
@Service @Service
public class ExDataSourcesImpl implements DataSources { public class ExDataSourcesImpl implements DataSources {
@Autowired
private RedisUtils redisUtils;
@Override @Override
public String[] selectList(String type, String method) throws Exception { public String[] selectList(String type, String method) throws Exception {
String[] str = {}; String[] str = {};
...@@ -40,13 +52,20 @@ public class ExDataSourcesImpl implements DataSources { ...@@ -40,13 +52,20 @@ public class ExDataSourcesImpl implements DataSources {
private String[] getArea() { private String[] getArea() {
FeignClientResult<Collection<CompanyModel>> de = Privilege.companyClient.queryAgencyTree(null); //获取当前登录人单位
Collection<CompanyModel> listco = new ArrayList<>(); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
Long companyId=reginParams.getCompany().getSequenceNbr();
FeignClientResult<Collection<UserOrgTreeModel>> de =Privilege.companyClient.queryOrgTree(companyId);
Collection<UserOrgTreeModel> listco = new ArrayList<>();
String[] str = null; String[] str = null;
if (!ObjectUtils.isEmpty(de)) { if (!ObjectUtils.isEmpty(de)) {
if (de.getStatus() == 200) { if (de.getStatus() == 200) {
listco = de.getResult(); listco = de.getResult();
List<String> collect = this.getCompanyModel(listco); List<String> collect=new ArrayList<>();
this.getCompanyModel(listco,collect);
str = collect.toArray(new String[collect.size()]); str = collect.toArray(new String[collect.size()]);
} else { } else {
throw new RuntimeException(de.getMessage()); throw new RuntimeException(de.getMessage());
...@@ -57,14 +76,14 @@ public class ExDataSourcesImpl implements DataSources { ...@@ -57,14 +76,14 @@ public class ExDataSourcesImpl implements DataSources {
public List<String> getCompanyModel(Collection<CompanyModel> data) { public List<String> getCompanyModel(Collection<UserOrgTreeModel> data,List<String> datas) {
List<String> datas = new ArrayList<>();
if (!data.isEmpty()) { if (!data.isEmpty()) {
for (CompanyModel datum : data) { for (UserOrgTreeModel datum : data) {
datas.add(datum.getCompanyName() + "@" + datum.getSequenceNbr()); datas.add(datum.getId() + "@" + datum.getName());
if (datum.getChildren() != null) { if (datum.getChildren() != null) {
this.getCompanyModelchildren((List<LinkedHashMap<String,Object>> ) datum.getChildren(),datas); this.getCompanyModel(datum.getChildren(),datas);
} }
} }
...@@ -74,19 +93,7 @@ public class ExDataSourcesImpl implements DataSources { ...@@ -74,19 +93,7 @@ public class ExDataSourcesImpl implements DataSources {
} }
public void getCompanyModelchildren(List<LinkedHashMap<String,Object>> data, List<String> datas) {
if (!data.isEmpty()) {
for (LinkedHashMap<String,Object> datum : data) {
datas.add(datum.get("companyName") + "@" + datum.get("sequenceNbr"));
if (datum.get("children")!= null) {
this.getCompanyModelchildren((List<LinkedHashMap<String,Object>> ) datum.get("children"),datas);
}
}
}
}
private String[] getDataDictionary(String type) { private String[] getDataDictionary(String type) {
List<String> collect =new ArrayList<>(); List<String> collect =new ArrayList<>();
......
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