mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-20 18:26:38 +08:00
[重磅更新] 重写项目整体结构 数据处理下沉至 Mapper 符合 MVC 规范 减少循环依赖
This commit is contained in:
parent
5413b37d71
commit
8f6484e470
@ -5,7 +5,6 @@ import cn.hutool.core.convert.Convert;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.http.HttpException;
|
import cn.hutool.http.HttpException;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
@ -134,8 +133,7 @@ public class SysOssController extends BaseController {
|
|||||||
@PutMapping("/changePreviewListResource")
|
@PutMapping("/changePreviewListResource")
|
||||||
public AjaxResult<Void> changePreviewListResource(@RequestBody String body) {
|
public AjaxResult<Void> changePreviewListResource(@RequestBody String body) {
|
||||||
Map<String, Boolean> map = JsonUtils.parseMap(body);
|
Map<String, Boolean> map = JsonUtils.parseMap(body);
|
||||||
SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>()
|
SysConfig config = iSysConfigService.getOne(new SysConfig().setConfigKey(OssConstant.PEREVIEW_LIST_RESOURCE_KEY));
|
||||||
.eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY));
|
|
||||||
config.setConfigValue(map.get("previewListResource").toString());
|
config.setConfigValue(map.get("previewListResource").toString());
|
||||||
return toAjax(iSysConfigService.updateConfig(config));
|
return toAjax(iSysConfigService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,229 @@
|
|||||||
|
package com.ruoyi.common.core.mapper;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.*;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
||||||
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
||||||
|
import org.apache.ibatis.binding.MapperMethod;
|
||||||
|
import org.apache.ibatis.logging.Log;
|
||||||
|
import org.apache.ibatis.logging.LogFactory;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 Mapper 接口, 实现 自定义扩展
|
||||||
|
*
|
||||||
|
* @param <M> mapper 泛型
|
||||||
|
* @param <T> table 泛型
|
||||||
|
* @param <V> vo 泛型
|
||||||
|
* @author Lion Li
|
||||||
|
* @since 2021-05-13
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
|
||||||
|
|
||||||
|
Log log = LogFactory.getLog(BaseMapperPlus.class);
|
||||||
|
|
||||||
|
int DEFAULT_BATCH_SIZE = 1000;
|
||||||
|
|
||||||
|
default Class<V> currentVoClass() {
|
||||||
|
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Class<T> currentModelClass() {
|
||||||
|
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Class<M> currentMapperClass() {
|
||||||
|
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseMapperPlus.class, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<T> selectList() {
|
||||||
|
return this.selectList(new QueryWrapper<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入
|
||||||
|
*/
|
||||||
|
default boolean insertBatch(Collection<T> entityList) {
|
||||||
|
return insertBatch(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新
|
||||||
|
*/
|
||||||
|
default boolean updateBatchById(Collection<T> entityList) {
|
||||||
|
return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入或更新
|
||||||
|
*/
|
||||||
|
default boolean insertOrUpdateBatch(Collection<T> entityList) {
|
||||||
|
return insertOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入(包含限制条数)
|
||||||
|
*/
|
||||||
|
default boolean insertBatch(Collection<T> entityList, int batchSize) {
|
||||||
|
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE);
|
||||||
|
return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize,
|
||||||
|
(sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新(包含限制条数)
|
||||||
|
*/
|
||||||
|
default boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
||||||
|
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID);
|
||||||
|
return SqlHelper.executeBatch(this.currentModelClass(), log, entityList, batchSize,
|
||||||
|
(sqlSession, entity) -> {
|
||||||
|
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
||||||
|
param.put(Constants.ENTITY, entity);
|
||||||
|
sqlSession.update(sqlStatement, param);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入或更新(包含限制条数)
|
||||||
|
*/
|
||||||
|
default boolean insertOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
||||||
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass());
|
||||||
|
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
||||||
|
String keyProperty = tableInfo.getKeyProperty();
|
||||||
|
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
||||||
|
return SqlHelper.saveOrUpdateBatch(this.currentModelClass(), getClass(), log, entityList, batchSize, (sqlSession, entity) -> {
|
||||||
|
Object idVal = tableInfo.getPropertyValue(entity, keyProperty);
|
||||||
|
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE);
|
||||||
|
return StringUtils.checkValNull(idVal)
|
||||||
|
|| CollectionUtils.isEmpty(sqlSession.selectList(sqlStatement, entity));
|
||||||
|
}, (sqlSession, entity) -> {
|
||||||
|
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
||||||
|
param.put(Constants.ENTITY, entity);
|
||||||
|
String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.UPDATE_BY_ID);
|
||||||
|
sqlSession.update(sqlStatement, param);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入或更新(包含限制条数)
|
||||||
|
*/
|
||||||
|
default boolean insertOrUpdate(T entity) {
|
||||||
|
if (null != entity) {
|
||||||
|
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.currentModelClass());
|
||||||
|
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
||||||
|
String keyProperty = tableInfo.getKeyProperty();
|
||||||
|
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
||||||
|
Object idVal = tableInfo.getPropertyValue(entity, tableInfo.getKeyProperty());
|
||||||
|
return StringUtils.checkValNull(idVal) || Objects.isNull(selectById((Serializable) idVal)) ? insert(entity) > 0 : updateById(entity) > 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default V selectVoById(Serializable id) {
|
||||||
|
return selectVoById(id, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 查询
|
||||||
|
*/
|
||||||
|
default <C> C selectVoById(Serializable id, Class<C> voClass) {
|
||||||
|
T obj = this.selectById(id);
|
||||||
|
if (ObjectUtil.isNull(obj)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copy(obj, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<V> selectVoById(Collection<? extends Serializable> idList) {
|
||||||
|
return selectVoBatchIds(idList, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据ID 批量查询)
|
||||||
|
*/
|
||||||
|
default <C> List<C> selectVoBatchIds(Collection<? extends Serializable> idList, Class<C> voClass) {
|
||||||
|
List<T> list = this.selectBatchIds(idList);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<V> selectVoByMap(Map<String, Object> map) {
|
||||||
|
return selectVoByMap(map, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据 columnMap 条件)
|
||||||
|
*/
|
||||||
|
default <C> List<C> selectVoByMap(Map<String, Object> map, Class<C> voClass) {
|
||||||
|
List<T> list = this.selectByMap(map);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
default V selectVoOne(Wrapper<T> wrapper) {
|
||||||
|
return selectVoOne(wrapper, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 entity 条件,查询一条记录
|
||||||
|
*/
|
||||||
|
default <C> C selectVoOne(Wrapper<T> wrapper, Class<C> voClass) {
|
||||||
|
T obj = this.selectOne(wrapper);
|
||||||
|
if (ObjectUtil.isNull(obj)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copy(obj, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<V> selectVoList(Wrapper<T> wrapper) {
|
||||||
|
return selectVoList(wrapper, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 entity 条件,查询全部记录
|
||||||
|
*/
|
||||||
|
default <C> List<C> selectVoList(Wrapper<T> wrapper, Class<C> voClass) {
|
||||||
|
List<T> list = this.selectList(wrapper);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return BeanCopyUtils.copyList(list, voClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
default <P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper) {
|
||||||
|
return selectVoPage(page, wrapper, this.currentVoClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询VO
|
||||||
|
*/
|
||||||
|
default <C, P extends IPage<C>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<C> voClass) {
|
||||||
|
IPage<T> pageData = this.selectPage(page, wrapper);
|
||||||
|
IPage<C> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
|
||||||
|
if (CollUtil.isEmpty(pageData.getRecords())) {
|
||||||
|
return (P) voPage;
|
||||||
|
}
|
||||||
|
voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
|
||||||
|
return (P) voPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,98 +0,0 @@
|
|||||||
package com.ruoyi.common.core.mybatisplus.core;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.ruoyi.common.utils.BeanCopyUtils;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义 Mapper 接口, 实现 自定义扩展
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
* @since 2021-05-13
|
|
||||||
*/
|
|
||||||
public interface BaseMapperPlus<T> extends BaseMapper<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单sql批量插入( 全量填充 )
|
|
||||||
*/
|
|
||||||
int insertAll(@Param("list") Collection<T> batchList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 ID 查询
|
|
||||||
*/
|
|
||||||
default <V> V selectVoById(Serializable id, Class<V> voClass) {
|
|
||||||
T obj = this.selectById(id);
|
|
||||||
if (ObjectUtil.isNull(obj)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copy(obj, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据ID 批量查询)
|
|
||||||
*/
|
|
||||||
default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass) {
|
|
||||||
List<T> list = this.selectBatchIds(idList);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据 columnMap 条件)
|
|
||||||
*/
|
|
||||||
default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass) {
|
|
||||||
List<T> list = this.selectByMap(map);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 entity 条件,查询一条记录
|
|
||||||
*/
|
|
||||||
default <V> V selectVoOne(Wrapper<T> wrapper, Class<V> voClass) {
|
|
||||||
T obj = this.selectOne(wrapper);
|
|
||||||
if (ObjectUtil.isNull(obj)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copy(obj, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 entity 条件,查询全部记录
|
|
||||||
*/
|
|
||||||
default <V> List<V> selectVoList(Wrapper<T> wrapper, Class<V> voClass) {
|
|
||||||
List<T> list = this.selectList(wrapper);
|
|
||||||
if (CollUtil.isEmpty(list)) {
|
|
||||||
return CollUtil.newArrayList();
|
|
||||||
}
|
|
||||||
return BeanCopyUtils.copyList(list, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询VO
|
|
||||||
*/
|
|
||||||
default <V, P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) {
|
|
||||||
IPage<T> pageData = this.selectPage(page, wrapper);
|
|
||||||
IPage<V> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
|
|
||||||
if (CollUtil.isEmpty(pageData.getRecords())) {
|
|
||||||
return (P) voPage;
|
|
||||||
}
|
|
||||||
voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
|
|
||||||
return (P) voPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
package com.ruoyi.common.core.mybatisplus.core;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义 Service 接口, 实现 数据库实体与 vo 对象转换返回
|
|
||||||
*
|
|
||||||
* @param <T> 数据实体类
|
|
||||||
* @param <V> vo类
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
public interface IServicePlus<T, V> extends IService<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id 主键id
|
|
||||||
* @return V对象
|
|
||||||
*/
|
|
||||||
V getVoById(Serializable id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default V getVoById(Serializable id, Function<T, V> convertor) {
|
|
||||||
return convertor.apply(getById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param idList id列表
|
|
||||||
* @return V对象
|
|
||||||
*/
|
|
||||||
List<V> listVoByIds(Collection<? extends Serializable> idList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default List<V> listVoByIds(Collection<? extends Serializable> idList,
|
|
||||||
Function<Collection<T>, List<V>> convertor) {
|
|
||||||
List<T> list = getBaseMapper().selectBatchIds(idList);
|
|
||||||
if (list == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return convertor.apply(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param columnMap 表字段 map 对象
|
|
||||||
* @return V对象
|
|
||||||
*/
|
|
||||||
List<V> listVoByMap(Map<String, Object> columnMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default List<V> listVoByMap(Map<String, Object> columnMap,
|
|
||||||
Function<Collection<T>, List<V>> convertor) {
|
|
||||||
List<T> list = getBaseMapper().selectByMap(columnMap);
|
|
||||||
if (list == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return convertor.apply(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param queryWrapper 查询条件
|
|
||||||
* @return V对象
|
|
||||||
*/
|
|
||||||
V getVoOne(Wrapper<T> queryWrapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default V getVoOne(Wrapper<T> queryWrapper, Function<T, V> convertor) {
|
|
||||||
return convertor.apply(getOne(queryWrapper, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param queryWrapper 查询条件
|
|
||||||
* @return V对象
|
|
||||||
*/
|
|
||||||
List<V> listVo(Wrapper<T> queryWrapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default List<V> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<V>> convertor) {
|
|
||||||
List<T> list = getBaseMapper().selectList(queryWrapper);
|
|
||||||
if (list == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return convertor.apply(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<V> listVo() {
|
|
||||||
return listVo(Wrappers.emptyWrapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param convertor 自定义转换器
|
|
||||||
*/
|
|
||||||
default List<V> listVo(Function<Collection<T>, List<V>> convertor) {
|
|
||||||
return listVo(Wrappers.emptyWrapper(), convertor);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean saveAll(Collection<T> entityList);
|
|
||||||
|
|
||||||
boolean saveOrUpdateAll(Collection<T> entityList);
|
|
||||||
}
|
|
||||||
|
|
@ -1,211 +0,0 @@
|
|||||||
package com.ruoyi.common.core.mybatisplus.core;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IServicePlus 实现类
|
|
||||||
*
|
|
||||||
* @param <M> Mapper类
|
|
||||||
* @param <T> 数据实体类
|
|
||||||
* @param <V> vo类
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceImpl<M, T> implements IServicePlus<T, V> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected M baseMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public M getBaseMapper() {
|
|
||||||
return baseMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected Class<T> entityClass = currentModelClass();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<T> getEntityClass() {
|
|
||||||
return entityClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Class<M> mapperClass = currentMapperClass();
|
|
||||||
|
|
||||||
protected Class<V> voClass = currentVoClass();
|
|
||||||
|
|
||||||
public Class<V> getVoClass() {
|
|
||||||
return voClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<M> currentMapperClass() {
|
|
||||||
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<T> currentModelClass() {
|
|
||||||
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Class<V> currentVoClass() {
|
|
||||||
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单条执行性能差 适用于列表对象内容不确定
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveBatch(Collection<T> entityList, int batchSize) {
|
|
||||||
return super.saveBatch(entityList, batchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean saveOrUpdate(T entity) {
|
|
||||||
return super.saveOrUpdate(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单条执行性能差 适用于列表对象内容不确定
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
|
||||||
return super.saveOrUpdateBatch(entityList, batchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
|
||||||
return super.updateBatchById(entityList, batchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单sql批量插入( 全量填充 无视数据库默认值 )
|
|
||||||
* 适用于无脑插入
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveBatch(Collection<T> entityList) {
|
|
||||||
return saveBatch(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean saveOrUpdateBatch(Collection<T> entityList) {
|
|
||||||
return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateBatchById(Collection<T> entityList) {
|
|
||||||
return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单sql批量插入( 全量填充 )
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveAll(Collection<T> entityList) {
|
|
||||||
if (CollUtil.isEmpty(entityList)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return baseMapper.insertAll(entityList) == entityList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全量保存或更新 ( 按主键区分 )
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean saveOrUpdateAll(Collection<T> entityList) {
|
|
||||||
if (CollUtil.isEmpty(entityList)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
|
|
||||||
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
|
||||||
String keyProperty = tableInfo.getKeyProperty();
|
|
||||||
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
|
||||||
List<T> addList = new ArrayList<>();
|
|
||||||
List<T> updateList = new ArrayList<>();
|
|
||||||
int row = 0;
|
|
||||||
for (T entity : entityList) {
|
|
||||||
Object id = ReflectUtils.invokeGetter(entity, keyProperty);
|
|
||||||
if (ObjectUtil.isNull(id)) {
|
|
||||||
addList.add(entity);
|
|
||||||
} else {
|
|
||||||
updateList.add(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) {
|
|
||||||
row += updateList.size();
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(addList)) {
|
|
||||||
row += baseMapper.insertAll(addList);
|
|
||||||
}
|
|
||||||
return row == entityList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 ID 查询
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public V getVoById(Serializable id) {
|
|
||||||
return getBaseMapper().selectVoById(id, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据ID 批量查询)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<V> listVoByIds(Collection<? extends Serializable> idList) {
|
|
||||||
return getBaseMapper().selectVoBatchIds(idList, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询(根据 columnMap 条件)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<V> listVoByMap(Map<String, Object> columnMap) {
|
|
||||||
return getBaseMapper().selectVoByMap(columnMap, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据 Wrapper,查询一条记录 <br/>
|
|
||||||
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public V getVoOne(Wrapper<T> queryWrapper) {
|
|
||||||
return getBaseMapper().selectVoOne(queryWrapper, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<V> listVo(Wrapper<T> queryWrapper) {
|
|
||||||
return getBaseMapper().selectVoList(queryWrapper, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 翻页查询
|
|
||||||
*
|
|
||||||
* @param page 翻页对象
|
|
||||||
* @param queryWrapper 实体对象封装操作类
|
|
||||||
*/
|
|
||||||
public <P extends IPage<V>> P pageVo(IPage<T> page, Wrapper<T> queryWrapper) {
|
|
||||||
return getBaseMapper().selectVoPage(page, queryWrapper, voClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
package com.ruoyi.common.core.mybatisplus.methods;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
|
|
||||||
import org.apache.ibatis.executor.keygen.KeyGenerator;
|
|
||||||
import org.apache.ibatis.executor.keygen.NoKeyGenerator;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.mapping.SqlSource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单sql批量插入( 全量填充 )
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
public class InsertAll extends AbstractMethod {
|
|
||||||
|
|
||||||
private final static String[] FILL_PROPERTY = {"createTime", "createBy", "updateTime", "updateBy"};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
|
||||||
final String sql = "<script>insert into %s %s values %s</script>";
|
|
||||||
final String fieldSql = prepareFieldSql(tableInfo);
|
|
||||||
final String valueSql = prepareValuesSqlForMysqlBatch(tableInfo);
|
|
||||||
KeyGenerator keyGenerator = new NoKeyGenerator();
|
|
||||||
String sqlMethod = "insertAll";
|
|
||||||
String keyProperty = null;
|
|
||||||
String keyColumn = null;
|
|
||||||
// 表包含主键处理逻辑,如果不包含主键当普通字段处理
|
|
||||||
if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
|
|
||||||
if (tableInfo.getIdType() == IdType.AUTO) {
|
|
||||||
/** 自增主键 */
|
|
||||||
keyGenerator = new Jdbc3KeyGenerator();
|
|
||||||
keyProperty = tableInfo.getKeyProperty();
|
|
||||||
keyColumn = tableInfo.getKeyColumn();
|
|
||||||
} else {
|
|
||||||
if (null != tableInfo.getKeySequence()) {
|
|
||||||
keyGenerator = TableInfoHelper.genKeyGenerator(sqlMethod, tableInfo, builderAssistant);
|
|
||||||
keyProperty = tableInfo.getKeyProperty();
|
|
||||||
keyColumn = tableInfo.getKeyColumn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql);
|
|
||||||
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass);
|
|
||||||
return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod, sqlSource, keyGenerator, keyProperty, keyColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String prepareFieldSql(TableInfo tableInfo) {
|
|
||||||
StringBuilder fieldSql = new StringBuilder();
|
|
||||||
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
|
|
||||||
fieldSql.append(tableInfo.getKeyColumn()).append(",");
|
|
||||||
}
|
|
||||||
tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(","));
|
|
||||||
fieldSql.delete(fieldSql.length() - 1, fieldSql.length());
|
|
||||||
fieldSql.insert(0, "(");
|
|
||||||
fieldSql.append(")");
|
|
||||||
return fieldSql.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String prepareValuesSqlForMysqlBatch(TableInfo tableInfo) {
|
|
||||||
final StringBuilder valueSql = new StringBuilder();
|
|
||||||
valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">");
|
|
||||||
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
|
|
||||||
valueSql.append("\n#{item.").append(tableInfo.getKeyProperty()).append("},\n");
|
|
||||||
}
|
|
||||||
List<TableFieldInfo> fieldList = tableInfo.getFieldList();
|
|
||||||
int last = fieldList.size() - 1;
|
|
||||||
for (int i = 0; i < fieldList.size(); i++) {
|
|
||||||
String property = fieldList.get(i).getProperty();
|
|
||||||
if (!StringUtils.equalsAny(property, FILL_PROPERTY)) {
|
|
||||||
valueSql.append("<if test=\"item.").append(property).append(" != null\">");
|
|
||||||
valueSql.append("#{item.").append(property).append("}");
|
|
||||||
if (i != last) {
|
|
||||||
valueSql.append(",");
|
|
||||||
}
|
|
||||||
valueSql.append("</if>");
|
|
||||||
valueSql.append("<if test=\"item.").append(property).append(" == null\">");
|
|
||||||
valueSql.append("DEFAULT");
|
|
||||||
if (i != last) {
|
|
||||||
valueSql.append(",");
|
|
||||||
}
|
|
||||||
valueSql.append("</if>");
|
|
||||||
} else {
|
|
||||||
valueSql.append("#{item.").append(property).append("}");
|
|
||||||
if (i != last) {
|
|
||||||
valueSql.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
valueSql.append("</foreach>");
|
|
||||||
return valueSql.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.demo.domain.TestDemo;
|
import com.ruoyi.demo.domain.TestDemo;
|
||||||
import com.ruoyi.demo.service.ITestDemoService;
|
import com.ruoyi.demo.mapper.TestDemoMapper;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -29,7 +29,10 @@ import java.util.List;
|
|||||||
@RequestMapping("/demo/batch")
|
@RequestMapping("/demo/batch")
|
||||||
public class TestBatchController extends BaseController {
|
public class TestBatchController extends BaseController {
|
||||||
|
|
||||||
private final ITestDemoService iTestDemoService;
|
/**
|
||||||
|
* 为了便于测试 直接引入mapper
|
||||||
|
*/
|
||||||
|
private final TestDemoMapper testDemoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增批量方法 可完美替代 saveBatch 秒级插入上万数据 (对mysql负荷较大)
|
* 新增批量方法 可完美替代 saveBatch 秒级插入上万数据 (对mysql负荷较大)
|
||||||
@ -44,7 +47,7 @@ public class TestBatchController extends BaseController {
|
|||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
||||||
}
|
}
|
||||||
return toAjax(iTestDemoService.saveAll(list) ? 1 : 0);
|
return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +63,7 @@ public class TestBatchController extends BaseController {
|
|||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
||||||
}
|
}
|
||||||
iTestDemoService.saveAll(list);
|
testDemoMapper.insertBatch(list);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TestDemo testDemo = list.get(i);
|
TestDemo testDemo = list.get(i);
|
||||||
testDemo.setTestKey("批量新增或修改").setValue("批量新增或修改");
|
testDemo.setTestKey("批量新增或修改").setValue("批量新增或修改");
|
||||||
@ -68,7 +71,7 @@ public class TestBatchController extends BaseController {
|
|||||||
testDemo.setId(null);
|
testDemo.setId(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0);
|
return toAjax(testDemoMapper.insertOrUpdateBatch(list) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,8 +81,8 @@ public class TestBatchController extends BaseController {
|
|||||||
@DeleteMapping()
|
@DeleteMapping()
|
||||||
// @DS("slave")
|
// @DS("slave")
|
||||||
public AjaxResult<Void> remove() {
|
public AjaxResult<Void> remove() {
|
||||||
return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>()
|
return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>()
|
||||||
.eq(TestDemo::getOrderNum, -1L)) ? 1 : 0);
|
.eq(TestDemo::getOrderNum, -1L)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class TestDemoController extends BaseController {
|
|||||||
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
|
||||||
List<TestDemoImportVo> volist = excelResult.getList();
|
List<TestDemoImportVo> volist = excelResult.getList();
|
||||||
List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class);
|
List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class);
|
||||||
iTestDemoService.saveAll(list);
|
iTestDemoService.saveBatch(list);
|
||||||
return AjaxResult.success(excelResult.getAnalysis());
|
return AjaxResult.success(excelResult.getAnalysis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.annotation.DataColumn;
|
import com.ruoyi.common.annotation.DataColumn;
|
||||||
import com.ruoyi.common.annotation.DataPermission;
|
import com.ruoyi.common.annotation.DataPermission;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.demo.domain.TestDemo;
|
import com.ruoyi.demo.domain.TestDemo;
|
||||||
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
public interface TestDemoMapper extends BaseMapperPlus<TestDemo> {
|
public interface TestDemoMapper extends BaseMapperPlus<TestDemoMapper, TestDemo, TestDemoVo> {
|
||||||
|
|
||||||
@DataPermission({
|
@DataPermission({
|
||||||
@DataColumn(key = "deptName", value = "dept_id"),
|
@DataColumn(key = "deptName", value = "dept_id"),
|
||||||
|
@ -2,8 +2,9 @@ package com.ruoyi.demo.mapper;
|
|||||||
|
|
||||||
import com.ruoyi.common.annotation.DataColumn;
|
import com.ruoyi.common.annotation.DataColumn;
|
||||||
import com.ruoyi.common.annotation.DataPermission;
|
import com.ruoyi.common.annotation.DataPermission;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.demo.domain.TestTree;
|
import com.ruoyi.demo.domain.TestTree;
|
||||||
|
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试树表Mapper接口
|
* 测试树表Mapper接口
|
||||||
@ -15,6 +16,6 @@ import com.ruoyi.demo.domain.TestTree;
|
|||||||
@DataColumn(key = "deptName", value = "dept_id"),
|
@DataColumn(key = "deptName", value = "dept_id"),
|
||||||
@DataColumn(key = "userName", value = "user_id")
|
@DataColumn(key = "userName", value = "user_id")
|
||||||
})
|
})
|
||||||
public interface TestTreeMapper extends BaseMapperPlus<TestTree> {
|
public interface TestTreeMapper extends BaseMapperPlus<TestTreeMapper, TestTree, TestTreeVo> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.demo.service;
|
package com.ruoyi.demo.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.demo.domain.TestDemo;
|
import com.ruoyi.demo.domain.TestDemo;
|
||||||
import com.ruoyi.demo.domain.bo.TestDemoBo;
|
import com.ruoyi.demo.domain.bo.TestDemoBo;
|
||||||
@ -16,7 +15,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> {
|
public interface ITestDemoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询单个
|
* 查询单个
|
||||||
@ -64,4 +63,9 @@ public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存
|
||||||
|
*/
|
||||||
|
Boolean saveBatch(List<TestDemo> list);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.ruoyi.demo.service;
|
package com.ruoyi.demo.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
|
||||||
import com.ruoyi.demo.domain.TestTree;
|
|
||||||
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
||||||
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
||||||
|
|
||||||
@ -14,7 +12,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
public interface ITestTreeService extends IServicePlus<TestTree, TestTreeVo> {
|
public interface ITestTreeService {
|
||||||
/**
|
/**
|
||||||
* 查询单个
|
* 查询单个
|
||||||
*
|
*
|
||||||
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.demo.domain.TestDemo;
|
import com.ruoyi.demo.domain.TestDemo;
|
||||||
@ -13,6 +12,7 @@ import com.ruoyi.demo.domain.bo.TestDemoBo;
|
|||||||
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
import com.ruoyi.demo.domain.vo.TestDemoVo;
|
||||||
import com.ruoyi.demo.mapper.TestDemoMapper;
|
import com.ruoyi.demo.mapper.TestDemoMapper;
|
||||||
import com.ruoyi.demo.service.ITestDemoService;
|
import com.ruoyi.demo.service.ITestDemoService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -25,18 +25,21 @@ import java.util.Map;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo, TestDemoVo> implements ITestDemoService {
|
public class TestDemoServiceImpl implements ITestDemoService {
|
||||||
|
|
||||||
|
private final TestDemoMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestDemoVo queryById(Long id) {
|
public TestDemoVo queryById(Long id) {
|
||||||
return getVoById(id);
|
return baseMapper.selectVoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) {
|
public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo);
|
||||||
Page<TestDemoVo> result = pageVo(pageQuery.build(), lqw);
|
Page<TestDemoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TestDemoVo> queryList(TestDemoBo bo) {
|
public List<TestDemoVo> queryList(TestDemoBo bo) {
|
||||||
return listVo(buildQueryWrapper(bo));
|
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) {
|
private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) {
|
||||||
@ -69,7 +72,7 @@ public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDem
|
|||||||
public Boolean insertByBo(TestDemoBo bo) {
|
public Boolean insertByBo(TestDemoBo bo) {
|
||||||
TestDemo add = BeanUtil.toBean(bo, TestDemo.class);
|
TestDemo add = BeanUtil.toBean(bo, TestDemo.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
boolean flag = save(add);
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
}
|
}
|
||||||
@ -80,7 +83,7 @@ public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDem
|
|||||||
public Boolean updateByBo(TestDemoBo bo) {
|
public Boolean updateByBo(TestDemoBo bo) {
|
||||||
TestDemo update = BeanUtil.toBean(bo, TestDemo.class);
|
TestDemo update = BeanUtil.toBean(bo, TestDemo.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
return updateById(update);
|
return baseMapper.updateById(update) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,6 +100,11 @@ public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDem
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
return removeByIds(ids);
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean saveBatch(List<TestDemo> list) {
|
||||||
|
return baseMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@ package com.ruoyi.demo.service.impl;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.demo.domain.TestTree;
|
import com.ruoyi.demo.domain.TestTree;
|
||||||
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
import com.ruoyi.demo.domain.bo.TestTreeBo;
|
||||||
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
import com.ruoyi.demo.domain.vo.TestTreeVo;
|
||||||
import com.ruoyi.demo.mapper.TestTreeMapper;
|
import com.ruoyi.demo.mapper.TestTreeMapper;
|
||||||
import com.ruoyi.demo.service.ITestTreeService;
|
import com.ruoyi.demo.service.ITestTreeService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -23,19 +23,22 @@ import java.util.Map;
|
|||||||
* @date 2021-07-26
|
* @date 2021-07-26
|
||||||
*/
|
*/
|
||||||
// @DS("slave") // 切换从库查询
|
// @DS("slave") // 切换从库查询
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService {
|
public class TestTreeServiceImpl implements ITestTreeService {
|
||||||
|
|
||||||
|
private final TestTreeMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestTreeVo queryById(Long id) {
|
public TestTreeVo queryById(Long id) {
|
||||||
return getVoById(id);
|
return baseMapper.selectVoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @DS("slave") // 切换从库查询
|
// @DS("slave") // 切换从库查询
|
||||||
@Override
|
@Override
|
||||||
public List<TestTreeVo> queryList(TestTreeBo bo) {
|
public List<TestTreeVo> queryList(TestTreeBo bo) {
|
||||||
LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo);
|
||||||
return listVo(lqw);
|
return baseMapper.selectVoList(lqw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) {
|
private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) {
|
||||||
@ -51,7 +54,7 @@ public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTre
|
|||||||
public Boolean insertByBo(TestTreeBo bo) {
|
public Boolean insertByBo(TestTreeBo bo) {
|
||||||
TestTree add = BeanUtil.toBean(bo, TestTree.class);
|
TestTree add = BeanUtil.toBean(bo, TestTree.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
boolean flag = save(add);
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
}
|
}
|
||||||
@ -62,7 +65,7 @@ public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTre
|
|||||||
public Boolean updateByBo(TestTreeBo bo) {
|
public Boolean updateByBo(TestTreeBo bo) {
|
||||||
TestTree update = BeanUtil.toBean(bo, TestTree.class);
|
TestTree update = BeanUtil.toBean(bo, TestTree.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
return updateById(update);
|
return baseMapper.updateById(update) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +82,6 @@ public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTre
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
return removeByIds(ids);
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,9 @@ import cn.hutool.core.net.NetUtil;
|
|||||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
|
||||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
|
||||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import com.ruoyi.common.core.mybatisplus.methods.InsertAll;
|
|
||||||
import com.ruoyi.framework.handler.CreateAndUpdateMetaObjectHandler;
|
import com.ruoyi.framework.handler.CreateAndUpdateMetaObjectHandler;
|
||||||
import com.ruoyi.framework.interceptor.PlusDataPermissionInterceptor;
|
import com.ruoyi.framework.interceptor.PlusDataPermissionInterceptor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
@ -19,8 +14,6 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mybatis-plus配置类(下方注释有插件介绍)
|
* mybatis-plus配置类(下方注释有插件介绍)
|
||||||
*
|
*
|
||||||
@ -77,21 +70,6 @@ public class MybatisPlusConfig {
|
|||||||
return new CreateAndUpdateMetaObjectHandler();
|
return new CreateAndUpdateMetaObjectHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* sql注入器配置
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public ISqlInjector sqlInjector() {
|
|
||||||
return new DefaultSqlInjector() {
|
|
||||||
@Override
|
|
||||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
|
||||||
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
|
||||||
methodList.add(new InsertAll());
|
|
||||||
return methodList;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用网卡信息绑定雪花生成器
|
* 使用网卡信息绑定雪花生成器
|
||||||
* 防止集群雪花ID重复
|
* 防止集群雪花ID重复
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.generator.mapper;
|
package com.ruoyi.generator.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.generator.domain.GenTableColumn;
|
import com.ruoyi.generator.domain.GenTableColumn;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@InterceptorIgnore(dataPermission = "true")
|
@InterceptorIgnore(dataPermission = "true")
|
||||||
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn> {
|
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumnMapper, GenTableColumn, GenTableColumn> {
|
||||||
/**
|
/**
|
||||||
* 根据表名称查询列信息
|
* 根据表名称查询列信息
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,7 @@ package com.ruoyi.generator.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.generator.domain.GenTable;
|
import com.ruoyi.generator.domain.GenTable;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@InterceptorIgnore(dataPermission = "true")
|
@InterceptorIgnore(dataPermission = "true")
|
||||||
public interface GenTableMapper extends BaseMapperPlus<GenTable> {
|
public interface GenTableMapper extends BaseMapperPlus<GenTableMapper, GenTable, GenTable> {
|
||||||
|
|
||||||
|
|
||||||
Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);
|
Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.ruoyi.generator.service;
|
package com.ruoyi.generator.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.generator.domain.GenTableColumn;
|
import com.ruoyi.generator.domain.GenTableColumn;
|
||||||
import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -14,8 +14,11 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMapper, GenTableColumn, GenTableColumn> implements IGenTableColumnService {
|
public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
||||||
|
|
||||||
|
private final GenTableColumnMapper baseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
@ -25,7 +28,7 @@ public class GenTableColumnServiceImpl extends ServicePlusImpl<GenTableColumnMap
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
||||||
return list(new LambdaQueryWrapper<GenTableColumn>()
|
return baseMapper.selectList(new LambdaQueryWrapper<GenTableColumn>()
|
||||||
.eq(GenTableColumn::getTableId, tableId)
|
.eq(GenTableColumn::getTableId, tableId)
|
||||||
.orderByAsc(GenTableColumn::getSort));
|
.orderByAsc(GenTableColumn::getSort));
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.GenConstants;
|
import com.ruoyi.common.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.JsonUtils;
|
import com.ruoyi.common.utils.JsonUtils;
|
||||||
@ -22,12 +21,11 @@ import com.ruoyi.generator.mapper.GenTableMapper;
|
|||||||
import com.ruoyi.generator.util.GenUtils;
|
import com.ruoyi.generator.util.GenUtils;
|
||||||
import com.ruoyi.generator.util.VelocityInitializer;
|
import com.ruoyi.generator.util.VelocityInitializer;
|
||||||
import com.ruoyi.generator.util.VelocityUtils;
|
import com.ruoyi.generator.util.VelocityUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.util.IOUtils;
|
|
||||||
import org.apache.velocity.Template;
|
import org.apache.velocity.Template;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.Velocity;
|
import org.apache.velocity.app.Velocity;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -47,11 +45,12 @@ import java.util.zip.ZipOutputStream;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTable, GenTable> implements IGenTableService {
|
public class GenTableServiceImpl implements IGenTableService {
|
||||||
|
|
||||||
@Autowired
|
private final GenTableMapper baseMapper;
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
private final GenTableColumnMapper genTableColumnMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
@ -150,7 +149,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteGenTableByIds(Long[] tableIds) {
|
public void deleteGenTableByIds(Long[] tableIds) {
|
||||||
List<Long> ids = Arrays.asList(tableIds);
|
List<Long> ids = Arrays.asList(tableIds);
|
||||||
removeByIds(ids);
|
baseMapper.deleteBatchIds(ids);
|
||||||
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids));
|
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +176,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
saveColumns.add(column);
|
saveColumns.add(column);
|
||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(saveColumns)) {
|
if (CollUtil.isNotEmpty(saveColumns)) {
|
||||||
genTableColumnMapper.insertAll(saveColumns);
|
genTableColumnMapper.insertBatch(saveColumns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,7 +227,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
IOUtils.closeQuietly(zip);
|
IoUtil.close(zip);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +293,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (CollUtil.isNotEmpty(saveColumns)) {
|
if (CollUtil.isNotEmpty(saveColumns)) {
|
||||||
genTableColumnMapper.insertAll(saveColumns);
|
genTableColumnMapper.insertBatch(saveColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||||
@ -317,7 +316,7 @@ public class GenTableServiceImpl extends ServicePlusImpl<GenTableMapper, GenTabl
|
|||||||
for (String tableName : tableNames) {
|
for (String tableName : tableNames) {
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
}
|
}
|
||||||
IOUtils.closeQuietly(zip);
|
IoUtil.close(zip);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.generator.service;
|
package com.ruoyi.generator.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.generator.domain.GenTableColumn;
|
import com.ruoyi.generator.domain.GenTableColumn;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,7 +9,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface IGenTableColumnService extends IService<GenTableColumn> {
|
public interface IGenTableColumnService {
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
|
@ -13,7 +13,7 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface IGenTableService extends IService<GenTable> {
|
public interface IGenTableService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);
|
TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ${packageName}.mapper;
|
package ${packageName}.mapper;
|
||||||
|
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Mapper接口
|
* ${functionName}Mapper接口
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysConfig;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysConfigMapper extends BaseMapperPlus<SysConfig> {
|
public interface SysConfigMapper extends BaseMapperPlus<SysConfigMapper, SysConfig, SysConfig> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.ruoyi.system.mapper;
|
|||||||
import com.ruoyi.common.annotation.DataColumn;
|
import com.ruoyi.common.annotation.DataColumn;
|
||||||
import com.ruoyi.common.annotation.DataPermission;
|
import com.ruoyi.common.annotation.DataPermission;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysDeptMapper extends BaseMapperPlus<SysDept> {
|
public interface SysDeptMapper extends BaseMapperPlus<SysDeptMapper, SysDept, SysDept> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
|
@ -2,7 +2,7 @@ package com.ruoyi.system.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysDictDataMapper extends BaseMapperPlus<SysDictData> {
|
public interface SysDictDataMapper extends BaseMapperPlus<SysDictDataMapper, SysDictData, SysDictData> {
|
||||||
|
|
||||||
default List<SysDictData> selectDictDataByType(String dictType) {
|
default List<SysDictData> selectDictDataByType(String dictType) {
|
||||||
return selectList(
|
return selectList(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典表 数据层
|
* 字典表 数据层
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysDictTypeMapper extends BaseMapperPlus<SysDictType> {
|
public interface SysDictTypeMapper extends BaseMapperPlus<SysDictTypeMapper, SysDictType, SysDictType> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysLogininfor;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysLogininforMapper extends BaseMapperPlus<SysLogininfor> {
|
public interface SysLogininforMapper extends BaseMapperPlus<SysLogininforMapper, SysLogininfor, SysLogininfor> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenu> {
|
public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, SysMenu> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户所有权限
|
* 根据用户所有权限
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysNotice;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysNoticeMapper extends BaseMapperPlus<SysNotice> {
|
public interface SysNoticeMapper extends BaseMapperPlus<SysNoticeMapper, SysNotice, SysNotice> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysOperLog;
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysOperLog;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysOperLogMapper extends BaseMapperPlus<SysOperLog> {
|
public interface SysOperLogMapper extends BaseMapperPlus<SysOperLogMapper, SysOperLog, SysOperLog> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysOssConfig;
|
import com.ruoyi.system.domain.SysOssConfig;
|
||||||
|
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对象存储配置Mapper接口
|
* 对象存储配置Mapper接口
|
||||||
@ -10,6 +11,6 @@ import com.ruoyi.system.domain.SysOssConfig;
|
|||||||
* @author 孤舟烟雨
|
* @author 孤舟烟雨
|
||||||
* @date 2021-08-13
|
* @date 2021-08-13
|
||||||
*/
|
*/
|
||||||
public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfig> {
|
public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysOss;
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传 数据层
|
* 文件上传 数据层
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysOssMapper extends BaseMapperPlus<SysOss> {
|
public interface SysOssMapper extends BaseMapperPlus<SysOssMapper, SysOss, SysOssVo> {
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysPostMapper extends BaseMapperPlus<SysPost> {
|
public interface SysPostMapper extends BaseMapperPlus<SysPostMapper, SysPost, SysPost> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID获取岗位选择框列表
|
* 根据用户ID获取岗位选择框列表
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysRoleDept;
|
import com.ruoyi.system.domain.SysRoleDept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysRoleDept;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept> {
|
public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDeptMapper, SysRoleDept, SysRoleDept> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.common.annotation.DataColumn;
|
import com.ruoyi.common.annotation.DataColumn;
|
||||||
import com.ruoyi.common.annotation.DataPermission;
|
import com.ruoyi.common.annotation.DataPermission;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysRoleMapper extends BaseMapperPlus<SysRole> {
|
public interface SysRoleMapper extends BaseMapperPlus<SysRoleMapper, SysRole, SysRole> {
|
||||||
|
|
||||||
@DataPermission({
|
@DataPermission({
|
||||||
@DataColumn(key = "deptName", value = "d.dept_id")
|
@DataColumn(key = "deptName", value = "d.dept_id")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysRoleMenu;
|
import com.ruoyi.system.domain.SysRoleMenu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysRoleMenu;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu> {
|
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenuMapper, SysRoleMenu, SysRoleMenu> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.common.annotation.DataColumn;
|
import com.ruoyi.common.annotation.DataColumn;
|
||||||
import com.ruoyi.common.annotation.DataPermission;
|
import com.ruoyi.common.annotation.DataPermission;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysUserMapper extends BaseMapperPlus<SysUser> {
|
public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, SysUser> {
|
||||||
|
|
||||||
@DataPermission({
|
@DataPermission({
|
||||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysUserPost;
|
import com.ruoyi.system.domain.SysUserPost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysUserPost;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost> {
|
public interface SysUserPostMapper extends BaseMapperPlus<SysUserPostMapper, SysUserPost, SysUserPost> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ruoyi.system.mapper;
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysUserRole;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole> {
|
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, SysUserRole, SysUserRole> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
@ -12,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysConfigService extends IService<SysConfig> {
|
public interface ISysConfigService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery);
|
TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery);
|
||||||
@ -94,4 +93,7 @@ public interface ISysConfigService extends IService<SysConfig> {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
String checkConfigKeyUnique(SysConfig config);
|
String checkConfigKeyUnique(SysConfig config);
|
||||||
|
|
||||||
|
SysConfig getOne(SysConfig config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,7 +10,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysDeptService extends IService<SysDept> {
|
public interface ISysDeptService {
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
@ -12,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysDictDataService extends IService<SysDictData> {
|
public interface ISysDictDataService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery);
|
TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery);
|
||||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysDictTypeService extends IService<SysDictType> {
|
public interface ISysDictTypeService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery);
|
TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
@ -12,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysLogininforService extends IService<SysLogininfor> {
|
public interface ISysLogininforService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery);
|
TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysMenuService extends IService<SysMenu> {
|
public interface ISysMenuService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户查询系统菜单列表
|
* 根据用户查询系统菜单列表
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
@ -12,7 +11,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysNoticeService extends IService<SysNotice> {
|
public interface ISysNoticeService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery);
|
TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery);
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysOperLogService extends IService<SysOperLog> {
|
public interface ISysOperLogService {
|
||||||
|
|
||||||
TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery);
|
TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery);
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysOssConfig;
|
|
||||||
import com.ruoyi.system.domain.bo.SysOssConfigBo;
|
import com.ruoyi.system.domain.bo.SysOssConfigBo;
|
||||||
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
||||||
|
|
||||||
@ -16,7 +14,7 @@ import java.util.Collection;
|
|||||||
* @author 孤舟烟雨
|
* @author 孤舟烟雨
|
||||||
* @date 2021-08-13
|
* @date 2021-08-13
|
||||||
*/
|
*/
|
||||||
public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssConfigVo> {
|
public interface ISysOssConfigService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化OSS配置
|
* 初始化OSS配置
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.system.domain.SysOss;
|
import com.ruoyi.system.domain.SysOss;
|
||||||
import com.ruoyi.system.domain.bo.SysOssBo;
|
import com.ruoyi.system.domain.bo.SysOssBo;
|
||||||
@ -15,11 +14,14 @@ import java.util.Collection;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysOssService extends IServicePlus<SysOss, SysOssVo> {
|
public interface ISysOssService {
|
||||||
|
|
||||||
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
|
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
|
||||||
|
|
||||||
|
SysOss getById(Long ossId);
|
||||||
|
|
||||||
SysOss upload(MultipartFile file);
|
SysOss upload(MultipartFile file);
|
||||||
|
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysPostService extends IService<SysPost> {
|
public interface ISysPostService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery);
|
TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
@ -14,7 +13,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysRoleService extends IService<SysRole> {
|
public interface ISysRoleService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery);
|
TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
@ -13,7 +12,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public interface ISysUserService extends IService<SysUser>, UserService {
|
public interface ISysUserService extends UserService {
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery);
|
TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery);
|
||||||
|
@ -12,16 +12,15 @@ import com.ruoyi.common.exception.user.CaptchaExpireException;
|
|||||||
import com.ruoyi.common.exception.user.UserException;
|
import com.ruoyi.common.exception.user.UserException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -30,23 +29,15 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysLoginService {
|
public class SysLoginService {
|
||||||
|
|
||||||
@Autowired
|
private final TokenService tokenService;
|
||||||
private TokenService tokenService;
|
private final AuthenticationManager authenticationManager;
|
||||||
|
private final ISysUserService userService;
|
||||||
@Resource
|
private final ISysConfigService configService;
|
||||||
private AuthenticationManager authenticationManager;
|
private final LogininforService asyncService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysUserService userService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysConfigService configService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LogininforService asyncService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -12,14 +12,12 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysPermissionService {
|
public class SysPermissionService {
|
||||||
|
|
||||||
@Autowired
|
private final ISysRoleService roleService;
|
||||||
private ISysRoleService roleService;
|
private final ISysMenuService menuService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysMenuService menuService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色数据权限
|
* 获取角色数据权限
|
||||||
|
@ -7,9 +7,12 @@ import com.ruoyi.common.core.domain.model.RegisterBody;
|
|||||||
import com.ruoyi.common.core.service.LogininforService;
|
import com.ruoyi.common.core.service.LogininforService;
|
||||||
import com.ruoyi.common.exception.user.CaptchaException;
|
import com.ruoyi.common.exception.user.CaptchaException;
|
||||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||||
import com.ruoyi.common.utils.*;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,17 +20,13 @@ import org.springframework.stereotype.Service;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysRegisterService {
|
public class SysRegisterService {
|
||||||
|
|
||||||
@Autowired
|
private final ISysUserService userService;
|
||||||
private ISysUserService userService;
|
private final ISysConfigService configService;
|
||||||
|
private final LogininforService asyncService;
|
||||||
@Autowired
|
|
||||||
private ISysConfigService configService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LogininforService asyncService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
|
@ -7,15 +7,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.service.ConfigService;
|
import com.ruoyi.common.core.service.ConfigService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.mapper.SysConfigMapper;
|
import com.ruoyi.system.mapper.SysConfigMapper;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -28,8 +28,11 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService, ConfigService {
|
public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||||
|
|
||||||
|
private final SysConfigMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery) {
|
public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery) {
|
||||||
@ -40,7 +43,7 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
|||||||
.like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey())
|
.like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey())
|
||||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||||
Page<SysConfig> page = page(pageQuery.build(), lqw);
|
Page<SysConfig> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +205,11 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
|||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysConfig getOne(SysConfig config) {
|
||||||
|
return baseMapper.selectOne(new LambdaQueryWrapper<>(config));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数 key 获取参数值
|
* 根据参数 key 获取参数值
|
||||||
*
|
*
|
||||||
|
@ -8,19 +8,18 @@ import com.ruoyi.system.domain.SysRoleDept;
|
|||||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleDeptMapper;
|
import com.ruoyi.system.mapper.SysRoleDeptMapper;
|
||||||
import com.ruoyi.system.service.SysDataScopeService;
|
import com.ruoyi.system.service.SysDataScopeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service("sdss")
|
@Service("sdss")
|
||||||
public class SysDataScopeServiceImpl implements SysDataScopeService {
|
public class SysDataScopeServiceImpl implements SysDataScopeService {
|
||||||
|
|
||||||
@Autowired
|
private final SysRoleDeptMapper roleDeptMapper;
|
||||||
private SysRoleDeptMapper roleDeptMapper;
|
private final SysDeptMapper deptMapper;
|
||||||
@Autowired
|
|
||||||
private SysDeptMapper deptMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRoleCustom(Long roleId) {
|
public String getRoleCustom(Long roleId) {
|
||||||
|
@ -9,7 +9,6 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -19,7 +18,7 @@ import com.ruoyi.system.mapper.SysDeptMapper;
|
|||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.mapper.SysUserMapper;
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -30,14 +29,13 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept, SysDept> implements ISysDeptService {
|
public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
|
|
||||||
@Autowired
|
private final SysDeptMapper baseMapper;
|
||||||
private SysRoleMapper roleMapper;
|
private final SysRoleMapper roleMapper;
|
||||||
|
private final SysUserMapper userMapper;
|
||||||
@Autowired
|
|
||||||
private SysUserMapper userMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
@ -47,8 +45,6 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDept> selectDeptList(SysDept dept) {
|
public List<SysDept> selectDeptList(SysDept dept) {
|
||||||
// return baseMapper.selectList();
|
|
||||||
// return baseMapper.selectList(new LambdaQueryWrapper<>());
|
|
||||||
return baseMapper.selectDeptList(dept);
|
return baseMapper.selectDeptList(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +87,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysDept selectDeptById(Long deptId) {
|
public SysDept selectDeptById(Long deptId) {
|
||||||
return getById(deptId);
|
return baseMapper.selectById(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +98,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long selectNormalChildrenDeptById(Long deptId) {
|
public long selectNormalChildrenDeptById(Long deptId) {
|
||||||
return count(new LambdaQueryWrapper<SysDept>()
|
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
||||||
.eq(SysDept::getStatus, 0)
|
.eq(SysDept::getStatus, 0)
|
||||||
.apply("find_in_set({0}, ancestors)", deptId));
|
.apply("find_in_set({0}, ancestors)", deptId));
|
||||||
}
|
}
|
||||||
@ -115,9 +111,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasChildByDeptId(Long deptId) {
|
public boolean hasChildByDeptId(Long deptId) {
|
||||||
long result = count(new LambdaQueryWrapper<SysDept>()
|
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||||
.eq(SysDept::getParentId, deptId));
|
.eq(SysDept::getParentId, deptId));
|
||||||
return result > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,9 +123,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkDeptExistUser(Long deptId) {
|
public boolean checkDeptExistUser(Long deptId) {
|
||||||
long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
|
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(SysUser::getDeptId, deptId));
|
.eq(SysUser::getDeptId, deptId));
|
||||||
return result > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,11 +136,11 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
@Override
|
@Override
|
||||||
public String checkDeptNameUnique(SysDept dept) {
|
public String checkDeptNameUnique(SysDept dept) {
|
||||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||||
long count = count(new LambdaQueryWrapper<SysDept>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||||
.eq(SysDept::getDeptName, dept.getDeptName())
|
.eq(SysDept::getDeptName, dept.getDeptName())
|
||||||
.eq(SysDept::getParentId, dept.getParentId())
|
.eq(SysDept::getParentId, dept.getParentId())
|
||||||
.ne(SysDept::getDeptId, deptId));
|
.ne(SysDept::getDeptId, deptId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -177,7 +171,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertDept(SysDept dept) {
|
public int insertDept(SysDept dept) {
|
||||||
SysDept info = getById(dept.getParentId());
|
SysDept info = baseMapper.selectById(dept.getParentId());
|
||||||
// 如果父节点不为正常状态,则不允许新增子节点
|
// 如果父节点不为正常状态,则不允许新增子节点
|
||||||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
@ -194,8 +188,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateDept(SysDept dept) {
|
public int updateDept(SysDept dept) {
|
||||||
SysDept newParentDept = getById(dept.getParentId());
|
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
||||||
SysDept oldDept = getById(dept.getDeptId());
|
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
||||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||||
String oldAncestors = oldDept.getAncestors();
|
String oldAncestors = oldDept.getAncestors();
|
||||||
@ -219,7 +213,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
private void updateParentDeptStatusNormal(SysDept dept) {
|
private void updateParentDeptStatusNormal(SysDept dept) {
|
||||||
String ancestors = dept.getAncestors();
|
String ancestors = dept.getAncestors();
|
||||||
Long[] deptIds = Convert.toLongArray(ancestors);
|
Long[] deptIds = Convert.toLongArray(ancestors);
|
||||||
update(null, new LambdaUpdateWrapper<SysDept>()
|
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
|
||||||
.set(SysDept::getStatus, "0")
|
.set(SysDept::getStatus, "0")
|
||||||
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
||||||
}
|
}
|
||||||
@ -232,7 +226,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
* @param oldAncestors 旧的父ID集合
|
* @param oldAncestors 旧的父ID集合
|
||||||
*/
|
*/
|
||||||
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
||||||
List<SysDept> children = list(new LambdaQueryWrapper<SysDept>()
|
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||||
.apply("find_in_set({0},ancestors)", deptId));
|
.apply("find_in_set({0},ancestors)", deptId));
|
||||||
for (SysDept child : children) {
|
for (SysDept child : children) {
|
||||||
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||||
|
@ -5,12 +5,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,8 +20,11 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, SysDictData, SysDictData> implements ISysDictDataService {
|
public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||||
|
|
||||||
|
private final SysDictDataMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) {
|
public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) {
|
||||||
@ -30,7 +33,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
|||||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||||
.orderByAsc(SysDictData::getDictSort);
|
.orderByAsc(SysDictData::getDictSort);
|
||||||
Page<SysDictData> page = page(pageQuery.build(), lqw);
|
Page<SysDictData> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +45,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDictData> selectDictDataList(SysDictData dictData) {
|
public List<SysDictData> selectDictDataList(SysDictData dictData) {
|
||||||
return list(new LambdaQueryWrapper<SysDictData>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysDictData>()
|
||||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||||
@ -58,7 +61,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectDictLabel(String dictType, String dictValue) {
|
public String selectDictLabel(String dictType, String dictValue) {
|
||||||
return getOne(new LambdaQueryWrapper<SysDictData>()
|
return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||||
.select(SysDictData::getDictLabel)
|
.select(SysDictData::getDictLabel)
|
||||||
.eq(SysDictData::getDictType, dictType)
|
.eq(SysDictData::getDictType, dictType)
|
||||||
.eq(SysDictData::getDictValue, dictValue))
|
.eq(SysDictData::getDictValue, dictValue))
|
||||||
@ -73,7 +76,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysDictData selectDictDataById(Long dictCode) {
|
public SysDictData selectDictDataById(Long dictCode) {
|
||||||
return getById(dictCode);
|
return baseMapper.selectById(dictCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +89,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
|||||||
public void deleteDictDataByIds(Long[] dictCodes) {
|
public void deleteDictDataByIds(Long[] dictCodes) {
|
||||||
for (Long dictCode : dictCodes) {
|
for (Long dictCode : dictCodes) {
|
||||||
SysDictData data = selectDictDataById(dictCode);
|
SysDictData data = selectDictDataById(dictCode);
|
||||||
removeById(dictCode);
|
baseMapper.deleteById(dictCode);
|
||||||
List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType());
|
List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType());
|
||||||
RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas);
|
RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas);
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,15 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.service.DictService;
|
import com.ruoyi.common.core.service.DictService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||||
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -32,11 +31,12 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType, SysDictType> implements ISysDictTypeService, DictService {
|
public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService {
|
||||||
|
|
||||||
@Autowired
|
private final SysDictTypeMapper baseMapper;
|
||||||
private SysDictDataMapper dictDataMapper;
|
private final SysDictDataMapper dictDataMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery) {
|
public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery) {
|
||||||
@ -47,7 +47,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
||||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||||
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||||
Page<SysDictType> page = page(pageQuery.build(), lqw);
|
Page<SysDictType> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
@Override
|
@Override
|
||||||
public List<SysDictType> selectDictTypeList(SysDictType dictType) {
|
public List<SysDictType> selectDictTypeList(SysDictType dictType) {
|
||||||
Map<String, Object> params = dictType.getParams();
|
Map<String, Object> params = dictType.getParams();
|
||||||
return list(new LambdaQueryWrapper<SysDictType>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysDictType>()
|
||||||
.like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName())
|
.like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName())
|
||||||
.eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus())
|
.eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus())
|
||||||
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
||||||
@ -75,7 +75,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDictType> selectDictTypeAll() {
|
public List<SysDictType> selectDictTypeAll() {
|
||||||
return list();
|
return baseMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +106,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysDictType selectDictTypeById(Long dictId) {
|
public SysDictType selectDictTypeById(Long dictId) {
|
||||||
return getById(dictId);
|
return baseMapper.selectById(dictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +117,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysDictType selectDictTypeByType(String dictType) {
|
public SysDictType selectDictTypeByType(String dictType) {
|
||||||
return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
return baseMapper.selectById(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +144,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadingDictCache() {
|
public void loadingDictCache() {
|
||||||
List<SysDictType> dictTypeList = list();
|
List<SysDictType> dictTypeList = baseMapper.selectList();
|
||||||
for (SysDictType dictType : dictTypeList) {
|
for (SysDictType dictType : dictTypeList) {
|
||||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
||||||
RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas);
|
RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas);
|
||||||
@ -193,7 +193,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int updateDictType(SysDictType dict) {
|
public int updateDictType(SysDictType dict) {
|
||||||
SysDictType oldDict = getById(dict.getDictId());
|
SysDictType oldDict = baseMapper.selectById(dict.getDictId());
|
||||||
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
|
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
|
||||||
.set(SysDictData::getDictType, dict.getDictType())
|
.set(SysDictData::getDictType, dict.getDictType())
|
||||||
.eq(SysDictData::getDictType, oldDict.getDictType()));
|
.eq(SysDictData::getDictType, oldDict.getDictType()));
|
||||||
@ -214,7 +214,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
|||||||
@Override
|
@Override
|
||||||
public String checkDictTypeUnique(SysDictType dict) {
|
public String checkDictTypeUnique(SysDictType dict) {
|
||||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||||
long count = count(new LambdaQueryWrapper<SysDictType>()
|
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysDictType>()
|
||||||
.eq(SysDictType::getDictType, dict.getDictType())
|
.eq(SysDictType::getDictType, dict.getDictType())
|
||||||
.ne(SysDictType::getDictId, dictId));
|
.ne(SysDictType::getDictId, dictId));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.service.LogininforService;
|
import com.ruoyi.common.core.service.LogininforService;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
@ -15,6 +14,7 @@ import com.ruoyi.common.utils.ip.AddressUtils;
|
|||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.mapper.SysLogininforMapper;
|
import com.ruoyi.system.mapper.SysLogininforMapper;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -30,9 +30,12 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMapper, SysLogininfor, SysLogininfor> implements ISysLogininforService, LogininforService {
|
public class SysLogininforServiceImpl implements ISysLogininforService, LogininforService {
|
||||||
|
|
||||||
|
private final SysLogininforMapper baseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录登录信息
|
* 记录登录信息
|
||||||
@ -99,7 +102,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
|||||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||||
pageQuery.setOrderByColumn("info_id").setIsAsc("desc");
|
pageQuery.setOrderByColumn("info_id").setIsAsc("desc");
|
||||||
}
|
}
|
||||||
Page<SysLogininfor> page = page(pageQuery.build(), lqw);
|
Page<SysLogininfor> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +114,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
|||||||
@Override
|
@Override
|
||||||
public void insertLogininfor(SysLogininfor logininfor) {
|
public void insertLogininfor(SysLogininfor logininfor) {
|
||||||
logininfor.setLoginTime(new Date());
|
logininfor.setLoginTime(new Date());
|
||||||
save(logininfor);
|
baseMapper.insert(logininfor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +126,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
|||||||
@Override
|
@Override
|
||||||
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) {
|
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) {
|
||||||
Map<String, Object> params = logininfor.getParams();
|
Map<String, Object> params = logininfor.getParams();
|
||||||
return list(new LambdaQueryWrapper<SysLogininfor>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysLogininfor>()
|
||||||
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
|
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
|
||||||
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
|
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
|
||||||
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
|
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
|
||||||
@ -148,6 +151,6 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cleanLogininfor() {
|
public void cleanLogininfor() {
|
||||||
remove(new LambdaQueryWrapper<>());
|
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.TreeBuildUtils;
|
import com.ruoyi.common.utils.TreeBuildUtils;
|
||||||
@ -19,7 +18,7 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
|||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -29,14 +28,13 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu, SysMenu> implements ISysMenuService {
|
public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
|
|
||||||
@Autowired
|
private final SysMenuMapper baseMapper;
|
||||||
private SysRoleMapper roleMapper;
|
private final SysRoleMapper roleMapper;
|
||||||
|
private final SysRoleMenuMapper roleMenuMapper;
|
||||||
@Autowired
|
|
||||||
private SysRoleMenuMapper roleMenuMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户查询系统菜单列表
|
* 根据用户查询系统菜单列表
|
||||||
@ -60,7 +58,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
List<SysMenu> menuList = null;
|
List<SysMenu> menuList = null;
|
||||||
// 管理员显示所有菜单信息
|
// 管理员显示所有菜单信息
|
||||||
if (SysUser.isAdmin(userId)) {
|
if (SysUser.isAdmin(userId)) {
|
||||||
menuList = list(new LambdaQueryWrapper<SysMenu>()
|
menuList = baseMapper.selectList(new LambdaQueryWrapper<SysMenu>()
|
||||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||||
@ -198,7 +196,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysMenu selectMenuById(Long menuId) {
|
public SysMenu selectMenuById(Long menuId) {
|
||||||
return getById(menuId);
|
return baseMapper.selectById(menuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,8 +207,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasChildByMenuId(Long menuId) {
|
public boolean hasChildByMenuId(Long menuId) {
|
||||||
long result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
||||||
return result > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,8 +218,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkMenuExistRole(Long menuId) {
|
public boolean checkMenuExistRole(Long menuId) {
|
||||||
long result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
||||||
return result > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,11 +263,11 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
|||||||
@Override
|
@Override
|
||||||
public String checkMenuNameUnique(SysMenu menu) {
|
public String checkMenuNameUnique(SysMenu menu) {
|
||||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||||
long count = count(new LambdaQueryWrapper<SysMenu>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||||
.eq(SysMenu::getParentId, menu.getParentId())
|
.eq(SysMenu::getParentId, menu.getParentId())
|
||||||
.ne(SysMenu::getMenuId, menuId));
|
.ne(SysMenu::getMenuId, menuId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
@ -3,12 +3,12 @@ package com.ruoyi.system.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.mapper.SysNoticeMapper;
|
import com.ruoyi.system.mapper.SysNoticeMapper;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -19,8 +19,11 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNotice, SysNotice> implements ISysNoticeService {
|
public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||||
|
|
||||||
|
private final SysNoticeMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) {
|
public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) {
|
||||||
@ -28,7 +31,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
|||||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
|
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
|
||||||
Page<SysNotice> page = page(pageQuery.build(), lqw);
|
Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +43,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysNotice selectNoticeById(Long noticeId) {
|
public SysNotice selectNoticeById(Long noticeId) {
|
||||||
return getById(noticeId);
|
return baseMapper.selectById(noticeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +54,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysNotice> selectNoticeList(SysNotice notice) {
|
public List<SysNotice> selectNoticeList(SysNotice notice) {
|
||||||
return list(new LambdaQueryWrapper<SysNotice>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
||||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
|
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
|
||||||
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.dto.OperLogDTO;
|
import com.ruoyi.common.core.domain.dto.OperLogDTO;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.service.OperLogService;
|
import com.ruoyi.common.core.service.OperLogService;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -14,6 +13,7 @@ import com.ruoyi.common.utils.ip.AddressUtils;
|
|||||||
import com.ruoyi.system.domain.SysOperLog;
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
import com.ruoyi.system.mapper.SysOperLogMapper;
|
import com.ruoyi.system.mapper.SysOperLogMapper;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -27,8 +27,11 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, SysOperLog, SysOperLog> implements ISysOperLogService, OperLogService {
|
public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService {
|
||||||
|
|
||||||
|
private final SysOperLogMapper baseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作日志记录
|
* 操作日志记录
|
||||||
@ -64,7 +67,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
|||||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||||
pageQuery.setOrderByColumn("oper_id").setIsAsc("desc");
|
pageQuery.setOrderByColumn("oper_id").setIsAsc("desc");
|
||||||
}
|
}
|
||||||
Page<SysOperLog> page = page(pageQuery.build(), lqw);
|
Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
|||||||
@Override
|
@Override
|
||||||
public void insertOperlog(SysOperLog operLog) {
|
public void insertOperlog(SysOperLog operLog) {
|
||||||
operLog.setOperTime(new Date());
|
operLog.setOperTime(new Date());
|
||||||
save(operLog);
|
baseMapper.insert(operLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +91,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
|||||||
@Override
|
@Override
|
||||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
|
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
|
||||||
Map<String, Object> params = operLog.getParams();
|
Map<String, Object> params = operLog.getParams();
|
||||||
return list(new LambdaQueryWrapper<SysOperLog>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysOperLog>()
|
||||||
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
||||||
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
||||||
SysOperLog::getBusinessType, operLog.getBusinessType())
|
SysOperLog::getBusinessType, operLog.getBusinessType())
|
||||||
@ -124,7 +127,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysOperLog selectOperLogById(Long operId) {
|
public SysOperLog selectOperLogById(Long operId) {
|
||||||
return getById(operId);
|
return baseMapper.selectById(operId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,6 +135,6 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cleanOperLog() {
|
public void cleanOperLog() {
|
||||||
remove(new LambdaQueryWrapper<>());
|
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.JsonUtils;
|
import com.ruoyi.common.utils.JsonUtils;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
import com.ruoyi.oss.constant.OssConstant;
|
import com.ruoyi.oss.constant.OssConstant;
|
||||||
import com.ruoyi.oss.factory.OssFactory;
|
import com.ruoyi.oss.factory.OssFactory;
|
||||||
import com.ruoyi.system.domain.SysOssConfig;
|
import com.ruoyi.system.domain.SysOssConfig;
|
||||||
@ -24,7 +23,6 @@ import com.ruoyi.system.mapper.SysOssConfigMapper;
|
|||||||
import com.ruoyi.system.service.ISysOssConfigService;
|
import com.ruoyi.system.service.ISysOssConfigService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -39,16 +37,18 @@ import java.util.List;
|
|||||||
* @date 2021-08-13
|
* @date 2021-08-13
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> implements ISysOssConfigService {
|
public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||||
|
|
||||||
|
private final SysOssConfigMapper baseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目启动时,初始化参数到缓存,加载配置类
|
* 项目启动时,初始化参数到缓存,加载配置类
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
List<SysOssConfig> list = list();
|
List<SysOssConfig> list = baseMapper.selectList();
|
||||||
// 加载OSS初始化配置
|
// 加载OSS初始化配置
|
||||||
for (SysOssConfig config : list) {
|
for (SysOssConfig config : list) {
|
||||||
String configKey = config.getConfigKey();
|
String configKey = config.getConfigKey();
|
||||||
@ -63,13 +63,13 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysOssConfigVo queryById(Integer ossConfigId) {
|
public SysOssConfigVo queryById(Integer ossConfigId) {
|
||||||
return getVoById(ossConfigId);
|
return baseMapper.selectVoById(ossConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo);
|
||||||
Page<SysOssConfigVo> result = pageVo(pageQuery.build(), lqw);
|
Page<SysOssConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
public Boolean insertByBo(SysOssConfigBo bo) {
|
public Boolean insertByBo(SysOssConfigBo bo) {
|
||||||
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
|
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
|
||||||
validEntityBeforeSave(config);
|
validEntityBeforeSave(config);
|
||||||
return setConfigCache(save(config), config);
|
return setConfigCache(baseMapper.insert(config) > 0, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +98,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, "");
|
luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, "");
|
||||||
luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, "");
|
luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, "");
|
||||||
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
|
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
|
||||||
return setConfigCache(update(config, luw), config);
|
return setConfigCache(baseMapper.update(config, luw) > 0, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,10 +120,10 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
}
|
}
|
||||||
List<SysOssConfig> list = Lists.newArrayList();
|
List<SysOssConfig> list = Lists.newArrayList();
|
||||||
for (Long configId : ids) {
|
for (Long configId : ids) {
|
||||||
SysOssConfig config = getById(configId);
|
SysOssConfig config = baseMapper.selectById(configId);
|
||||||
list.add(config);
|
list.add(config);
|
||||||
}
|
}
|
||||||
boolean flag = removeByIds(ids);
|
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
list.stream().forEach(sysOssConfig -> {
|
list.stream().forEach(sysOssConfig -> {
|
||||||
RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey()));
|
RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey()));
|
||||||
@ -137,7 +137,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
|||||||
*/
|
*/
|
||||||
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
||||||
long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
||||||
SysOssConfig info = getOne(new LambdaQueryWrapper<SysOssConfig>()
|
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||||
if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
||||||
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -16,6 +15,7 @@ import com.ruoyi.system.domain.bo.SysOssBo;
|
|||||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||||
import com.ruoyi.system.mapper.SysOssMapper;
|
import com.ruoyi.system.mapper.SysOssMapper;
|
||||||
import com.ruoyi.system.service.ISysOssService;
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -29,13 +29,16 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, SysOssVo> implements ISysOssService {
|
public class SysOssServiceImpl implements ISysOssService {
|
||||||
|
|
||||||
|
private final SysOssMapper baseMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
|
||||||
Page<SysOssVo> result = pageVo(pageQuery.build(), lqw);
|
Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +56,11 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
|||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysOss getById(Long ossId) {
|
||||||
|
return baseMapper.selectById(ossId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysOss upload(MultipartFile file) {
|
public SysOss upload(MultipartFile file) {
|
||||||
String originalfileName = file.getOriginalFilename();
|
String originalfileName = file.getOriginalFilename();
|
||||||
@ -71,7 +79,7 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
|||||||
.setFileName(uploadResult.getFilename())
|
.setFileName(uploadResult.getFilename())
|
||||||
.setOriginalName(originalfileName)
|
.setOriginalName(originalfileName)
|
||||||
.setService(storage.getServiceType());
|
.setService(storage.getServiceType());
|
||||||
save(oss);
|
baseMapper.insert(oss);
|
||||||
return oss;
|
return oss;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +88,12 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
// 做一些业务上的校验,判断是否需要校验
|
// 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
List<SysOss> list = listByIds(ids);
|
List<SysOss> list = baseMapper.selectBatchIds(ids);
|
||||||
for (SysOss sysOss : list) {
|
for (SysOss sysOss : list) {
|
||||||
IOssStrategy storage = OssFactory.instance(sysOss.getService());
|
IOssStrategy storage = OssFactory.instance(sysOss.getService());
|
||||||
storage.delete(sysOss.getUrl());
|
storage.delete(sysOss.getUrl());
|
||||||
}
|
}
|
||||||
return removeByIds(ids);
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -13,7 +12,7 @@ import com.ruoyi.system.domain.SysUserPost;
|
|||||||
import com.ruoyi.system.mapper.SysPostMapper;
|
import com.ruoyi.system.mapper.SysPostMapper;
|
||||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -24,11 +23,12 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost, SysPost> implements ISysPostService {
|
public class SysPostServiceImpl implements ISysPostService {
|
||||||
|
|
||||||
@Autowired
|
private final SysPostMapper baseMapper;
|
||||||
private SysUserPostMapper userPostMapper;
|
private final SysUserPostMapper userPostMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) {
|
public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) {
|
||||||
@ -36,7 +36,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName());
|
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName());
|
||||||
Page<SysPost> page = page(pageQuery.build(), lqw);
|
Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(page);
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysPost> selectPostList(SysPost post) {
|
public List<SysPost> selectPostList(SysPost post) {
|
||||||
return list(new LambdaQueryWrapper<SysPost>()
|
return baseMapper.selectList(new LambdaQueryWrapper<SysPost>()
|
||||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
||||||
@ -61,7 +61,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysPost> selectPostAll() {
|
public List<SysPost> selectPostAll() {
|
||||||
return list();
|
return baseMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +72,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysPost selectPostById(Long postId) {
|
public SysPost selectPostById(Long postId) {
|
||||||
return getById(postId);
|
return baseMapper.selectById(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,10 +95,10 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
@Override
|
@Override
|
||||||
public String checkPostNameUnique(SysPost post) {
|
public String checkPostNameUnique(SysPost post) {
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||||
long count = count(new LambdaQueryWrapper<SysPost>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||||
.eq(SysPost::getPostName, post.getPostName())
|
.eq(SysPost::getPostName, post.getPostName())
|
||||||
.ne(SysPost::getPostId, postId));
|
.ne(SysPost::getPostId, postId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -113,10 +113,10 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
|||||||
@Override
|
@Override
|
||||||
public String checkPostCodeUnique(SysPost post) {
|
public String checkPostCodeUnique(SysPost post) {
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||||
long count = count(new LambdaQueryWrapper<SysPost>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||||
.eq(SysPost::getPostCode, post.getPostCode())
|
.eq(SysPost::getPostCode, post.getPostCode())
|
||||||
.ne(SysPost::getPostId, postId));
|
.ne(SysPost::getPostId, postId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
@ -6,7 +6,6 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
@ -20,7 +19,7 @@ import com.ruoyi.system.mapper.SysRoleMapper;
|
|||||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -31,17 +30,14 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole, SysRole> implements ISysRoleService {
|
public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
|
|
||||||
@Autowired
|
private final SysRoleMapper baseMapper;
|
||||||
private SysRoleMenuMapper roleMenuMapper;
|
private final SysRoleMenuMapper roleMenuMapper;
|
||||||
|
private final SysUserRoleMapper userRoleMapper;
|
||||||
@Autowired
|
private final SysRoleDeptMapper roleDeptMapper;
|
||||||
private SysUserRoleMapper userRoleMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysRoleDeptMapper roleDeptMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) {
|
public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) {
|
||||||
@ -128,7 +124,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysRole selectRoleById(Long roleId) {
|
public SysRole selectRoleById(Long roleId) {
|
||||||
return getById(roleId);
|
return baseMapper.selectById(roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,10 +136,10 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
@Override
|
@Override
|
||||||
public String checkRoleNameUnique(SysRole role) {
|
public String checkRoleNameUnique(SysRole role) {
|
||||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||||
long count = count(new LambdaQueryWrapper<SysRole>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||||
.eq(SysRole::getRoleName, role.getRoleName())
|
.eq(SysRole::getRoleName, role.getRoleName())
|
||||||
.ne(SysRole::getRoleId, roleId));
|
.ne(SysRole::getRoleId, roleId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -158,10 +154,10 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
@Override
|
@Override
|
||||||
public String checkRoleKeyUnique(SysRole role) {
|
public String checkRoleKeyUnique(SysRole role) {
|
||||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||||
long count = count(new LambdaQueryWrapper<SysRole>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||||
.ne(SysRole::getRoleId, roleId));
|
.ne(SysRole::getRoleId, roleId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -281,7 +277,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
list.add(rm);
|
list.add(rm);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
rows = roleMenuMapper.insertAll(list);
|
rows = roleMenuMapper.insertBatch(list) ? list.size() : 0;
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
@ -302,7 +298,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
list.add(rd);
|
list.add(rd);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
rows = roleDeptMapper.insertAll(list);
|
rows = roleDeptMapper.insertBatch(list) ? list.size() : 0;
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
@ -393,7 +389,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
list.add(ur);
|
list.add(ur);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
rows = userRoleMapper.insertAll(list);
|
rows = userRoleMapper.insertBatch(list) ? list.size() : 0;
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,11 +14,11 @@ import org.springframework.stereotype.Service;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
||||||
|
|
||||||
@Autowired
|
private final SysUserMapper userMapper;
|
||||||
private ISysUserService userService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过登录地址查询信息
|
* 通过登录地址查询信息
|
||||||
@ -77,7 +77,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
|||||||
if (StringUtils.isNull(user)) {
|
if (StringUtils.isNull(user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SysUser sysUser = userService.selectUserById(user.getUserId());
|
SysUser sysUser = userMapper.selectUserById(user.getUserId());
|
||||||
SysUserOnline sysUserOnline = new SysUserOnline();
|
SysUserOnline sysUserOnline = new SysUserOnline();
|
||||||
sysUserOnline.setTokenId(user.getToken());
|
sysUserOnline.setTokenId(user.getToken());
|
||||||
sysUserOnline.setUserName(user.getUsername());
|
sysUserOnline.setUserName(user.getUsername());
|
||||||
|
@ -8,7 +8,6 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.service.UserService;
|
import com.ruoyi.common.core.service.UserService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
@ -20,8 +19,8 @@ import com.ruoyi.system.domain.SysUserPost;
|
|||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.mapper.*;
|
import com.ruoyi.system.mapper.*;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -36,20 +35,15 @@ import java.util.stream.Collectors;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser, SysUser> implements ISysUserService, UserService {
|
public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||||
|
|
||||||
@Autowired
|
private final SysUserMapper baseMapper;
|
||||||
private SysRoleMapper roleMapper;
|
private final SysRoleMapper roleMapper;
|
||||||
|
private final SysPostMapper postMapper;
|
||||||
@Autowired
|
private final SysUserRoleMapper userRoleMapper;
|
||||||
private SysPostMapper postMapper;
|
private final SysUserPostMapper userPostMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserRoleMapper userRoleMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserPostMapper userPostMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) {
|
public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) {
|
||||||
@ -152,7 +146,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkUserNameUnique(String userName) {
|
public String checkUserNameUnique(String userName) {
|
||||||
long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
@ -168,10 +162,10 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
@Override
|
@Override
|
||||||
public String checkPhoneUnique(SysUser user) {
|
public String checkPhoneUnique(SysUser user) {
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
long count = count(new LambdaQueryWrapper<SysUser>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
||||||
.ne(SysUser::getUserId, userId));
|
.ne(SysUser::getUserId, userId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -186,10 +180,10 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
@Override
|
@Override
|
||||||
public String checkEmailUnique(SysUser user) {
|
public String checkEmailUnique(SysUser user) {
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
long count = count(new LambdaQueryWrapper<SysUser>()
|
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(SysUser::getEmail, user.getEmail())
|
.eq(SysUser::getEmail, user.getEmail())
|
||||||
.ne(SysUser::getUserId, userId));
|
.ne(SysUser::getUserId, userId));
|
||||||
if (count > 0) {
|
if (count) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@ -368,7 +362,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
list.add(ur);
|
list.add(ur);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
userRoleMapper.insertAll(list);
|
userRoleMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,7 +384,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
list.add(up);
|
list.add(up);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
userPostMapper.insertAll(list);
|
userPostMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +406,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
list.add(ur);
|
list.add(ur);
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
userRoleMapper.insertAll(list);
|
userRoleMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ import com.ruoyi.common.constant.Constants;
|
|||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.service.TokenService;
|
import com.ruoyi.common.core.service.TokenService;
|
||||||
import com.ruoyi.common.properties.TokenProperties;
|
import com.ruoyi.common.properties.TokenProperties;
|
||||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.ip.AddressUtils;
|
import com.ruoyi.common.utils.ip.AddressUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class TokenServiceImpl implements TokenService {
|
public class TokenServiceImpl implements TokenService {
|
||||||
|
|
||||||
@ -37,8 +38,7 @@ public class TokenServiceImpl implements TokenService {
|
|||||||
|
|
||||||
private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
|
private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
|
||||||
|
|
||||||
@Autowired
|
private final TokenProperties tokenProperties;
|
||||||
private TokenProperties tokenProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户身份信息
|
* 获取用户身份信息
|
||||||
|
@ -7,8 +7,8 @@ import com.ruoyi.common.exception.user.UserException;
|
|||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import com.ruoyi.system.service.SysPermissionService;
|
import com.ruoyi.system.service.SysPermissionService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
@ -20,14 +20,12 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
|
|
||||||
@Autowired
|
private final ISysUserService userService;
|
||||||
private ISysUserService userService;
|
private final SysPermissionService permissionService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysPermissionService permissionService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
|
Loading…
Reference in New Issue
Block a user