|
@ -26,6 +26,7 @@ package cn.stylefeng.guns.sys.core.context;
|
|
|
|
|
|
import cn.hutool.core.lang.Dict;
|
|
import cn.hutool.core.lang.Dict;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.log.Log;
|
|
import cn.stylefeng.guns.core.context.system.SystemContext;
|
|
import cn.stylefeng.guns.core.context.system.SystemContext;
|
|
import cn.stylefeng.guns.core.pojo.login.SysLoginUser;
|
|
import cn.stylefeng.guns.core.pojo.login.SysLoginUser;
|
|
import cn.stylefeng.guns.sys.modular.auth.service.AuthService;
|
|
import cn.stylefeng.guns.sys.modular.auth.service.AuthService;
|
|
@ -36,9 +37,14 @@ import cn.stylefeng.guns.sys.modular.role.service.SysRoleService;
|
|
import cn.stylefeng.guns.sys.modular.user.entity.SysUser;
|
|
import cn.stylefeng.guns.sys.modular.user.entity.SysUser;
|
|
import cn.stylefeng.guns.sys.modular.user.param.SysUserParam;
|
|
import cn.stylefeng.guns.sys.modular.user.param.SysUserParam;
|
|
import cn.stylefeng.guns.sys.modular.user.service.SysUserService;
|
|
import cn.stylefeng.guns.sys.modular.user.service.SysUserService;
|
|
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
|
|
|
import com.alibaba.druid.pool.DruidPooledConnection;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -50,6 +56,8 @@ import java.util.List;
|
|
@Component
|
|
@Component
|
|
public class SystemContextImpl implements SystemContext {
|
|
public class SystemContextImpl implements SystemContext {
|
|
|
|
|
|
|
|
Log log = Log.get();
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private AuthService authService;
|
|
private AuthService authService;
|
|
|
|
|
|
@ -62,6 +70,9 @@ public class SystemContextImpl implements SystemContext {
|
|
@Resource
|
|
@Resource
|
|
private SysDictDataService sysDictDataService;
|
|
private SysDictDataService sysDictDataService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private DruidDataSource druidDataSource;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String getNameByUserId(Long userId) {
|
|
public String getNameByUserId(Long userId) {
|
|
return sysUserService.getNameByUserId(userId);
|
|
return sysUserService.getNameByUserId(userId);
|
|
@ -112,4 +123,29 @@ public class SystemContextImpl implements SystemContext {
|
|
return sysDictDataService.getDictCodesByDictTypeCode(dictTypeCodes);
|
|
return sysDictDataService.getDictCodesByDictTypeCode(dictTypeCodes);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean tableUniValueFlag(String tableName, String columnName, String value) {
|
|
|
|
try {
|
|
|
|
DruidPooledConnection connection = druidDataSource.getConnection();
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("select count(*) from " + tableName + " where " + columnName + " = ?");
|
|
|
|
|
|
|
|
preparedStatement.setString(1, value);
|
|
|
|
|
|
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
|
|
if (resultSet.next()) {
|
|
|
|
long sumValue = resultSet.getLong(1);
|
|
|
|
if (sumValue == 0L) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} catch (SQLException throwables) {
|
|
|
|
log.error("执行sql错误!", throwables);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|