//package com.jiayue.ipp.common.mybatis.aspect;
//
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.stereotype.Component;
//
///**
// * 数据过滤处理
// *
// * @author L.ym
// */
//@Aspect
//@Component
//public class DataScopeAspect {
////
////	/**
////	 * 数据权限过滤关键字
////	 */
////	private static final String DATA_SCOPE = "dataScope";
////
////	/**
////	 * 配置织入点
////	 **/
////	@Pointcut("@annotation(com.jiayuep.ipp.common.mybatis.annotation.DataScope)")
////	public void dataScopePointCut() {
////	}
////
////	@Before("dataScopePointCut()")
////	public void doBefore(JoinPoint point) {
////		handleDataScope(point);
////	}
////
////	private void handleDataScope(final JoinPoint joinPoint) {
////		// 获得注解
////		DataScope dataScope = getAnnotationLog(joinPoint);
////		if (dataScope == null) {
////			return;
////		}
////		// 获取当前的用户
////		List<String> unitCodes = SecurityUtils.getUser().getUnitCodes();
////		if(CollectionUtil.isNotEmpty(unitCodes)){
////
////			dataScopeFilter(joinPoint, unitCodes, dataScope.unitAlias());
////		}else{
////
////		}
////
////	}
////	/**
////	 *
////	 * @param joinPoint 切点
////	 * @param unitCodes 当前用户集合
////	 * @param unitAlias 权限字段别名
////	 * @return void
////	 * @author yh
////	 * @date 2022/2/25
////	 */
////	private void dataScopeFilter(JoinPoint joinPoint, List<String> unitCodes, String unitAlias) {
////		StringBuilder sqlString = new StringBuilder();
////
////		for (String unit:unitCodes){
////			sqlString.append(StrUtil.format("'{}',", unit, sqlString .toString()).toString());
////		}
////		sqlString.deleteCharAt(sqlString.length()-1);
////
////		String appendSql = StrUtil.format("{} IN ({}) ", unitAlias, sqlString .toString()).toString();
////
////		if (StrUtil.isNotBlank(appendSql)) {
////
////			Object params = joinPoint.getArgs()[0];
////			if (Validator.isNotNull(params) && params instanceof BaseEntity) {
////				BaseEntity baseEntity = (BaseEntity) params;
////				baseEntity.getParams().put(DATA_SCOPE, " AND  " + appendSql + "");
////			} else if (Validator.isNotNull(params) && params instanceof QueryWrapper) {
////				QueryWrapper queryWrapper = (QueryWrapper) params;
////				queryWrapper.apply(appendSql);
////			} else if (Validator.isNotNull(params) && params instanceof LambdaQueryWrapper) {
////				LambdaQueryWrapper queryWrapper = (LambdaQueryWrapper) params;
////				queryWrapper.apply(appendSql);
////			}
////		}
////	}
////
////	/**
////	 * 是否存在注解，如果存在就获取
////	 */
////	private DataScope getAnnotationLog(JoinPoint joinPoint) {
////		Signature signature = joinPoint.getSignature();
////		MethodSignature methodSignature = (MethodSignature) signature;
////		Method method = methodSignature.getMethod();
////		if (Validator.isNotNull(method)) {
////			return method.getAnnotation(DataScope.class);
////		}
////		return null;
////	}
//}
