多余代码 删除
This commit is contained in:
parent
868aa1bf0f
commit
effe59b804
|
|
@ -1,45 +0,0 @@
|
|||
package com.czg.config;
|
||||
|
||||
import com.mybatisflex.core.dialect.impl.CommonsDialectImpl;
|
||||
import com.mybatisflex.core.exception.FlexExceptions;
|
||||
import com.mybatisflex.core.exception.locale.LocalizedFormats;
|
||||
import com.mybatisflex.core.query.CPI;
|
||||
import com.mybatisflex.core.query.QueryCondition;
|
||||
import com.mybatisflex.core.query.QueryTable;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.mybatisflex.core.constant.SqlConsts.ASTERISK;
|
||||
import static com.mybatisflex.core.constant.SqlConsts.WHERE;
|
||||
|
||||
/**
|
||||
* 自定义sql解析器 备用
|
||||
*/
|
||||
//@Component
|
||||
public class MyCommonsDialectImpl extends CommonsDialectImpl {
|
||||
@Override
|
||||
public String wrap(String keyword) {
|
||||
return ASTERISK.equals(keyword) ? keyword : keywordWrap.wrap(keyword);
|
||||
}
|
||||
|
||||
protected void buildWhereSql(StringBuilder sqlBuilder, QueryWrapper queryWrapper, List<QueryTable> queryTables, boolean allowNoCondition) {
|
||||
QueryCondition whereQueryCondition = CPI.getWhereQueryCondition(queryWrapper);
|
||||
if (whereQueryCondition != null) {
|
||||
String whereSql = whereQueryCondition.toSql(queryTables, this);
|
||||
if (StringUtil.hasText(whereSql)) {
|
||||
sqlBuilder.append(WHERE).append(whereSql);
|
||||
} else if (!allowNoCondition) {
|
||||
throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
|
||||
}
|
||||
} else {
|
||||
// whereQueryCondition == null
|
||||
if (!allowNoCondition) {
|
||||
throw FlexExceptions.wrap(LocalizedFormats.UPDATE_OR_DELETE_NOT_ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package com.czg.config;
|
||||
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.dialect.DbType;
|
||||
import com.mybatisflex.core.dialect.DialectFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 自定义sql方言
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j(topic = "mybatis-flex-sql")
|
||||
public class MybatisFlexConfig {
|
||||
|
||||
public MybatisFlexConfig() {
|
||||
//开启审计功能
|
||||
AuditManager.setAuditEnable(true);
|
||||
|
||||
//设置 SQL 审计收集器
|
||||
AuditManager.setMessageCollector(auditMessage ->
|
||||
log.info("{},{}ms", auditMessage.getFullSql()
|
||||
, auditMessage.getElapsedTime())
|
||||
);
|
||||
}
|
||||
|
||||
// @Resource
|
||||
private MyCommonsDialectImpl myCommonsDialect;
|
||||
|
||||
// @PostConstruct
|
||||
public void init() {
|
||||
DialectFactory.registerDialect(DbType.MYSQL, myCommonsDialect);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue