租户id切面
This commit is contained in:
parent
b334803cd1
commit
b0023784ee
@ -0,0 +1,160 @@
|
|||||||
|
package com.xhpc.charging.station;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xhpc.common.core.constant.CacheConstants;
|
||||||
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
||||||
|
* @author fjd
|
||||||
|
* @date 2020-07-09 11:59
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class DaoAspect {
|
||||||
|
|
||||||
|
private static final String CREATE_USER = "createBy";
|
||||||
|
private static final String CREATE_TIME = "createTime";
|
||||||
|
private static final String UPDATE_USER = "updateBy";
|
||||||
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
private static final String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
|
public void daoUpdate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.insert*(..))")
|
||||||
|
public void daoCreate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Around("daoUpdate()")
|
||||||
|
public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
if (userName != null) {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("daoCreate()")
|
||||||
|
public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
Date date = new Date();
|
||||||
|
if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProperty(Object bean, String field) {
|
||||||
|
|
||||||
|
return StringUtils.isProperty(bean, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
package com.xhpc.general;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xhpc.common.core.constant.CacheConstants;
|
||||||
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
||||||
|
* @author fjd
|
||||||
|
* @date 2020-07-09 11:59
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class DaoAspect {
|
||||||
|
|
||||||
|
private static final String CREATE_USER = "createBy";
|
||||||
|
private static final String CREATE_TIME = "createTime";
|
||||||
|
private static final String UPDATE_USER = "updateBy";
|
||||||
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
private static final String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
|
public void daoUpdate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.insert*(..))")
|
||||||
|
public void daoCreate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Around("daoUpdate()")
|
||||||
|
public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
if (userName != null) {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("daoCreate()")
|
||||||
|
public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
Date date = new Date();
|
||||||
|
if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProperty(Object bean, String field) {
|
||||||
|
|
||||||
|
return StringUtils.isProperty(bean, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
package com.xhpc.invoice.aspect;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xhpc.common.core.constant.CacheConstants;
|
||||||
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
||||||
|
* @author fjd
|
||||||
|
* @date 2020-07-09 11:59
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class DaoAspect {
|
||||||
|
|
||||||
|
private static final String CREATE_USER = "createBy";
|
||||||
|
private static final String CREATE_TIME = "createTime";
|
||||||
|
private static final String UPDATE_USER = "updateBy";
|
||||||
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
private static final String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
|
public void daoUpdate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("execution(* com.xhpc..*.insert*(..))")
|
||||||
|
public void daoCreate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Around("daoUpdate()")
|
||||||
|
public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
if (userName != null) {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("daoCreate()")
|
||||||
|
public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable {
|
||||||
|
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attributes == null) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
try {
|
||||||
|
Object[] objects = point.getArgs();
|
||||||
|
if (objects != null && objects.length > 0) {
|
||||||
|
for (Object arg : objects) {
|
||||||
|
String token = request.getHeader(CacheConstants.HEADER);
|
||||||
|
token = token.substring(7);
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
try {
|
||||||
|
loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
String userName = "";
|
||||||
|
try {
|
||||||
|
userName = SecurityUtils.getUsername();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = loginUser.getUsername();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(userName)) {
|
||||||
|
userName = "admin";
|
||||||
|
}
|
||||||
|
Date date = new Date();
|
||||||
|
if (isProperty(arg, CREATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_USER) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_USER))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
|
}
|
||||||
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
Object object = point.proceed();
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProperty(Object bean, String field) {
|
||||||
|
|
||||||
|
return StringUtils.isProperty(bean, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -159,6 +159,8 @@ public class XhpcInvoice implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -261,7 +261,7 @@
|
|||||||
creator_id, creator_type, creator,
|
creator_id, creator_type, creator,
|
||||||
create_time, `status`, invoicing_time,
|
create_time, `status`, invoicing_time,
|
||||||
drawer, finance_notes, electric_invoice_url,
|
drawer, finance_notes, electric_invoice_url,
|
||||||
updator, update_time, del_flag)
|
updator, update_time, del_flag, tenant_id)
|
||||||
values (#{receiveEmail,jdbcType=VARCHAR}, #{titleType,jdbcType=INTEGER}, #{titleContent,jdbcType=VARCHAR},
|
values (#{receiveEmail,jdbcType=VARCHAR}, #{titleType,jdbcType=INTEGER}, #{titleContent,jdbcType=VARCHAR},
|
||||||
#{dutyNumber,jdbcType=VARCHAR}, #{invoiceContent,jdbcType=VARCHAR}, #{invoiceMoney,jdbcType=DECIMAL},
|
#{dutyNumber,jdbcType=VARCHAR}, #{invoiceContent,jdbcType=VARCHAR}, #{invoiceMoney,jdbcType=DECIMAL},
|
||||||
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL}, #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
|
#{invoiceOrderEletricTotalMoney,jdbcType=DECIMAL}, #{invoiceOrderServiceTotalMoney,jdbcType=DECIMAL},
|
||||||
@ -270,7 +270,8 @@
|
|||||||
#{creatorId,jdbcType=BIGINT}, #{creatorType,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR},
|
#{creatorId,jdbcType=BIGINT}, #{creatorType,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{invoicingTime,jdbcType=TIMESTAMP},
|
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{invoicingTime,jdbcType=TIMESTAMP},
|
||||||
#{drawer,jdbcType=VARCHAR}, #{financeNotes,jdbcType=VARCHAR}, #{electricInvoiceUrl,jdbcType=VARCHAR},
|
#{drawer,jdbcType=VARCHAR}, #{financeNotes,jdbcType=VARCHAR}, #{electricInvoiceUrl,jdbcType=VARCHAR},
|
||||||
#{updator,jdbcType=BIGINT}, #{updateTime,jdbcType=DATE}, #{delFlag,jdbcType=INTEGER})
|
#{updator,jdbcType=BIGINT}, #{updateTime,jdbcType=DATE}, #{delFlag,jdbcType=INTEGER},
|
||||||
|
#{tenantId,jdbcType=VARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" keyColumn="invoice_id" keyProperty="invoiceId"
|
<insert id="insertSelective" keyColumn="invoice_id" keyProperty="invoiceId"
|
||||||
parameterType="com.xhpc.invoice.pojo.XhpcInvoice" useGeneratedKeys="true">
|
parameterType="com.xhpc.invoice.pojo.XhpcInvoice" useGeneratedKeys="true">
|
||||||
@ -354,6 +355,9 @@
|
|||||||
<if test="delFlag != null">
|
<if test="delFlag != null">
|
||||||
del_flag,
|
del_flag,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="receiveEmail != null">
|
<if test="receiveEmail != null">
|
||||||
@ -434,6 +438,9 @@
|
|||||||
<if test="delFlag != null">
|
<if test="delFlag != null">
|
||||||
#{delFlag,jdbcType=INTEGER},
|
#{delFlag,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelectiveAndReturnId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
|
<insert id="insertSelectiveAndReturnId" parameterType="com.xhpc.invoice.pojo.XhpcInvoice"
|
||||||
@ -518,6 +525,9 @@
|
|||||||
<if test="delFlag != null">
|
<if test="delFlag != null">
|
||||||
del_flag,
|
del_flag,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="receiveEmail != null">
|
<if test="receiveEmail != null">
|
||||||
@ -598,6 +608,9 @@
|
|||||||
<if test="delFlag != null">
|
<if test="delFlag != null">
|
||||||
#{delFlag,jdbcType=INTEGER},
|
#{delFlag,jdbcType=INTEGER},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.invoice.pojo.XhpcInvoice">
|
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.invoice.pojo.XhpcInvoice">
|
||||||
@ -749,4 +762,4 @@
|
|||||||
WHERE invoice_id = #{invoiceId};
|
WHERE invoice_id = #{invoiceId};
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public class DaoAspect {
|
|||||||
private static final String CREATE_TIME = "createTime";
|
private static final String CREATE_TIME = "createTime";
|
||||||
private static final String UPDATE_USER = "updateBy";
|
private static final String UPDATE_USER = "updateBy";
|
||||||
private static final String UPDATE_TIME = "updateTime";
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
private static final String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
public void daoUpdate() {
|
public void daoUpdate() {
|
||||||
@ -134,6 +135,10 @@ public class DaoAspect {
|
|||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public class DaoAspect {
|
|||||||
private static final String CREATE_TIME = "createTime";
|
private static final String CREATE_TIME = "createTime";
|
||||||
private static final String UPDATE_USER = "updateBy";
|
private static final String UPDATE_USER = "updateBy";
|
||||||
private static final String UPDATE_TIME = "updateTime";
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
private static final String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
public void daoUpdate() {
|
public void daoUpdate() {
|
||||||
@ -135,6 +136,9 @@ public class DaoAspect {
|
|||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isEmpty(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -121,7 +121,9 @@ public class UserDaoAspect {
|
|||||||
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
if (isProperty(arg, TENANT_ID) && StringUtils.isEmpty(BeanUtils.getProperty(arg, TENANT_ID))) {
|
||||||
|
BeanUtils.setProperty(arg, TENANT_ID, loginUser.getTenantId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user