|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.ims.eval.cache.CacheContext;
|
|
|
import com.ims.eval.entity.DataDictionary;
|
|
|
+import com.ims.eval.entity.OrganizationEvaluationRule;
|
|
|
import com.ims.eval.entity.custom.PostUser;
|
|
|
import com.ims.eval.entity.dto.response.MyuserResDTO;
|
|
|
import com.ims.eval.entity.dto.result.PagResult;
|
|
@@ -38,7 +39,6 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.sound.midi.Soundbank;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.sql.Connection;
|
|
|
import java.util.*;
|
|
@@ -55,17 +55,18 @@ public class PermissionAspect implements Interceptor {
|
|
|
|
|
|
@Autowired
|
|
|
private RemoteServiceBuilder serviceBuilder;
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
private HttpServletRequest request;
|
|
|
@Autowired
|
|
|
private PostUserService postUserService;
|
|
|
|
|
|
+
|
|
|
//扫描的包路径,需要权限的加在mapper类及方法上
|
|
|
private String packagePath = "com.ims.eval.dao";
|
|
|
private final static String DEPT_ID = "dept_id";
|
|
|
private final static String ORGANIZATION_ID = "organization_id";
|
|
|
+
|
|
|
+ private final static String BIN_SECTION = "bin_section";
|
|
|
private final static String DEPT_MARK = "BM0001";//部门
|
|
|
private final static String POS_MARK = "GW0001";//岗位
|
|
|
|
|
@@ -190,10 +191,16 @@ public class PermissionAspect implements Interceptor {
|
|
|
if (dataPermission != null) {
|
|
|
methodNames.put(newId + "-" + method.getName(), dataPermission.isPermission());
|
|
|
methodNames.put(newId + "-" + method.getName()+"type", dataPermission.type());
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"zbtype", dataPermission.zbtype());
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"jbtype", dataPermission.jbtype());
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"bktype", dataPermission.bktype());
|
|
|
}
|
|
|
} else {
|
|
|
methodNames.put(newId + "-" + method.getName(), true);
|
|
|
methodNames.put(newId + "-" + method.getName()+"type", false);
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"zbtype", false);
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"jbtype", false);
|
|
|
+ methodNames.put(newId + "-" + method.getName()+"bktype", false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -208,15 +215,42 @@ public class PermissionAspect implements Interceptor {
|
|
|
if (mappedStatement.getSqlCommandType().toString().equals("SELECT")) {
|
|
|
|
|
|
|
|
|
- if(null != post && post.getKeyValue().equals("JCDW")){
|
|
|
+// boolean jbtype = null != methodNames.get(newId + "-" + newName+"jbtype") ?methodNames.get(newId + "-" + newName+"jbtype") :false;
|
|
|
+ boolean type = null != methodNames.get(newId + "-" + newName + "type") ? methodNames.get(newId + "-" + newName + "type") : false;
|
|
|
+ boolean zbtype = null != methodNames.get(newId + "-" + newName+"zbtype") ?methodNames.get(newId + "-" + newName+"zbtype") :false;
|
|
|
+ boolean bktype = null != methodNames.get(newId + "-" + newName+"bktype") ?methodNames.get(newId + "-" + newName+"bktype") :false;
|
|
|
+
|
|
|
+ if (null != post && post.getKeyValue().equals("JCDW")) {
|
|
|
|
|
|
- boolean type = null != methodNames.get(newId + "-" + newName+"type") ?methodNames.get(newId + "-" + newName+"type") :false;
|
|
|
if (type) {
|
|
|
- sql = getSql(sql, organizationId,"JCDW");
|
|
|
+ sql = getSql(sql, organizationId, "JCDW");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (zbtype) {
|
|
|
+ sql = getSql(sql, "", "JCDW");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bktype) {
|
|
|
+
|
|
|
+ List<OrganizationEvaluationRule> list = CacheContext.ruleMap.get(organizationId);
|
|
|
+ StringBuilder bis = new StringBuilder("(");
|
|
|
+ for (OrganizationEvaluationRule rule : list) {
|
|
|
+ rule.getBinSection();
|
|
|
+ for (String bi : rule.getBinSection().split(",")) {
|
|
|
+ bis.append("'").append(bi).append("',");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bis.append(")");
|
|
|
+
|
|
|
+ System.out.println("查询条件:"+bis.toString().replace(",)",")"));
|
|
|
+ sql = getSql(sql, bis.toString().replace(",)",")"), "bktype");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (!type) {
|
|
|
+ sql = getSql(sql, deptId, "");
|
|
|
}
|
|
|
|
|
|
- }else {
|
|
|
- sql = getSql(sql, deptId,"");
|
|
|
}
|
|
|
|
|
|
// 修改sql
|
|
@@ -247,7 +281,12 @@ public class PermissionAspect implements Interceptor {
|
|
|
if (table.getAlias() != null) {
|
|
|
if (unitFlag.equals("JCDW")) {
|
|
|
|
|
|
- condition = table.getAlias().getName() + "." + ORGANIZATION_ID + "='" + deptId + "'";;
|
|
|
+ if(!"".equals(deptId.trim())){
|
|
|
+ condition = table.getAlias().getName() + "." + ORGANIZATION_ID + "='" + deptId + "'";
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (unitFlag.equals("bktype")) {
|
|
|
+ condition = table.getAlias().getName() + "." + BIN_SECTION + " in " + deptId;
|
|
|
} else {
|
|
|
condition = "("+table.getAlias().getName() + "." + DEPT_ID + "='" + deptId + "' or "+table.getAlias().getName() + "." + DEPT_ID + "='PUBLIC')";;
|
|
|
}
|