Browse Source

fix:[基础配置] 设置默认字段

master
memorylkf 3 weeks ago
parent
commit
63ba4c5600
7 changed files with 146 additions and 74 deletions
  1. +0
    -6
      hxhq-common/hxhq-common-core/pom.xml
  2. +1
    -2
      hxhq-common/hxhq-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  3. +5
    -0
      hxhq-common/hxhq-common-security/pom.xml
  4. +73
    -0
      hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/config/BaseMetaObjectHandler.java
  5. +1
    -1
      hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/config/MyBatisPlusConfig.java
  6. +1
    -0
      hxhq-common/hxhq-common-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

+ 0
- 6
hxhq-common/hxhq-common-core/pom.xml View File

@ -112,12 +112,6 @@
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency> </dependency>
<!-- hxhq Common Redis-->
<dependency>
<groupId>com.hxhq</groupId>
<artifactId>hxhq-common-security</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

+ 1
- 2
hxhq-common/hxhq-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports View File

@ -1,2 +1 @@
com.hxhq.common.core.utils.SpringUtils
com.hxhq.common.core.config.MyBatisPlusConfig
com.hxhq.common.core.utils.SpringUtils

+ 5
- 0
hxhq-common/hxhq-common-security/pom.xml View File

@ -34,6 +34,11 @@
<artifactId>hxhq-common-redis</artifactId> <artifactId>hxhq-common-redis</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

+ 73
- 0
hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/config/BaseMetaObjectHandler.java View File

@ -0,0 +1,73 @@
package com.hxhq.common.security.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.hxhq.common.security.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import java.util.Date;
/**
*
* @author memory
*/
public class BaseMetaObjectHandler implements MetaObjectHandler {
/**
* 删除标记
*/
public static final String DEL_FLAG = "delFlag";
/**
* 创建时间
*/
public static final String CREATE_BY = "createBy";
/**
* 创建时间
*/
public static final String CREATE_DATE = "createTime";
/**
* 创建时间
*/
public static final String UPDATE_BY = "updateBy";
/**
* 更新时间
*/
public static final String UPDATE_DATE = "updateTime";
/**
* 新增
*/
@Override
public void insertFill(MetaObject metaObject) {
// 创建用户
Object createBy = getFieldValByName(CREATE_BY, metaObject);
if (createBy == null || createBy.equals("")) {
setFieldValByName(CREATE_BY, SecurityUtils.getLoginUserOfEmpty().getUserid()==null?"": SecurityUtils.getLoginUserOfEmpty().getUserid().toString(), metaObject);
}
// 创建时间
Object createDate = getFieldValByName(CREATE_DATE, metaObject);
if (createDate == null) {
setFieldValByName(CREATE_DATE, new Date(), metaObject);
}
// 删除标记
Object delFlag = getFieldValByName(DEL_FLAG, metaObject);
if (delFlag == null) {
setFieldValByName(DEL_FLAG, "0", metaObject);
}
}
@Override
public void updateFill(MetaObject metaObject) {
// Object updateBy = getFieldValByName(UPDATE_BY, metaObject);
// if (updateBy == null || updateBy.equals("")) {
setFieldValByName(UPDATE_BY, SecurityUtils.getLoginUserOfEmpty().getUserid()==null?"": SecurityUtils.getLoginUserOfEmpty().getUserid().toString(), metaObject);
// }
// 更新用户
// Object updateDate = getFieldValByName(UPDATE_DATE, metaObject);
// if (updateDate == null) {
setFieldValByName(UPDATE_DATE, new Date(), metaObject);
// }
}
}

hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/config/MyBatisPlusConfig.java → hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/config/MyBatisPlusConfig.java View File

@ -1,4 +1,4 @@
package com.hxhq.common.core.config;
package com.hxhq.common.security.config;
import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

+ 1
- 0
hxhq-common/hxhq-common-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports View File

@ -3,3 +3,4 @@ com.hxhq.common.security.service.TokenService
com.hxhq.common.security.aspect.PreAuthorizeAspect com.hxhq.common.security.aspect.PreAuthorizeAspect
com.hxhq.common.security.aspect.InnerAuthAspect com.hxhq.common.security.aspect.InnerAuthAspect
com.hxhq.common.security.handler.GlobalExceptionHandler com.hxhq.common.security.handler.GlobalExceptionHandler
com.hxhq.common.security.config.MyBatisPlusConfig

Loading…
Cancel
Save